Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/tabs/sessions/terminal/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ const TerminalComponent = forwardRef<TerminalHandle, TerminalProps>(
.xterm-viewport {
width: 100% !important;
height: 100% !important;
-webkit-overflow-scrolling: touch;
}

.xterm {
Expand Down Expand Up @@ -593,6 +594,25 @@ const TerminalComponent = forwardRef<TerminalHandle, TerminalProps>(
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');
Expand Down