/** * The style range at the given offset * * @param offset * the offset * @return the style range */ public StyleRange getStyleRangeAtOffset(int offset) { if (offset < 0 || offset >= getCharCount()) { throw new IllegalArgumentException(); } // if (!isListening(ST.LineGetStyle)) { StyleRange[] ranges = this.renderer.getStyleRanges(offset, 1, true); if (ranges != null) return ranges[0]; // } return null; }
/** * The style range at the given offset * * @param offset * the offset * @return the style range */ public StyleRange getStyleRangeAtOffset(int offset) { if (offset < 0 || offset >= getCharCount()) { throw new IllegalArgumentException(); } // if (!isListening(ST.LineGetStyle)) { StyleRange[] ranges = this.renderer.getStyleRanges(offset, 1, true); if (ranges != null) return ranges[0]; // } return null; }
/** * 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#TEXT_END} */ protected void defaultSelectTextEnd() { moveCaretAbsolute(getControl().getCharCount(), true); }
void moveCaretAbsolute(int absoluteOffset) { int offset = Math.max(0, absoluteOffset); offset = Math.min(getControl().getCharCount(), offset); getControl().setCaretOffset(offset); }
@SuppressWarnings("deprecation") private void moveCaretAbsolute(int absoluteOffset, boolean select) { int offset = Math.max(0, absoluteOffset); offset = Math.min(getControl().getCharCount(), offset); // we need to jump 2 chars if windows line endings are in effect if( offset > 0 ) { String textRange = getControl().getContent().getTextRange(offset-1, 1); // check the navigation direction if( getControl().getCaretOffset() > offset ) { if( textRange.equals("\r") ) { //$NON-NLS-1$ offset -= 1; } } else { if( textRange.equals("\r") ) { //$NON-NLS-1$ offset += 1; } } } getControl().impl_setCaretOffset(Math.max(0,offset), select); }
void handleTextChanged(TextChangedEvent xxx) { if (this.changingEvent == null) { // full text change 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()).computeModel(); // } } else { // partial text change // TextChangingEvent event = this.changingEvent; this.changingEvent = null; // if (getSkin() instanceof StyledTextSkin) { // ((StyledTextSkin) getSkin()).computeModelDelta(event); // } } }
void updateSelection(int startOffset, int replacedLength, int newLength) { if (getSelection().offset + getSelection().length > startOffset && getSelection().offset < startOffset + replacedLength) { // selection intersects replaced text. set caret behind text change setSelection(new TextSelection(startOffset + newLength, 0)/* , true, false */); } else { // move selection to keep same text selected int computedOffset = getSelection().offset + newLength - replacedLength; if (computedOffset >= 0 && computedOffset < getCharCount()) { // we only set this if the offset is valid!! setSelection(new TextSelection(computedOffset, getSelection().length)/* , true, false */); } if (getSelection().length > 0) { int delta = this.lastTextChangeNewCharCount - this.lastTextChangeReplaceCharCount; this.caretOffsetProperty.set(Math.max(0, Math.min(getCharCount() - 1, getCaretOffset() + delta))); } } }
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(); } }
void updateSelection(int startOffset, int replacedLength, int newLength) { if (getSelection().offset + getSelection().length > startOffset && getSelection().offset < startOffset + replacedLength) { // selection intersects replaced text. set caret behind text change setSelection(new TextSelection(startOffset + newLength, 0)/*, true, false*/); } else { // move selection to keep same text selected setSelection(new TextSelection(getSelection().offset + newLength - replacedLength, getSelection().length)/*, true, false*/); if( getSelection().length > 0 ) { int delta = this.lastTextChangeNewCharCount - this.lastTextChangeReplaceCharCount; this.caretOffsetProperty.set(Math.max(0,Math.min(getCharCount()-1,getCaretOffset() + delta))); } } }
String allContent = getControl().getContent().getTextRange(0, getControl().getCharCount()); StringBuffer dataBuffer = new StringBuffer(allContent);
String allContent = getControl().getContent().getTextRange(0, getControl().getCharCount()); StringBuffer dataBuffer = new StringBuffer(allContent);