header and documentation updeates

This commit is contained in:
Peterino2 2026-09-20 23:30:23 -07:00
parent fcf4c7ec4c
commit 51ca8bd438
1 changed files with 54 additions and 23 deletions

View File

@ -626,37 +626,57 @@ UHDK_API uhdk_status UHDK_CALL uhdk_window_set_pointer_mode(
uhdk_pointer_mode mode
);
/* Text offsets/lengths are UTF-8 byte counts, always at scalar boundaries.
* surrounding_text is a bounded snapshot; document_offset locates it in the
* document. Selection and replacement ranges are relative to this snapshot.
* Events are ordered. Apply all edits in order, including edits sharing a base
* revision; do not discard a burst just because its first edit changed revision.
* acknowledged_input_id is the last applied text/edit input ID. Snapshots behind
* outstanding native edits are ignored; publish again after consuming the batch.
* On macOS, a semantic edit invalidates the native snapshot. Subsequent text
* input waits for an acknowledging snapshot, including when an edit is ignored.
* Acknowledge asynchronous edits (such as paste) only once their result is applied.
* Disabling text input discards deferred input. Raw key IDs are observational;
* acknowledge applied text/edit events, not raw keys that may precede them.
* Commit/preedit events carry text + an optional replacement range. A preedit
* updates temporary composition, never the permanent document by itself.
/* Document snapshot for native text input and IME.
*
* Publish with [`uhdk_window_set_text_state`](api:uhdk_window_set_text_state)
* after applying text and edit events. Offsets and lengths are UTF-8 byte
* counts at Unicode scalar boundaries.
*
* `surrounding_text` is a bounded window into the document, not the whole
* buffer. `document_offset` is that window's origin. Selection here, and
* replacement ranges on [`uhdk_text_event`](api:uhdk_text_event), are relative
* to this window.
*
* `revision` is the application's document generation. Apply every text and
* edit event in batch order, including a burst that shares one revision. Do
* not drop later events because the first one already changed your revision.
*
* `acknowledged_input_id` is the last applied text or edit
* [`input_id`](api:uhdk_event). Set it from TEXT_COMMIT, TEXT_PREEDIT,
* TEXT_COMPOSITION_END, or EDIT_COMMAND after that event is applied or
* ignored. Do not take it from a raw KEY that may precede those events. For
* an asynchronous edit such as paste, wait until the result is in the
* document.
*
* UHDK ignores a snapshot whose acknowledgment is behind outstanding native
* edits. After consuming the batch, publish again with the new id.
*
* On macOS, a semantic EDIT_COMMAND invalidates the native snapshot. Later
* text input waits for an acknowledging snapshot, including when the command
* was ignored.
*/
typedef struct uhdk_text_state {
uint32_t struct_size;
uint32_t reserved;
uhdk_text surrounding_text;
uint64_t revision;
uint64_t acknowledged_input_id;
uint64_t document_offset;
uint64_t selection_start;
uint64_t selection_len;
uhdk_text surrounding_text; /* Bounded UTF-8 window; copied on publish. */
uint64_t revision; /* Application document generation. */
uint64_t acknowledged_input_id; /* Last applied text/edit input_id. */
uint64_t document_offset; /* Byte origin of surrounding_text in the document. */
uint64_t selection_start; /* Relative to surrounding_text. */
uint64_t selection_len; /* Relative to surrounding_text. */
uhdk_rect caret; /* Window-local logical coordinates. */
} uhdk_text_state;
/* Enable native text input and IME. Disabling discards deferred input and
* ends composition. */
UHDK_API uhdk_status UHDK_CALL uhdk_window_set_text_input(uhdk_window *window, uhdk_bool enabled);
/* Copy `state` and publish it for IME and surrounding-text queries. Ignored
* when `acknowledged_input_id` is behind outstanding native edits; publish
* again after consuming the batch. See [`uhdk_text_state`](api:uhdk_text_state). */
UHDK_API uhdk_status UHDK_CALL uhdk_window_set_text_state(
uhdk_window *window,
const uhdk_text_state *state
);
/* End the current composition without committing it. */
UHDK_API uhdk_status UHDK_CALL uhdk_window_cancel_composition(uhdk_window *window);
/* File references preserve native names, including non-UTF-8 POSIX paths.
@ -1062,13 +1082,24 @@ typedef struct uhdk_scroll_event {
uhdk_bool momentum;
} uhdk_scroll_event;
/* TEXT_COMMIT or TEXT_PREEDIT payload.
*
* `text` is UTF-8. When `has_replacement` is true, replace
* `replacement_start`/`replacement_len` in the current
* [`uhdk_text_state`](api:uhdk_text_state) window, then insert `text`. Those
* ranges are relative to `surrounding_text`.
*
* PREEDIT updates temporary composition only; it does not change the
* permanent document by itself. COMMIT inserts into the document. Apply
* events in delivery order; see [`uhdk_text_state`](api:uhdk_text_state).
*/
typedef struct uhdk_text_event {
uhdk_text text;
uint64_t revision;
uint64_t revision; /* Snapshot revision this event is based on. */
uhdk_bool has_replacement;
uint32_t reserved;
uint64_t replacement_start;
uint64_t replacement_len;
uint64_t replacement_start; /* Relative to surrounding_text. */
uint64_t replacement_len; /* Relative to surrounding_text. */
uint64_t selection_start;
uint64_t selection_len; /* Within preedit text. */
} uhdk_text_event;