X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTEditorWidget.java;h=dcf5e9e6d267380d3b541bf275d4cdef67f8dcea;hb=7d922e0dfd9a6da42b84e01d52adeec6fff10025;hp=823dea2d113c2d62b66e164dc06b2ce070e8cb69;hpb=b1a8acec8adc13327268b1e600d367b2ba0cccc0;p=fanfix.git diff --git a/src/jexer/TEditorWidget.java b/src/jexer/TEditorWidget.java index 823dea2..dcf5e9e 100644 --- a/src/jexer/TEditorWidget.java +++ b/src/jexer/TEditorWidget.java @@ -43,7 +43,7 @@ import static jexer.TKeypress.*; * TEditorWidget displays an editable text document. It is unaware of * scrolling behavior, but can respond to mouse and keyboard events. */ -public final class TEditorWidget extends TWidget { +public class TEditorWidget extends TWidget { /** * The number of lines to scroll on mouse wheel up/down. @@ -164,7 +164,7 @@ public final class TEditorWidget extends TWidget { document.setLineNumber(newLine); setCursorY(mouse.getY()); - if (newX > document.getCurrentLine().getDisplayLength()) { + if (newX >= document.getCurrentLine().getDisplayLength()) { document.end(); alignCursor(); } else { @@ -385,6 +385,28 @@ public final class TEditorWidget extends TWidget { return document.getLineCount(); } + /** + * Get the current visible top row number. 1-based. + * + * @return the visible top row number. Row 1 is the first row. + */ + public int getVisibleRowNumber() { + return topLine + 1; + } + + /** + * Set the current visible row number. 1-based. + * + * @param row the new visible row number. Row 1 is the first row. + */ + public void setVisibleRowNumber(final int row) { + assert (row > 0); + if ((row > 0) && (row < document.getLineCount())) { + topLine = row - 1; + alignDocument(true); + } + } + /** * Get the current editing row number. 1-based. *