From fea34941d3b4b38877584ef3878adf95b9ee6b23 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 25 Nov 2026 23:39:00 +0000 Subject: [PATCH] xterm: answer DSR 6 one-based; list the local patches The cursor position report sent zero-based coordinates (the app's terminal session overrides it with the same fix, which keeps working). The vendored README now lists every local patch. Co-Authored-By: Claude Opus 5.5 --- .../cursor_movement_test.dart | 5 ++++ app/third_party/xterm/README.md | 27 ++++++++++++------- .../xterm/lib/src/core/escape/emitter.dart | 4 ++- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/test/third_party_xterm/cursor_movement_test.dart b/app/test/third_party_xterm/cursor_movement_test.dart index c932c482..7816b278 100644 --- a/app/test/third_party_xterm/cursor_movement_test.dart +++ b/app/test/third_party_xterm/cursor_movement_test.dart @@ -52,6 +52,11 @@ void main() { expect(t.buffer.cursorY, 3); }); + test('DSR 6 reports the one-based cursor position', () { + final t = FixtureTerminal()..feed('\x1b[3;7H\x1b[6n'); + expect(t.takeReplies(), '\x1b[3;7R'); + }); + test('zero counts mean one', () { final t = FixtureTerminal()..feed('\x1b[0C\x1b[0B'); expect(t.buffer.cursorX, 1); diff --git a/app/third_party/xterm/README.md b/app/third_party/xterm/README.md index fb792648..fa2ffc63 100644 --- a/app/third_party/xterm/README.md +++ b/app/third_party/xterm/README.md @@ -15,12 +15,21 @@ still compiles as part of every app build. Local patches (keep this list current): -- colon-form SGR subparameters (`4:3`, `38:2::r:g:b`, `58`/`59`) -- DCS/APC/PM/SOS strings consumed rather than printed -- full RIS (`ESC c`) reset -- DECSCUSR cursor shapes, SCOSC/SCORC, CHT, CBT, HPA, HPR, VPR -- OSC 10/11/12 colour queries, OSC 8/52/7 callbacks -- alternate screen 1049 cursor restore, separate DECCKM mode -- mouse wheel, drag/motion and middle-button reporting; Shift selection override -- cursor and attribute rendering (inverse block cursor, strikethrough, conceal) -- focus reporting (`?1004`) +- CSI parsing: colon subparameters (`4:3`, `38:2::r:g:b`, `58`/`59`), + intermediates and private prefixes (`CSI > 4;2 m` is not SGR), empty + parameters as defaults; SGR 21 is double underline, 53/55 overline +- DCS/APC/PM/SOS strings consumed rather than printed; DECRQSS (`m`, `r`, + ` q`) answered +- RIS (`ESC c`) full reset and DECSTR (`CSI ! p`) +- DECSCUSR cursor shapes (blinking is stored, not animated); SCOSC/SCORC, + CHT, CBT, HPA, HPR, VPR; HTS sets tab stops; DSR 6 one-based +- OSC 10/11/12 colour queries from the view's theme; OSC 8 links on cells + (`Terminal.hyperlinkAt`); OSC 52 set (`onClipboardSet`, no reads); OSC 7 + (`onWorkingDirectoryChange`) +- alternate screen 1049 restores the cursor; arrow keys follow DECCKM +- mouse: wheel 64/65, screen-cell coordinates, drag (1002) and motion + (1003) reporting, middle button, Shift+drag selects + (`ui/mouse_listener.dart`) +- rendering: block cursor shows the character inverted, underline/bar + cursor position, strikethrough, conceal, overline, underline styles +- focus reporting (`?1004`, `Terminal.focusInput`, called by `TerminalView`) diff --git a/app/third_party/xterm/lib/src/core/escape/emitter.dart b/app/third_party/xterm/lib/src/core/escape/emitter.dart index e697f73a..f30a8f67 100644 --- a/app/third_party/xterm/lib/src/core/escape/emitter.dart +++ b/app/third_party/xterm/lib/src/core/escape/emitter.dart @@ -19,8 +19,10 @@ class EscapeEmitter { return '\x1b[0n'; } + /// The CPR reply for the zero-based cursor ([x], [y]); the protocol is + /// one-based. String cursorPosition(int x, int y) { - return '\x1b[$y;${x}R'; + return '\x1b[${y + 1};${x + 1}R'; } String bracketedPaste(String text) {