Skip to main content

Module clipboard

Module clipboard 

Source
Expand description

The system clipboard, reached two ways, and the shapes a copy takes.

native talks to the display server through arboard. On Wayland the copy is owned by this process, so it survives only as long as datui runs unless a clipboard manager persists it. For tabular copies the native path offers two flavors at once — text/html (a real <table>) beside plain text — so a paste into a spreadsheet or an email lands as a table while a paste into a terminal stays TSV.

osc52 prints an OSC 52 escape sequence for the terminal to act on, which is what works over SSH with no display server in sight. The sequence must go straight to stdout: the ratatui buffer is sanitized (crate::sanitize), and an escape drawn as cell text is an escape stripped. Terminals cap how much OSC 52 they accept, so the payload is capped here first, with the limit in the config where a generous terminal’s user can raise it. The cap is known before a copy is built: a table copy to the terminal is read in batches and stops at the first byte over it, and no HTML flavor is built for a destination that cannot offer one.

auto is native where it initializes and osc52 everywhere else, decided once per run at the first copy.

Structs§

Accepts
What a destination takes, known before a copy is built.
Native
arboard, kept alive for the life of the app: on Wayland and X11 the copy dies with the process that owns it, so dropping the handle early would revoke the copy the flash just announced.
Osc52
The OSC 52 writer. Carries only the cap; stdout is fetched per write.
Payload
One copy, ready for whichever destination takes it. The text flavor is always there; the HTML flavor rides along when the copy is a table and the destination can offer both.

Enums§

BackendChoice
Which clipboard mechanism [clipboard] backend asks for.
CopyFormat
The formats the dialog offers for tabular scopes.

Traits§

Destination
Somewhere a payload can go. A trait so the integration tests can hand the app a destination that only records what it was given.

Functions§

base64_len
The length of bytes bytes in padded base64.
bounded_table_text
The text of a table copy and its row count, read from lf a batch at a time and given up at the first batch that takes it past limit bytes of base64: a copy the terminal will not take is never read or written whole. Text only; a capped destination offers no HTML flavor.
delimited
A DataFrame as delimited text, quoted the way spreadsheets parse a paste: only fields holding the delimiter, a quote or a newline are quoted, which is QuoteStyle::Necessary, the writer’s default. Raw values, like export; a null is an empty field, never the UI’s ∅.
destination
The destination a backend choice names, built at the first copy.
html_table
A DataFrame as an HTML table, the rich flavor beside a TSV or CSV copy. Everything is escaped; a null is an empty cell.
markdown
A DataFrame as a Markdown table. Always with the header: the delimiter row under it is what makes Markdown read the block as a table at all. Numeric columns declare right alignment, pipes are escaped, and embedded newlines flatten to spaces — a Markdown cell has no way to hold one.
osc52_sequence
The escape sequence that asks the terminal to set the system clipboard, or why it was not built. Split from Osc52::write so a test can read the bytes without owning stdout. The size is checked before anything is encoded.
tabular_payload
The payload for a tabular copy: the chosen format as text, with the HTML flavor beside a TSV or CSV copy when html asks for it (the destination can offer it). A Markdown copy is the Markdown itself — pasting rich HTML where Markdown was asked for would defeat the choice. List and struct cells are JSON in every format, as in a CSV export.