Zero-allocation, panic-free DEC VT500 terminal parser with UTF-8 decoding (MoonBit port)
Dependencies
let rec = @vtty.Recording::new()
let p = @vtty.Parser::new() // or Parser::with_simd() for the SIMD fast path
let input : Array[Int] = [0x1b, 0x5b, 0x31, 0x3b, 0x33, 0x31, 0x6d] // CSI 1;31m
p.advance(rec, input[:])
inspect(rec.events())moon run --target native cmd/term # interactive (native only)
# or pipe a session:
printf 'ls\nexit\n' | moon run --target native cmd/termmoon test
moon checkpub(open) trait Perform {
fn print(Self, Char) -> Unit = _
fn print_bytes(Self, ArrayView[Int]) -> Unit = _
fn print_codepoints(Self, ArrayView[Int]) -> Unit = _
fn execute(Self, Int) -> Unit = _
fn csi_dispatch(Self, ArrayView[Int], Int, ArrayView[Int], Int) -> Unit = _
fn esc_dispatch(Self, ArrayView[Int], Int) -> Unit = _
fn hook(Self, ArrayView[Int], ArrayView[Int], Int) -> Unit = _
fn put(Self, Int) -> Unit = _
fn put_slice(Self, ArrayView[Int]) -> Unit = _
fn unhook(Self) -> Unit = _
fn osc_dispatch(Self, Array[Array[Int]], Bool) -> Unit = _
}pub struct Parser {
state : ParseState
params : Array[Int]
params_len : Int
param : Int
param_empty : Bool
sep : Int
intermediates : Array[Int]
intermediates_len : Int
ignore : Bool
partial : Int
partial_need : Int
osc : Array[Int]
osc_starts : Array[Int]
simd : Bool
}fn utf8_expected(lead : Int) -> Intfn utf8_lead_cp(lead : Int) -> Intfn utf8_second_byte_valid(lead : Int, second : Int) -> BoolInstall
Download zipZero-allocation, panic-free DEC VT500 terminal parser with UTF-8 decoding (MoonBit port)
Dependencies