Mouse wheel by 3
authorKevin Lamonte <kevin.lamonte@gmail.com>
Tue, 15 Aug 2017 16:22:26 +0000 (12:22 -0400)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Tue, 15 Aug 2017 16:22:26 +0000 (12:22 -0400)
src/jexer/TEditorWidget.java

index 690c5731f280a936cd1ce6f5ac3bbcf0c4d4f4ac..823dea2d113c2d62b66e164dc06b2ce070e8cb69 100644 (file)
@@ -45,6 +45,11 @@ import static jexer.TKeypress.*;
  */
 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.
      */
@@ -122,16 +127,20 @@ public final class TEditorWidget extends TWidget {
     @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()) {
-            if (topLine < document.getLineCount() - 1) {
-                topLine++;
-                alignDocument(true);
+            for (int i = 0; i < wheelScrollSize; i++) {
+                if (topLine < document.getLineCount() - 1) {
+                    topLine++;
+                    alignDocument(true);
+                }
             }
             return;
         }