public void deleteEnclosedText(TextLocation start, TextLocation end) { ArrayList<TypedLayout> lines = getLines(); int startIndex = start.toIndex(lines); int endIndex = end.toIndex(lines); synchronized (this) { text.delete(startIndex, endIndex); clearCache(); } setCaretLocation(start); setSelectionLocation(start); }
public TextLocation findWordsRightEdge(TextLocation location) { for (int i = location.toIndex(getLines()); i <= text.length() - 1; i++) { if (i == 0) i = 1; if (isAtEndOfWord(i)) return TextLocation.fromIndex(getLines(), i); } return getEndLocation(); }
public void pasteClipboard() { String clipboard = getClipboardContents(); if (clipboard != null && clipboard.length() > 0) { int caretIndex = caretLocation.toIndex(getLines()); synchronized (this) { text.insert(caretIndex, clipboard); clearCache(); } setCaretLocation(TextLocation.fromIndex(getLines(), caretIndex + clipboard.length())); } }
protected TextLocation findNextWordSkippingSpacesOrNewLines(TextLocation startLocation) { for (int i = startLocation.toIndex(getLines()); i <= text.length() - 1; i++) { if (isAtStartOfWord(i)) return TextLocation.fromIndex(getLines(), i); } return getEndLocation(); }
public TextLocation findWordsLeftEdge(TextLocation location) { for (int i = location.toIndex(getLines()); i > 1; i--) { if (isAtStartOfWord(i)) return TextLocation.fromIndex(getLines(), i); } return TextLocation.origin; }