7592aa1a82
ESC P, ESC X, ESC ^ and ESC _ now open a control string whose body is swallowed up to ST (ESC \), across writes; CAN/SUB or a non-ST ESC abort it. Previously the bodies were printed (nvim's DECRQSS ESC P $qm ESC \ showed as "$qm"). DECRQSS m and r are answered with DCS 1 $ r ... ST, other requests with DCS 0 $ r ST. ESC ESC restarts the escape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
1.9 KiB
Dart
62 lines
1.9 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'xterm_fixture.dart';
|
|
|
|
void main() {
|
|
test('DCS, APC, PM and SOS bodies are swallowed, not printed', () {
|
|
final t = FixtureTerminal()
|
|
..feed('a\x1bP+q544e\x1b\\b')
|
|
..feed('\x1b_Gf=24;AAAA\x1b\\c')
|
|
..feed('\x1b^private\x1b\\d')
|
|
..feed('\x1bXstring\x1b\\e');
|
|
expect(t.row(0), 'abcde');
|
|
});
|
|
|
|
test('a control string split across writes is still swallowed', () {
|
|
final t = FixtureTerminal()
|
|
..feed('x\x1bPtmux;')
|
|
..feed('\x1b')
|
|
..feed('\x1b[31mhidden')
|
|
..feed('\x1b')
|
|
..feed('\\y');
|
|
// An ESC that is not ST aborts the string, as on a VT; the next ESC
|
|
// starts a CSI, so the output after it is ordinary text again.
|
|
expect(t.row(0), 'xhiddeny');
|
|
expect(t.cell(1, 0).foreground, named(1));
|
|
});
|
|
|
|
test('ST split between writes ends the string', () {
|
|
final t = FixtureTerminal()
|
|
..feed('1\x1bPq#0;2;0;0;0#0~~@@')
|
|
..feed('\x1b')
|
|
..feed('\\2');
|
|
expect(t.row(0), '12');
|
|
});
|
|
|
|
test('CAN aborts a control string', () {
|
|
final t = FixtureTerminal()..feed('\x1bPjunk\x18ok');
|
|
expect(t.row(0), 'ok');
|
|
});
|
|
|
|
test('DECRQSS m reports the current SGR', () {
|
|
final t = FixtureTerminal()..feed('\x1b[1;4:3;38;5;196;48;2;1;2;3m');
|
|
t.takeReplies();
|
|
t.feed('\x1bP\$qm\x1b\\');
|
|
expect(t.takeReplies(), '\x1bP1\$r0;1;4:3;38;5;196;48;2;1;2;3m\x1b\\');
|
|
expect(t.row(0), '');
|
|
});
|
|
|
|
test('DECRQSS r reports margins; unknown requests are refused', () {
|
|
final t = FixtureTerminal()..feed('\x1b[2;4r');
|
|
t.feed('\x1bP\$qr\x1b\\');
|
|
expect(t.takeReplies(), '\x1bP1\$r2;4r\x1b\\');
|
|
t.feed('\x1bP\$qbogus\x1b\\');
|
|
expect(t.takeReplies(), '\x1bP0\$r\x1b\\');
|
|
});
|
|
|
|
test('a DCS other than DECRQSS sends nothing', () {
|
|
final t = FixtureTerminal()..feed('\x1bP+q544e\x1b\\');
|
|
expect(t.takeReplies(), '');
|
|
});
|
|
}
|