int getCaretLine() { return content.getLineAtOffset(caretOffset); } int getWrapWidth () {
int getCaretLine() { return content.getLineAtOffset(caretOffset); } int getWrapWidth () {
int getCaretLine() { return content.getLineAtOffset(caretOffset); } int getWrapWidth () {
int getCaretLine() { return content.getLineAtOffset(caretOffset); } int getWrapWidth () {
int getCaretLine() { return content.getLineAtOffset(caretOffset); } int getWrapWidth () {
/** * Returns whether the given offset is inside a multi byte line delimiter. * Example: * "Line1\r\n" isLineDelimiter(5) == false but isLineDelimiter(6) == true * * @return true if the given offset is inside a multi byte line delimiter. * false if the given offset is before or after a line delimiter. */ boolean isLineDelimiter(int offset) { int line = content.getLineAtOffset(offset); int lineOffset = content.getOffsetAtLine(line); int offsetInLine = offset - lineOffset; // offsetInLine will be greater than line length if the line // delimiter is longer than one character and the offset is set // in between parts of the line delimiter. return offsetInLine > content.getLine(line).length(); } /**
/** * Returns whether the given offset is inside a multi byte line delimiter. * Example: * "Line1\r\n" isLineDelimiter(5) == false but isLineDelimiter(6) == true * * @return true if the given offset is inside a multi byte line delimiter. * false if the given offset is before or after a line delimiter. */ boolean isLineDelimiter(int offset) { int line = content.getLineAtOffset(offset); int lineOffset = content.getOffsetAtLine(line); int offsetInLine = offset - lineOffset; // offsetInLine will be greater than line length if the line // delimiter is longer than one character and the offset is set // in between parts of the line delimiter. return offsetInLine > content.getLine(line).length(); } /**
/** * Returns whether the given offset is inside a multi byte line delimiter. * Example: * "Line1\r\n" isLineDelimiter(5) == false but isLineDelimiter(6) == true * * @return true if the given offset is inside a multi byte line delimiter. * false if the given offset is before or after a line delimiter. */ boolean isLineDelimiter(int offset) { int line = content.getLineAtOffset(offset); int lineOffset = content.getOffsetAtLine(line); int offsetInLine = offset - lineOffset; // offsetInLine will be greater than line length if the line // delimiter is longer than one character and the offset is set // in between parts of the line delimiter. return offsetInLine > content.getLine(line).length(); } /**
/** * Returns whether the given offset is inside a multi byte line delimiter. * Example: * "Line1\r\n" isLineDelimiter(5) == false but isLineDelimiter(6) == true * * @return true if the given offset is inside a multi byte line delimiter. * false if the given offset is before or after a line delimiter. */ boolean isLineDelimiter(int offset) { int line = content.getLineAtOffset(offset); int lineOffset = content.getOffsetAtLine(line); int offsetInLine = offset - lineOffset; // offsetInLine will be greater than line length if the line // delimiter is longer than one character and the offset is set // in between parts of the line delimiter. return offsetInLine > content.getLine(line).length(); } /**
/** * Moves the caret to the end of the next word . */ void doSelectionWordNext() { int offset = getWordNext(caretOffset, SWT.MOVEMENT_WORD); // don't change caret position if in single line mode and the cursor // would be on a different line. fixes 5673 if (!isSingleLine() || content.getLineAtOffset(caretOffset) == content.getLineAtOffset(offset)) { // Force symmetrical movement for word next and previous. Fixes 14536 setCaretOffset(offset, OFFSET_LEADING); showCaret(); } } /**
/** * Moves the caret to the end of the next word . */ void doSelectionWordNext() { int offset = getWordNext(caretOffset, SWT.MOVEMENT_WORD); // don't change caret position if in single line mode and the cursor // would be on a different line. fixes 5673 if (!isSingleLine() || content.getLineAtOffset(caretOffset) == content.getLineAtOffset(offset)) { // Force symmetrical movement for word next and previous. Fixes 14536 setCaretOffset(offset, OFFSET_LEADING); showCaret(); } } /**
/** * Returns whether the given offset is inside a multi byte line delimiter. * Example: * "Line1\r\n" isLineDelimiter(5) == false but isLineDelimiter(6) == true * * @return true if the given offset is inside a multi byte line delimiter. * false if the given offset is before or after a line delimiter. */ boolean isLineDelimiter(int offset) { int line = content.getLineAtOffset(offset); int lineOffset = content.getOffsetAtLine(line); int offsetInLine = offset - lineOffset; // offsetInLine will be greater than line length if the line // delimiter is longer than one character and the offset is set // in between parts of the line delimiter. return offsetInLine > content.getLine(line).length(); } /**
/** * Moves the caret to the end of the next word . */ void doSelectionWordNext() { int offset = getWordNext(caretOffset, SWT.MOVEMENT_WORD); // don't change caret position if in single line mode and the cursor // would be on a different line. fixes 5673 if (!isSingleLine() || content.getLineAtOffset(caretOffset) == content.getLineAtOffset(offset)) { // Force symmetrical movement for word next and previous. Fixes 14536 setCaretOffset(offset, OFFSET_LEADING); showCaret(); } } /**
/** * Moves the caret to the end of the next word . */ void doSelectionWordNext() { int offset = getWordNext(caretOffset, SWT.MOVEMENT_WORD); // don't change caret position if in single line mode and the cursor // would be on a different line. fixes 5673 if (!isSingleLine() || content.getLineAtOffset(caretOffset) == content.getLineAtOffset(offset)) { // Force symmetrical movement for word next and previous. Fixes 14536 setCaretOffset(offset, OFFSET_LEADING); showCaret(); } } /**
/** * Moves the caret to the end of the next word . */ void doSelectionWordNext() { int offset = getWordNext(caretOffset, SWT.MOVEMENT_WORD); // don't change caret position if in single line mode and the cursor // would be on a different line. fixes 5673 if (!isSingleLine() || content.getLineAtOffset(caretOffset) == content.getLineAtOffset(offset)) { // Force symmetrical movement for word next and previous. Fixes 14536 setCaretOffset(offset, OFFSET_LEADING); showCaret(); } } /**
/** * Returns the line at the specified offset in the text * where 0 < offset < getCharCount() so that getLineAtOffset(getCharCount()) * returns the line of the insert location. * * @param offset offset relative to the start of the content. * 0 <= offset <= getCharCount() * @return line at the specified offset in the text * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> * </ul> */ public int getLineAtOffset(int offset) { checkWidget(); if (offset < 0 || offset > getCharCount()) { SWT.error(SWT.ERROR_INVALID_RANGE); } return content.getLineAtOffset(offset); } /**
/** * Returns the line at the specified offset in the text * where 0 < offset < getCharCount() so that getLineAtOffset(getCharCount()) * returns the line of the insert location. * * @param offset offset relative to the start of the content. * 0 <= offset <= getCharCount() * @return line at the specified offset in the text * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> * </ul> */ public int getLineAtOffset(int offset) { checkWidget(); if (offset < 0 || offset > getCharCount()) { SWT.error(SWT.ERROR_INVALID_RANGE); } return content.getLineAtOffset(offset); } /**
/** * Returns the line at the specified offset in the text * where 0 < offset < getCharCount() so that getLineAtOffset(getCharCount()) * returns the line of the insert location. * * @param offset offset relative to the start of the content. * 0 <= offset <= getCharCount() * @return line at the specified offset in the text * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> * </ul> */ public int getLineAtOffset(int offset) { checkWidget(); if (offset < 0 || offset > getCharCount()) { SWT.error(SWT.ERROR_INVALID_RANGE); } return content.getLineAtOffset(offset); } /**
Rectangle getBoundsAtOffset(int offset) { int lineIndex = content.getLineAtOffset(offset); int lineOffset = content.getOffsetAtLine(lineIndex); String line = content.getLine(lineIndex); Rectangle bounds; if (line.length() != 0) { int offsetInLine = offset - lineOffset; TextLayout layout = renderer.getTextLayout(lineIndex); bounds = layout.getBounds(offsetInLine, offsetInLine); renderer.disposeTextLayout(layout); } else { bounds = new Rectangle (0, 0, 0, renderer.getLineHeight()); } if (offset == caretOffset && !wordWrap) { int lineEnd = lineOffset + line.length(); if (offset == lineEnd) { bounds.width += getCaretWidth(); } } bounds.x += leftMargin - horizontalScrollOffset; bounds.y += getLinePixel(lineIndex); return bounds; } /**
int getWordNext (int offset, int movement, boolean ignoreListener) { int newOffset, lineOffset; String lineText; if (offset >= getCharCount()) { newOffset = offset; int lineIndex = content.getLineCount() - 1; lineOffset = content.getOffsetAtLine(lineIndex); lineText = content.getLine(lineIndex); } else { int lineIndex = content.getLineAtOffset(offset); lineOffset = content.getOffsetAtLine(lineIndex); lineText = content.getLine(lineIndex); int lineLength = lineText.length(); if (offset >= lineOffset + lineLength) { newOffset = content.getOffsetAtLine(lineIndex + 1); } else { TextLayout layout = renderer.getTextLayout(lineIndex); newOffset = lineOffset + layout.getNextOffset(offset - lineOffset, movement); renderer.disposeTextLayout(layout); } } if (ignoreListener) return newOffset; return sendWordBoundaryEvent(ST.WordNext, movement, offset, newOffset, lineText, lineOffset); } int getWordPrevious(int offset, int movement) {