private void show(TextChangingEvent changingEvent) { System.out.println("start: " + changingEvent.start + "\n" + "newCharCount: " + changingEvent.newCharCount + "\n" + "newLineCount: " + changingEvent.newLineCount + "\n" + "replaceCharCount: " + changingEvent.replaceCharCount + "\n" + "replaceLineCount: " + changingEvent.replaceLineCount + "\n" + "text: " + printable(changingEvent.newText) + "\n"); }
private TextChangingEvent makeTextChangingEvent(int start, int length, String newText) { TextChangingEvent result = new TextChangingEvent(this); result.start = start; result.newCharCount = newText.length(); result.newLineCount = lineOffsets.countLines(newText); result.newText = newText; result.replaceCharCount = length; result.replaceLineCount = lineOffsets.linesInRange(pos2offset(start), pos2offset(start + length)); return result; }
private void notifyListeners(TextChangingEvent changingEvent) { for (Iterator iter = textChangeListeners.iterator(); iter.hasNext();) { TextChangeListener element = (TextChangeListener) iter.next(); element.textChanging(changingEvent); } }
/** * @param start * @param length * @param newText * @return */ private TextChangingEvent makeTextChangingEvent(int start, int length, String newText) { TextChangingEvent result = new TextChangingEvent(this); result.start = start; result.newCharCount = newText.length(); result.newLineCount = lineOffsets.countLines(newText); result.newText = newText; result.replaceCharCount = length; result.replaceLineCount = lineOffsets.linesInRange(pos2offset(start), pos2offset(start + length)); return result; }
/** * @param changingEvent */ private void notifyListeners(TextChangingEvent changingEvent) { for (Iterator iter = textChangeListeners.iterator(); iter.hasNext();) { TextChangeListener element = (TextChangeListener) iter.next(); element.textChanging(changingEvent); } }
@Override public void replaceTextRange(final int inStart, final int inReplaceLength, final String inText) { if (!isValidReplace(inStart, inReplaceLength)) SWT.error(SWT.ERROR_INVALID_ARGUMENT); // inform listeners final TextChangingEvent lChanging = new TextChangingEvent(this); lChanging.start = inStart; lChanging.replaceLineCount = lineCount(inStart, inReplaceLength); lChanging.newText = inText; lChanging.newLineCount = lineCount(inText); lChanging.replaceCharCount = inReplaceLength; lChanging.newCharCount = inText.length(); final Object[] lListeners = listeners.getListeners(); for (int i = 0; i < lListeners.length; ++i) { ((TextChangeListener) lListeners[i]).textChanging(lChanging); } delete(inStart, inReplaceLength, lChanging.replaceLineCount + 1); insert(inStart, inText); // inform listeners again for (int i = 0; i < lListeners.length; ++i) { ((TextChangeListener) lListeners[i]) .textChanged(new TextChangedEvent(this)); } }
@Override public void textChanging(final TextChangingEvent event) { }
@Override public void textChanging(TextChangingEvent event) { this.currClientArea = null; //will force redrawing everything askFullRedraw = true; }