aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-10 08:30:43 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-10 08:30:43 -0500
commit90d19a9cc76fd36b3155bd5d06cf72f7e76ce9a5 (patch)
tree82a90b9600dab68748535e257f8ed18ec9286671
parent1fde57f6119e2a0a0cc6edd3123cb20c884a6ced (diff)
downloadvt100-rust-90d19a9cc76fd36b3155bd5d06cf72f7e76ce9a5.tar.gz
vt100-rust-90d19a9cc76fd36b3155bd5d06cf72f7e76ce9a5.zip
docs
-rw-r--r--src/parser.rs3
-rw-r--r--src/screen.rs31
2 files changed, 25 insertions, 9 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 0cabb1a..5099eb9 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -6,7 +6,8 @@ pub struct Parser {
}
impl Parser {
- /// Creates a new terminal parser of the given size.
+ /// Creates a new terminal parser of the given size and with the given
+ /// amount of scrollback.
pub fn new(rows: u16, cols: u16, scrollback_len: usize) -> Self {
Self {
parser: vte::Parser::new(),
diff --git a/src/screen.rs b/src/screen.rs
index c2fef6b..57b37fb 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -112,14 +112,6 @@ impl Screen {
}
}
- pub fn scrollback(&self) -> usize {
- self.grid().scrollback()
- }
-
- pub fn set_scrollback(&mut self, rows: usize) {
- self.grid_mut().set_scrollback(rows);
- }
-
/// Resizes the terminal.
pub fn set_size(&mut self, rows: u16, cols: u16) {
self.grid.set_size(crate::grid::Size { rows, cols });
@@ -135,6 +127,29 @@ impl Screen {
(size.rows, size.cols)
}
+ /// Returns the current position in the scrollback.
+ ///
+ /// This position indicates the offset from the top of the screen, and is
+ /// `0` when the normal screen is in view.
+ pub fn scrollback(&self) -> usize {
+ self.grid().scrollback()
+ }
+
+ /// 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.grid_mut().set_scrollback(rows);
+ }
+
/// Returns the text contents of the terminal.
///
/// This will not include any formatting information, and will be in plain