git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes for TJIDE
[fanfix.git]
/
src
/
jexer
/
TEditorWidget.java
diff --git
a/src/jexer/TEditorWidget.java
b/src/jexer/TEditorWidget.java
index 8d2a0104b4c598aec5de23f06a4e879e4871171a..823dea2d113c2d62b66e164dc06b2ce070e8cb69 100644
(file)
--- a/
src/jexer/TEditorWidget.java
+++ b/
src/jexer/TEditorWidget.java
@@
-45,6
+45,11
@@
import static jexer.TKeypress.*;
*/
public final class TEditorWidget extends TWidget {
*/
public final class TEditorWidget extends TWidget {
+ /**
+ * The number of lines to scroll on mouse wheel up/down.
+ */
+ private static final int wheelScrollSize = 3;
+
/**
* The document being edited.
*/
/**
* The document being edited.
*/
@@
-122,16
+127,20
@@
public final class TEditorWidget extends TWidget {
@Override
public void onMouseDown(final TMouseEvent mouse) {
if (mouse.isMouseWheelUp()) {
@Override
public void onMouseDown(final TMouseEvent mouse) {
if (mouse.isMouseWheelUp()) {
- if (topLine > 0) {
- topLine--;
- alignDocument(false);
+ for (int i = 0; i < wheelScrollSize; i++) {
+ if (topLine > 0) {
+ topLine--;
+ alignDocument(false);
+ }
}
return;
}
if (mouse.isMouseWheelDown()) {
}
return;
}
if (mouse.isMouseWheelDown()) {
- if (topLine < document.getLineCount() - 1) {
- topLine++;
- alignDocument(true);
+ for (int i = 0; i < wheelScrollSize; i++) {
+ if (topLine < document.getLineCount() - 1) {
+ topLine++;
+ alignDocument(true);
+ }
}
return;
}
}
return;
}
@@
-183,8
+192,13
@@
public final class TEditorWidget extends TWidget {
// Need to move topLine to bring document back into view.
if (topLineIsTop) {
topLine = line - (getHeight() - 1);
// 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;
} else {
topLine = line;
+ assert (topLine >= 0);
}
}
}
}
@@
-193,6
+207,7
@@
public final class TEditorWidget extends TWidget {
*/
// Document is in view, let's set cursorY
*/
// Document is in view, let's set cursorY
+ assert (line >= topLine);
setCursorY(line - topLine);
alignCursor();
}
setCursorY(line - topLine);
alignCursor();
}
@@
-385,7
+400,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) {
* @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
+423,10
@@
public final class TEditorWidget extends TWidget {
* column.
*/
public void setEditingColumnNumber(final int column) {
* column.
*/
public void setEditingColumnNumber(final int column) {
- document.setCursor(column - 1);
+ if ((column > 0) && (column < document.getLineLength())) {
+ document.setCursor(column - 1);
+ alignCursor();
+ }
}
/**
}
/**