Ports ZIG/src/terminal/stream.zig: the Stream feeds bytes through the UTF-8 decoder and parser and dispatches every CSI/ESC/OSC/DCS/APC and C0/C1 control to a Handler as a high-level Action (all 95 Zig variants). Zig's comptime handler interface becomes a Handler trait with an associated error type, a required vt() and an optional vt_raw() hook. Performance: next_slice() processes 4 KiB chunks, finds ESC with memchr and decodes printable runs in bulk (scalar port of ZIG/src/simd's index_of / utf8_decode_until_control_seq), plus the CSI parameter fast path. Terminals must construct the stream with Stream::new_alloc so the OSC parser accepts allocating commands (colors, OSC 133), as in Zig. Minor differences: after a stray UTF-8 byte the rest of the chunk returns to the fast path, and a spurious Zig warning after CSI 2/5 W is dropped. Test Plan: - cargo test -p ghostty-vt (448 passed; 37/38 stream tests ported, the skipped one only exercises the C ABI)
23 lines
446 B
Rust
23 lines
446 B
Rust
//! ghostty-vt: VT parsing layer of Ghostty (parser, OSC/CSI/DCS/APC, SGR,
|
|
//! colors, modes, stream). See docs/rewrite/ARCHITECTURE.md.
|
|
|
|
pub mod ansi;
|
|
pub mod apc;
|
|
pub mod charsets;
|
|
pub mod color;
|
|
pub mod csi;
|
|
pub mod dcs;
|
|
pub mod device_status;
|
|
pub mod kitty;
|
|
pub mod modes;
|
|
pub mod mouse_shape;
|
|
pub mod osc;
|
|
pub mod parse_table;
|
|
pub mod parser;
|
|
pub mod sgr;
|
|
pub mod simd;
|
|
pub mod stream;
|
|
pub mod tmux;
|
|
pub mod utf8_decoder;
|
|
pub mod x11_color;
|