Skip to main content

Module keysender

Module keysender 

Source
Expand description

Key forwarding — abstracts how the UI streams keystrokes into a tmux pane so tests can stub it out. Production hits tmux send-keys; tests pass a MockKeySender recording every call. Mirrors the trait + prod + mock shape pane.rs uses for capture so the two surfaces evolve together.

Used by Stage::StreamKeys (the ticket-#108 modal): once stream mode is active, every operator keystroke that isn’t Esc gets translated to a tmux key-name and shipped over.

Modules§

test_support
Test fixtures. Made pub (rather than #[cfg(test)]) so the integration tests in tests/ can reach them — same pattern as compose::test_support and mailbox::test_support.

Structs§

AsyncKeySender
Non-blocking KeySender decorator — moves the blocking tmux round-trip off the caller’s thread. send/scroll enqueue onto an unbounded channel and return immediately (sub-microsecond); a single background thread drains the channel in FIFO order and replays each job against the wrapped sender.
EncodedKey
One encoded keystroke ready for tmux send-keys. Carries the argument list so the prod impl can shell out without re-doing the translation, and so tests can inspect exactly what the encoder produced.
TmuxKeySender
Production implementation — shells out to tmux send-keys, one subprocess per keystroke. The round-trip blocks the caller ~3ms (pure tmux client/server cost; the key delivery itself is free), so the TUI wraps this in AsyncKeySender to keep that block off its render/event loop (#386).

Enums§

ScrollDirection
Direction of one mouse-wheel tick. Maps to tmux copy-mode commands scroll-up / scroll-down.

Traits§

KeySender
Lookup contract: forward one tmux key-name to the named session. key is already encoded — see encode_key for the crossterm → tmux translation. The production implementation (TmuxKeySender) blocks on a tmux send-keys round-trip; callers on a latency- sensitive thread should wrap it in AsyncKeySender so the round- trip happens off the caller’s thread (#386).

Functions§

encode_key
Translate a crossterm KeyEvent to the form tmux send-keys expects. Returns None for keys we deliberately drop (release events on kitty-protocol terminals, modifier-only presses).