From c8a23e4837441ecb02b0fe89143433b652192e7f Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 5 Nov 2019 01:39:34 -0500 Subject: docs --- README.md | 8 ++++++-- src/lib.rs | 4 ++++ src/parser.rs | 6 ++++++ src/screen.rs | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 29c25d5..2b7152f 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ such as terminal multiplexers or terminal recording applications. ## Synopsis ```rust -let mut screen = vt100::Screen::new(24, 80); -screen.process(b"this text is \x1b[31mRED\x1b[m"); +let mut parser = vt100::Parser::new(24, 80); +parser.process(b"this text is \x1b[31mRED\x1b[m"); +assert_eq!( + parser.screen().cell(0, 13).unwrap().fgcolor(), + vt100::Color::Idx(1), +); ``` diff --git a/src/lib.rs b/src/lib.rs index f7ef98e..570f2d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,10 @@ //! ``` //! let mut parser = vt100::Parser::new(24, 80); //! parser.process(b"this text is \x1b[31mRED\x1b[m"); +//! assert_eq!( +//! parser.screen().cell(0, 13).unwrap().fgcolor(), +//! vt100::Color::Idx(1), +//! ); //! ``` // XXX this is broken with ale diff --git a/src/parser.rs b/src/parser.rs index 2e27399..77373bd 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,3 +1,5 @@ +/// A parser for terminal output which produces an in-memory representation of +/// the terminal contents. pub struct Parser { parser: vte::Parser, screen: crate::screen::Screen, @@ -23,10 +25,14 @@ impl Parser { } } + /// 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 } diff --git a/src/screen.rs b/src/screen.rs index 1aa9321..1d4eda0 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -69,6 +69,7 @@ impl Default for MouseProtocolEncoding { } } +/// Represents the overall terminal state. #[derive(Clone, Debug)] pub struct Screen { grid: crate::grid::Grid, -- cgit v1.2.3-54-g00ecf