public synchronized void insertChar(char c) { if (c == KeyEvent.CHAR_UNDEFINED) return; if (selectionActivated) deleteSelection(); text.insert(getCaretLocation().toIndex(getLines()), c); clearCache(); setCaretLocation(getCaretLocation().moved(getLines(), 1)); }
public synchronized void setText(String newText) { if (newText == null) newText = ""; if (newText.length() == text.length() && newText.equals(getText())) return; text = new StringBuffer(newText); clearCache(); setCaretLocation(getEndLocation()); }
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 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())); } }