X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTEditorWidget.java;h=690c5731f280a936cd1ce6f5ac3bbcf0c4d4f4ac;hb=fe0770f988e64fc0ccafd3d3b086b4a0eb559d3b;hp=8d2a0104b4c598aec5de23f06a4e879e4871171a;hpb=df602ccf5e32585c26dc618dd3b4a759b6820943;p=fanfix.git diff --git a/src/jexer/TEditorWidget.java b/src/jexer/TEditorWidget.java index 8d2a010..690c573 100644 --- a/src/jexer/TEditorWidget.java +++ b/src/jexer/TEditorWidget.java @@ -183,8 +183,13 @@ public final class TEditorWidget extends TWidget { // Need to move topLine to bring document back into view. if (topLineIsTop) { topLine = line - (getHeight() - 1); + if (topLine < 0) { + topLine = 0; + } + assert (topLine >= 0); } else { topLine = line; + assert (topLine >= 0); } } @@ -193,6 +198,7 @@ public final class TEditorWidget extends TWidget { */ // Document is in view, let's set cursorY + assert (line >= topLine); setCursorY(line - topLine); alignCursor(); } @@ -385,7 +391,11 @@ public final class TEditorWidget extends TWidget { * @param row the new editing row number. Row 1 is the first row. */ public void setEditingRowNumber(final int row) { - document.setLineNumber(row - 1); + assert (row > 0); + if ((row > 0) && (row < document.getLineCount())) { + document.setLineNumber(row - 1); + alignTopLine(true); + } } /** @@ -404,7 +414,10 @@ public final class TEditorWidget extends TWidget { * column. */ public void setEditingColumnNumber(final int column) { - document.setCursor(column - 1); + if ((column > 0) && (column < document.getLineLength())) { + document.setCursor(column - 1); + alignCursor(); + } } /**