int availableHeight = 0; if (partialHeight != 0) { availableHeight = lineHeight - partialHeight; } int lineIndex = partialTopIndex - 1; while (height > availableHeight && lineIndex >= 0) { availableHeight += renderer.getLineHeight(lineIndex--); } int caretHeight = height; if (wordWrap) { int offsetInLine = caretOffset - content.getOffsetAtLine(caretLine); TextLayout layout = renderer.getTextLayout(caretLine); lineIndex = layout.getLineIndex(offsetInLine); int[] offsets = layout.getLineOffsets(); if (lineIndex != 0 && offsetInLine == offsets[lineIndex] && caretAlignment == PREVIOUS_OFFSET_TRAILING) { lineIndex--; } caretHeight += layout.getBounds().height - layout.getLineBounds(lineIndex).y; renderer.disposeTextLayout(layout); } lineIndex = caretLine; lineHeight = renderer.getLineHeight(lineIndex); while (caretHeight - lineHeight >= 0 && lineIndex > 0) { caretHeight -= lineHeight; lineHeight = renderer.getLineHeight(--lineIndex); } lineHeight = renderer.getLineHeight(lineIndex); caretOffset = getOffsetAtPoint(columnX, lineHeight - caretHeight, lineIndex); if (select) doSelection(ST.COLUMN_PREVIOUS); height = Math.min(height, availableHeight); scrollVertical(-height, true); if (height == 0) setCaretLocation();
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;}