diff options
author | Joe Wilm <joe@jwilm.com> | 2016-09-17 16:52:57 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-09-17 17:03:24 -0700 |
commit | 85388ab070fbc41c8cce3ffbfbcc0d1d917109e0 (patch) | |
tree | 29e2d5e9c0e1a9b0a9795f17668c32dfab5246eb /examples/parselog.rs | |
parent | 98276717f6335a92a97ddec72edb9348768d1e4e (diff) | |
download | r-alacritty-vte-85388ab070fbc41c8cce3ffbfbcc0d1d917109e0.tar.gz r-alacritty-vte-85388ab070fbc41c8cce3ffbfbcc0d1d917109e0.tar.bz2 r-alacritty-vte-85388ab070fbc41c8cce3ffbfbcc0d1d917109e0.zip |
Rename and document vte crate
Diffstat (limited to 'examples/parselog.rs')
-rw-r--r-- | examples/parselog.rs | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/examples/parselog.rs b/examples/parselog.rs index f4ae86a..5c1836b 100644 --- a/examples/parselog.rs +++ b/examples/parselog.rs @@ -3,51 +3,60 @@ extern crate vtparse; use std::io::{self, Read}; -use vtparse::{StateMachine, Parser}; - -/// A type implementing Parser that just logs actions +/// A type implementing Perform that just logs actions struct Log; -impl Parser for Log { +impl vte::Perform for Log { fn print(&mut self, c: char) { println!("[print] {:?}", c); } - fn execute(&mut self, _machine: &StateMachine, byte: u8) { - println!("[execute] byte={:02x}", byte); + + fn execute(&mut self, byte: u8) { + println!("[execute] {:02x}", byte); } - fn hook(&mut self, _machine: &StateMachine, byte: u8) { - println!("[hook] byte={:02x}", byte); + + fn hook(&mut self, params: &[i64], intermediates: &[u8], ignore: bool, byte: u8) { + println!("[hook] params={:?}, intermediates={:?}, ignore={:?}, byte={:02x}", + params, intermediates, ignore, byte); } - fn put(&mut self, _machine: &StateMachine, byte: u8) { - println!("[put] byte={:02x}", byte); + + fn put(&mut self, byte: u8) { + println!("[put] {:02x}", byte); } - fn osc_start(&mut self, _machine: &StateMachine, byte: u8) { - println!("[osc_start] byte={:02x}", byte); + + fn unhook(&mut self, byte: u8) { + println!("[unhook] {:02x}", byte); } - fn osc_put(&mut self, _machine: &StateMachine, byte: u8) { - println!("[osc_put] byte={:02x}", byte); + + fn osc_start(&mut self) { + println!("[osc_start]"); } - fn osc_end(&mut self, _machine: &StateMachine, byte: u8) { - println!("[osc_end] byte={:02x}", byte); + + fn osc_put(&mut self, byte: u8) { + println!("[osc_put] {:02x}", byte); } - fn unhook(&mut self, _machine: &StateMachine, byte: u8) { - println!("[unhook] byte={:02x}", byte); + + fn osc_end(&mut self, byte: u8) { + println!("[osc_end] {:02x}", byte); } - fn csi_dispatch(&mut self, machine: &StateMachine, c: char) { - println!("[csi_dispatch] params={:?}, intermediates={:?}, action={:?}", - machine.params(), machine.intermediates(), c); + + fn csi_dispatch(&mut self, params: &[i64], intermediates: &[u8], ignore: bool, c: char) { + println!("[csi_dispatch] params={:?}, intermediates={:?}, ignore={:?}, char={:?}", + params, intermediates, ignore, c); } - fn esc_dispatch(&mut self, machine: &StateMachine, byte: u8) { - println!("[csi_dispatch] params={:?}, intermediates={:?}, action={:?}", - machine.params(), machine.intermediates(), byte as char); + + fn esc_dispatch(&mut self, params: &[i64], intermediates: &[u8], ignore: bool, byte: u8) { + println!("[esc_dispatch] params={:?}, intermediates={:?}, ignore={:?}, byte={:02x}", + params, intermediates, ignore, byte); } + } fn main() { let input = io::stdin(); let mut handle = input.lock(); - let mut statemachine = StateMachine::new(); + let mut statemachine = vte::Parser::new(); let mut parser = Log; let mut buf: [u8; 2048] = unsafe { std::mem::uninitialized() }; |