Skip to main content

TerminalAccess

Trait TerminalAccess 

Source
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§

Source

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.

Source

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.

Source

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.

Source

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].

Source

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 coordinates
  • pressedtrue for press, false for release
  • modifiers — 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

Source§

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

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

Returns the current modifyOtherKeys level (0 = off, 1 = basic, 2 = full).

Delegates to TerminalManager::modify_other_keys_mode.

Source§

fn application_cursor(&self) -> bool

Returns true if DECCKM (application cursor key) mode is active.

Delegates to TerminalManager::application_cursor.

Source§

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 be written to the PTY.

Delegates to TerminalManager::encode_mouse_event.

Implementors§