if (layout.getLineCount() > 0) { Point pos = getCaret().getLocation(); pos.x = columnX + horizontalScrollOffset; pos.y -= getLinePixel(caretLine); int offset = layout.getOffset(pos, null); int lineInParagraph = layout.getLineIndex(offset); if (lineInParagraph < layout.getLineCount() - 1) { int lineOffset = content.getOffsetAtLine(caretLine); paragraphDown = false; pos.y += layout.getLineBounds(lineInParagraph).height; caretOffset = lineOffset + layout.getOffset(pos, null); advancing = false; }
int lineIndex = layout.getLineIndex(offsetInLine); int[] offsets = layout.getLineOffsets(); int layoutLineCount = layout.getLineCount(); if (lineIndex != 0 && offsetInLine == offsets[lineIndex] && caretAlignment == PREVIOUS_OFFSET_TRAILING) { lineIndex--;
void doLineDown(boolean select) {	int caretLine = getCaretLine();	boolean paragraphDown = true;	if (wordWrap) {		TextLayout layout = renderer.getTextLayout(caretLine);		if (layout.getLineCount() > 0) {			Point pos = getCaret().getLocation();			pos.x = columnX + horizontalScrollOffset;			pos.y -= getLinePixel(caretLine);			int offset = layout.getOffset(pos, null);			int lineInParagraph = layout.getLineIndex(offset);			if (lineInParagraph < layout.getLineCount() - 1) {				int lineOffset = content.getOffsetAtLine(caretLine);				paragraphDown = false;				pos.y += layout.getLineBounds(lineInParagraph).height;				caretOffset = lineOffset + layout.getOffset(pos, null);				advancing = false;			}		}		renderer.disposeTextLayout(layout);	}	if (select && caretLine == content.getLineCount() - 1) {		caretOffset = content.getCharCount();	}	if (paragraphDown && caretLine < content.getLineCount() - 1) {		caretLine++;		int lineOffset = content.getOffsetAtLine(caretLine);		TextLayout layout = renderer.getTextLayout(caretLine);		int x = columnX + horizontalScrollOffset - leftMargin;		caretOffset = lineOffset + layout.getOffset(x, 0, null);		advancing = false;		renderer.disposeTextLayout(layout);	}	int oldColumnX = columnX;	int oldHScrollOffset = horizontalScrollOffset;	if (select) {		setMouseWordSelectionAnchor();			// select first and then scroll to reduce flash when key 		// repeat scrolls lots of lines		doSelection(ST.COLUMN_NEXT);	}	showCaret();	int hScrollChange = oldHScrollOffset - horizontalScrollOffset;	columnX = oldColumnX + hScrollChange;}