Skip to main content

Module tty

Module tty 

Source
Expand description

Terminal clipboard support via the OSC52 escape sequence.

OSC52 is a last-resort clipboard mechanism: it asks the terminal emulator to set the system clipboard, so it works over SSH and without any native clipboard tool. The bytes must reach the real terminal - the controlling /dev/tty or stdout.

This module holds the pure, fully-tested pieces: osc52_sequence (the base64/escape encoding) and osc52_write_via (the tty-then-stdout branch logic, parameterized over the tty opener and the fallback sink so every branch is exercised via injected fakes). The genuinely-untestable real-I/O leaves (opening /dev/tty, writing the real stdout()) are composed in the CLI binary - see real_yank in crates/leviath-cli/src/main.rs.

Functionsยง

osc52_write_via
Core OSC52 write logic, parameterized over how to open the TTY and where the stdout fallback writes, so every branch is exercisable without touching a real terminal. pub so the CLI binary can compose it with the real /dev/tty opener + real stdout() (the un-unit-testable leaves) - see real_yank in crates/leviath-cli/src/main.rs.