M3.6: integrated terminal with PTY sessions and xterm.js sub-tabs
- crates/terminal: portable-pty sessions (ConPTY on Windows) with reader, writer and waiter threads, UTF-8 chunking, a 1 MiB output buffer with backpressure, a non-blocking input queue, resize, kill and exit codes; default shell pwsh -> powershell -> cmd on Windows, $SHELL or /bin/sh. - Engine: terminal.create/input/resize/close, terminalOutput (capped per terminal and per pump, round-robin) and terminalExited through the pump; terminals close with the project and on app.quit. - UI: Terminal tab in the bottom panel (tabs next to Find), xterm.js with the fit addon, sub-tabs, copy/paste, a focus rule that leaves plain Ctrl keys to the shell, terminal.open (Mod+Shift+T), --lt-terminal-* ANSI tokens in both themes (text colours AA) and a 4.5:1 minimum contrast. - Tests: real-shell crate tests (UTF-8, backpressure), engine and TCP control tests, Vitest with a mocked xterm; live check on port 7936; docs and parity rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5fa7f0c8b3
commit
a8daf269fb
45 changed files with 3935 additions and 49 deletions
|
|
@ -62,6 +62,35 @@ pub const SYNTAX_TOKENS: &[&str] = &[
|
|||
"operator",
|
||||
];
|
||||
|
||||
/// Terminal token names (`--lt-terminal-<name>`) every theme defines: the
|
||||
/// terminal's background, text, cursor and selection, and the 16 ANSI
|
||||
/// colours xterm.js maps escape sequences to. Every ANSI colour that shows
|
||||
/// as text reaches 4.5:1 on `terminal-bg` (`ui/tests/theme/contrast.test.ts`);
|
||||
/// the exceptions are the colour meant to vanish into the background: ANSI
|
||||
/// black in the dark theme, white and bright white in the light one.
|
||||
pub const TERMINAL_TOKENS: &[&str] = &[
|
||||
"bg",
|
||||
"fg",
|
||||
"cursor",
|
||||
"selection-bg",
|
||||
"ansi-black",
|
||||
"ansi-red",
|
||||
"ansi-green",
|
||||
"ansi-yellow",
|
||||
"ansi-blue",
|
||||
"ansi-magenta",
|
||||
"ansi-cyan",
|
||||
"ansi-white",
|
||||
"ansi-bright-black",
|
||||
"ansi-bright-red",
|
||||
"ansi-bright-green",
|
||||
"ansi-bright-yellow",
|
||||
"ansi-bright-blue",
|
||||
"ansi-bright-magenta",
|
||||
"ansi-bright-cyan",
|
||||
"ansi-bright-white",
|
||||
];
|
||||
|
||||
/// The default dark theme.
|
||||
pub const DARK: Theme = Theme {
|
||||
id: "lutra-dark",
|
||||
|
|
@ -97,6 +126,26 @@ pub const DARK: Theme = Theme {
|
|||
("syntax-tag", "#e08b70"),
|
||||
("syntax-attribute", "#cdb87e"),
|
||||
("syntax-operator", "#b8afa6"),
|
||||
("terminal-bg", "#191817"),
|
||||
("terminal-fg", "#e6e1da"),
|
||||
("terminal-cursor", "#d39a5c"),
|
||||
("terminal-selection-bg", "#513f2c"),
|
||||
("terminal-ansi-black", "#2e2b28"),
|
||||
("terminal-ansi-red", "#ef7b6c"),
|
||||
("terminal-ansi-green", "#a9bd7e"),
|
||||
("terminal-ansi-yellow", "#e6c46f"),
|
||||
("terminal-ansi-blue", "#8fa8e0"),
|
||||
("terminal-ansi-magenta", "#c4a0d6"),
|
||||
("terminal-ansi-cyan", "#7fbac6"),
|
||||
("terminal-ansi-white", "#d0c9c1"),
|
||||
("terminal-ansi-bright-black", "#9a928a"),
|
||||
("terminal-ansi-bright-red", "#f59a8d"),
|
||||
("terminal-ansi-bright-green", "#c2d69a"),
|
||||
("terminal-ansi-bright-yellow", "#f2d88e"),
|
||||
("terminal-ansi-bright-blue", "#aebff0"),
|
||||
("terminal-ansi-bright-magenta", "#dbbde8"),
|
||||
("terminal-ansi-bright-cyan", "#a2d3dc"),
|
||||
("terminal-ansi-bright-white", "#f5f1ec"),
|
||||
],
|
||||
};
|
||||
|
||||
|
|
@ -135,6 +184,26 @@ pub const LIGHT: Theme = Theme {
|
|||
("syntax-tag", "#a5432a"),
|
||||
("syntax-attribute", "#695d1a"),
|
||||
("syntax-operator", "#5a5149"),
|
||||
("terminal-bg", "#fbfaf8"),
|
||||
("terminal-fg", "#2a2622"),
|
||||
("terminal-cursor", "#965a22"),
|
||||
("terminal-selection-bg", "#e5d7c9"),
|
||||
("terminal-ansi-black", "#2a2622"),
|
||||
("terminal-ansi-red", "#b23a29"),
|
||||
("terminal-ansi-green", "#4e6a24"),
|
||||
("terminal-ansi-yellow", "#7a5808"),
|
||||
("terminal-ansi-blue", "#2f55a4"),
|
||||
("terminal-ansi-magenta", "#73479a"),
|
||||
("terminal-ansi-cyan", "#24697a"),
|
||||
("terminal-ansi-white", "#ddd6cd"),
|
||||
("terminal-ansi-bright-black", "#6b625a"),
|
||||
("terminal-ansi-bright-red", "#8f2a1c"),
|
||||
("terminal-ansi-bright-green", "#3b5418"),
|
||||
("terminal-ansi-bright-yellow", "#5f4404"),
|
||||
("terminal-ansi-bright-blue", "#233f7f"),
|
||||
("terminal-ansi-bright-magenta", "#5a3480"),
|
||||
("terminal-ansi-bright-cyan", "#1a5260"),
|
||||
("terminal-ansi-bright-white", "#f4f1ec"),
|
||||
],
|
||||
};
|
||||
|
||||
|
|
@ -280,6 +349,20 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn themes_define_the_terminal_tokens() {
|
||||
for theme in BUILTIN {
|
||||
let tokens = token_map(theme);
|
||||
for name in TERMINAL_TOKENS {
|
||||
assert!(
|
||||
tokens.contains_key(&format!("--lt-terminal-{name}")),
|
||||
"{} lacks terminal-{name}",
|
||||
theme.id
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolves_settings() {
|
||||
assert_eq!(resolve("lutra-light", Some(true)), LIGHT);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue