Lutra/crates/engine/src/cmd/app.rs
danny a8daf269fb 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>
2026-10-20 21:10:37 +02:00

54 lines
1.5 KiB
Rust

//! Application commands: `app.about` and `app.quit`.
use serde_json::{Value, json};
use crate::{Command, CommandSpec, Effect, EngineError, Outcome, State};
/// Product name shown in the About window and window titles.
pub const PRODUCT_NAME: &str = "Lutra";
/// Product slogan.
pub const SLOGAN: &str = "An otterly perfect IDE";
/// `app.about`: returns the product name, version and slogan.
pub struct About;
impl Command for About {
fn spec(&self) -> &CommandSpec {
&CommandSpec {
id: "app.about",
label: "About Lutra",
menu_path: Some("Help/About Lutra"),
default_shortcut: None,
params: "none; returns { name, version, slogan }",
}
}
fn run(&self, _state: &mut State, _params: Value) -> Result<Outcome, EngineError> {
Ok(Outcome::value(json!({
"name": PRODUCT_NAME,
"version": env!("CARGO_PKG_VERSION"),
"slogan": SLOGAN,
})))
}
}
/// `app.quit`: asks the host to quit the application.
pub struct Quit;
impl Command for Quit {
fn spec(&self) -> &CommandSpec {
&CommandSpec {
id: "app.quit",
label: "Quit",
menu_path: Some("File/Quit"),
default_shortcut: Some("Mod+Q"),
params: "none; returns null and the effect quit",
}
}
fn run(&self, state: &mut State, _params: Value) -> Result<Outcome, EngineError> {
crate::cmd::terminal::close_all(state);
Ok(Outcome::effect(Effect::Quit))
}
}