diff --git a/Architecture.md b/Architecture.md index 0d55685..21a59dd 100644 --- a/Architecture.md +++ b/Architecture.md @@ -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: diff --git a/README.md b/README.md index 4b8a7e3..6941afa 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/vterm.sublime-settings b/vterm.sublime-settings index 09bc410..8e6b1cf 100644 --- a/vterm.sublime-settings +++ b/vterm.sublime-settings @@ -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, diff --git a/vterm/mouse.py b/vterm/mouse.py index 1290cfa..62e5fb1 100644 --- a/vterm/mouse.py +++ b/vterm/mouse.py @@ -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."""