aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-10 08:46:10 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-10 08:48:14 -0500
commitd39467ace49c06b277ed4421b30b371374cdb491 (patch)
tree935631dbcedfc33f4a1f06f5b111d8f529fb0734
parentdb86c9b73de246dd1cfeb7f86ef598a5299481a3 (diff)
downloadvt100-rust-d39467ace49c06b277ed4421b30b371374cdb491.tar.gz
vt100-rust-d39467ace49c06b277ed4421b30b371374cdb491.zip
update crate docs a bit
-rw-r--r--README.md23
-rw-r--r--src/lib.rs21
2 files changed, 35 insertions, 9 deletions
diff --git a/README.md b/README.md
index 2b7152f..a8e1b8f 100644
--- a/README.md
+++ b/README.md
@@ -6,18 +6,31 @@ representation of the rendered contents.
## Overview
This is essentially the terminal parser component of a graphical terminal
-emulator pulled out into a separate crate. This can be used to not only
-build graphical terminal emulators, but also many other types of
-applications that need to interact with a terminal data stream directly,
-such as terminal multiplexers or terminal recording applications.
+emulator pulled out into a separate crate. Although you can use this crate
+to build a graphical terminal emulator, it also contains functionality
+necessary for implementing terminal applications that want to run other
+terminal applications - programs like `screen` or `tmux` for example.
## Synopsis
```rust
-let mut parser = vt100::Parser::new(24, 80);
+let mut parser = vt100::Parser::new(24, 80, 0);
+
+let screen = parser.screen().clone();
parser.process(b"this text is \x1b[31mRED\x1b[m");
assert_eq!(
parser.screen().cell(0, 13).unwrap().fgcolor(),
vt100::Color::Idx(1),
);
+
+let screen = parser.screen().clone();
+parser.process(b"\x1b[3D\x1b[32mGREEN");
+assert_eq!(
+ parser.screen().contents_formatted(),
+ &b"\x1b[?25h\x1b[m\x1b[H\x1b[Jthis text is \x1b[32mGREEN"[..],
+);
+assert_eq!(
+ parser.screen().contents_diff(&screen),
+ &b"\x1b[1;14H\x1b[32mGREEN"[..],
+);
```
diff --git a/src/lib.rs b/src/lib.rs
index 7f391c6..f408a19 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,20 +4,33 @@
//! # Overview
//!
//! This is essentially the terminal parser component of a graphical terminal
-//! emulator pulled out into a separate crate. This can be used to not only
-//! build graphical terminal emulators, but also many other types of
-//! applications that need to interact with a terminal data stream directly,
-//! such as terminal multiplexers or terminal recording applications.
+//! emulator pulled out into a separate crate. Although you can use this crate
+//! to build a graphical terminal emulator, it also contains functionality
+//! necessary for implementing terminal applications that want to run other
+//! terminal applications - programs like `screen` or `tmux` for example.
//!
//! # Synopsis
//!
//! ```
//! let mut parser = vt100::Parser::new(24, 80, 0);
+//!
+//! let screen = parser.screen().clone();
//! parser.process(b"this text is \x1b[31mRED\x1b[m");
//! assert_eq!(
//! parser.screen().cell(0, 13).unwrap().fgcolor(),
//! vt100::Color::Idx(1),
//! );
+//!
+//! let screen = parser.screen().clone();
+//! parser.process(b"\x1b[3D\x1b[32mGREEN");
+//! assert_eq!(
+//! parser.screen().contents_formatted(),
+//! &b"\x1b[?25h\x1b[m\x1b[H\x1b[Jthis text is \x1b[32mGREEN"[..],
+//! );
+//! assert_eq!(
+//! parser.screen().contents_diff(&screen),
+//! &b"\x1b[1;14H\x1b[32mGREEN"[..],
+//! );
//! ```
// XXX this is broken with ale