Skip to main content

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