int oldVScrollOffset = getVerticalScrollOffset(); int caretY = getCaret().getLocation().y; int vscroll = Math.min(getVerticalScrollOffset(), height); scrollVertical(-vscroll, true); caretY -= height - (oldVScrollOffset - getVerticalScrollOffset()); caretOffset = getOffsetAtPoint(columnX, caretY); setCaretLocation(); if (select) { doSelection(ST.COLUMN_PREVIOUS);
int caretLine = getCaretLine(); int partialTopIndex = getPartialTopIndex(); int lineHeight = renderer.getLineHeight(partialTopIndex); if (height == -1) { if (partialHeight == 0) { height = clientAreaHeight; } else { height = clientAreaHeight - partialHeight; if (wordWrap) { int y = lineHeight - partialHeight; TextLayout layout = renderer.getTextLayout(partialTopIndex); for (int i = 0; i < layout.getLineCount(); i++) { Rectangle bounds = layout.getLineBounds(i); if (bounds.contains(bounds.x, y)) { height += lineHeight - (bounds.y + bounds.height); break; } } renderer.disposeTextLayout(layout); } } } else { int lineIndex = getLineIndex(clientAreaHeight - height); int topLineY = getLinePixel(lineIndex); if (wordWrap) { TextLayout layout = renderer.getTextLayout(lineIndex); int y = topLineY; for (int i = 0; i < layout.getLineCount(); i++) { Rectangle bounds = layout.getLineBounds(i); if (bounds.contains(bounds.x, y)) { height = clientAreaHeight - (topLineY + bounds.y); break; } } renderer.disposeTextLayout(layout); } else { height = clientAreaHeight - topLineY; }
void doPageUp(boolean select, int height) {	if (isSingleLine()) {		return;	}	int oldHScrollOffset = horizontalScrollOffset;	int oldColumnX = columnX;		if (isFixedLineHeight()) {		int caretLine = getCaretLine();			if (caretLine > 0) {			int lineHeight = renderer.getLineHeight();			int lines = height / lineHeight;			int scrollLines = Math.max(1, Math.min(caretLine, lines));			caretLine -= scrollLines;			caretOffset = getOffsetAtPoint(columnX, getLinePixel(caretLine));			if (select) {				doSelection(ST.COLUMN_PREVIOUS);			}			// scroll one page up or to the top			int scrollOffset = Math.max(0, getVerticalScrollOffset() - scrollLines * getVerticalIncrement());			if (scrollOffset < getVerticalScrollOffset()) {				scrollVertical(scrollOffset - getVerticalScrollOffset(), true);			}		}	} else {		int oldVScrollOffset = getVerticalScrollOffset();		int caretY = getCaret().getLocation().y;			int vscroll = Math.min(getVerticalScrollOffset(), height);		scrollVertical(-vscroll, true);		caretY -= height - (oldVScrollOffset - getVerticalScrollOffset());		caretOffset = getOffsetAtPoint(columnX, caretY);		setCaretLocation();		if (select) {			doSelection(ST.COLUMN_PREVIOUS);		}	}	showCaret();	int hScrollChange = oldHScrollOffset - horizontalScrollOffset;	columnX = oldColumnX + hScrollChange;}