feat(vt): port Ghostty's VT parsing layer
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
This commit is contained in:
1 parent
864ef82acb
commit
b2b248e003
44 files changed
+15040
-6
No files matched your search
@@ -0,0 +1,40 @@
|
||||
//! OSC 7 (ZIG/src/terminal/osc/parsers/report_pwd.zig).
|
||||
use crate::osc::{Command, Parser};
|
||||
|
||||
/// Parse OSC 7
|
||||
pub fn parse(parser: &mut Parser, _terminator_ch: Option<u8>) -> Option<Command> {
|
||||
let data = parser.data()?;
|
||||
Some(Command::ReportPwd { value: data })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(clippy::unwrap_used)]
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn osc_7_report_pwd() {
|
||||
let mut p = Parser::init(false);
|
||||
for c in b"7;file:///tmp/example" {
|
||||
p.next(*c);
|
||||
}
|
||||
assert_eq!(
|
||||
p.end(None).unwrap(),
|
||||
Command::ReportPwd {
|
||||
value: b"file:///tmp/example".to_vec()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn osc_7_report_pwd_empty() {
|
||||
let mut p = Parser::init(false);
|
||||
for c in b"7;" {
|
||||
p.next(*c);
|
||||
}
|
||||
assert_eq!(
|
||||
p.end(None).unwrap(),
|
||||
Command::ReportPwd { value: Vec::new() }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user