// TODO not used public void appendString(String str) { Document doc = getDocument(); try { int start = doc.getLength(); doc.insertString(doc.getLength(), str, null); int end = doc.getLength(); // end = parseLine(start, end, patHistoryBtnStr); } catch (Exception e) { Debug.error(me + "appendString: Problem while trying to append\n%s", e.getMessage()); } }
/* * public int search(String str){ * return search(str, true); * } */ public int search(String str, int pos, boolean forward) { boolean isCaseSensitive = true; String toSearch = str; if (str.startsWith("!")) { str = str.substring(1).toUpperCase(); isCaseSensitive = false; } int ret = -1; Document doc = getDocument(); Debug.log(9, "search caret: " + pos + ", " + doc.getLength()); try { String body; int begin; if (forward) { int len = doc.getLength() - pos; body = doc.getText(pos, len > 0 ? len : 0); begin = pos; } else { body = doc.getText(0, pos); begin = 0; } if (!isCaseSensitive) { body = body.toUpperCase(); } Pattern pattern = Pattern.compile(Pattern.quote(str)); Matcher matcher = pattern.matcher(body); ret = continueSearch(matcher, begin, forward); if (ret < 0) { if (forward && pos != 0) { return search(toSearch, 0, forward); } if (!forward && pos != doc.getLength()) { return search(toSearch, doc.getLength(), forward); } } } catch (BadLocationException e) { Debug.log(7, "search caret: " + pos + ", " + doc.getLength() + e.getStackTrace()); } return ret; }