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
}
}