hackagent.interfaces.tui.widgets.clipboard
Shared clipboard helper for TUI widgets.
Copying from a Textual app is awkward: the app captures the mouse, so native
terminal drag-select doesn't work, and not every terminal honours every
clipboard mechanism. :func:copy_to_clipboard tries the reliable options in
order so a "Copy" button works locally and over SSH:
- Textual's terminal-native clipboard (OSC 52) — works over SSH, no tools.
- OS clipboard tools (pbcopy / xclip / xsel / clip).
pyperclipif installed.- A temp file, as a last resort, so the text is never simply lost.
copy_to_clipboard
def copy_to_clipboard(app: Any, text: str) -> bool
Copy text to the clipboard using the first method that works.
Arguments:
app- The TextualApp(used for its OSC-52 clipboard). May be None.text- The text to copy.
Returns:
True if at least one method accepted the text, else False.
richlog_plaintext
def richlog_plaintext(rich_log: Any) -> Optional[str]
Return the plain text currently rendered in a RichLog widget.
Reads the widget's rendered line strips (markup/colour already removed),
so it works for viewers that write straight to the log without keeping a
separate text buffer. None on failure.