pub trait TerminalAccess {
// Required methods
fn is_alt_screen_active(&self) -> bool;
fn should_report_mouse_motion(&self, button_pressed: bool) -> bool;
fn modify_other_keys_mode(&self) -> u8;
fn application_cursor(&self) -> bool;
fn encode_mouse_event(
&self,
button: u8,
col: usize,
row: usize,
pressed: bool,
modifiers: u8,
) -> Vec<u8> ⓘ;
}Expand description
Provides read-only access to terminal mode and state for input/mouse handlers.
Implemented by TerminalManager (and mock types in tests). Decouples
app/mouse_events/ and app/input_events/ from the concrete terminal type,
enabling unit tests without a live PTY session.
§Notes
All methods take &self — this trait is intentionally read-only. State
mutation goes through TerminalManager directly (write, resize, etc.).
Required Methods§
Sourcefn is_alt_screen_active(&self) -> bool
fn is_alt_screen_active(&self) -> bool
Returns true if the alternate screen buffer (DECSC/smcup) is active.
Used by mouse handlers to suppress scrollback scrolling while TUI apps (vim, htop, etc.) own the display.
Sourcefn should_report_mouse_motion(&self, button_pressed: bool) -> bool
fn should_report_mouse_motion(&self, button_pressed: bool) -> bool
Returns true if mouse motion events should be reported to the PTY.
button_pressed — whether a mouse button is currently held. Some
modes (ButtonEvent) only report motion while a button is pressed.
Sourcefn modify_other_keys_mode(&self) -> u8
fn modify_other_keys_mode(&self) -> u8
Returns the current modifyOtherKeys level (0 = off, 1 = basic, 2 = full).
Controls how modifier-key combinations are encoded in key sequences.
Sourcefn application_cursor(&self) -> bool
fn application_cursor(&self) -> bool
Returns true if DECCKM (application cursor key) mode is active.
In application mode, cursor keys send \x1bO[ABCD] instead of \x1b[ABCD].
Sourcefn encode_mouse_event(
&self,
button: u8,
col: usize,
row: usize,
pressed: bool,
modifiers: u8,
) -> Vec<u8> ⓘ
fn encode_mouse_event( &self, button: u8, col: usize, row: usize, pressed: bool, modifiers: u8, ) -> Vec<u8> ⓘ
Encode a mouse event into the bytes to send to the PTY.
Parameters match the X10 / SGR / UTF-8 encoding conventions used by
par-term-emu-core-rust:
button— button index (0-2 for primary/middle/secondary, 64+ for scroll)col/row— 0-based cell coordinatespressed—truefor press,falsefor releasemodifiers— bitmask: bit 2 = Shift, bit 3 = Alt, bit 4 = Ctrl
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl TerminalAccess for TerminalManager
impl TerminalAccess for TerminalManager
Source§fn is_alt_screen_active(&self) -> bool
fn is_alt_screen_active(&self) -> bool
Returns true if the alternate screen buffer (DECSC/smcup) is active.
Delegates to TerminalManager::is_alt_screen_active.
Source§fn should_report_mouse_motion(&self, button_pressed: bool) -> bool
fn should_report_mouse_motion(&self, button_pressed: bool) -> bool
Returns true if mouse motion events should be forwarded to the PTY.
Delegates to TerminalManager::should_report_mouse_motion.
Source§fn modify_other_keys_mode(&self) -> u8
fn modify_other_keys_mode(&self) -> u8
Returns the current modifyOtherKeys level (0 = off, 1 = basic, 2 = full).
Delegates to TerminalManager::modify_other_keys_mode.
Source§fn application_cursor(&self) -> bool
fn application_cursor(&self) -> bool
Returns true if DECCKM (application cursor key) mode is active.
Delegates to TerminalManager::application_cursor.