Draw chat shell runs in an xterm terminal that takes typed input
The card's output area is now an xterm.dart emulator kept per run by the controller: it is fed the raw stream in order, takes typing and paste while the command runs (with a key toolbar and a soft-keyboard field on touch platforms), resizes the process to its layout, opens printed links, shrinks finished runs to their output and opens full screen. A reconnect resumes from the byte the card holds; Copy output copies the server's plain text.
This commit is contained in:
@@ -27,6 +27,10 @@ class ChatShellRun {
|
||||
this.outputEnd = 0,
|
||||
this.outputBytes = 0,
|
||||
this.gap = false,
|
||||
this.terminal = false,
|
||||
this.cols = 0,
|
||||
this.rows = 0,
|
||||
this.text = '',
|
||||
});
|
||||
|
||||
final String id;
|
||||
@@ -53,6 +57,17 @@ class ChatShellRun {
|
||||
/// stretch of what the command wrote.
|
||||
final bool gap;
|
||||
|
||||
/// True when the command runs in a pseudo-terminal of [cols] x [rows]:
|
||||
/// [output] is then the raw terminal stream and it accepts typed input
|
||||
/// while it runs. Older runs (and servers without terminals) are plain.
|
||||
final bool terminal;
|
||||
final int cols;
|
||||
final int rows;
|
||||
|
||||
/// The server's plain-text rendering of its retained output (escape codes
|
||||
/// removed); only a whole-output readback carries it.
|
||||
final String text;
|
||||
|
||||
/// Whether earlier output is not shown here.
|
||||
bool get truncated => outputStart > 0 || gap;
|
||||
|
||||
@@ -92,6 +107,10 @@ class ChatShellRun {
|
||||
// A readback's text runs to the newest byte the server had.
|
||||
outputEnd: output.isEmpty && start == 0 ? 0 : bytes,
|
||||
outputBytes: bytes,
|
||||
terminal: value['terminal'] == true,
|
||||
cols: _int(value['cols']),
|
||||
rows: _int(value['rows']),
|
||||
text: '${value['text'] ?? ''}',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,6 +133,10 @@ class ChatShellRun {
|
||||
? next.outputBytes
|
||||
: outputBytes,
|
||||
gap: gap,
|
||||
terminal: next.terminal || terminal,
|
||||
cols: next.cols == 0 ? cols : next.cols,
|
||||
rows: next.rows == 0 ? rows : next.rows,
|
||||
text: text,
|
||||
);
|
||||
|
||||
/// This run with one live output chunk covering bytes [offset, end). A
|
||||
@@ -144,6 +167,9 @@ class ChatShellRun {
|
||||
outputEnd: end,
|
||||
outputBytes: end > outputBytes ? end : outputBytes,
|
||||
gap: gap || dropped || (!contiguous && offset > 0),
|
||||
terminal: terminal,
|
||||
cols: cols,
|
||||
rows: rows,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user