diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-05 16:24:20 +0300 |
|---|---|---|
| committer | Can Celik <ogulcancelik@gmail.com> | 2026-04-05 16:38:50 +0300 |
| commit | b2e6929aa8199574565fd4adf1e631c68d479e6c (patch) | |
| tree | 99964965fe84f9ea31a0dec7ede2393631dc7f50 /vendor/vt100/src/parser.rs | |
| parent | 822c3b9e2d1edb7481fa558497dd33c7f5dca9ee (diff) | |
refactor: remove vt100 backend and make ghostty default
Diffstat (limited to 'vendor/vt100/src/parser.rs')
| -rw-r--r-- | vendor/vt100/src/parser.rs | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/vendor/vt100/src/parser.rs b/vendor/vt100/src/parser.rs deleted file mode 100644 index c81495b8..00000000 --- a/vendor/vt100/src/parser.rs +++ /dev/null @@ -1,96 +0,0 @@ -/// A parser for terminal output which produces an in-memory representation of -/// the terminal contents. -pub struct Parser<CB: crate::callbacks::Callbacks = ()> { - parser: vte::Parser, - screen: crate::perform::WrappedScreen<CB>, -} - -impl Parser { - /// Creates a new terminal parser of the given size and with the given - /// amount of scrollback. - #[must_use] - pub fn new(rows: u16, cols: u16, scrollback_len: usize) -> Self { - Self { - parser: vte::Parser::new(), - screen: crate::perform::WrappedScreen::new( - rows, - cols, - scrollback_len, - ), - } - } -} - -impl<CB: crate::callbacks::Callbacks> Parser<CB> { - /// Creates a new terminal parser of the given size and with the given - /// amount of scrollback. Terminal events will be reported via method - /// calls on the provided [`Callbacks`](crate::callbacks::Callbacks) - /// implementation. - pub fn new_with_callbacks( - rows: u16, - cols: u16, - scrollback_len: usize, - callbacks: CB, - ) -> Self { - Self { - parser: vte::Parser::new(), - screen: crate::perform::WrappedScreen::new_with_callbacks( - rows, - cols, - scrollback_len, - callbacks, - ), - } - } - - /// Processes the contents of the given byte string, and updates the - /// in-memory terminal state. - pub fn process(&mut self, bytes: &[u8]) { - self.parser.advance(&mut self.screen, bytes); - } - - /// Returns a reference to a [`Screen`](crate::Screen) object containing - /// the terminal state. - #[must_use] - pub fn screen(&self) -> &crate::Screen { - &self.screen.screen - } - - /// Returns a mutable reference to a [`Screen`](crate::Screen) object - /// containing the terminal state. - #[must_use] - pub fn screen_mut(&mut self) -> &mut crate::Screen { - &mut self.screen.screen - } - - /// Returns a reference to the [`Callbacks`](crate::callbacks::Callbacks) - /// state object passed into the constructor. - pub fn callbacks(&self) -> &CB { - &self.screen.callbacks - } - - /// Returns a mutable reference to the - /// [`Callbacks`](crate::callbacks::Callbacks) state object passed into - /// the constructor. - pub fn callbacks_mut(&mut self) -> &mut CB { - &mut self.screen.callbacks - } -} - -impl Default for Parser { - /// Returns a parser with dimensions 80x24 and no scrollback. - fn default() -> Self { - Self::new(24, 80, 0) - } -} - -impl std::io::Write for Parser { - fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { - self.process(buf); - Ok(buf.len()) - } - - fn flush(&mut self) -> std::io::Result<()> { - Ok(()) - } -} |
