wijjit_ssh.backend
A TerminalBackend bridged to an SSH channel.
This is the whole reason the backend seam exists: RemoteTerminalBackend
runs an ordinary Wijjit app against an asyncssh session instead of the local
console. It:
writes rendered frames and screen-control sequences to the SSH channel,
decodes inbound channel bytes into Wijjit key/mouse events on the event loop (see
wijjit_ssh.input), so every element behaves exactly as it does locally, andreports the client’s negotiated PTY size (refreshed on
SIGWINCH-style resize events) as a task-local override, so many differently-sized sessions coexist in one server process.
It sets owns_terminal = False so the event loop installs none of the
process-global terminal machinery (SIGTERM/SIGHUP/atexit restore, SIGTSTP
suspend) - there is no local tty to restore, and those handlers are
process-global and would collide across concurrent sessions.
The channel is opened in binary mode (encoding=None on the server), so
inbound data arrives as raw bytes for the decoder and outbound frames are
encoded here, at the one boundary where text becomes wire bytes.
- class wijjit_ssh.backend.RemoteTerminalBackend(chan, columns, lines)[source]
Bases:
TerminalBackendTerminal backend that drives a Wijjit app over an SSH channel.
- Parameters:
chan (asyncssh.SSHServerChannel) – The client’s session channel; frames are written here.
columns (int) – Initial terminal width negotiated by the PTY request.
lines (int) – Initial terminal height negotiated by the PTY request.
- property screen_output: TextIO | None
Stream the
ScreenManagerwrites to.- Returns:
The output stream for screen-control sequences (alternate buffer, cursor visibility, title).
Nonemeans “usesys.stdout”, matchingScreenManager’s default.- Return type:
TextIO or None
- write_frame(data)[source]
Write a fully rendered frame to the terminal.
- Parameters:
data (str) – The frame’s ANSI byte string (already diffed by the renderer).
- Return type:
None
- create_input_handler(*, enable_mouse, mouse_tracking_mode)[source]
Build this session’s input source.
Called once by
Wijjitduring construction. The instance is retained sofeed()can route inbound channel bytes to it.- Parameters:
enable_mouse (bool) – Whether the app wants mouse tracking.
mouse_tracking_mode (MouseTrackingMode or None) – Requested tracking granularity.
- Returns:
An input source fed by this channel’s byte stream.
- Return type:
- feed(data)[source]
Push inbound channel bytes into the input decoder.
- Parameters:
data (bytes) – Raw bytes received on the channel.
- Return type:
None
Notes
A no-op until the app has been constructed (which is what creates the input source), so data racing session startup is dropped rather than crashing the session.
- resize(columns, lines)[source]
Record a new client terminal size.
The running event loop reads this via
get_size()on its next frame and republishes it to the task-local size override, so overlays, notifications, and layout reflow to the new dimensions.