Documentation
¶
Overview ¶
Package compose turns keysym sequences into text: pressing ' then e on a us-intl/deadkeys layout commits "é". The XKB keymap only yields the dead_acute keysym; composing needs an XKB compose table (~/.XCompose plus the system file), which this package resolves and parses once per process and shares across input contexts.
The parser, trie, and state machine come from lys-lib's pure-Go compose implementation (no cgo, the Compose file is just data); this package adds lys-ui's semantics on top: Feed answers pending, done-with-text, or none; backspace unwinds one level; a nil table — no compose file anywhere — is the disabled state and every call is a no-op, so callers never branch on whether compose exists.
Compose commits on completion only, X11 style: while a sequence is in flight no text is emitted, and there is no preedit display (that is the IME's territory). Composing works without the text-input protocol.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result uint8
Result classifies what one Feed did to the sequence in flight.
const ( // None means the keysym took no part in a sequence: the caller // routes it through normal text handling. A sequence that was in // flight is cancelled by the time None returns. None Result = iota // Pending means the keysym joined a sequence that is still waiting // for more keysyms; nothing has been emitted. Pending // Done means a sequence completed and text is its committed string. Done )
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is one compose state machine: feed it the committed keysyms of key presses and it answers pending, done-with-text, or none. Not safe for concurrent use; it lives on the input thread. The nil State is the disabled machine: every method is a no-op.
func (*State) Backspace ¶
Backspace unwinds one level of an in-flight sequence and reports whether anything was pending. Outside a sequence it reports false — the caller must then let backspace through as the widget's delete action. Backspace itself never emits text either way.
func (*State) Feed ¶
Feed advances the machine by one committed keysym. A keysym that matches no continuation cancels the sequence and reports None, so the key itself still goes through normal text handling; the dead-key prefix is dropped (there is no replay of cancelled prefixes). Modifier keysyms are not fed and never cancel: they cannot appear in sequences, and tapping shift mid-sequence must not lose it.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is an immutable set of compose sequences: keysym chains mapped to their committed text. Safe for concurrent use; a process needs one table (Load) and each input context its own State (Start).
func Load ¶
func Load() *Table
Load resolves the active compose file the way X11 clients do and parses it: $XCOMPOSEFILE, then ~/.XCompose, then the system file for the locale (LC_ALL/LC_CTYPE/LANG, with en_US.UTF-8 as the fallback). A nil Table means compose is disabled — no compose file exists, and dead-key layouts simply keep producing bare dead keysyms, which callers then treat like any other non-text key.
func NewTableFile ¶
NewTableFile parses one explicit Compose file — the seam tests and unusual setups use instead of the Load search order.