header and documentation updeates
This commit is contained in:
parent
fcf4c7ec4c
commit
51ca8bd438
|
|
@ -626,37 +626,57 @@ UHDK_API uhdk_status UHDK_CALL uhdk_window_set_pointer_mode(
|
||||||
uhdk_pointer_mode mode
|
uhdk_pointer_mode mode
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Text offsets/lengths are UTF-8 byte counts, always at scalar boundaries.
|
/* Document snapshot for native text input and IME.
|
||||||
* surrounding_text is a bounded snapshot; document_offset locates it in the
|
*
|
||||||
* document. Selection and replacement ranges are relative to this snapshot.
|
* Publish with [`uhdk_window_set_text_state`](api:uhdk_window_set_text_state)
|
||||||
* Events are ordered. Apply all edits in order, including edits sharing a base
|
* after applying text and edit events. Offsets and lengths are UTF-8 byte
|
||||||
* revision; do not discard a burst just because its first edit changed revision.
|
* counts at Unicode scalar boundaries.
|
||||||
* acknowledged_input_id is the last applied text/edit input ID. Snapshots behind
|
*
|
||||||
* outstanding native edits are ignored; publish again after consuming the batch.
|
* `surrounding_text` is a bounded window into the document, not the whole
|
||||||
* On macOS, a semantic edit invalidates the native snapshot. Subsequent text
|
* buffer. `document_offset` is that window's origin. Selection here, and
|
||||||
* input waits for an acknowledging snapshot, including when an edit is ignored.
|
* replacement ranges on [`uhdk_text_event`](api:uhdk_text_event), are relative
|
||||||
* Acknowledge asynchronous edits (such as paste) only once their result is applied.
|
* to this window.
|
||||||
* Disabling text input discards deferred input. Raw key IDs are observational;
|
*
|
||||||
* acknowledge applied text/edit events, not raw keys that may precede them.
|
* `revision` is the application's document generation. Apply every text and
|
||||||
* Commit/preedit events carry text + an optional replacement range. A preedit
|
* edit event in batch order, including a burst that shares one revision. Do
|
||||||
* updates temporary composition, never the permanent document by itself.
|
* 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 {
|
typedef struct uhdk_text_state {
|
||||||
uint32_t struct_size;
|
uint32_t struct_size;
|
||||||
uint32_t reserved;
|
uint32_t reserved;
|
||||||
uhdk_text surrounding_text;
|
uhdk_text surrounding_text; /* Bounded UTF-8 window; copied on publish. */
|
||||||
uint64_t revision;
|
uint64_t revision; /* Application document generation. */
|
||||||
uint64_t acknowledged_input_id;
|
uint64_t acknowledged_input_id; /* Last applied text/edit input_id. */
|
||||||
uint64_t document_offset;
|
uint64_t document_offset; /* Byte origin of surrounding_text in the document. */
|
||||||
uint64_t selection_start;
|
uint64_t selection_start; /* Relative to surrounding_text. */
|
||||||
uint64_t selection_len;
|
uint64_t selection_len; /* Relative to surrounding_text. */
|
||||||
uhdk_rect caret; /* Window-local logical coordinates. */
|
uhdk_rect caret; /* Window-local logical coordinates. */
|
||||||
} uhdk_text_state;
|
} 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);
|
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_API uhdk_status UHDK_CALL uhdk_window_set_text_state(
|
||||||
uhdk_window *window,
|
uhdk_window *window,
|
||||||
const uhdk_text_state *state
|
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);
|
UHDK_API uhdk_status UHDK_CALL uhdk_window_cancel_composition(uhdk_window *window);
|
||||||
|
|
||||||
/* File references preserve native names, including non-UTF-8 POSIX paths.
|
/* File references preserve native names, including non-UTF-8 POSIX paths.
|
||||||
|
|
@ -1062,13 +1082,24 @@ typedef struct uhdk_scroll_event {
|
||||||
uhdk_bool momentum;
|
uhdk_bool momentum;
|
||||||
} uhdk_scroll_event;
|
} 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 {
|
typedef struct uhdk_text_event {
|
||||||
uhdk_text text;
|
uhdk_text text;
|
||||||
uint64_t revision;
|
uint64_t revision; /* Snapshot revision this event is based on. */
|
||||||
uhdk_bool has_replacement;
|
uhdk_bool has_replacement;
|
||||||
uint32_t reserved;
|
uint32_t reserved;
|
||||||
uint64_t replacement_start;
|
uint64_t replacement_start; /* Relative to surrounding_text. */
|
||||||
uint64_t replacement_len;
|
uint64_t replacement_len; /* Relative to surrounding_text. */
|
||||||
uint64_t selection_start;
|
uint64_t selection_start;
|
||||||
uint64_t selection_len; /* Within preedit text. */
|
uint64_t selection_len; /* Within preedit text. */
|
||||||
} uhdk_text_event;
|
} uhdk_text_event;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue