void handleTextChanged(TextChangedEvent event) { // int firstLine = getContent().getLineAtOffset(lastTextChangeStart); if (getSkin() instanceof StyledTextSkin) { ((StyledTextSkin) getSkin()).recalculateItems(); } updateSelection(this.lastTextChangeStart, this.lastTextChangeReplaceCharCount, this.lastTextChangeNewCharCount); // lastCharCount += lastTextChangeNewCharCount; // lastCharCount -= lastTextChangeReplaceCharCount; }
/** * Get the char offset at the give coordinates * * @param x * the x * @param y * the y * @return the offset */ public int getOffsetAtPosition(double x, double y) { int result = ((StyledTextSkin) getSkin()).getOffsetAtPosition(x, y); return result; }
/** * Check the location at the given offset * * @param offset * the offset * @return the point */ public @Nullable Point2D getLocationAtOffset(int offset) { if (offset < 0 || offset > getCharCount()) { throw new IllegalArgumentException(); } return ((StyledTextSkin) getSkin()).getCaretLocation(offset); }
/** * Get the line height * * @param offset * the offset * @return the height */ public double getLineHeight(int offset) { if (offset < 0 || offset > getCharCount()) { throw new IllegalArgumentException(); } return ((StyledTextSkin) getSkin()).getLineHeight(offset); }
/** * Get the line height * * @param offset * the offset * @return the height */ public double getLineHeight(int offset) { if (offset < 0 || offset > getCharCount()) { throw new IllegalArgumentException(); } return ((StyledTextSkin) getSkin()).getLineHeight(offset); }
/** * Check the location at the given offset * * @param offset * the offset * @param locationHint * hint for y coordinate relative to line * @return the point */ public @Nullable Point2D getLocationAtOffset(int offset, LineLocation locationHint) { if (offset < 0 || offset > getCharCount()) { throw new IllegalArgumentException(); } return ((StyledTextSkin) getSkin()).getCaretLocation(offset, locationHint); }
/** * default implementation for {@link DefaultTextEditActions#SCROLL_LINE_UP} */ protected void defaultScrollLineUp() { ((StyledTextSkin) getControl().getSkin()).scrollLineUp(); }
/** * Trigger the respective action * @param action the action */ public void triggerAction(TextEditAction action) { ((StyledTextBehavior)((StyledTextSkin)getSkin()).getBehavior()).triggerAction(action); } }
/** * default implementation for {@link DefaultTextEditActions#SCROLL_LINE_DOWN} */ protected void defaultScrollLineDown() { ((StyledTextSkin) getControl().getSkin()).scrollLineDown(); }
/** * default implementation for {@link DefaultTextEditActions#NAVIGATE_TO_LINE} */ protected void defaultNavigateToLine() { try { Optional<Integer> num = ((StyledTextSkin)getControl().getSkin()).fastQuery("Goto Line", "Line Number", Integer::parseInt); num.ifPresent((n)->defaultNavigateToLine(n-1)); } catch (Exception e) { e.printStackTrace(); } }
void handleTextSet(TextChangedEvent event) { int newCharCount = getCharCount(); if( this.caretOffsetProperty.get() > newCharCount ) { this.caretOffsetProperty.set(newCharCount); } // in SWT this is done in reset() clearSelection(); if( getSkin() instanceof StyledTextSkin ) { ((StyledTextSkin)getSkin()).recalculateItems(); } }
private void onTextPositionMoved(TextPositionEvent event) { if (event.isShortcutDown()) { Optional<QuickLinkable> linkable = getControl().getQuickLinkCallback().apply(event.getOffset()); if (linkable.isPresent()) { Point2D screenLocation = new Point2D(event.getScreenX(), event.getScreenY()); Optional<TextNode> node = ((StyledTextSkin)getControl().getSkin()).findTextNode(screenLocation); if (!this.currentQuickLinkNode.equals(node)) { // changed setCurrentQuickLinkNode(node); } } else { setCurrentQuickLinkNode(Optional.empty()); } } else { setCurrentQuickLinkNode(Optional.empty()); } }
private int calculatePageUpOffset() { final int linesPerPage = ((StyledTextSkin)getControl().getSkin()).getVisibleLineCount(); final int globalOffset = getControl().getCaretOffset(); final int lineIndex = getControl().getContent().getLineAtOffset(globalOffset); final int lineLocalOffset = globalOffset - getControl().getContent().getOffsetAtLine(lineIndex); final int newLineIndex = Math.max(0, lineIndex - linesPerPage); final int newLineLocalOffset = Math.min(getControl().getContent().getLine(newLineIndex).length(), lineLocalOffset); return getControl().getOffsetAtLine(newLineIndex) + newLineLocalOffset; }
private int calculatePageDownOffset() { final int linesPerPage = ((StyledTextSkin)getControl().getSkin()).getVisibleLineCount(); final int globalOffset = getControl().getCaretOffset(); final int lineIndex = getControl().getContent().getLineAtOffset(globalOffset); final int lineLocalOffset = globalOffset - getControl().getContent().getOffsetAtLine(lineIndex); final int newLineIndex = Math.min(getControl().getContent().getLineCount()-1, lineIndex + linesPerPage); final int newLineLocalOffset = Math.min(getControl().getContent().getLine(newLineIndex).length(), lineLocalOffset); return getControl().getOffsetAtLine(newLineIndex) + newLineLocalOffset; }
} else if (this.dragMoveTextMode) { ((StyledTextSkin)getControl().getSkin()).updateInsertionMarkerIndex(-1);
((StyledTextSkin)getControl().getSkin()).updateInsertionMarkerIndex(-1);