vt100/lib.rs
1//! This crate parses a terminal byte stream and provides an in-memory
2//! representation of the rendered contents.
3//!
4//! # Overview
5//!
6//! This is essentially the terminal parser component of a graphical terminal
7//! emulator pulled out into a separate crate. Although you can use this crate
8//! to build a graphical terminal emulator, it also contains functionality
9//! necessary for implementing terminal applications that want to run other
10//! terminal applications - programs like `screen` or `tmux` for example.
11//!
12//! # Synopsis
13//!
14//! ```
15//! let mut parser = vt100::Parser::new(24, 80, 0);
16//!
17//! let screen = parser.screen().clone();
18//! parser.process(b"this text is \x1b[31mRED\x1b[m");
19//! assert_eq!(
20//! parser.screen().cell(0, 13).unwrap().fgcolor(),
21//! vt100::Color::Idx(1),
22//! );
23//!
24//! let screen = parser.screen().clone();
25//! parser.process(b"\x1b[3D\x1b[32mGREEN");
26//! assert_eq!(
27//! parser.screen().contents_formatted(),
28//! &b"\x1b[?25h\x1b[m\x1b[H\x1b[Jthis text is \x1b[32mGREEN"[..],
29//! );
30//! assert_eq!(
31//! parser.screen().contents_diff(&screen),
32//! &b"\x1b[1;14H\x1b[32mGREEN"[..],
33//! );
34//! ```
35
36#![warn(clippy::cargo)]
37#![warn(clippy::pedantic)]
38#![warn(clippy::nursery)]
39#![warn(clippy::as_conversions)]
40#![warn(clippy::get_unwrap)]
41#![allow(clippy::cognitive_complexity)]
42#![allow(clippy::missing_const_for_fn)]
43#![allow(clippy::similar_names)]
44#![allow(clippy::struct_excessive_bools)]
45#![allow(clippy::too_many_arguments)]
46#![allow(clippy::too_many_lines)]
47#![allow(clippy::type_complexity)]
48
49mod attrs;
50mod cell;
51mod grid;
52mod parser;
53mod row;
54mod screen;
55mod term;
56
57pub use attrs::Color;
58pub use cell::Cell;
59pub use parser::Parser;
60pub use screen::{MouseProtocolEncoding, MouseProtocolMode, Screen};