326e7710d4
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>
48 lines
1.4 KiB
Dart
48 lines
1.4 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 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();
|
|
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;
|