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(missing_docs)]
37#![warn(clippy::cargo)]
38#![warn(clippy::pedantic)]
39#![warn(clippy::nursery)]
40#![warn(clippy::as_conversions)]
41#![warn(clippy::get_unwrap)]
42#![allow(clippy::cognitive_complexity)]
43#![allow(clippy::missing_const_for_fn)]
44#![allow(clippy::similar_names)]
45#![allow(clippy::struct_excessive_bools)]
46#![allow(clippy::too_many_arguments)]
47#![allow(clippy::too_many_lines)]
48#![allow(clippy::type_complexity)]
49
50mod attrs;
51mod callbacks;
52mod cell;
53mod grid;
54mod parser;
55mod perform;
56mod row;
57mod screen;
58mod term;
59
60pub use attrs::Color;
61pub use callbacks::Callbacks;
62pub use cell::Cell;
63pub use parser::Parser;
64pub use screen::{MouseProtocolEncoding, MouseProtocolMode, Screen};