configurable scrolling speed implemented

This commit is contained in:
Vaclav Tvrdik
2026-09-16 16:14:42 +02:00
parent 119d4124f0
commit d371d35fb3
4 changed files with 16 additions and 8 deletions

View File

@@ -362,9 +362,11 @@ replaces both together.
**Plugin settings** (`vterm.sublime-settings`, read through the cached `settings()`
handle): `auto_close`, `scrollback_history_size`, `honor_erase_scrollback`,
`scroll_modifier`, `min_columns`, `max_columns`, `theme`, `ansi_colors`, `terminal`,
`scroll_modifier`, `wheel_lines`, `min_columns`, `max_columns`, `theme`, `ansi_colors`, `terminal`,
`parameters`, `debug`. `scroll_modifier` is the modifier that turns PgUp/PgDn and Up/Down
into a scroll of the view — a page, a row — instead of a key for the app. `terminal` and
into a scroll of the view — a page, a row — instead of a key for the app. `wheel_lines`
is how many scroll lines one wheel notch sends the app (3, as iTerm2 delivers per notch;
a trackpad converted to notches scrolls that much faster, so lower it). `terminal` and
`parameters` name the external terminal spawned by *vterm: Open Terminal in Project
Folder* (`%CWD%` in `parameters` becomes the project folder). ED 3 never touches the visible screen (as in
xterm), and `honor_erase_scrollback` is off, so it does not drop the scrollback either:

View File

@@ -56,7 +56,9 @@ wheel tick sends arrow keys (alternate scroll, as kitty/iTerm2 do — this is
what scrolls Claude Code's fullscreen UI before it enables mouse reporting).
Sublime raises no wheel event at all for the trackpad (sublime_text#1838): set
a utility such as [LinearMouse](https://linearmouse.app/) to discrete scrolling
for Sublime Text and it arrives as wheel notches like any other. While an app owns the
for Sublime Text and it arrives as wheel notches like any other. A notch sends the
app three scroll lines, as iTerm2 does; `wheel_lines` lowers that when a swipe
scrolls too far. While an app owns the
alternate screen the scrollback above it is folded away, kitty-style, and
unfolds when the app leaves it.
@@ -154,7 +156,8 @@ instead), image protocols, Windows, panels.
- Trackpad scrolling needs a helper on macOS: Sublime never delivers it to a
plugin (sublime_text#1838), so set a utility such as
[LinearMouse](https://linearmouse.app/) to discrete/linear scrolling for
Sublime Text. It then arrives as wheel notches and scrolls the app. Without
Sublime Text. It then arrives as wheel notches and scrolls the app, three
lines a notch unless `wheel_lines` says otherwise. Without
one, the trackpad does nothing in a full-screen app; the mouse wheel,
`shift+pageup/pagedown` and `shift+up/down` work regardless.

View File

@@ -15,6 +15,10 @@
// null sends the keys to the app
"scroll_modifier": "shift",
// scroll lines sent to the app per wheel notch (iTerm2 sends 3).
// A trackpad via LinearMouse makes many notches per swipe; 1 is calmer.
"wheel_lines": 1,
"min_columns": 20,
"max_columns": 500,

View File

@@ -8,14 +8,12 @@ notches and take the path below.
import sublime_plugin
from .terminal import Terminal
from .utils import settings
# SGR button numbers for the wheel; 64 is the "scroll" bit plus direction
WHEEL_UP = 64
WHEEL_DOWN = 65
# lines per wheel tick, as iTerm2 delivers per notch
WHEEL_LINES = 3
def send_scroll(terminal, up, lines, cell=None):
"""Report `lines` scroll lines to the app, or fake arrow keys on the alt screen.
@@ -105,7 +103,8 @@ class VtermScrollCommand(sublime_plugin.TextCommand):
cell = None
if terminal.screen.mouse_reporting_enabled() and event:
cell = _event_to_cell(self.view, terminal, event, clamp=True)
send_scroll(terminal, up, WHEEL_LINES, cell)
lines = max(0, int(settings().get("wheel_lines", 3)))
send_scroll(terminal, up, lines, cell)
def want_event(self):
"""Ask sublime for the wheel coordinates."""