From: Kevin Lamonte Date: Tue, 15 Aug 2017 16:22:26 +0000 (-0400) Subject: Mouse wheel by 3 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=b1a8acec8adc13327268b1e600d367b2ba0cccc0;p=fanfix-jexer.git Mouse wheel by 3 --- diff --git a/src/jexer/TEditorWidget.java b/src/jexer/TEditorWidget.java index 690c573..823dea2 100644 --- a/src/jexer/TEditorWidget.java +++ b/src/jexer/TEditorWidget.java @@ -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; }