/** * Returns the line at the given index with delimiters. * <p> * * @param index * the index of the line to return * @return the logical line text (i.e., without the gap) with delimiters */ String getFullLine(int index) { int start = this.lines[index][0]; int length = this.lines[index][1]; int end = start + length - 1; if (!gapExists() || (end < this.gapStart) || (start >= this.gapEnd)) { // line is before or after the gap return new String(this.textStore, start, length); } else { // gap is in the specified range, strip out the gap StringBuffer buffer = new StringBuffer(); int gapLength = this.gapEnd - this.gapStart; buffer.append(this.textStore, start, this.gapStart - start); buffer.append(this.textStore, this.gapEnd, length - gapLength - (this.gapStart - start)); return buffer.toString(); } }
/** * Returns the line at the given index with delimiters. * <p> * * @param index * the index of the line to return * @return the logical line text (i.e., without the gap) with delimiters */ String getFullLine(int index) { int start = this.lines[index][0]; int length = this.lines[index][1]; int end = start + length - 1; if (!gapExists() || (end < this.gapStart) || (start >= this.gapEnd)) { // line is before or after the gap return new String(this.textStore, start, length); } else { // gap is in the specified range, strip out the gap StringBuffer buffer = new StringBuffer(); int gapLength = this.gapEnd - this.gapStart; buffer.append(this.textStore, start, this.gapStart - start); buffer.append(this.textStore, this.gapEnd, length - gapLength - (this.gapStart - start)); return buffer.toString(); } }
/** * Returns a string representing the logical content of the text store * (i.e., gap stripped out). * <p> * * @param start * the logical start offset of the text to return * @param length * the logical length of the text to return * @return the text */ @SuppressWarnings("null") @Override public String getTextRange(int start, int length) { if (this.textStore == null) return ""; //$NON-NLS-1$ if (length == 0) return ""; //$NON-NLS-1$ int end = start + length; if (!gapExists() || (end < this.gapStart)) return new String(this.textStore, start, length); if (this.gapStart < start) { int gapLength = this.gapEnd - this.gapStart; return new String(this.textStore, start + gapLength, length); } StringBuffer buf = new StringBuffer(); buf.append(this.textStore, start, this.gapStart - start); buf.append(this.textStore, this.gapEnd, end - this.gapStart); return buf.toString(); }
/** * Returns a string representing the logical content of the text store * (i.e., gap stripped out). * <p> * * @param start * the logical start offset of the text to return * @param length * the logical length of the text to return * @return the text */ @SuppressWarnings("null") @Override public String getTextRange(int start, int length) { if (this.textStore == null) return ""; //$NON-NLS-1$ if (length == 0) return ""; //$NON-NLS-1$ int end = start + length; if (!gapExists() || (end < this.gapStart)) return new String(this.textStore, start, length); if (this.gapStart < start) { int gapLength = this.gapEnd - this.gapStart; return new String(this.textStore, start + gapLength, length); } StringBuffer buf = new StringBuffer(); buf.append(this.textStore, start, this.gapStart - start); buf.append(this.textStore, this.gapEnd, end - this.gapStart); return buf.toString(); }
int length = this.lines[index][1]; int end = start + length - 1; if (!gapExists() || (end < this.gapStart) || (start >= this.gapEnd)) {
int length = this.lines[index][1]; int end = start + length - 1; if (!gapExists() || (end < this.gapStart) || (start >= this.gapEnd)) {