TerminalFocusHandler

Trait TerminalFocusHandler 

Source
pub trait TerminalFocusHandler: Send + Sync {
    // Required method
    fn app_name(&self) -> &'static str;

    // Provided methods
    fn try_focus(&self, _tty_device: &str, mode: FocusMode) -> bool { ... }
    fn try_focus_by_pid(
        &self,
        _pid: i32,
        tty_device: &str,
        mode: FocusMode,
    ) -> bool { ... }
}
Expand description

Trait for terminal-specific focus handling.

Terminals implement this trait to provide focus behavior. Simple terminals that only need app activation can implement just app_name() and inherit default implementations. Complex terminals override try_focus().

§Example

Simple terminal (inherits default focus behavior):

struct WaveHandler;
impl TerminalFocusHandler for WaveHandler {
    fn app_name(&self) -> &'static str { "Wave" }
}

Complex terminal (custom focus logic):

struct ITerm2Handler;
impl TerminalFocusHandler for ITerm2Handler {
    fn app_name(&self) -> &'static str { "iTerm2" }
    fn try_focus(&self, tty_device: &str, mode: FocusMode) -> bool {
        // Custom JXA logic to find session by TTY
    }
}

Required Methods§

Source

fn app_name(&self) -> &'static str

The application name used for activation (e.g., “Wave”, “iTerm2”).

Provided Methods§

Source

fn try_focus(&self, _tty_device: &str, mode: FocusMode) -> bool

Try to focus the terminal window/tab/pane containing the given TTY.

Default implementation uses JXA to activate by app name. Override this for terminals with custom focusing logic (e.g., iTerm2’s session lookup).

Source

fn try_focus_by_pid(&self, _pid: i32, tty_device: &str, mode: FocusMode) -> bool

Try to focus using PID-based matching when available.

Default delegates to try_focus(). Override for terminals that support PID-based window/tab lookup (e.g., Kitty).

Implementors§