Skip to main content

Module traits_impl

Module traits_impl 

Source
Expand description

Concrete implementations of the traits defined in crate::traits.

§What is implemented here

§How to use TerminalAccess in new code

Any function that only needs to inspect terminal mode (e.g. mouse handlers, input encoders) can be written against T: TerminalAccess instead of taking a concrete &TerminalManager. This makes the function testable with a lightweight mock:

use par_term::traits::TerminalAccess;

fn encode_if_tracking<T: TerminalAccess>(t: &T, button: u8, col: usize, row: usize) -> Vec<u8> {
    if t.is_mouse_tracking_active() {
        t.encode_mouse_event(button, col, row, true, 0)
    } else {
        Vec::new()
    }
}

See src/traits.rs for the full trait contract and migration path notes.

Structs§

StatusBarCtx
Per-call context for StatusBarUI.
TabBarCtx
Per-call context for TabBarUI.