Files
terminal-lab/pxterm/scripts/archive/cjs_tools/let_xterm_scroll.cjs
2026-03-04 13:25:26 +08:00

9 lines
684 B
JavaScript

const fs = require('fs');
let code = fs.readFileSync('src/components/TerminalPanel.vue', 'utf8');
// To let xterm's native mobile JS scroll work, we MUST NOT intercept touchmove with stopImmediatePropagation. We must pass the events cleanly to xterm.
const regexTouchMove = /onTouchKeyboardTouchMove = \(event: TouchEvent\) => \{[\s\S]*?event\.stopImmediatePropagation\(\);\n\s*\};/;
code = code.replace(regexTouchMove, `onTouchKeyboardTouchMove = (event: TouchEvent) => {\n // Let xterm handle the touchmove natively! Do not stop propagation. It needs to calculate delta and apply it to viewportScroller.\n };`);
fs.writeFileSync('src/components/TerminalPanel.vue', code);