From 70b0423a31016798592fc0e96ce316cb3f1e9d46 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Sat, 28 May 2016 22:09:25 -0700 Subject: Initial ANSI parser implementation This is the initial terminal stream parsing implementation for Alacritty. There are currently several TODOs, FIXMEs, and unimplemented! things scattered about still, but what's here is good enough to correctly parse my zsh startup. The `Parser` implementation is largely based on the suck-less _simple terminal_ parser. Because this is Rust and Rust has a fantastic type system, some improvements are possible. First, `Parser` is a struct, and its data is stored internally instead of statically. Second, there's no terminal updates hard-coded into the parser. Instead, `Parser` is generic over a `Handler` type which has methods for all of the actions supported by the parser. Because Parser is generic, it should be possible (with proper inlining) to have equivalent performance to the hard-coded version. In addition to using _simple terminal_ as a reference, there's a doc in Alacritty's repository `docs/ansicode.txt`, a summary of the ANSI terminal protocol, which has been referenced extensively. There's probably a large number escapes we don't handle, and that's ok. There's a lot that aren't necessary for everyday terminal usage. If you feel like something that's not supported should be, feel free to add it. Please try not to become overzealous and adding support for sequences only used by folks trapped in 1988. --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index e95908d3..1f945420 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ //! Alacritty - The GPU Enhanced Terminal #![feature(question_mark)] +#![feature(range_contains)] +#![feature(inclusive_range_syntax)] +#![feature(io)] extern crate fontconfig; extern crate freetype; @@ -12,12 +15,16 @@ use std::collections::HashMap; use std::io::{BufReader, Read, BufRead}; +#[macro_use] +mod macros; + mod list_fonts; mod text; mod renderer; mod grid; mod meter; mod tty; +mod ansi; use renderer::{Glyph, QuadRenderer}; use text::FontDesc; @@ -86,7 +93,8 @@ fn main() { ::std::thread::spawn(move || { for byte in cmd.bytes() { - println!("{:?}", byte); + let b = byte.unwrap(); + println!("{:02x}, {:?}", b, ::std::char::from_u32(b as u32)); } }); -- cgit