Skip to content
pindash-ioPublic

About

Zero-allocation, panic-free DEC VT500 terminal parser with UTF-8 decoding and no_std support.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

533 Commits

Folders and files

Repository files navigation

vtty: 3D VT terminal mark

vtty

Zero-allocation, panic-free DEC VT500 terminal parser with UTF-8 decoding and no_std support

crates.io docs.rs dependency status Apache 2.0 or MIT license. Build status

Crates

crate purpose
vtty the parser (re-exports vtty_core)
vtty_core terminal model types + Perform
vtty_codec no_std binary Encode/Decode codec for vtty_core
vtty_width display cell width + emoji sequences
vtty_grapheme UAX #29 grapheme cluster segmentation
vtty_status OSC 7501 Program Status Protocol
vtty_screen cell-grid terminal screen
vtty_ffi raw C ABI
vtty_bench throughput benchmarks

Features

  • Safety: #![forbid(unsafe_code)], no unwrap/expect/panic.
  • Zero-allocation: bulk print_bytes / print_codepoints.
  • no_std: optional simd / simd-transcode features.
  • UTF-8: maximal-subpart substitution; 8-bit C1 controls.
  • Serialization: compact, no_std, zero-allocation Encode/Decode codec (vtty_codec) for events, replies, and terminal state.

Install

cargo add vtty

Usage

use vtty::{Parser, Perform};

struct Screen;

impl Perform for Screen {
    fn print_bytes(&mut self, _s: &[u8]) { /* printable ASCII run */ }
    fn print(&mut self, _c: char) { /* non-ASCII code point */ }
    fn execute(&mut self, _b: u8) { /* \n \t \x1b … */ }
    fn csi_dispatch(&mut self, _params: &[i32], _sep: u16, _intermediates: &[u8], _final_byte: u8) {
        /* CSI Ps ; Ps final */
    }
    fn osc_dispatch(&mut self, _params: &[&[u8]], _bell: bool) { /* OSC */ }
}

let mut screen = Screen;
let mut parser = Parser::new();
parser.advance(&mut screen, b"\x1b[1;31mhello\x1b[0m");

Serialization

Owned events, replies and terminal state round-trip through a compact, no_std binary codec:

use vtty_codec::{decode_from_slice, encode_to_vec};
use vtty::{Event, Parser};

let mut parser = Parser::new();
let events = parser.parse_events(b"\x1b[1;31mhi");

let bytes = encode_to_vec(&events)?;
assert_eq!(decode_from_slice::<Vec<Event>>(&bytes)?, events);

Benchmarks

Throughput vs vte/vt100/vtparse/rio-vt; see vtty_bench for the full table.

Documentation

Testing

cargo test --workspace
cargo test -p vtty --test vt_differential -- --nocapture      # parity vs vte
cargo test -p vtty --test vt_differential_rio -- --nocapture  # parity vs rio-vt

License

Licensed under either of

at your option.

About

Zero-allocation, panic-free DEC VT500 terminal parser with UTF-8 decoding and no_std support.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages