diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-12 05:47:32 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-12 05:51:17 -0500 |
commit | 28eea9f6a837dad5febfe9b021b7070e96b286f9 (patch) | |
tree | c48d13955c045b892b95f6e652f8be22938705d1 /src/parser.rs | |
parent | bdda29c8e82e22bf49b5588f341549d3f94d6d30 (diff) | |
download | vt100-rust-28eea9f6a837dad5febfe9b021b7070e96b286f9.tar.gz vt100-rust-28eea9f6a837dad5febfe9b021b7070e96b286f9.zip |
remove parser.screen_mut
it's easier to reason about if you are only able to get an immutable
reference to the internal screen. this also required changing the api
for bells.
Diffstat (limited to 'src/parser.rs')
-rw-r--r-- | src/parser.rs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/parser.rs b/src/parser.rs index 07ee7c9..613e18e 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -26,17 +26,31 @@ impl Parser { } } + /// Resizes the terminal. + pub fn set_size(&mut self, rows: u16, cols: u16) { + self.screen.set_size(rows, cols); + } + + /// Scrolls to the given position in the scrollback. + /// + /// This position indicates the offset from the top of the screen, and + /// should be `0` to put the normal screen in view. + /// + /// This affects the return values of methods called on `parser.screen()`: + /// for instance, `parser.screen().cell(0, 0)` will return the top left + /// corner of the screen after taking the scrollback offset into account. + /// It does not affect `parser.process()` at all. + /// + /// The value given will be clamped to the actual size of the scrollback. + pub fn set_scrollback(&mut self, rows: usize) { + self.screen.set_scrollback(rows); + } + /// Returns a reference to a `Screen` object containing the terminal /// state. pub fn screen(&self) -> &crate::screen::Screen { &self.screen } - - /// Returns a mutable reference to a `Screen` object containing the - /// terminal state. - pub fn screen_mut(&mut self) -> &mut crate::screen::Screen { - &mut self.screen - } } impl Default for Parser { |