/** * @return the current caret offset */ public int getCaretOffset() { return caretOffsetProperty().get(); }
/** * @return the current caret offset */ public int getCaretOffset() { return caretOffsetProperty().get(); }
@Override public Subscription registerOnCaretOffsetChanged(Consumer<Integer> listener) { ChangeListener<? super Number> l = (x, o, n) -> { listener.accept(n.intValue()); }; viewer.getTextWidget().caretOffsetProperty().addListener(l); return new Subscription() { @Override public void dispose() { viewer.getTextWidget().caretOffsetProperty().removeListener(l); } }; }
/** * Set the current caret offset * * @param offset * the new offset */ public void setCaretOffset(int offset) { this.anchor = offset; caretOffsetProperty().set(offset); clearSelection(); }
/** * Set the current caret offset * * @param offset * the new offset */ public void setCaretOffset(int offset) { this.anchor = offset; caretOffsetProperty().set(offset); clearSelection(); }
/** * Setting the caret offset and updateing the selection if requested * * @param offset * the offset * @param selection * <code>true</code> to update the current selection * @deprecated internal API for now */ @Deprecated public void impl_setCaretOffset(int offset, boolean selection) { if (selection) { caretOffsetProperty().set(offset); if (offset > this.anchor) { setSelectionRange(this.anchor, offset - this.anchor); } else { setSelectionRange(offset, this.anchor - offset); } } else { setCaretOffset(offset); } }
/** * Setting the caret offset and updateing the selection if requested * * @param offset * the offset * @param selection * <code>true</code> to update the current selection * @deprecated internal API for now */ @Deprecated public void impl_setCaretOffset(int offset, boolean selection) { if (selection) { caretOffsetProperty().set(offset); if (offset > this.anchor) { setSelectionRange(this.anchor, offset - this.anchor); } else { setSelectionRange(offset, this.anchor - offset); } } else { setCaretOffset(offset); } }
getChildren().addAll(this.rootContainer); styledText.caretOffsetProperty().addListener(new ChangeListener<Number>() {
styledText.caretOffsetProperty().addListener((obs, ol, ne) -> { int lineIdx = styledText.getContent().getLineAtOffset(ne.intValue()); int colIdx = ne.intValue() - styledText.getContent().getOffsetAtLine(lineIdx); this.content.caretOffsetProperty().bind(getSkinnable().caretOffsetProperty());