if (this.ranges != null) { int rangeCount = this.styleCount << 1; int modifyStart = getRangeIndex(start, -1, rangeCount); if (modifyStart == rangeCount) return; int end = start + replaceCharCount; int modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount); int offset = newCharCount - replaceCharCount; if (modifyStart == modifyEnd && this.ranges[modifyStart] < start && end < this.ranges[modifyEnd] + this.ranges[modifyEnd + 1]) { int modifyStart = getRangeIndex(start, -1, this.styleCount); if (modifyStart == this.styleCount) return; int end = start + replaceCharCount; int modifyEnd = getRangeIndex(end, modifyStart - 1, this.styleCount); int offset = newCharCount - replaceCharCount; if (modifyStart == modifyEnd && this.styles[modifyStart].start < start && end < this.styles[modifyEnd].start + this.styles[modifyEnd].length) {
/** * 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; }
this.renderer.setStyleRanges(null, null); } else { this.renderer.updateRanges(start, length, length); this.renderer.setStyleRanges(ranges, styles);
int rangeCount = this.styleCount << 1; int start = _newRanges[0]; int modifyStart = getRangeIndex(start, -1, rangeCount), modifyEnd; boolean insert = modifyStart == rangeCount; if (!insert) { int end = _newRanges[_newRanges.length - 2] + _newRanges[_newRanges.length - 1]; modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount); insert = modifyStart == modifyEnd && this.ranges[modifyStart] >= end; addMerge(_newRanges, _newStyles, _newRanges.length, modifyStart, modifyStart); return; int grow = addMerge(mergeRanges, mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast); rangeCount += grow; modifyStart = modifyEnd += grow; int modifyStart = getRangeIndex(start, -1, this.styleCount), modifyEnd; boolean insert = modifyStart == this.styleCount; if (!insert) { int end = _newStyles[_newStyles.length - 1].start + _newStyles[_newStyles.length - 1].length; modifyEnd = getRangeIndex(end, modifyStart - 1, this.styleCount); insert = modifyStart == modifyEnd && this.styles[modifyStart].start >= end; addMerge(_newStyles, _newStyles.length, modifyStart, modifyStart); return; int grow = addMerge(mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast); modifyStart = modifyEnd += grow;
int newLineCount = event.newLineCount, replaceLineCount = event.replaceLineCount; updateRanges(start, replaceCharCount, newCharCount);
int rangeCount = this.styleCount << 1; int start = _newRanges[0]; int modifyStart = getRangeIndex(start, -1, rangeCount), modifyEnd; boolean insert = modifyStart == rangeCount; if (!insert) { int end = _newRanges[_newRanges.length - 2] + _newRanges[_newRanges.length - 1]; modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount); insert = modifyStart == modifyEnd && this.ranges[modifyStart] >= end; addMerge(_newRanges, _newStyles, _newRanges.length, modifyStart, modifyStart); return; int grow = addMerge(mergeRanges, mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast); rangeCount += grow; modifyStart = modifyEnd += grow; int modifyStart = getRangeIndex(start, -1, this.styleCount), modifyEnd; boolean insert = modifyStart == this.styleCount; if (!insert) { int end = _newStyles[_newStyles.length - 1].start + _newStyles[_newStyles.length - 1].length; modifyEnd = getRangeIndex(end, modifyStart - 1, this.styleCount); insert = modifyStart == modifyEnd && this.styles[modifyStart].start >= end; addMerge(_newStyles, _newStyles.length, modifyStart, modifyStart); return; int grow = addMerge(mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast); modifyStart = modifyEnd += grow;
int newLineCount = event.newLineCount, replaceLineCount = event.replaceLineCount; updateRanges(start, replaceCharCount, newCharCount);
if (this.ranges != null) { int rangeCount = this.styleCount << 1; int modifyStart = getRangeIndex(start, -1, rangeCount); if (modifyStart == rangeCount) return; int end = start + replaceCharCount; int modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount); int offset = newCharCount - replaceCharCount; if (modifyStart == modifyEnd && this.ranges[modifyStart] < start && end < this.ranges[modifyEnd] + this.ranges[modifyEnd + 1]) { int modifyStart = getRangeIndex(start, -1, this.styleCount); if (modifyStart == this.styleCount) return; int end = start + replaceCharCount; int modifyEnd = getRangeIndex(end, modifyStart - 1, this.styleCount); int offset = newCharCount - replaceCharCount; if (modifyStart == modifyEnd && this.styles[modifyStart].start < start && end < this.styles[modifyEnd].start + this.styles[modifyEnd].length) {
if (this.ranges != null) { int rangeCount = this.styleCount << 1; int rangeStart = getRangeIndex(start, -1, rangeCount); if (rangeStart >= rangeCount) return null; if (this.ranges[rangeStart] > end) return null; int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount)); if (this.ranges[rangeEnd] > end) rangeEnd = Math.max(rangeStart, rangeEnd - 2); int rangeStart = getRangeIndex(start, -1, this.styleCount); if (rangeStart >= this.styleCount) return null; if (this.styles[rangeStart].start > end) return null; int rangeEnd = Math.min(this.styleCount - 1, getRangeIndex(end, rangeStart - 1, this.styleCount)); if (this.styles[rangeEnd].start > end) rangeEnd = Math.max(rangeStart, rangeEnd - 1);
this.renderer.setStyleRanges(null, null); } else { this.renderer.updateRanges(start, length, length); this.renderer.setStyleRanges(ranges, styles);
if (this.ranges != null) { int rangeCount = this.styleCount << 1; int rangeStart = getRangeIndex(start, -1, rangeCount); if (rangeStart >= rangeCount) return null; if (this.ranges[rangeStart] > end) return null; int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount)); if (this.ranges[rangeEnd] > end) rangeEnd = Math.max(rangeStart, rangeEnd - 2); int rangeStart = getRangeIndex(start, -1, this.styleCount); if (rangeStart >= this.styleCount) return null; if (this.styles[rangeStart].start > end) return null; int rangeEnd = Math.min(this.styleCount - 1, getRangeIndex(end, rangeStart - 1, this.styleCount)); if (this.styles[rangeEnd].start > end) rangeEnd = Math.max(rangeStart, rangeEnd - 1);
if (this.ranges != null) { int rangeCount = this.styleCount << 1; int rangeStart = getRangeIndex(start, -1, rangeCount); if (rangeStart >= rangeCount) return null; if (this.ranges[rangeStart] > end) return null; int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount)); if (this.ranges[rangeEnd] > end) rangeEnd = Math.max(rangeStart, rangeEnd - 2); System.arraycopy(this.ranges, rangeStart, newRanges, 0, newRanges.length); } else { int rangeStart = getRangeIndex(start, -1, this.styleCount); if (rangeStart >= this.styleCount) return null; if (this.styles[rangeStart].start > end) return null; int rangeEnd = Math.min(this.styleCount - 1, getRangeIndex(end, rangeStart - 1, this.styleCount)); if (this.styles[rangeEnd].start > end) rangeEnd = Math.max(rangeStart, rangeEnd - 1);
if (this.ranges != null) { int rangeCount = this.styleCount << 1; int rangeStart = getRangeIndex(start, -1, rangeCount); if (rangeStart >= rangeCount) return null; if (this.ranges[rangeStart] > end) return null; int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount)); if (this.ranges[rangeEnd] > end) rangeEnd = Math.max(rangeStart, rangeEnd - 2); System.arraycopy(this.ranges, rangeStart, newRanges, 0, newRanges.length); } else { int rangeStart = getRangeIndex(start, -1, this.styleCount); if (rangeStart >= this.styleCount) return null; if (this.styles[rangeStart].start > end) return null; int rangeEnd = Math.min(this.styleCount - 1, getRangeIndex(end, rangeStart - 1, this.styleCount)); if (this.styles[rangeEnd].start > end) rangeEnd = Math.max(rangeStart, rangeEnd - 1);
void handleTextChanging(TextChangingEvent event) { this.changingEvent = event; this.renderer.textChanging(event); if (event.replaceCharCount < 0) { event.offset += event.replaceCharCount; event.replaceCharCount *= -1; } // this.lastTextChangeStart = event.offset; // this.lastTextChangeNewLineCount = event.newLineCount; this.lastTextChangeNewCharCount = event.newCharCount; // this.lastTextChangeReplaceLineCount = event.replaceLineCount; this.lastTextChangeReplaceCharCount = event.replaceCharCount; // Update the caret offset if it is greater than the length of the // content. // This is necessary since style range API may be called between the // handleTextChanging and handleTextChanged events and this API sets the // caretOffset. int newEndOfText = getContent().getCharCount() - event.replaceCharCount + event.newCharCount; if (getCaretOffset() > newEndOfText) setCaretOffset(newEndOfText/* , SWT.DEFAULT */); }
void handleTextChanging(TextChangingEvent event) { if (event.replaceCharCount < 0) { event.offset += event.replaceCharCount; event.replaceCharCount *= -1; } this.lastTextChangeStart = event.offset; // this.lastTextChangeNewLineCount = event.newLineCount; this.lastTextChangeNewCharCount = event.newCharCount; // this.lastTextChangeReplaceLineCount = event.replaceLineCount; this.lastTextChangeReplaceCharCount = event.replaceCharCount; this.renderer.textChanging(event); // Update the caret offset if it is greater than the length of the // content. // This is necessary since style range API may be called between the // handleTextChanging and handleTextChanged events and this API sets the // caretOffset. int newEndOfText = getContent().getCharCount() - event.replaceCharCount + event.newCharCount; if (getCaretOffset() > newEndOfText) setCaretOffset(newEndOfText/* , SWT.DEFAULT */); }
/** * Access style ranges in the specified segment * * @param start * the start * @param length * the length * @param includeRanges * include ranges * @return the ranges */ public StyleRange[] getStyleRanges(int start, int length, boolean includeRanges) { StyleRange[] ranges = this.renderer.getStyleRanges(start, length, includeRanges); if (ranges != null) return ranges; return new StyleRange[0]; }
/** * 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; }
/** * Access style ranges in the specified segment * * @param start * the start * @param length * the length * @param includeRanges * include ranges * @return the ranges */ public StyleRange[] getStyleRanges(int start, int length, boolean includeRanges) { StyleRange[] ranges = this.renderer.getStyleRanges(start, length, includeRanges); if (ranges != null) return ranges; return new StyleRange[0]; }