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); }