From 3791f30f1f4ef420d73f1d4433a51af1f8e40e2b Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Wed, 13 May 2026 03:27:02 +0800 Subject: [PATCH] fix: improve iOS terminal scroll speed with touch-driven scrollLines iOS WebView does not generate wheel events from touch gestures, so xterm's built-in scroll was limited to the native viewport scroll which moves only one line at a time. Add a touchmove listener that maps vertical swipe distance to terminal.scrollLines() for responsive scrolling, and enable -webkit-overflow-scrolling: touch on the viewport. Fixes Termix-SSH/Support#551 --- app/tabs/sessions/terminal/Terminal.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/tabs/sessions/terminal/Terminal.tsx b/app/tabs/sessions/terminal/Terminal.tsx index 3c84ab3..6444752 100644 --- a/app/tabs/sessions/terminal/Terminal.tsx +++ b/app/tabs/sessions/terminal/Terminal.tsx @@ -262,6 +262,7 @@ const TerminalComponent = forwardRef( .xterm-viewport { width: 100% !important; height: 100% !important; + -webkit-overflow-scrolling: touch; } .xterm { @@ -593,6 +594,25 @@ const TerminalComponent = forwardRef( setTimeout(handleResize, 100); }); + // Touch-scroll acceleration for iOS WebView + (function() { + var scrollTouchY = null; + var lineH = terminal._core._renderService.dimensions.css.cell.height || ${baseFontSize * 1.2}; + terminalElement.addEventListener('touchstart', function(e) { + if (e.touches.length === 1) scrollTouchY = e.touches[0].clientY; + }, { passive: true, capture: true }); + terminalElement.addEventListener('touchmove', function(e) { + if (scrollTouchY === null || e.touches.length !== 1) return; + var dy = scrollTouchY - e.touches[0].clientY; + scrollTouchY = e.touches[0].clientY; + var lines = Math.trunc(dy / lineH); + if (lines !== 0) terminal.scrollLines(lines); + }, { passive: true, capture: true }); + terminalElement.addEventListener('touchend', function() { + scrollTouchY = null; + }, { passive: true, capture: true }); + })(); + terminal.clear(); terminal.reset(); terminal.write('\\x1b[2J\\x1b[H');