int getVisualLineIndex(TextLayout layout, int offsetInLine) { int lineIndex = layout.getLineIndex(offsetInLine); int[] offsets = layout.getLineOffsets(); Caret caret = getCaret(); if (caret != null && lineIndex != 0 && offsetInLine == offsets[lineIndex]) { int lineY = layout.getLineBounds(lineIndex).y; int caretY = caret.getLocation().y - getLinePixel(getCaretLine()); if (lineY > caretY) lineIndex--; caretAlignment = OFFSET_LEADING; } return lineIndex; } int getCaretDirection() {
int getVisualLineIndex(TextLayout layout, int offsetInLine) { int lineIndex = layout.getLineIndex(offsetInLine); int[] offsets = layout.getLineOffsets(); Caret caret = getCaret(); if (caret != null && lineIndex != 0 && offsetInLine == offsets[lineIndex]) { int lineY = layout.getLineBounds(lineIndex).y; int caretY = caret.getLocation().y - getLinePixel(getCaretLine()); if (lineY > caretY) lineIndex--; caretAlignment = OFFSET_LEADING; } return lineIndex; } int getCaretDirection() {
int getVisualLineIndex(TextLayout layout, int offsetInLine) { int lineIndex = layout.getLineIndex(offsetInLine); int[] offsets = layout.getLineOffsets(); if (lineIndex != 0 && offsetInLine == offsets[lineIndex]) { int lineY = layout.getLineBounds(lineIndex).y; int caretY = getCaret().getLocation().y - getLinePixel(getCaretLine()); if (lineY > caretY) lineIndex--; caretAlignment = OFFSET_LEADING; } return lineIndex; } int getCaretDirection() {
int getVisualLineIndex(TextLayout layout, int offsetInLine) { int lineIndex = layout.getLineIndex(offsetInLine); int[] offsets = layout.getLineOffsets(); Caret caret = getCaret(); if (caret != null && lineIndex != 0 && offsetInLine == offsets[lineIndex]) { int lineY = layout.getLineBounds(lineIndex).y; int caretY = caret.getLocation().y - getLinePixel(getCaretLine()); if (lineY > caretY) lineIndex--; caretAlignment = OFFSET_LEADING; } return lineIndex; } int getCaretDirection() {
int getVisualLineIndex(TextLayout layout, int offsetInLine) { int lineIndex = layout.getLineIndex(offsetInLine); int[] offsets = layout.getLineOffsets(); Caret caret = getCaret(); if (caret != null && lineIndex != 0 && offsetInLine == offsets[lineIndex]) { int lineY = layout.getLineBounds(lineIndex).y; int caretY = caret.getLocation().y - getLinePixel(getCaretLine()); if (lineY > caretY) lineIndex--; caretAlignment = OFFSET_LEADING; } return lineIndex; } int getCaretDirection() {
int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); int lineInParagraph = layout.getLineIndex(Math.min(offset - lineOffset, layout.getText().length())); int height = layout.getLineBounds(lineInParagraph).height; renderer.disposeTextLayout(layout);
int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); int lineInParagraph = layout.getLineIndex(Math.min(offset - lineOffset, layout.getText().length())); int height = layout.getLineBounds(lineInParagraph).height; renderer.disposeTextLayout(layout);
int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); int lineInParagraph = layout.getLineIndex(Math.min(offset - lineOffset, layout.getText().length())); FontMetrics metrics = layout.getLineMetrics(lineInParagraph); renderer.disposeTextLayout(layout);
int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); int lineInParagraph = layout.getLineIndex(Math.min(offset - lineOffset, layout.getText().length())); FontMetrics metrics = layout.getLineMetrics(lineInParagraph); renderer.disposeTextLayout(layout);
int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); int lineInParagraph = layout.getLineIndex(Math.min(offset - lineOffset, layout.getText().length())); FontMetrics metrics = layout.getLineMetrics(lineInParagraph); renderer.disposeTextLayout(layout);
int getOffsetAtPoint(int x, int y, int[] trailing, boolean inTextOnly) { if (inTextOnly && y + getVerticalScrollOffset() < 0 || x + horizontalScrollOffset < 0) { return -1; } int bottomIndex = getPartialBottomIndex(); int height = getLinePixel(bottomIndex + 1); if (inTextOnly && y > height) { return -1; } int lineIndex = getLineIndex(y); int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); x += horizontalScrollOffset - leftMargin; y -= getLinePixel(lineIndex); int offset = layout.getOffset(x, y, trailing); Rectangle rect = layout.getLineBounds(layout.getLineIndex(offset)); renderer.disposeTextLayout(layout); if (inTextOnly && !(rect.x <= x && x <= rect.x + rect.width)) { return -1; } return offset + lineOffset; } /**
int getOffsetAtPoint(int x, int y, int[] trailing, boolean inTextOnly) { if (inTextOnly && y + getVerticalScrollOffset() < 0 || x + horizontalScrollOffset < 0) { return -1; } int bottomIndex = getPartialBottomIndex(); int height = getLinePixel(bottomIndex + 1); if (inTextOnly && y > height) { return -1; } int lineIndex = getLineIndex(y); int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); x += horizontalScrollOffset - leftMargin; y -= getLinePixel(lineIndex); int offset = layout.getOffset(x, y, trailing); Rectangle rect = layout.getLineBounds(layout.getLineIndex(offset)); renderer.disposeTextLayout(layout); if (inTextOnly && !(rect.x <= x && x <= rect.x + rect.width)) { return -1; } return offset + lineOffset; } /**
int getOffsetAtPoint(int x, int y, int[] trailing, boolean inTextOnly) { if (inTextOnly && y + getVerticalScrollOffset() < 0 || x + horizontalScrollOffset < 0) { return -1; } int bottomIndex = getPartialBottomIndex(); int height = getLinePixel(bottomIndex + 1); if (inTextOnly && y > height) { return -1; } int lineIndex = getLineIndex(y); int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); x += horizontalScrollOffset - leftMargin; y -= getLinePixel(lineIndex); int offset = layout.getOffset(x, y, trailing); Rectangle rect = layout.getLineBounds(layout.getLineIndex(offset)); renderer.disposeTextLayout(layout); if (inTextOnly && !(rect.x <= x && x <= rect.x + rect.width)) { return -1; } return offset + lineOffset; } /**
int getOffsetAtPoint(int x, int y, int[] trailing, boolean inTextOnly) { if (inTextOnly && y + getVerticalScrollOffset() < 0 || x + horizontalScrollOffset < 0) { return -1; } int bottomIndex = getPartialBottomIndex(); int height = getLinePixel(bottomIndex + 1); if (inTextOnly && y > height) { return -1; } int lineIndex = getLineIndex(y); int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); x += horizontalScrollOffset - leftMargin; y -= getLinePixel(lineIndex); int offset = layout.getOffset(x, y, trailing); Rectangle rect = layout.getLineBounds(layout.getLineIndex(offset)); renderer.disposeTextLayout(layout); if (inTextOnly && !(rect.x <= x && x <= rect.x + rect.width)) { return -1; } return offset + lineOffset; } /**
int getOffsetAtPoint(int x, int y, int[] trailing, boolean inTextOnly) { if (inTextOnly && y + getVerticalScrollOffset() < 0 || x + horizontalScrollOffset < 0) { return -1; } int bottomIndex = getPartialBottomIndex(); int height = getLinePixel(bottomIndex + 1); if (inTextOnly && y > height) { return -1; } int lineIndex = getLineIndex(y); int lineOffset = content.getOffsetAtLine(lineIndex); TextLayout layout = renderer.getTextLayout(lineIndex); x += horizontalScrollOffset - leftMargin; y -= getLinePixel(lineIndex); int offset = layout.getOffset(x, y, trailing); Rectangle rect = layout.getLineBounds(layout.getLineIndex(offset)); renderer.disposeTextLayout(layout); if (inTextOnly && !(rect.x <= x && x <= rect.x + rect.width)) { return -1; } return offset + lineOffset; } /**
/** * Moves the caret to the next character or to the beginning of the * next line if the cursor is at the end of a line. */ void doSelectionCursorNext() { int caretLine = getCaretLine(); int lineOffset = content.getOffsetAtLine(caretLine); int offsetInLine = caretOffset - lineOffset; int offset, alignment; if (offsetInLine < content.getLine(caretLine).length()) { TextLayout layout = renderer.getTextLayout(caretLine); offsetInLine = layout.getNextOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); int lineStart = layout.getLineOffsets()[layout.getLineIndex(offsetInLine)]; renderer.disposeTextLayout(layout); offset = offsetInLine + lineOffset; alignment = offsetInLine == lineStart ? OFFSET_LEADING : PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } else if (caretLine < content.getLineCount() - 1 && !isSingleLine()) { caretLine++; offset = content.getOffsetAtLine(caretLine); alignment = PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } } /**
/** * Moves the caret to the next character or to the beginning of the * next line if the cursor is at the end of a line. */ void doSelectionCursorNext() { int caretLine = getCaretLine(); int lineOffset = content.getOffsetAtLine(caretLine); int offsetInLine = caretOffset - lineOffset; int offset, alignment; if (offsetInLine < content.getLine(caretLine).length()) { TextLayout layout = renderer.getTextLayout(caretLine); offsetInLine = layout.getNextOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); int lineStart = layout.getLineOffsets()[layout.getLineIndex(offsetInLine)]; renderer.disposeTextLayout(layout); offset = offsetInLine + lineOffset; alignment = offsetInLine == lineStart ? OFFSET_LEADING : PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } else if (caretLine < content.getLineCount() - 1 && !isSingleLine()) { caretLine++; offset = content.getOffsetAtLine(caretLine); alignment = PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } } /**
/** * Moves the caret to the next character or to the beginning of the * next line if the cursor is at the end of a line. */ void doSelectionCursorNext() { int caretLine = getCaretLine(); int lineOffset = content.getOffsetAtLine(caretLine); int offsetInLine = caretOffset - lineOffset; int offset, alignment; if (offsetInLine < content.getLine(caretLine).length()) { TextLayout layout = renderer.getTextLayout(caretLine); offsetInLine = layout.getNextOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); int lineStart = layout.getLineOffsets()[layout.getLineIndex(offsetInLine)]; renderer.disposeTextLayout(layout); offset = offsetInLine + lineOffset; alignment = offsetInLine == lineStart ? OFFSET_LEADING : PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } else if (caretLine < content.getLineCount() - 1 && !isSingleLine()) { caretLine++; offset = content.getOffsetAtLine(caretLine); alignment = PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } } /**
/** * Moves the caret to the next character or to the beginning of the * next line if the cursor is at the end of a line. */ void doSelectionCursorNext() { int caretLine = getCaretLine(); int lineOffset = content.getOffsetAtLine(caretLine); int offsetInLine = caretOffset - lineOffset; int offset, alignment; if (offsetInLine < content.getLine(caretLine).length()) { TextLayout layout = renderer.getTextLayout(caretLine); offsetInLine = layout.getNextOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); int lineStart = layout.getLineOffsets()[layout.getLineIndex(offsetInLine)]; renderer.disposeTextLayout(layout); offset = offsetInLine + lineOffset; alignment = offsetInLine == lineStart ? OFFSET_LEADING : PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } else if (caretLine < content.getLineCount() - 1 && !isSingleLine()) { caretLine++; offset = content.getOffsetAtLine(caretLine); alignment = PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } } /**
/** * Moves the caret to the next character or to the beginning of the * next line if the cursor is at the end of a line. */ void doSelectionCursorNext() { int caretLine = getCaretLine(); int lineOffset = content.getOffsetAtLine(caretLine); int offsetInLine = caretOffset - lineOffset; int offset, alignment; if (offsetInLine < content.getLine(caretLine).length()) { TextLayout layout = renderer.getTextLayout(caretLine); offsetInLine = layout.getNextOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); int lineStart = layout.getLineOffsets()[layout.getLineIndex(offsetInLine)]; renderer.disposeTextLayout(layout); offset = offsetInLine + lineOffset; alignment = offsetInLine == lineStart ? OFFSET_LEADING : PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } else if (caretLine < content.getLineCount() - 1 && !isSingleLine()) { caretLine++; offset = content.getOffsetAtLine(caretLine); alignment = PREVIOUS_OFFSET_TRAILING; setCaretOffset(offset, alignment); showCaret(); } } /**