xterm: add SCOSC/SCORC, CHT, CBT, HPA, HPR and VPR; fix HTS
CSI s / CSI u save and restore the cursor (without parameters; prefixed forms such as the kitty keyboard query CSI ? u are left alone). CSI I and CSI Z move by tab stops, CSI ` sets the column, CSI a and CSI e move relative. ESC H (HTS) set no tab stop because it called isSetAt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
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('zero counts mean one', () {
|
||||
final t = FixtureTerminal()..feed('\x1b[0C\x1b[0B');
|
||||
expect(t.buffer.cursorX, 1);
|
||||
expect(t.buffer.cursorY, 1);
|
||||
});
|
||||
}
|
||||
@@ -26,6 +26,12 @@ class FixtureTerminal {
|
||||
return data;
|
||||
}
|
||||
|
||||
/// The character at column [x] of screen row [y], '' for an empty cell.
|
||||
String charAt(int x, int y) {
|
||||
final code = cell(x, y).content & CellContent.codepointMask;
|
||||
return code == 0 ? '' : String.fromCharCode(code);
|
||||
}
|
||||
|
||||
/// The replies sent so far, joined, and then forgotten.
|
||||
String takeReplies() {
|
||||
final all = replies.join();
|
||||
|
||||
Reference in New Issue
Block a user