Skip to content

Forward touch scroll events as terminal input#2708

Open
splch wants to merge 3 commits intoish-app:masterfrom
splch:scroll-input-forwarding
Open

Forward touch scroll events as terminal input#2708
splch wants to merge 3 commits intoish-app:masterfrom
splch:scroll-input-forwarding

Conversation

@splch
Copy link
Copy Markdown

@splch splch commented Mar 21, 2026

Dispatches synthetic WheelEvents into hterm's existing onMouse_ pipeline so that touch scroll gestures reach programs that listen for them.

When mouse reporting is active (e.g. tmux set -g mouse on), hterm's VT.onTerminalMouse_ generates the appropriate escape sequences. When on the alternate screen (less, vim, man), hterm's built-in alternate scroll mode (DECSET 1007) sends arrow keys. On the primary screen with no mouse reporting, the handler is a no-op and existing scrollback behavior is unchanged.

Changes

TerminalView.m: compute scroll delta in scrollViewDidScroll: and forward to JS
term.js: add handleScrollDelta export that dispatches WheelEvents to scrollPort_.screen_

Test plan

  • tmux with set -g mouse on: touch scroll enters copy-mode and scrolls
  • less / man: touch scroll moves through content
  • Primary screen shell prompt: scrollback works as before

Fixes #2375
Fixes #2537

@tbodt
Copy link
Copy Markdown
Member

tbodt commented Mar 21, 2026

This feels too independent from hterm. Surely hterm already supports passing scroll events? iSH should reuse that as much as possible

@splch
Copy link
Copy Markdown
Author

splch commented Mar 21, 2026

This feels too independent from hterm. Surely hterm already supports passing scroll events? iSH should reuse that as much as possible

Great point i'm looking into this right now

@splch splch force-pushed the scroll-input-forwarding branch from dad428c to 529d715 Compare March 21, 2026 18:53
Dispatches synthetic WheelEvents into hterm's existing onMouse_
pipeline so touch scroll gestures reach programs that listen for
them. hterm handles mouse reporting (VT) and alternate screen
arrow keys (DECSET 1007) automatically.

On the primary screen with mouse reporting disabled, the existing
visual scrollback behavior is preserved unchanged.

Fixes ish-app#2375
Fixes ish-app#2537
@splch splch force-pushed the scroll-input-forwarding branch from 529d715 to d501ca9 Compare March 21, 2026 18:59
@splch
Copy link
Copy Markdown
Author

splch commented Mar 21, 2026

Note: Synthetic WheelEvents use default clientX/clientY (0, 0), so mouse wheel reports always map to terminal coordinates (1, 1). This works fine for scrolling in tmux, vim, less, etc., but programs that need accurate scroll position won't get it

Manho added a commit to Manho/ish that referenced this pull request Mar 24, 2026
…apps

When a full-screen TUI (e.g. Claude Code, vim, less) uses the alternate
screen buffer, UIScrollView has no scrollable content and
scrollViewDidScroll: never fires. This means touch swipe gestures are
silently dropped instead of reaching the remote program.

Changes:
- Add UIPanGestureRecognizer to detect vertical swipes independently of
  UIScrollView's scroll state
- Call exports.handleScrollDelta() from the pan gesture only, removing
  it from scrollViewDidScroll: to prevent spurious events on keyboard
  show/hide layout changes
- Add exports.handleScrollDelta() in term.js (from PR ish-app#2708) which
  dispatches synthetic WheelEvents into hterm's mouse pipeline; hterm
  forwards them as xterm mouse scroll sequences when mouse reporting is
  active or on the alternate screen

This enables touch scroll to work in tmux copy mode, allowing users to
scroll through conversation history in Claude Code and similar TUIs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants