e94f4856e3
CSI parameters now record colon subparameters (ITU T.416), so SGR 4:3 is a curly underline instead of 4 and 3 = 43 (yellow background), and 38:2::r:g:b, 38:2:r:g:b and 38:5:n set colours. Underline styles 4:0-4:5 and 21 (double) are stored on the cell; 58/59 underline colours are consumed and ignored; 53/55 toggle overline; 22 clears bold and faint; truncated 38;5 no longer throws. Intermediate bytes and private prefixes are kept, so CSI > 4;2 m (modifyOtherKeys) is no longer applied as SGR. An empty parameter reads as 0 (default), so CSI ;5H and CSI 3H position the cursor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.1 KiB
Dart
42 lines
1.1 KiB
Dart
import 'package:xterm/xterm.dart';
|
|
|
|
/// A terminal fed raw bytes in byte-fixture tests, with every reply it sends
|
|
/// to the program collected in [replies].
|
|
class FixtureTerminal {
|
|
FixtureTerminal({int width = 20, int height = 5}) {
|
|
terminal.onOutput = replies.add;
|
|
terminal.resize(width, height);
|
|
}
|
|
|
|
final terminal = Terminal(maxLines: 100);
|
|
final replies = <String>[];
|
|
|
|
Buffer get buffer => terminal.buffer;
|
|
|
|
void feed(String bytes) => terminal.write(bytes);
|
|
|
|
/// The text of screen row [y], trailing blanks trimmed.
|
|
String row(int y) =>
|
|
buffer.lines[buffer.scrollBack + y].getText().trimRight();
|
|
|
|
/// The cell at column [x] of screen row [y].
|
|
CellData cell(int x, int y) {
|
|
final data = CellData.empty();
|
|
buffer.lines[buffer.scrollBack + y].getCellData(x, data);
|
|
return data;
|
|
}
|
|
|
|
/// The replies sent so far, joined, and then forgotten.
|
|
String takeReplies() {
|
|
final all = replies.join();
|
|
replies.clear();
|
|
return all;
|
|
}
|
|
}
|
|
|
|
int rgb(int r, int g, int b) => CellColor.rgb | (r << 16) | (g << 8) | b;
|
|
|
|
int palette(int index) => CellColor.palette | index;
|
|
|
|
int named(int index) => CellColor.named | index;
|