Files
pipelines/app/test/third_party_xterm/cursor_movement_test.dart
T
alan fea34941d3 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 <noreply@anthropic.com>
2026-11-25 23:39:00 +00:00

66 lines
1.9 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'xterm_fixture.dart';
void main() {
test('CSI s / CSI u save and restore the cursor (SCOSC / SCORC)', () {
final t = FixtureTerminal()..feed('\x1b[2;3H\x1b[s\x1b[5;9Hx\x1b[uy');
expect(t.charAt(2, 1), 'y');
expect(t.charAt(8, 4), 'x');
expect(t.buffer.cursorX, 3);
expect(t.buffer.cursorY, 1);
});
test('CSI ? u (kitty keyboard query) does not restore the cursor', () {
final t = FixtureTerminal()..feed('\x1b[s\x1b[3;3H\x1b[?u');
expect(t.buffer.cursorX, 2);
expect(t.buffer.cursorY, 2);
expect(t.takeReplies(), '');
});
test('CHT moves forward by tab stops and stops at the last column', () {
final t = FixtureTerminal()..feed('\x1b[I');
expect(t.buffer.cursorX, 8);
t.feed('\x1b[2I');
expect(t.buffer.cursorX, 19);
});
test('CBT moves back by tab stops and stops at column 0', () {
final t = FixtureTerminal()..feed('\x1b[1;19H\x1b[Z');
expect(t.buffer.cursorX, 16);
t.feed('\x1b[5Z');
expect(t.buffer.cursorX, 0);
});
test('HTS sets a tab stop that HT and CBT use', () {
final t = FixtureTerminal()..feed('\x1b[1;4H\x1bH\r\t');
expect(t.buffer.cursorX, 3);
t.feed('\x1b[1;7H\x1b[Z');
expect(t.buffer.cursorX, 3);
});
test('HPA, HPR and VPR', () {
final t = FixtureTerminal()..feed('\x1b[7`');
expect(t.buffer.cursorX, 6);
t.feed('\x1b[3a');
expect(t.buffer.cursorX, 9);
t.feed('\x1b[a');
expect(t.buffer.cursorX, 10);
t.feed('\x1b[2e');
expect(t.buffer.cursorY, 2);
t.feed('\x1b[e');
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);
expect(t.buffer.cursorY, 1);
});
}