Ports the parsing half of ZIG/src/terminal into the ghostty-vt crate: - Parser state machine with a compile-time generated parse table and the UTF-8 decoder - OSC parser incl. all sub-parsers (titles, colors, clipboard, hyperlinks, semantic prompts/OSC 133, OSC 9 / ConEmu, iTerm2, kitty clipboard, color and text-sizing protocols, context signals) - CSI, SGR, modes table with save/restore, charsets, ansi, device status, mouse shapes, APC, DCS (incl. XTGETTCAP), tmux control-mode parser - color palette / X11 color names, kitty color and graphics command parser Deviations from Zig (documented in docs/rewrite/notes/ghostty-vt-W*.md): parser actions own their payloads instead of borrowing parser buffers; OSC strings are Vec<u8>; non-exhaustive Zig enums gain an Other(raw) variant; tmux regexes replaced by equivalent hand-written matchers. Known follow-up: semantic_prompt.rs carries local copies of the printf-q and percent decoders that belong in ghostty-os. Test Plan: - cargo test -p ghostty-vt: 395 passed, 1 ignored (skipped in Zig too) - cargo clippy -p ghostty-vt --all-targets -- -D warnings: clean
25 lines
621 B
Rust
25 lines
621 B
Rust
//! OSC 1 (ZIG/src/terminal/osc/parsers/change_window_icon.zig).
|
|
use crate::osc::{Command, Parser};
|
|
|
|
/// Parse OSC 1
|
|
pub fn parse(parser: &mut Parser, _terminator_ch: Option<u8>) -> Option<Command> {
|
|
let data = parser.data()?;
|
|
Some(Command::ChangeWindowIcon(data))
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
#![allow(clippy::unwrap_used)]
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn osc_1_change_window_icon() {
|
|
let mut p = Parser::init(false);
|
|
for c in b"1;ab" {
|
|
p.next(*c);
|
|
}
|
|
let cmd = p.end(None).unwrap();
|
|
assert_eq!(cmd, Command::ChangeWindowIcon(b"ab".to_vec()));
|
|
}
|
|
}
|