aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-03-08 22:31:00 -0500
committerJesse Luehrs <doy@tozt.net>2023-03-09 00:27:25 -0500
commita705c1f07de2b8ec3ba4fe46377242f151b996c1 (patch)
treefcd415ca7390aa47b4c7af56948506fc15571fdf /src/parser.rs
parent939fd8bed87dd67de9d0e00ba151ef637ef1c16a (diff)
downloadvt100-rust-a705c1f07de2b8ec3ba4fe46377242f151b996c1.tar.gz
vt100-rust-a705c1f07de2b8ec3ba4fe46377242f151b996c1.zip
use callbacks for events rather than tracking counters
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 01ba019..10ebf10 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -27,6 +27,20 @@ impl Parser {
}
}
+ /// Processes the contents of the given byte string, and updates the
+ /// in-memory terminal state. Calls methods on the given `Callbacks`
+ /// object when relevant escape sequences are seen.
+ pub fn process_cb(
+ &mut self,
+ bytes: &[u8],
+ callbacks: &mut impl crate::callbacks::Callbacks,
+ ) {
+ let mut state = crate::state::State::new(&mut self.screen, callbacks);
+ for byte in bytes {
+ self.parser.advance(&mut state, *byte);
+ }
+ }
+
/// Returns a reference to a `Screen` object containing the terminal
/// state.
#[must_use]