1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! VT parser, screen buffer, byte encoders, and input types for terminal
//! sessions.
//!
//! # What it is
//!
//! Use this crate when you want parser, screen, input-encoding, or host-reply
//! behavior without a managed PTY session. Use the `tastty` crate when you want
//! spawning, resizing, input delivery, and shutdown handled for you.
//!
//! The main entry points are [`Parser`], [`Screen`], [`KeyEncoder`],
//! [`MouseEncoder`], [`frame`], [`HostProfile`], and [`HostReply`].
//!
//! # I/O boundary
//!
//! Feed bytes from your PTY, socket, fixture, or test harness into
//! [`Parser::process`]. After processing, inspect the [`Screen`] and drain
//! [`ScreenEvent`] values with [`Screen::drain_events`]. Use [`HostReply`] for
//! supported terminal replies, and keep [`KeyEncoder`] / [`MouseEncoder`] in
//! sync before sending encoded input bytes back to the child process.
//!
//! # Callback flow
//!
//! A typical loop looks like this:
//!
//! ```
//! use tastty_core::{HostProfile, KeyEncoder, Parser, TerminalSize};
//! use tastty_core::host_reply::auto_reply_bytes;
//! use tastty_core::input::{KeyCode, KeyEvent, KeyModifiers};
//!
//! let host = HostProfile::default();
//! let mut parser = Parser::new(TerminalSize { rows: 24, cols: 80 }, 0);
//! parser.process(b"\x1b[>q");
//!
//! // Default behavior: auto-reply to host queries with the canonical bytes.
//! // Tastty's `Terminal` wrapper does this automatically; bare-Parser
//! // embedders call `auto_reply_bytes` themselves.
//! for event in parser.screen_mut().drain_events() {
//! if let Some(_wire_bytes) = auto_reply_bytes(&event, &host) {
//! // Write `_wire_bytes` back to the guest program (e.g., the PTY
//! // master). For an override (claim DA1 = xterm in a fixture,
//! // suppress XTVERSION), match on the event yourself and
//! // synthesize a custom `HostReply::*::encode()` instead.
//! }
//! }
//!
//! let mut encoder = KeyEncoder::new();
//! encoder.sync(parser.screen());
//! let key = KeyEvent::new(KeyCode::Char('a'), KeyModifiers::NONE);
//! let _wire_bytes = encoder.encode_key(&key);
//! ```
//!
//! # Basic usage
//!
//! ```
//! use tastty_core::{KeyEncoder, Parser, TerminalSize, frame};
//! use tastty_core::input::{KeyCode, KeyEvent, KeyModifiers};
//!
//! // Drive the virtual screen from bytes the caller obtained however it
//! // likes (PTY read, network socket, recorded fixture, ...).
//! let mut parser = Parser::new(TerminalSize { rows: 24, cols: 80 }, 0);
//! parser.process(b"hello\n");
//! let _size = parser.screen().size();
//!
//! // Encode a keystroke to wire bytes for the child process.
//! let enc = KeyEncoder::new();
//! let key = KeyEvent::new(KeyCode::Char('a'), KeyModifiers::NONE);
//! let _bytes: Option<Vec<u8>> = enc.encode_key(&key);
//!
//! // Build an atomic bracketed-paste frame.
//! let _frame: Vec<u8> = frame::bracketed_paste("pasted text", true);
//! ```
//!
//! # Stability
//!
//! `tastty-core` follows semver. The crate is pre-1.0, so expect additions
//! to enums marked `#[non_exhaustive]` without a major-version bump. Breaking
//! changes to existing item signatures get a minor-version bump until 1.0.
//!
//! # Feature flags
//!
//! - **`crossterm`**: adds `From<crossterm::...>` impls that convert
//! crossterm input events into this crate's [`KeyEvent`] / [`MouseEvent`].
//! - **`widget`**: adds `tui_term::widget::{Screen, Cell}` impls so the
//! virtual screen can be rendered directly as a ratatui widget.
//!
//! [`vte`]: https://crates.io/crates/vte
/// Text attributes and terminal color types.
/// Virtual terminal cell storage and accessors.
/// Keyboard and mouse event encoders.
/// Core error types.
/// Atomic byte-frame helpers for bracketed paste and focus reports.
/// Virtual terminal grid internals.
/// Host identity and default-color configuration.
/// Typed replies to terminal host queries.
/// Keyboard and mouse input event types.
pub
/// VT parser wrapper that drives a virtual [`Screen`].
pub
/// Virtual terminal row internals.
/// Virtual screen state, modes, events, and text extraction.
pub use ;
pub use ;
pub use ;
pub use ;
pub use HostProfile;
pub use ;
pub use ;
pub use Parser;
pub use ;