diff --git a/src/screen.rs b/src/screen.rs index 7dfec97..f6663a3 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -100,6 +100,12 @@ impl Screen { (size.rows, size.cols) } + /// Returns the number of lines in the scrollback. + #[must_use] + pub fn scrollback_len(&self) -> usize { + self.grid().scrollback_len() + } + /// Scrolls to the given position in the scrollback. /// /// This position indicates the offset from the top of the screen, and diff --git a/tests/scroll.rs b/tests/scroll.rs index a73a688..96e64c2 100644 --- a/tests/scroll.rs +++ b/tests/scroll.rs @@ -16,6 +16,8 @@ fn origin_mode() { fn scrollback() { let mut parser = vt100::Parser::new(24, 80, 10); + assert_eq!(parser.screen().scrollback_len(), 10); + parser.process(b"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24"); assert_eq!( parser.screen().contents(),