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§
- Clipboard
Error - 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_replacementcall 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.