aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-03-08 21:21:24 -0500
committerJesse Luehrs <doy@tozt.net>2023-03-09 00:13:52 -0500
commite5bdee42da0cf6f74db46fca4bcc6c6a32c7a639 (patch)
tree78b14e8cb11e27563d91e1de46be70a1fec75bc1 /src
parent4c9e5da3de10d838d792929f1691024d6bf59c85 (diff)
downloadvt100-rust-e5bdee42da0cf6f74db46fca4bcc6c6a32c7a639.tar.gz
vt100-rust-e5bdee42da0cf6f74db46fca4bcc6c6a32c7a639.zip
allow getting a mutable screen, and move some operations there
Diffstat (limited to 'src')
-rw-r--r--src/parser.rs27
-rw-r--r--src/screen.rs21
2 files changed, 23 insertions, 25 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 26431ac..673e0d9 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -27,32 +27,19 @@ 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.
#[must_use]
pub fn screen(&self) -> &crate::screen::Screen {
&self.screen
}
+
+ /// Returns a mutable reference to a `Screen` object containing the
+ /// terminal state.
+ #[must_use]
+ pub fn screen_mut(&mut self) -> &mut crate::screen::Screen {
+ &mut self.screen
+ }
}
impl Default for Parser {
diff --git a/src/screen.rs b/src/screen.rs
index a50671f..cc89c20 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -110,7 +110,8 @@ impl Screen {
}
}
- pub(crate) fn set_size(&mut self, rows: u16, cols: u16) {
+ /// Resizes the terminal.
+ pub fn set_size(&mut self, rows: u16, cols: u16) {
self.grid.set_size(crate::grid::Size { rows, cols });
self.alternate_grid
.set_size(crate::grid::Size { rows, cols });
@@ -125,6 +126,20 @@ impl Screen {
(size.rows, size.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 the screen: for
+ /// instance, `screen.cell(0, 0)` will return the top left corner of the
+ /// screen after taking the scrollback offset into account.
+ ///
+ /// The value given will be clamped to the actual size of the scrollback.
+ pub fn set_scrollback(&mut self, rows: usize) {
+ self.grid_mut().set_scrollback(rows);
+ }
+
/// Returns the current position in the scrollback.
///
/// This position indicates the offset from the top of the screen, and is
@@ -134,10 +149,6 @@ impl Screen {
self.grid().scrollback()
}
- pub(crate) fn set_scrollback(&mut self, rows: usize) {
- self.grid_mut().set_scrollback(rows);
- }
-
/// Returns the text contents of the terminal.
///
/// This will not include any formatting information, and will be in plain