Skip to main content

Module clipboard

Module clipboard 

Source
Expand description

Clipboard / selection fallback (M5).

When the focused window’s keystroke buffer is empty — typically because focus moved and the user wants to fix something they didn’t just type — we simulate Ctrl+Shift+Left to select the previous word, Ctrl+C to copy it, read the clipboard via wl-paste, run the offline corrector over it, and then type the correction. The selection is still active when we type, so the replacement overwrites it in place.

Best-effort: doesn’t work in terminals (no select-previous-word shortcut) or in apps that interpret Ctrl+Shift+Left differently. Per DESIGN.md’s secondary-mode notes.

Enums§

ClipboardError
Errors from a clipboard-fallback round trip.

Functions§

copy_previous_word
Select the previous word, copy it, and return the contents. Leaves the selection active so a subsequent type_replacement call overwrites it.
type_replacement
Type the replacement text. With a selection still active (from copy_previous_word), this overwrites the selection in place. Safe to call standalone too.