shadow_terminal/
lib.rs

1//! # Shadow Terminal
2//! A fully-functional, fully-rendered terminal purely in memory.
3//!
4//! Useful for terminal multiplexers (a la `tmux`, `zellij`) and end to end testing TUI
5//! applications.
6//!
7//! There are 2 convenience modules for using this library: [`ActiveTerminal`] and
8//! [`SteppableTerminal`]. The former is run in a thread and can only be interacted with through
9//! channels, it's aimed more towards real world applications. Whilst the latter must be stepped
10//! through and is aimed more at end to end testing.
11//!
12//! The underlying [`ShadowTerminal`] is also designed to be used directly, but requires a bit
13//! more setup. See `ActiveTerminal` and `SteppableTerminal` to see how.
14
15#![expect(clippy::pub_use, reason = "How else are you supposed re-export??")]
16
17pub use termwiz;
18pub use wezterm_term;
19
20pub mod active_terminal;
21pub mod errors;
22/// How to send and manage the output of the shadow terminal.
23pub mod output {
24    pub mod foreign;
25    pub mod native;
26}
27pub mod pty;
28pub mod shadow_terminal;
29pub mod steppable_terminal;
30
31/// Tests
32pub mod tests {
33    pub mod helpers;
34}
35
36/// All the control signals
37#[derive(Debug, Clone)]
38#[non_exhaustive]
39pub enum Protocol {
40    /// End all loops to allow graceful shutdown
41    End,
42    /// Resize the PTY and shadow terminal
43    Resize {
44        /// Width of the shadow terminal
45        width: u16,
46        /// Height of the shadow terminal
47        height: u16,
48    },
49    /// Scrolling of the terminal scrollback
50    Scroll(Scroll),
51}
52
53/// The various states of scrolling
54#[derive(Debug, Clone)]
55#[non_exhaustive]
56pub enum Scroll {
57    /// Scroll the Wezterm terminal frontend up
58    Up,
59    /// Scroll the Wezterm terminal frontend down
60    Down,
61    /// Exit the scroll, returning the terminal to how it was before scrolling started.
62    Cancel,
63}