Expand description
C API for kui: a cdylib plus include/kui.h, and CExtension for loading a C plugin into a Rust host.
kui splits a UI into a model that lays out and paints into a display
list (kui-core), a renderer (kui-wgpu) and a windowed runner
(kui-native). This crate puts the model, and optionally the runner,
behind a flat C ABI: every pub extern "C" fn here is a kui_*
symbol declared in include/kui.h, and the Kui* structs are the
repr(C) mirrors the header declares field for field.
Two kinds of program use it:
- A C, C++ or other-language host links the cdylib (
libkui_ffi) and includeskui.h. It either hands a window tokui_runand builds its view in a callback, or owns its own event loop and renderer: it feeds input withkui_input_*, builds a frame betweenkui_frame_beginandkui_frame_finish, pollskui_poll_eventand drawskui_draw_data. - A Rust host running
kui-nativeloads a C shared library as a guest extension throughCExtension: the plugin draws into a slot the host declares and gets its own events back.
The C programs under examples/c/ in the repository are working
references for every call below.
§Conventions
- Strings cross as
KuiStr, a(ptr, len)pair of UTF-8 bytes that is never NUL-terminated (KUI_STR("literal")in C). Invalid UTF-8 is replaced. A string the library hands back is borrowed until the next call of the same function on that context. - Values. A
KuiValuefrom akui_value_*constructor is yours until you pass it to a function documented as consuming it (anon_clickpayload, the value given tokui_value_map_set); free anything else withkui_value_free. The payload on a polled event is borrowed until the nextkui_poll_event. - Panics never cross. Every entry point catches panics and returns
its failure value instead (
false,0or NULL). A NULL context is answered the same way. - ABI handshake. Call
kui_abi_versionfirst and compare it for equality with the header’sKUI_ABI_VERSION(seeKUI_ABI_VERSION). Structs the library writes into your memory lead with asizeyou set fromsizeof(theKUI_*_INITinitializers do), and the library writes no further than that. - Coordinates are logical pixels; draw data comes back in physical
pixels at the frame’s
scale.
§A host’s frame loop in C
The shape without kui_run: the calls a host makes around a window and
renderer of its own (the same calls work headless, which is how the C
examples test themselves).
#include "kui.h"
if (kui_abi_version() != KUI_ABI_VERSION) return 1;
KuiCtx *ctx = kui_ctx_new();
long long count = 0;
for (;;) {
/* Input from the windowing library, in logical pixels. */
kui_input_cursor(ctx, mouse_x, mouse_y);
if (clicked) { kui_input_mouse(ctx, true, 1); kui_input_mouse(ctx, false, 1); }
/* What the UI emitted; a payload is borrowed until the next poll. */
KuiEvent ev = KUI_EVENT_INIT;
while (kui_poll_event(ctx, &ev)) {
const KuiValue *kind = kui_value_get(ev.payload, KUI_STR("kind"));
KuiStr s;
if (kind && kui_value_as_str(kind, &s) && kui_str_eq(s, "inc")) count++;
}
/* Build the frame from scratch. */
kui_set_time(ctx, now_seconds());
kui_frame_begin(ctx, width, height, scale);
KuiTheme t = KUI_THEME_INIT;
kui_theme(ctx, &t);
KuiSpec root = {.width = {KUI_GROW, 1}, .height = {KUI_GROW, 1},
.main_align = KUI_CENTER, .cross_align = KUI_CENTER, .bg = t.bg};
kui_root(ctx, &root);
char buf[32];
snprintf(buf, sizeof buf, "%lld", count);
KuiTextStyle big = {.size = 56};
kui_text(ctx, KUI_STR(buf), &big);
KuiValue *inc = kui_value_map();
kui_value_map_set(inc, KUI_STR("kind"), kui_value_str(KUI_STR("inc")));
kui_button(ctx, KUI_STR("+1"), inc); /* consumes inc */
kui_frame_finish(ctx);
/* Draw it: one quad list, physical pixels, plus the glyph atlas to mirror. */
KuiDrawData dd = KUI_DRAW_DATA_INIT;
if (kui_draw_data(ctx, &dd)) {
if (dd.atlas_dirty) upload_atlas(dd.atlas_pixels, dd.atlas_size);
draw_quads(dd.quads, dd.quad_count, dd.clips);
}
if (!kui_animating(ctx)) wait_for_input();
}
kui_ctx_free(ctx);With the runner feature, kui_run(title, view, on_event, user) does
all of this around a window of its own and calls view once per frame
with a context to build into; examples/c/apps/counter.c is that
program.
§A C extension in a Rust app
A plugin is a shared library exporting kui_ext_abi and kui_ext_view
(and optionally kui_ext_name, kui_ext_init, kui_ext_slots,
kui_ext_on_event, kui_ext_free); examples/c/features/slots/panel.c
is one. The host loads it and declares where it draws:
use kui_ffi::CExtension;
use kui_native::{App, NodeSpec, Ui};
struct Host;
impl App for Host {
fn view(&mut self, ui: &mut Ui<'_>) {
ui.open(NodeSpec::row().fill());
// The plugin fills this position: `todos` is the namespace the
// host loaded it under, `panel` a slot the plugin lists.
ui.slot("todos/panel");
ui.close();
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
// SAFETY: the plugin's code runs in this process. Loading it is
// trusting it as much as linking it would be.
let ext = unsafe { CExtension::open("target/debug/panel.so")? };
kui_native::app("host").extension_as("todos", ext).run(Host)
}§Where to look
Everything is exported flat at the crate root. By job:
- Context:
kui_ctx_new,kui_ctx_free,KuiCtx. - Building a frame:
kui_frame_begin,kui_root,kui_open,kui_open_keyed,kui_text,kui_close,kui_frame_finish;KuiSpecandKuiTextStyleare what a node is built from. - Input and events:
kui_input_cursor,kui_input_mouse,kui_input_press,kui_input_text,kui_poll_event,KuiEvent. - Values:
kui_value_map,kui_value_str,kui_value_get,kui_value_as_str,KuiValue. - Drawing:
kui_draw_data,KuiDrawData,KuiQuad,kui_set_subpixel_text. - Widgets:
kui_button,kui_text_input,kui_checkbox,kui_slider,kui_select. - Theme and metrics:
kui_env_set_system,kui_theme,KuiTheme,kui_metrics. - Windows:
kui_window_declare,kui_take_window_command,KuiWindowCommand. - Accessibility:
kui_access_tree,KuiAccessNode,kui_input_access. - Extensions:
CExtension,kui_ctx_add_extension,kui_slot,kui_reply. - Diagnostics:
kui_set_diagnostics,kui_take_warnings,kui_set_devtools. - The windowed runner (feature
runner):kui_run,kui_run_with,KuiRunConfig.
§Features
runner(on by default):kui_runandkui_run_with, the windowed runner fromkui-native. A host that owns its own window and renderer builds with--no-default-featuresand ships less than half the library.
The book: https://kui-book.qxuken.dev. Repository:
https://github.com/qxuken/kui (design records live under docs/adr
there).
Structs§
- CExtension
- A C shared library loaded as a guest extension of a Rust host.
- KuiAccess
Node - One node of the access tree (
kui_access_tree): what assistive technology sees.roleis KUI_ROLE_,flagsKUI_ACCESS_HAS_ / FOCUSED / CHECKED bits saying which optional fields hold,actionsthe KUI_ACCESS_* bits the node accepts throughkui_input_access. Strings are borrowed until the nextkui_access_treeon the context. - KuiAccess
Run - One laid-out run of an editor’s text (
kui_access_runs): what a screen reader reads by character and word.textends with"\n"(counted as a zero-width character) when the line continues into another. Character positions are relative tox. Arrays and strings are borrowed until the nextkui_access_tree/kui_access_runson the context. - KuiAnnouncement
- One queued announcement (
kui_take_announcements): something to say once, with no node behind it.liveis KUI_LIVE_POLITE or KUI_LIVE_ASSERTIVE — never KUI_LIVE_OFF, whichkui_announcedrops.textborrows the context’s buffer and stays valid until the nextkui_take_announcementson the same context. - KuiAudio
- What a
kui_audionode declares; read literally (KUI_AUDIO_INIT). - KuiAudio
Command - One audio command for a host that drives its own device
(
kui_take_audio_commands);kindisKUI_AUDIO_*and says which of the other fields mean anything. - KuiCaret
Rect - A caret rect (
kui_caret_rect): logical px in viewport coordinates, zero wide, one line tall. - KuiCell
- One cell of a
kui_cellsgrid: a Unicode scalar, colours as0xRRGGBBAA(abgof 0 is none),KUI_CELL_*attribute bits. Travels as an array, so a change here is an ABI bump. - KuiClip
- One clip a frame’s quads name, in physical pixels. Mirrors
kui_core::Clip, soKuiDrawData::clipsis a cast and not a copy. - KuiColor
Op - One step of a derived colour token’s recipe as
kui_tokens_derivereads it: the verb as one of theKUI_OP_*numbers, the number it takes, and (forKUI_OP_MIXandKUI_OP_READABLEonly) the colour token or role the verb names, empty otherwise. Array-carried, so an append here is an ABI bump. - KuiColor
Token - One colour token as
kui_tokens_setreads it: a name and a value per base,0xRRGGBBAAeach (the same value twice for a colour that does not follow the appearance). Travels as an array, so an append here is an ABI bump. - KuiCtx
- The opaque context every
kui_*call takes: a core plus its pending event queue. - KuiDerived
Token - One derived colour token: a name, the colour token or theme role it
derives from, and its chain of ops in order (none for an alias).
Array-carried like
KuiColorToken. - KuiDraw
Data - The finished frame’s draw list, as
kui_draw_datawrites it: the quads, the clips they index, the glyph atlas to mirror as a texture, and the side lists for fragments and texture-backed images. - KuiEnter
- Where a node starts the first frame it is seen (
KuiSpec.enter): the slotssetnames ease in from these values overtransition_msinstead of snapping. A zeroed struct is no entrance. - KuiEvent
- One event from the UI, as
kui_poll_eventwrites it andkui_run’son_eventreceives it. - KuiFile
Dialog - The dialog
kui_request_filesasks for. Zeroed, it is an Open dialog for one file of any type. - KuiFile
Filter - One entry of a dialog’s file-type menu.
- KuiFragment
Draw - One
KUI_QUAD_FRAGMENT’s draw, addressed by that quad’suv[0]. - KuiGradient
- A box’s gradient (
KuiSpec.gradient,docs/adr/0042-a-gradient-is-an-image-the-core-paints.md): linear alongangle— turns clockwise from east, in the box’s unit square — or radial out from (at_x,at_y), fractions of the box, to its farthest corner.stops_lenstops, two or more. - KuiGradient
Stop - One stop of a
KuiGradient: a colour and where along the gradient it sits, 0..1 — or a negativeatfor a stop spaced evenly between its neighbours that have one. - KuiKeyframe
- One keyframe stop (
KuiSpec.keyframes): a zeroed stop sets nothing.setsays which fields count, so 0 stays a legal value for each. - KuiLayout
Rect - The rect a node was laid out at (
kui_layout_of): logical px in viewport coordinates, thelayoutevent’s numbers without the event. - KuiLength
Token - One length token: a name and logical px, before the scale factor.
Array-carried like
KuiColorToken. - KuiMenu
- One menu of the application menu bar (
kui_menu_bar), read while the call runs; the core copies what it needs. - KuiMenu
Action - What choosing a context-menu row left for the host
(
kui_take_menu_action): the clipboard, which is the host’s in this library.KUI_MENU_ACTION_SET_CLIPBOARDcarries the text to put there;KUI_MENU_ACTION_PASTEcarries nothing and asks for what is there, which the host delivers back withkui_input_paste(orkui_input_commit);KUI_MENU_ACTION_SET_CLIPBOARD_SECRETcarries a secret to put there marked concealed and transient. - KuiMenu
Item - One row of a menu (
kui_open_menu,kui_menu_bar,kui_select), read while the call runs. - KuiMetrics
- The sizes the stock widgets are built from (
kui_metrics,kui_metrics_set), in logical px before the scale factor:kui_core::schema::METRIC_ROLESfield for field, in that order. An append here bumpsKUI_ABI_VERSION. - KuiPlay
- Options for
kui_play. NULL means defaults; a given struct is read literally (sovolumemust be set —KUI_PLAY_INITin kui.h does). - KuiQuad
- One quad of a frame’s draw list, in physical pixels: a rounded
rectangle, border, shadow, glyph, image or segment, told apart by
kind. A renderer draws them in order, every one with the same instanced pipeline;KuiDrawDatahands out the array. - KuiReply
Sink - Where a
kui_replyfrom insidekui_ext_on_eventsends its value: an opaque handle the library puts on the event for the callback and takes back when it returns. Never allocate, dereference or store one. - KuiRun
Config - How
kui_run_withopens its window: the options a Rust host’sLauncherhas, as one struct. Read literally, so start fromKUI_RUN_CONFIG_INIT(every zero) or pass NULL for exactly that: a 960x640 native window, unbounded, antialiasing chosen by the GPU, diagnostics as the build has them. - KuiScroll
Geometry - What the last layout resolved for a scroll container (
kui_scroll_geometry): its own box, its content size and the clamped offset, all logical px in viewport coordinates. - KuiSizing
- One axis of a node’s size: a
KUI_*tag and its value. - KuiSpan
- One styled run of a rich-text paragraph (
kui_rich_text,kui_measure_rich_text): its text and what differs from the base style. Travels as an array, so an append here is an ABI bump. - KuiSpec
- Everything a box node is built from: size, layout, paint, behaviour
tags and accessibility, as the
kui_open*family and the stock widgets read it. - KuiStr
- A borrowed string:
lenbytes of UTF-8 atptr, not NUL-terminated. - KuiSystem
Font - One installed or loaded font family (
kui_system_fonts), as the font database read its faces.familyandweightsare borrowed until the nextkui_system_fontson the same context. - KuiText
Hit - Where a point landed in the text a keyed node drew (
kui_text_hit): a byte offset into that text, across the node’s text runs in order, and the visual (wrapped) line it is on. - KuiText
Metrics - What a piece of text measures (
kui_measure_text), logical px at the scale of the current or last frame. - KuiText
Style - How a run of text is set: size, line height, colour, family or font,
wrapping and decoration. A zeroed struct is the default style at size
0, so set at least
size; NULL where a style pointer is taken is the default style. - KuiTexture
Draw - One
KUI_QUAD_TEXTURE’s draw, addressed by that quad’suv[0]. - KuiTheme
- The palette a frame paints with: one
0xRRGGBBAAper role, derived from what the host reported throughkui_env_set_systemunless it pinned something else. Written bykui_theme([out], so start fromKUI_THEME_INIT) and read whole bykui_theme_set([in]). - KuiValue
- An opaque dynamic value: null, bool, int, float, string, list or map.
- KuiWarning
- One diagnostic (
kui_take_warnings): a silent misconfiguration the core noticed.codeis stable (grow-weight-ignored,transition-auto-key,duplicate-key); the strings are borrowed until the nextkui_take_warningson the same context. - KuiWindow
Command - One window command (
kui_take_window_command): what a chrome node asked for, or what the declared window set’s diff decided. Plain data (anOpencarries no title; the window’s first frame declares one throughkui_window_title), so nothing borrowed enters a host’s drain loop. An[out]struct: start fromKUI_WINDOW_COMMAND_INIT. - KuiWindow
Config - What a declared window is (
kui_window_declare), and what anOpencommand carries back out insideKuiWindowCommand. Read literally, so start fromKUI_WINDOW_CONFIG_INIT(a normal, activating 640x480 window) or pass NULL for exactly that.
Constants§
- KUI_
ABI_ VERSION - The ABI this build implements, returned by
kui_abi_version. - KUI_
ACCESS_ CHECKED - KUI_
ACCESS_ CHECKED_ SET - KUI_
ACCESS_ DISABLED - The node is
disabled: inert, not a Tab stop (bit 9 is KUI_ACCESS_HAS_TEXT_SELECTION). - KUI_
ACCESS_ EXPANDED - KUI_
ACCESS_ EXPANDED_ SET - The node expands, and whether it is open (see
KuiSpec.expanded). - KUI_
ACCESS_ FOCUSED - KUI_
ACCESS_ HAS_ MAX - KUI_
ACCESS_ HAS_ MIN - KUI_
ACCESS_ HAS_ NUMBER - KUI_
ACCESS_ HAS_ POS_ IN_ SET pos_in_setholds (on an item),set_sizeholds (on its container).- KUI_
ACCESS_ HAS_ SCROLL - KUI_
ACCESS_ HAS_ SELECTION - KUI_
ACCESS_ HAS_ SET_ SIZE - KUI_
ACCESS_ HAS_ TEXT_ SELECTION - KUI_
ACCESS_ HAS_ VALUE - KUI_
ACCESS_ LIVE_ ASSERTIVE - KUI_
ACCESS_ LIVE_ POLITE - The node declared
live(seeKuiSpec.live), and which politeness. Two bits rather than a field, becauseKuiAccessNodeis an array the host allocates and appending to it would be an ABI break. - KUI_
ACCESS_ MIXED - A checkbox that is neither on nor off (
KuiSpec.mixed); set besideKUI_ACCESS_CHECKED_SET, whoseKUI_ACCESS_CHECKEDit outranks. - KUI_
ACCESS_ MODAL - The node is the frame’s
modalsurface (aria-modal): focus and input are confined to it. - KUI_
ACCESS_ SELECTED - KUI_
ACCESS_ SELECTED_ SET - The node has a selected state at all, and what it is: every
KUI_ROLE_TAB, and a row or link the view marked (see
KuiSpec.selected). - KUI_
AUDIO_ MASTER_ VOLUME - KUI_
AUDIO_ PAUSE - KUI_
AUDIO_ PLAY KUI_AUDIO_*: aKuiAudioCommand.kind.- KUI_
AUDIO_ RESUME - KUI_
AUDIO_ SET_ VOLUME - KUI_
AUDIO_ STOP - KUI_
AUDIO_ UNLOAD - KUI_
BUTTONS_ MIDDLE - KUI_
BUTTONS_ OTHER - KUI_
BUTTONS_ SECONDARY KUI_BUTTONS_*: the buttonsKuiSpec.on_buttonclaims (KuiSpec.buttons); none set is all three.- KUI_
CHROME_ BORDERLESS KUI_CHROME_BORDERLESS: no decorations and no chrome expectations.- KUI_
CHROME_ CUSTOM KUI_CHROME_CUSTOM: undecorated; the view draws akui_titlebarand the runner synthesizes edge resizing and double-click maximize.- KUI_
CHROME_ NATIVE KUI_CHROME_NATIVE: the OS’s decorations.- KUI_
CMD_ CLOSE - KUI_
CMD_ FOCUS - KUI_
CMD_ MINIMIZE - KUI_
CMD_ OPEN KUI_CMD_OPEN: the declared set gained a window;configsays what.- KUI_
CMD_ REDRAW KUI_CMD_REDRAW: drawwindowagain, because another window’s input changed what it shows. A host that redraws every window on every event may ignore it.- KUI_
CMD_ SET_ SIZE KUI_CMD_SET_SIZE: the app asked for a size (kui_set_window_size);width/heightcarry it.KUI_CMD_FOCUS: it asked for focus.- KUI_
CMD_ START_ DRAG KUI_CMD_START_DRAG,KUI_CMD_CLOSE,KUI_CMD_MINIMIZE,KUI_CMD_TOGGLE_MAXIMIZE: the verbs chrome nodes issue.- KUI_
CMD_ TOGGLE_ MAXIMIZE - KUI_
COPY_ ASKED - KUI_
COPY_ NOTHING - KUI_
COPY_ READY KUI_COPY_*: whatkui_request_copyreturns.- KUI_
DIAG_ DEFAULT KUI_DIAG_DEFAULT: the build’s — on in debug, off in release.- KUI_
DIAG_ OFF KUI_DIAG_OFF.- KUI_
DIAG_ ON KUI_DIAG_ON.- KUI_
DISMISS_ ESCAPE - KUI_
DISMISS_ OUTSIDE KUI_DISMISS_OUTSIDE,KUI_DISMISS_ESCAPE: why a window was asked to go away (kui_window_dismissed).- KUI_
EDIT_ AUTOFOCUS - KUI_
EDIT_ KEYS KUI_KEY_*: the editing keyskui_input_keytakes, in the header’s order — which is notEditKey’s declaration order, so the table is the pin rather than a cast.edit_key_ofreads it andmod abi_parityemits it.- KUI_
EDIT_ MULTILINE KUI_EDIT_*: the flagskui_text_edittakes.WRAPis thewraprow declared on a field (the mode isKuiTextStyle.wrap, whose zero isKUI_WRAP_WORD, so the style alone cannot say): the field folds to its width the way a document does and keeps a field’s keyboard.- KUI_
EDIT_ WRAP - KUI_
ENTER_ BG - KUI_
ENTER_ HEIGHT - KUI_
ENTER_ OFFSET - KUI_
ENTER_ OPACITY - KUI_
ENTER_ RADIUS - KUI_
ENTER_ WIDTH - KUI_
EXPANDED_ COLLAPSED - KUI_EXPANDED_* is the position in
schema::EXPANDEDplus one (0 = unset: the node does not expand). - KUI_
EXPANDED_ EXPANDED - KUI_
FILE_ DIALOG_ FOLDER KUI_FILE_DIALOG_FOLDER: a folder, or several.- KUI_
FILE_ DIALOG_ OPEN KUI_FILE_DIALOG_OPEN: an existing file, or several.- KUI_
FILE_ DIALOG_ SAVE KUI_FILE_DIALOG_SAVE: a path to write.- KUI_
FLOAT_ NONE - Which of a
KuiEnter’s fields are set (itssetbits); 0 = no entrance.KuiSpec.float_mode: in flow, or which rect the float attaches to. The non-zero values arekui_core::FLOAT_PRESETSindices plus one, so zero can still mean “no float”. - KUI_
FLOAT_ PARENT - KUI_
FLOAT_ VIEWPORT - KUI_
FRAGMENT_ IMAGE_ ATLAS KuiFragmentDraw::image_source: the image is in the atlas.- KUI_
FRAGMENT_ IMAGE_ NONE KuiFragmentDraw::image_source: no image.- KUI_
FRAGMENT_ IMAGE_ TEXTURE KuiFragmentDraw::image_source: the image has a texture of its own.- KUI_
FRAME_ CAUSE_ ACCESS - KUI_
FRAME_ CAUSE_ AFTER_ FRAME - KUI_
FRAME_ CAUSE_ APPEARANCE - KUI_
FRAME_ CAUSE_ AUDIO - KUI_
FRAME_ CAUSE_ BUTTON - KUI_
FRAME_ CAUSE_ CARET - KUI_
FRAME_ CAUSE_ DEVICE - KUI_
FRAME_ CAUSE_ ELSEWHERE - KUI_
FRAME_ CAUSE_ FILES - KUI_
FRAME_ CAUSE_ FILE_ DRAG - KUI_
FRAME_ CAUSE_ FIRST - KUI_
FRAME_ CAUSE_ FOCUS - KUI_
FRAME_ CAUSE_ HOST - KUI_
FRAME_ CAUSE_ KEY - KUI_
FRAME_ CAUSE_ MENU - KUI_
FRAME_ CAUSE_ MODIFIERS - KUI_
FRAME_ CAUSE_ OCCLUSION - KUI_
FRAME_ CAUSE_ OVERDUE - KUI_
FRAME_ CAUSE_ OWED - KUI_
FRAME_ CAUSE_ POINTER_ LEAVE - KUI_
FRAME_ CAUSE_ POINTER_ MOVE KUI_FRAME_CAUSE_*: the bits of whatkui_frame_causereturns andkui_note_frame_causetakes.- KUI_
FRAME_ CAUSE_ PREEDIT - KUI_
FRAME_ CAUSE_ RESIZE - KUI_
FRAME_ CAUSE_ RETRY - KUI_
FRAME_ CAUSE_ SCALE - KUI_
FRAME_ CAUSE_ SMOKE - KUI_
FRAME_ CAUSE_ TEXT - KUI_
FRAME_ CAUSE_ WAKE - KUI_
FRAME_ CAUSE_ WHEEL - KUI_
GRADIENT_ LINEAR KuiGradient.kind: along a line, or out from a centre.- KUI_
GRADIENT_ RADIAL - KUI_
KF_ AT - Which of a
KuiKeyframe’s fields are set (itssetbits). - KUI_
KF_ BG - KUI_
KF_ HEIGHT - KUI_
KF_ OPACITY - KUI_
KF_ RADIUS - KUI_
KF_ WIDTH - KUI_
KLAYOUT_ NONLATIN KUI_KLAYOUT_NONLATIN: the press was typed on a layout that writes no Latin, so the US key stands in for its ASCII too. Zero judges each key by itself.- KUI_
KLOCK_ CAPS KUI_KLOCK_*andKUI_KLOC_*: which lock keys were on and which of a key’s twins it was, in the same word as theKUI_KMOD_*bitskui_input_key_downand its siblings take. Zero is no lock on and the standard key.- KUI_
KLOCK_ NUM - KUI_
KLOC_ LEFT - KUI_
KLOC_ NUMPAD - KUI_
KLOC_ RIGHT - KUI_
KMOD_ ALT - KUI_
KMOD_ CTRL - KUI_
KMOD_ SHIFT KUI_KMOD_*: the modifier bitskui_input_key_downand its siblings take, andkui_input_modifiersreports — the core’s ownKeyMods::bits, which is also what the conformance corpus’smodifiersstep spells, so the header and the corpus cannot drift.- KUI_
KMOD_ SUPER - KUI_
LIVE_ ASSERTIVE - KUI_
LIVE_ OFF - KUI_LIVE_* is the position in
schema::LIVEitself, not the position plus one: unlike a disclosure, a live region’s zero is a value — “not a live region” is what an unset field already means, so there is no unset state to reserve zero for. - KUI_
LIVE_ POLITE - KUI_
MENU_ ACTION_ LOOK_ UP - KUI_
MENU_ ACTION_ PASTE - KUI_
MENU_ ACTION_ SET_ CLIPBOARD KUI_MENU_ACTION_*: aKuiMenuAction.kind.- KUI_
MENU_ ACTION_ SET_ CLIPBOARD_ SECRET - A secret for the clipboard, to write marked concealed and transient
(
kui_set_clipboard_secret). A host that does not know the kind drops the copy, which for a secret is the safe way to fail. - KUI_
MENU_ COPY - KUI_
MENU_ CUSTOM KUI_MENU_*: aKuiMenuItem.role, the position inMenuRole::ALL.- KUI_
MENU_ CUT - KUI_
MENU_ ITEM_ CHECKED - KUI_
MENU_ ITEM_ ENABLED KUI_MENU_ITEM_*: the flagskui_menu_bar_itemandkui_menu_itemreport on a row.- KUI_
MENU_ ITEM_ SUBMENU KUI_MENU_ITEM_SUBMENU: the row opens rows of its own (backlog F128).- KUI_
MENU_ LOOK_ UP - KUI_
MENU_ PASTE - KUI_
MENU_ SELECT_ ALL - KUI_
MENU_ SEPARATOR - KUI_
MIN_ FIT KuiSpec.min_w/min_has the node’s own fit size (KUI_MIN_FIT).- KUI_
MIN_ NONE KuiSpec.min_w/min_has a declared floor of 0: no floor at all, not even the content’s that a share in an overflowing row gets for an undeclared (0) one; CSS’smin-width: 0.- KUI_
MOD_ DOC - KUI_
MOD_ SHIFT KUI_MOD_*: the editing modifierskui_input_keytakes — extend the selection, move by word, move by document.- KUI_
MOD_ WORD - KUI_
MOUSE_ MIDDLE - KUI_
MOUSE_ OTHER - KUI_
MOUSE_ PRIMARY KUI_MOUSE_*:kui_input_mouse_button’s button, which isMouseButton::code— the core owns the numbering, this is its name.- KUI_
MOUSE_ SECONDARY - KUI_
OPTION_ AS_ ALT_ BOTH - KUI_
OPTION_ AS_ ALT_ LEFT - KUI_
OPTION_ AS_ ALT_ NONE KUI_OPTION_AS_ALT_NONE,_LEFT,_RIGHT,_BOTH: which Option keys act as Alt on macOS (kui_set_option_as_alt).- KUI_
OPTION_ AS_ ALT_ RIGHT - KUI_
OP_ ALPHA - KUI_
OP_ DARKEN - KUI_
OP_ LIFT - The verbs of
KuiColorOp.op, numbered askui_core::ColorOp::VERBSlists them. - KUI_
OP_ MIX - KUI_
OP_ RAISE - KUI_
OP_ READABLE - KUI_
ORIENTATION_ HORIZONTAL - KUI_ORIENTATION_* is the position in
Orientation::ALLplus one (0 = unset: the node is not a composite container). - KUI_
ORIENTATION_ VERTICAL - KUI_
OVERSCROLL_ AUTO - KUI_OVERSCROLL_* is the position in
schema::OVERSCROLLSplus one (0 = unset, which isauto). - KUI_
OVERSCROLL_ CONTAIN - KUI_
OWED_ AUTOSCROLL - KUI_
OWED_ CYCLE - KUI_
OWED_ DEPART - KUI_
OWED_ REQUESTED - KUI_
OWED_ SCROLL - KUI_
OWED_ TRANSITION KUI_OWED_*: the bits of whatkui_owedreturns,kui_animatingby kind.- KUI_
PASTE_ CONCEALED KUI_PASTE_*: the pasteboard’s markers on a paste’s answer (kui_input_paste).- KUI_
PASTE_ TRANSIENT - KUI_
SCROLLBAR_ AUTO - KUI_
SCROLLBAR_ HIDDEN - KUI_
SCROLLBAR_ VISIBLE - KUI_SCROLLBAR_* is the position in
schema::SCROLLBARSplus one (0 = unset, which is the stock visible bar). - KUI_
SCROLL_ AXES_ BOTH - KUI_SCROLL_AXES_* is the position in
schema::SCROLL_AXESplus one (0 = unset, which is both). - KUI_
SCROLL_ AXES_ X - KUI_
SCROLL_ AXES_ Y - KUI_
SPAN_ BOLD KUI_SPAN_*: the flags on aKuiSpan.- KUI_
SPAN_ FAMILY KUI_SPAN_FAMILY:KuiSpan.familynames the span’s face (ABI 26).- KUI_
SPAN_ ITALIC - KUI_
SPAN_ STRIKETHROUGH - KUI_
SPAN_ UNDERLINE - KUI_
TEXT_ AA_ AUTO KUI_TEXT_AA_AUTO: LCD subpixel coverage when the GPU can blend per channel, grayscale otherwise.- KUI_
TEXT_ AA_ GRAYSCALE KUI_TEXT_AA_GRAYSCALE.- KUI_
TEXT_ AA_ SUBPIXEL KUI_TEXT_AA_SUBPIXEL.- KUI_
UNDERLINE_ DOTTED - KUI_
UNDERLINE_ SOLID KUI_UNDERLINE_*: an underline’s shape,KuiTextStyle.underline_styleandKuiSpan.underline_style.- KUI_
UNDERLINE_ WAVY - KUI_
VALUE_ ANCHOR - KUI_
VALUE_ CARET - KUI_
VALUE_ CARET_ SOLID - KUI_
VALUE_ MAX - KUI_
VALUE_ MIN - KUI_
VALUE_ NOW - KUI_
VALUE_ STEP KuiSpec.value_stepholds.- KUI_
WINDOW_ KIND_ NORMAL KUI_WINDOW_KIND_NORMAL: a regular top-level window.- KUI_
WINDOW_ KIND_ POPUP KUI_WINDOW_KIND_POPUP: a borderless, taskbar-less menu surface owned by the window that declared it, placed againstanchor_*in screen coordinates and closed when its owner closes.- KUI_
WINDOW_ NONE KUI_WINDOW_NONE: aKuiSpec.window_rolethat is no chrome role.
Functions§
- kui_
abi_ version - The ABI version this library implements (
KUI_ABI_VERSION), for a host to compare for equality with theKUI_ABI_VERSIONof the header it compiled against, before its first other call. - kui_
access_ runs - The laid-out text of editor node
keyas runs (seeKuiAccessRun): fillsoutwith up tocapof them and returns the total. Runs are whatKuiAccessNode.anchor_run/focus_runandkui_input_access_textrefer to. Borrowed until the nextkui_access_tree/kui_access_runson the context; a node with no text (or no such node) has none. - kui_
access_ tree - The access tree of the last finished frame, which is what assistive
technology sees: fills
outwith up tocapnodes in tree order (the root first) and returns the total count, so a short buffer can be resized and the call repeated. Strings stay valid until the next call on this context. A host that never asks pays nothing. - kui_
activate_ menu_ bar_ item - Reports that the platform’s menu bar chose row
itemof menumenu: the same path a press on the drawn bar’s row takes. Out of range does nothing. Returns whether an item was performed. - kui_
activate_ menu_ bar_ path - Reports that the platform’s menu bar chose the row at
pathin menumenu, inside its submenus:Core::activate_menu_bar_path. Returns whether a row was performed; a row that opens a submenu, a dead one and one not there are not. - kui_
activate_ menu_ item - Reports that the host’s menu chose row
index: the same path a press on the drawn menu’s row takes. An index past the end closes the menu and posts nothing. Returns false when nothing was taken: no menu was open, or the row cannot be chosen — disabled, or a separator — in which case the menu stays open and nothing is posted. - kui_
activate_ menu_ path - Reports that the host’s own menu chose the row at
path, inside its submenus:Core::activate_menu_path. False when nothing was taken — no menu open, an empty path, a row not there, or one that cannot be chosen (dead, a separator, or one that opens a submenu, which the host opens), the menu then left open and nothing posted. - kui_
always_ on_ top_ get - Whether the frame that just finished asked for the window on top — for hosts driving their own window: diff against the level applied and set it on change only. False for a frame that never asked, and on a bad context.
- kui_
animating - True when the last frame left a transition mid-flight: draw another frame without waiting for input.
- kui_
announce - Says something once, with no node behind it: “Saved”, “3 results”.
liveis KUI_LIVE_POLITE or KUI_LIVE_ASSERTIVE; KUI_LIVE_OFF and an empty string are both no-ops, the first so a caller can gate politeness without a branch. A region whose message is on screen isKuiSpec.liveinstead. - kui_
answer_ selection_ range - Answers a
selectionrangeask with the text for the range it named, whole. False when nothing asked — a late answer cannot overwrite what has been copied since. - kui_
audio - An audio node: a playback retained by key while the frame declares it
(present = playing, gone = stopped; volume/paused apply live, a changed
src restarts).
finishchanges what gone means — the playback is released to play itself out rather than stopped, except for a loop. Empty label = a key from the tree position.tag(nullable, consumed) rides theendedevent, and survives a release. Returns the node key. - kui_
audio_ ended - A host driving its own device reports a playback finished on its own;
a tagged one becomes a
soundevent for kui_poll_event. - kui_
audio_ refused - The same host reports that its device refused a play it drained: a
tagged playback becomes a
soundevent with phaserefusedfor kui_poll_event, and the node that asked is named in aplayback-refusedwarning either way. - kui_
audio_ truncated - The same host reports that a stop it drained landed on a playback
still running,
atseconds in: a one-shotaudionode that went away withoutfinishis named in atruncated-playbackwarning (kui_take_warnings); any other stop reports nothing. - kui_
awaiting_ files - Whether a file dialog asked for is still unanswered.
- kui_
awaiting_ paste - Whether a paste asked for is still unanswered:
kui_request_pastequeues one ask at a time, and thekui_input_committhat answers it (an empty one for an empty clipboard) is what lets the next through. - kui_
button - The stock button, labelled and keyed by
label: a press by the pointer, Space, Enter or assistive technology emitspayloadas aclickevent’s payload. Consumespayload(NULL for none). - kui_
button_ with kui_buttonwith the rows the stock button admits read offspec—label,description,tooltip,disabled— and every other field ignored: the look iswidgets::button_spec’s, and a zeroedKuiSpecis the schema default rather than “unset”, so there is nothing to merge. A NULLspeciskui_button. Consumes payload.- kui_
caret_ rect - The caret rect for byte offset
bytein the text the nodekeydrew: logical viewport px, zero wide, one line tall. A byte past the text is the end. False for a key that drew no text, a bad context or a NULLout. - kui_
caret_ stamp - Changes whenever the caret moved or focus changed — compare across frames to re-arm the blink with the caret solid.
- kui_
caret_ visible - The caret’s blink phase:
truedraws it. A custom editor reads it in its view and skips its caret node on the off phase, keeping thecaretrow on itsKUI_ROLE_LINEeither way. Underkui_runthe runner’s clock sets it; a host driving its own window sets it withkui_set_caret_visibleon a clock of its own, armed whilekui_has_caretand re-armed solid whenkui_caret_stampchanges. - kui_
cell_ selection - A
cellsgrid’s selection, the window’s when it lives in one: the grid’s key, the anchor and the focus as the drag made them — each an absolute line (originLineplus the row, so a scroll does not move it) and a column — and whether it is a block rather than linewise. False when the window’s selection is not a grid’s; a text selection’s ends arekui_selection_ends. Any out pointer may be NULL. - kui_
cells - A terminal’s screen as one node:
rowsbycolscells fromcells(fewer draw as blank), shaped once per character and placed on a fixed grid.stylesizes the cells (size,family/font,line_height);specis the node’s own (anon_keymakes it the key sink, anon_click/on_dragcarrycell: {row, col}), the three payloads consumed askui_open_withconsumes them;labelkeys the node (empty for auto).cursor_shapeisKUI_CELL_CURSOR_*or 0 for none, drawn at (cursor_row,cursor_col) incursor_color.origin_lineis the absolute line row 0 is, so a selection keeps its ends across a scroll; 0 says nothing. - kui_
checkbox - The stock checkbox: a box drawn from
spec’schecked/mixed, labelledtextand keyed by it; a press postspayload(consumed). Readschecked,mixed,label,description,tooltipanddisabledoffspec(NULL = none of them). Its key. - kui_
child_ key - The key a child labeled
labelof the currently open container would get. - kui_
clear_ selection - Drops the window’s selection, whichever kind it is; true when there was one.
- kui_
close - Closes the node the last
kui_open*opened. Every open must be closed beforekui_frame_finish. - kui_
close_ menu - Closes whatever menu is open; true when there was one.
- kui_
ctx_ add_ extension - Loads the shared library at
pathas an extension of this context, undernamespace— the word that makes the front of every slot name it fills (namespace/panel). An emptynamespacetakes the extension’s ownkui_ext_name, which is what a Rust host’sExtensions::pushdoes. - kui_
ctx_ backdrop - The window’s backdrop as views read it, a
KUI_BACKDROP_*:env.window.backdrop, whatkui_env_set_backdropset — and in akui_run_withview callback what the runner got forKuiRunConfig.backdrop, the answer and not the ask. Opaque on a bad context. - kui_
ctx_ extension_ count - How many extensions this context has loaded. Their origins are 1..=n, in the order they were added; 0 is the host’s own.
- kui_
ctx_ extension_ error - Why the last
kui_ctx_add_extensionon this context said false. False (andoutuntouched) when the last one succeeded, or when none has run. Borrowed until the next call on this context, like every other string this API hands back. - kui_
ctx_ extension_ namespace - The namespace the extension at
originwas loaded under — what turns an event’soriginback into a name the host chose. False (andoutuntouched) for 0 (the host) or an origin nothing was loaded at. Borrowed until the next call. - kui_
ctx_ free - Frees a context from
kui_ctx_new, its queued events, every string it lent out and every extension it loaded. NULL is a no-op. - kui_
ctx_ new - Creates a standalone context: a core of its own plus an event queue.
- kui_
ctx_ window - Which window this context draws:
env.window.id, askui_env_set_windowset it —KUI_WINDOW_MAINfor the launcher’s, and in akui_runview callback the id of the window being drawn. - kui_
ctx_ window_ name - The name of the window this context draws: “main” for the launcher’s, else the name the declaration that opened it used. Borrowed until the next call on the same context. False only on a bad context.
- kui_
cursor_ shape - The pointer shape for where the pointer is now (KUI_CURSOR_*, never 0):
the
cursorthe topmost node under it declared, the I-beam over text, the arrow otherwise. A query, not a queue — read it after each input and each frame and apply it to the real window when it changes. Hosts without a pointer simply never call. - kui_
devtools - Whether the devtools panel is on.
- kui_
devtools_ current_ tab - The devtools tab currently selected, by name, panel on or off; borrowed until the next call. False on a bad context.
- kui_
devtools_ dock - Where the devtools panel sits, as a word
kui_set_devtools_docktakes ("right"for the side); the string is static. False on a bad context. - kui_
devtools_ hovered - The tree row under the pointer, as a key, or 0.
- kui_
devtools_ key - The chord
kui_set_devtools_keyset, or the default, in its portable spelling ("ctrl+shift+i","f12","super+alt+d"); borrowed until the next call. False on a bad context. - kui_
devtools_ picked - The node the picker is over while picking, as a key, or 0.
- kui_
devtools_ picking - Whether the panel’s picker is up.
- kui_
devtools_ selected - The node the devtools tree tab has selected, as a key, or 0 for none: what an inspector in a declared tab reads.
- kui_
devtools_ tab - Declares a devtools tab an extension fills:
nameis the tab’s identity,labelwhat the strip shows,slotthe fullnamespace/slotthe extension names. While the tab is on show the panel declares that slot in the tab’s body; otherwise the extension is not asked, and nounknown-slotis raised. Call it every frame, panel on or off. False for a name already declared this frame (duplicate-tab) or outside a frame. - kui_
devtools_ tab_ open - Declares a devtools tab the host draws itself, and opens its content
node only while the tab is on show: true means the node is open, so
build inside it and
kui_close; false means the tab was declared and nothing opened, so skip the body and do not close. What the host builds keeps its own keys and events, painted as a layer over the panel’s tab body and clipped to it:if (kui_devtools_tab_open(ctx, KUI_STR("syntax"), KUI_STR("Tree-sitter"))) { ...; kui_close(ctx); }. - kui_
draw_ data - The finished frame’s draw list, into
out(start fromKUI_DRAW_DATA_INIT). The pointers are valid until the nextkui_frame_beginon this context; the quads are the core’s own array, not a copy. - kui_
drop_ target - The drop zone the dragged files are over, or 0: what a driver answers
the OS with after every
kui_input_drag_files(a copy cursor over a zone, not-allowed elsewhere, and a release off every zone refused). - kui_
edit_ set_ text - Replaces the text of the editor
key, as if the user had typed it; the caret moves to the end.kui_edit_set_text_labeldoes the same for an editor the host only knows by label. - kui_
edit_ set_ text_ label kui_edit_set_textby the label the view declares the editor with, for a host that has no key yet (an editor opened for the first time has fired no event). A label some frame declared is applied at once; one nothing has declared is held for the next frame, seeding a new editor over itsinitial. Held for that one frame only: if no editor is declared under it, the text is dropped with anedit-text-without-editorwarning.- kui_
edit_ text - The current text of the editor
key(kui_text_editorkui_text_input), borrowed until the nextkui_edit_texton this context orkui_ctx_free. False whenkeyis no editor. - kui_
env_ set - Window facts for views to read: the display’s refresh rate
(
refresh_hz <= 0is unknown) and whether the window has keyboard focus. - kui_
env_ set_ always_ on_ top - The window fact for views to read as
env.window.always_on_top: what the host actually did about the ask, so a pin button draws the platform’s answer and not the app’s guess. Its own setter rather than an argument onkui_env_set_windowbecause a setter is additive where an argument is an ABI break (thekui_env_set_assistivereasoning): a host that never applies a level has nothing to recompile, and reports false by never calling. - kui_
env_ set_ assistive - Whether assistive technology is listening, for views to read: a
KUI_ASSISTIVE_*(0 is unknown, which is what a host with no accessibility bridge reports by never calling this). - kui_
env_ set_ audio - What the host’s audio output is doing, for views to read:
deviceaKUI_AUDIO_DEVICE_*(0 is closed, which a host with no device reports by never calling this) andlivethe number of playbacks started or waiting on the open. A fact, not a command: nothing here closes the device. An out-of-range code is ignored. - kui_
env_ set_ backdrop - The window fact for views to read as
env.window.backdrop: aKUI_BACKDROP_*, what is actually behind the window’s transparent pixels —BLURorTINTEDfor the effect the host got,TRANSPARENTfor a see-through surface with none,OPAQUE(0, and what a host that never calls this reports) for neither (backlog F126). A host that makes its window translucent also clears its frames to nothing rather than to the theme’sbg. Its own setter, askui_env_set_always_on_topis. An out-of-range code is ignored. - kui_
env_ set_ system - The OS’s settings, for views and the theme to read:
appearanceis aKUI_APPEARANCE_*,motionaKUI_MOTION_*(0 is unknown for both),accentthe accent colour as0xRRGGBBAA(0 is unknown) andlocalea BCP-47 tag (empty is unknown; one over 31 bytes or not ASCII reads back as unknown). - kui_
env_ set_ window - Window facts for views to read (widgets::titlebar adapts to them).
windowis which window this context draws —KUI_WINDOW_MAIN, or the id anOpencommand carried — and is what every event it hands out will say inKuiEvent.window.controls_w/h > 0describe the keep-out rect of controls the OS draws over the content (macOS traffic lights), anchored top-left. - kui_
file_ request_ filter - Filter
iof the dialogkui_take_file_requestlast handed out: its name, and its extensions joined with;("png;jpg", no dots). Borrowed until the next call; false for a filter that is not there. - kui_
focus - Moves keyboard focus to
keynow (0 blurs). For focus that follows a declaration rather than a moment,kui_set_key_focus. - kui_
focus_ next - What Tab (
forward) / Shift-Tab does: focus the next / previous focusable node in tree order, wrapping. A key sink that binds Tab itself calls this to hand the keyboard on. - kui_
focus_ region - Enters the focus region
keynames (a node declared withfocus_region; 0 is the main ring) at the end of the frame being built: focus lands on what that ring last held, else itsinitial_focus, else its first stop. - kui_
focus_ visible - Whether focus got where it is by keyboard or assistive technology
rather than a click — when it shows (the core’s ring, or
focus_bg). - kui_
focus_ window - Asks the driver to give
windowkeyboard focus; queued and drained the same way, asKUI_CMD_FOCUS. Advisory, like every focus request an app makes of a window manager: whether it was granted shows up throughkui_env_set’sfocusedon the frames that follow, not as a reply here. - kui_
focused - The node holding keyboard focus; 0 for none.
- kui_
font_ add - Registers a font from file bytes (TTF/OTF/TTC, copied); returns its
handle for
KuiTextStyle.font, 0 when the data holds no usable face. - kui_
font_ add_ system - Registers an installed font by family name; 0 when none matches.
- kui_
font_ families - The family names
kui_font_add_systemcan take — every face the context knows, installed or loaded, sorted and deduplicated — written intooutup tocapand the total returned, so a short array can be resized and the call repeated. Strings are borrowed until the next call on this context. What Node’ssystemFontFamilies()answers. - kui_
font_ load_ dir - Loads every font file under a folder (recursively) so its families can
be picked by name with
kui_font_add_system; returns the face count. - kui_
font_ load_ file - Registers a font file by path (memory-mapped); 0 when it cannot be read or holds no usable face.
- kui_
font_ reload_ system - Scans the system’s fonts again, so a font installed while the app runs
is found (
Core::reload_system_fonts); returns how many faces came and went, 0 when nothing did. - kui_
font_ remove - Forgets a registered font; text still naming it falls back to the family.
- kui_
font_ ⚠set_ fallback - The families asked, in order, for a character the text’s own family
has no glyph for, before the platform’s fallback list
(
Core::set_fallback_fonts):lenfont handles atids, none (NULL or 0) for the platform’s list alone. A handle that names no font is left out. KUI_FONT_MONO text asks them straight after its own face, ahead of the machine’s other monospaced faces. A new list shapes every text again; the same list twice is nothing. - kui_
fragment - A box painted by the WGSL fragment function registered as
id(kui_fragment_add). It has no intrinsic size, sospecmust give it one.paramsarecountfloats the function reads, NULL whencountis 0; more than sixteen are dropped with a warning. - kui_
fragment_ add - Registers a WGSL fragment function; 0 when it does not compile, with a
fragment-rejectedwarning carrying the message. Idempotent by source. - kui_
fragment_ open kui_fragmentas a parent: its children paint over it. Balance withkui_close. An emptylabelis the unkeyed form.- kui_
fragment_ open_ with kui_fragment_withas a parent: its children paint over it. Balance withkui_close.- kui_
fragment_ remove - Forgets a registered fragment; nodes still naming it draw nothing.
- kui_
fragment_ source - The whole WGSL module behind a handle — the app’s source between the core’s prelude and epilogue — for a host that compiles it itself. The string is borrowed and valid until the next call; false when the handle is not live in this session.
- kui_
fragment_ with kui_fragmentreadingimagethrough the shader’skui_sample: an image handle fromkui_image_add, or 0 for none, which iskui_fragment.labelkeys the node (empty for a key from the tree position); a leaf.- kui_
frame_ begin - Starts a frame:
wbyhlogical pixels at device scalescale(a value of 0 or less reads as 1). - kui_
frame_ cause - The
KUI_FRAME_CAUSE_*bits of the frame being built, or between frames the last one’s. - kui_
frame_ finish - Finishes the frame: lets loaded extensions fill what the view did not,
lays the tree out and paints it. After it,
kui_draw_datahas the frame andkui_poll_eventhas anything the frame itself produced (aresize, a hover change under a still pointer, alayout). - kui_
frame_ unchanged - 1 when the last finished frame drew exactly what the one before drew,
0 when not, -1 when untraced (
kui_set_frame_trace) or on the first traced frame. - kui_
has_ caret - Whether there is a caret to blink: a focused editor’s, or the
careta line under the focused sink declares. What a host’s blink clock is armed on. - kui_
host_ rect - Where the last frame laid the host out in its window, in logical px:
the whole window with the devtools panel off or in its own window, the
pane beside the dock otherwise, and zeros before the first frame.
Scaled by the frame’s scale it separates the host’s quads from the
dock’s in
kui_draw_data, except the root’s background, which also fills the window beneath the pane. False on a bad context, a NULLoutor a shortsize. - kui_
image - An image node. Fit sizing takes the image’s pixel size as logical px; Fit height against a resolved width keeps the aspect. radius rounds it.
- kui_
image_ add - Registers a w×h RGBA image (pixels copied); returns its handle, 0 on
failure. Draw it with
kui_image; free it withkui_image_remove. - kui_
image_ pixels - The pixels behind an image handle, for a host that renders the draw
list itself and meets a
KUI_QUAD_TEXTUREquad:w,handrgba(w×h×4 bytes) are written and true returned when the handle is live here. The bytes are borrowed and valid until the next call of this function orkui_image_updateon the same handle. - kui_
image_ remove - Forgets a registered image; nodes still naming it draw nothing.
- kui_
image_ update - Replaces an image’s pixels in place (copied): the handle is unchanged,
so every node showing it draws the new pixels next frame;
w/hmay differ from the registration. From the first update on the image is drawn from a texture of its own, as aKUI_QUAD_TEXTUREquad. A dead or foreign handle warnsforeign-resourceand changes nothing. - kui_
image_ with kui_imagewith its two options:samplingisKUI_SAMPLING_LINEAR(0, the default) orKUI_SAMPLING_NEAREST;fitisKUI_FIT_FILL(0, the default),KUI_FIT_CONTAINorKUI_FIT_COVER. An index past the table reads as the default.- kui_
ime_ off_ get - Whether the frame that just finished asked for the input method off — for hosts driving their own window. False for a frame that never asked, and on a bad context.
- kui_
ime_ rect - Where the OS candidate window goes while a composition is under way:
the focused editor’s caret, or a custom editor’s
linecarryingcaret. False when nothing with a caret is focused. A host driving its own window reads it after each frame and hands it to the platform. - kui_
input_ access - A request from assistive technology on node
key: one KUI_ACCESS_* action bit (the node must advertise it inKuiAccessNode.actions), withvaluethe new text for KUI_ACCESS_SET_VALUE (empty otherwise). Resolved the way the pointer or keyboard equivalent would be: a click emits the node’s payload, focus lands on an editor, a slider nudge arrives as a{kind="access", action, tag}event. - kui_
input_ access_ text - A text request from assistive technology on editor node
key: KUI_ACCESS_SET_TEXT_SELECTION with the selection as run positions (anchor_*the end that stays,focus_*the caret), or KUI_ACCESS_REPLACE_SELECTED_TEXT / KUI_ACCESS_SET_VALUE withvalue. A built-in editor applies it (achangedevent follows an edit); a custom editor gets it as a{kind="access", action, anchor, focus, text, tag}event to apply itself. - kui_
input_ commit - Text an IME committed at the end of a composition: a focused editor
takes it as
kui_input_textwould; otherwise the focusedon_keysink hears{kind:"text", text, tag}, the one committed text akeyevent never carries. Typing stays onkui_input_text. - kui_
input_ cursor - The pointer moved to (
x,y) in logical pixels. Hover, drags and the cursor shape follow from it. - kui_
input_ cursor_ left - The pointer left the window: nothing is hovered until it comes back.
- kui_
input_ drag_ cancel - The dragged files left the window, or the OS ended the drag
elsewhere: the lit zone hears its
leave. - kui_
input_ drag_ files - Files dragged in from the OS are over the window at (
x,y), entering and moving alike: the drop zone under the point hears{kind:"drop", phase:"enter"|"move"}, a zone it left hearsleave.pathsarecountOS paths. The host’s answer to the OS (copy over a zone, not-allowed elsewhere) iskui_drop_target. - kui_
input_ drop_ files - The dragged files were released at (
x,y): the zone there hears{kind:"drop", phase:"drop", paths, x, y, tag}and noleaveafter; with no zone there, nothing but the lit zone’sleave. - kui_
input_ files - A file dialog’s answer: the
countpaths picked, none for a cancelled dialog. Whoever asked hears{kind:"files", paths, tag}; with nothing asked it is dropped. - kui_
input_ key - Editing key with modifier bits (1 = shift, 2 = word/alt, 4 = doc/primary).
- kui_
input_ key_ down - A raw key press for
on_keysinks; most hosts wantkui_input_press, which sends this and then what the key means. - kui_
input_ key_ up - The release of a key pressed with
kui_input_key_down, spelled the same way (physicalincluded, NULL for “same ascode”); the sink polls{kind="key", phase="up", ...}with a nulltext. A release whose press the sink never got resolves nothing, and moving focus while a key is held delivers the “up” first, so a held-key binding (WASD, press-and-hold) cannot be left stuck down. - kui_
input_ modifiers - Physical modifier state changed (KUI_KMOD_* bits). The host polls a
{kind="modifiers", shift, ctrl, alt, super}event when it differs from the last report. - kui_
input_ mouse - A primary-button press (
downtrue) or release at the last cursor position;clicksis the click count (1, or 2 for a double-click).kui_input_mouse_buttoncarries the other buttons. - kui_
input_ mouse_ button kui_input_mousefor a named button (KUI_MOUSE_*, or3 + nfor a further buttonn).- kui_
input_ open - The OS asked the app to open these
countdocuments (backlog F124): the host hears{kind:"open", paths}on the root, asked for or not; none emits nothing. A host driving its own window on macOS sends it from its app delegate’sapplication:openURLs:; underkui_runthe runner does. - kui_
input_ paste - The clipboard’s answer to a paste (
KUI_MENU_ACTION_PASTE), with the pasteboard’s markers asKUI_PASTE_*bits: routed askui_input_commitis, and a focusedon_keysink hears{kind:"text", text, tag}withconcealed: true/transient: truefor the bits that are set. A host that cannot read the markers answers with 0, or withkui_input_commit, which is the same answer. - kui_
input_ preedit - In-progress IME composition, shown at the focused editor’s caret, or
with no editor focused delivered to the focused
onKeysink as{kind:"preedit", text, cursor, tag}. Empty text clears it; the commit arrives viakui_input_commit.cursor_start/cursor_endare byte offsets intotext, orUINT32_MAXfor none. - kui_
input_ press - A whole key going down, the way a window sends it: the call a host
driving kui from its own event loop wants. Spelled exactly as
kui_input_key_down; it sends that raw press first, then what the key means (whatkui_input_keycarries on its own): Escape dismisses a modal, Tab walks the focus ring, an arrow nudges a focused slider, Space presses a focused control, a printable character reaches the focused editor. - kui_
input_ release - The same key coming up, spelled the way
kui_input_pressspells it (physicalincluded, {NULL, 0} for “same ascode”). One channel, because only one has a second half: the editing keys act on the way down, so this iskui_input_key_upunder the name that pairs withkui_input_press. - kui_
input_ scroll - A wheel or trackpad delta in logical px (positive
dyscrolls up), as a scroll gesture of its own: it goes to the innermost scroller under the pointer that can move that way. - kui_
input_ scroll_ gesture - A wheel or trackpad delta that is part of a scroll gesture:
beginson its first event, after which the rest go to the targets that one picked wherever the pointer or the content has gone. For a host whose event loop can tell one swipe from the next (kui_runbegins a new gesture after a 200 ms pause). - kui_
input_ text - Committed text input (typing, paste); routed to the focused editor.
- kui_
is_ drop_ target - Whether files dragged in from the OS are over
key, for drop-dependent layout; the colour alone isKuiSpec.drop_bg. - kui_
is_ focused - Whether the node
keyholds keyboard focus. - kui_
is_ hovered - Whether the pointer is over the node
key, as of the last input. Only a node that is hover-tracked (a click or hover tag,hoverable,hover_bg, a tooltip or a cursor) is ever hovered. - kui_
is_ pressed - Whether a primary press that started on the node
keyis still held. - kui_
key_ of - The key of the node opened under
label(kui_openwith a label, the widgets’labelargument) in the last finished frame — or, from inside a view callback, in the frame so far and then the last one. 0 when no node declared it. The door for a host that never saw an event from the node: keys hash the path from the root, through the auto-keyed ancestors a host cannot spell, sokui_focus(ctx, kui_key_of(ctx, KUI_STR("note")))is how “focus the editor I just declared” is said. Two nodes on one label under different parents resolve to the first in tree order and raiseambiguous-key(kui_take_warnings). - kui_
latency_ graph - Per-phase frame-latency bars vs the display budget. Reads the runner’s frame stats — renders empty chrome in a standalone (headless) context.
- kui_
latency_ hud - The graph in a translucent panel floating in a viewport corner picked by KUI_START/CENTER/END attach values.
- kui_
layout_ of - The rect the last frame laid
keyout at, for a node that declaredon_layout: thelayoutevent’s numbers, read back during the next build with no event. False for any other key, a bad context, a NULLoutor a shortsize. - kui_
line - A round-capped stroke from (x0, y0) to (x1, y1) in the parent’s box
space, as a float sized to its bounding box.
specmay be NULL.width <= 0is 1;color0 is the theme’s foreground, like a text style’s. - kui_
measure_ rich_ text kui_measure_textfor a rich-text paragraph.- kui_
measure_ text - Measures
textinstylethe way layout would, without adding a node: unwrapped withmax_w <= 0, else wrapped tomax_wlogical px. Logical px at the scale of the current or last frame (1 before any frame).wrap/max_lines/ellipsisin the style apply. Returns false only for a bad context or NULLout. - kui_
menu_ bar - The application menu for this frame:
countmenus read frommenus, in bar order, declared and, where the platform has no menu bar of its own, drawn into the frame right here as a row of titles that drop their menus. - kui_
menu_ bar_ item - Reads one row of one menu: its text into
label, its accelerator intoaccel(empty when it has none), and its role and flags through the out pointers. Both strings are borrowed until the next call on this context. False for a row that is not there. - kui_
menu_ bar_ item_ path - Reads the bar’s row at
pathin menumenu, spelled askui_menu_bar_itemspells one. False for a row that is not there, and for an empty path. - kui_
menu_ bar_ menu - Reads one menu of the declaration back: its title into
labeland how many rows it has. Both borrowed until the next call on this context. Returns false for a menu past the end. - kui_
menu_ bar_ menu_ count - How many menus the declaration in force has, and a revision that
changes only when the declaration does — a host with a native bar
keeps the last number it built and rebuilds nothing until it moves.
Writes the revision into
revisionwhen it is not NULL. - kui_
menu_ bar_ submenu_ count - How many rows the bar’s row at
pathin menumenuopens: 0 for a row with no submenu or one not there, and at a depth of 0 the menu’s own rows, askui_menu_bar_menucounts them. - kui_
menu_ item - Reads row
itemof the open menu, spelled exactly askui_menu_bar_itemspells a bar’s row. False for a row that is not there, including when no menu is open. Answer withkui_activate_menu_itemorkui_close_menu. - kui_
menu_ item_ count - The menu this window has open, for a host that said it shows menus
itself (
kui_set_native_menus): how many rows it has, writing the node it is about intotargetand where it opened (logical viewport px) intox/y— any of the three may be NULL. Zero when none is open, which is unambiguous because a menu never opens with no rows. What Node’smenu()andCore::menuanswer, so a C host is not the one binding told to read what is open and given nothing to read it with. - kui_
menu_ item_ path - Reads the open menu’s row at
path, spelled askui_menu_itemspells one;KUI_MENU_ITEM_SUBMENUin its flags when it opens rows of its own. False for a row that is not there, and for an empty path. - kui_
menu_ submenu_ count - How many rows the open menu’s row at
pathopens (depthindices, outermost first): 0 for a row with no submenu or one not there, and at a depth of 0 the menu’s own rows, askui_menu_item_countcounts them. - kui_
metrics - The sizes the stock widgets are built from, in logical px.
KuiMetrics m = KUI_METRICS_INIT; kui_metrics(ctx, &m);thenspec.radius = m.radiusmakes a control of your own agree with the stock ones. False for a bad context, a NULLout, or asizebelow the first ABI’s layout. - kui_
metrics_ set - Makes these the metrics every stock widget from the next node on is
built from; NULL restores the stock set. Start from
kui_metricsand change the fields you mean to change: a zeroed metric is zero, not “leave it”. Nothing in the OS is followed; density is the host’s call. - kui_
nodes - The last finished frame’s nodes in tree order, as a list of maps, each
with
key,parent,depth,kind,label,rect,role,text,flags,layer,origin,children, the layout spec andevents(the node’s payloads by handler name). Read it withkui_value_atandkui_value_get. Empty untilkui_set_inspect(ctx, true)and a frame after it. Borrowed until the next call; NULL on a bad context. - kui_
note_ frame_ cause - Adds
KUI_FRAME_CAUSE_*bits to the next frame’s reasons: the host’s own (a wake, a resize, a blink) beside the input thekui_input_*calls record. - kui_
on_ teardown - Sets what the next
kui_run/kui_run_withcalls as its window goes for good (the close button, Quit from the menu or the dock, aKUI_CMD_CLOSEon it): once, with theuserthe run’sviewandon_eventget, beforekui_runreturns or the process exits. - kui_
open - Opens a box node built from
spec; everything until the matchingkui_closeis its child. Returns the node’s key, or 0 for a bad context or a NULLspec. - kui_
open_ draggable kui_open_keyedfor a draggable node: a press-drag emits{kind="drag", phase, x, y, dx, dy, tag}events withon_dragas the tag.on_dragandon_click(either NULL) are consumed. A drag past the click slop suppresses the click.- kui_
open_ indexed kui_openunder a data index rather than a name: the key auto-keying would have given theith child, given to this node wherever it sits. A virtualising list opens each row with its own row number, so a row keeps its hover, focus, edit buffer and tweens as the built range slides over it — and agrees with a list that builds every row.- kui_
open_ keyed kui_openwith a stable identity: the key is derived fromlabelunder the parent, so hover, focus, scroll offsets, edit buffers and transitions follow the node while its siblings change.on_click(NULL for none) is consumed. Returns the key, or 0 on failure.- kui_
open_ menu - Opens a context menu at
(x, y)(logical viewport px) overkey, withcountitems read fromitems. The next frame draws it. - kui_
open_ with - The general keyed container: every event tag at once, each consumed,
NULL meaning absent (so a NULL
on_draghere does not make the node draggable, unlikekui_open_draggable). A non-NULLon_keymakes the node a key sink: give it focus withkui_set_key_focusand presses arrive as{kind="key", phase="down", code, ctrl, alt, shift, super, text, repeat, tag}, releases too (phase="up") when the spec setskey_up.on_hovertags pointer enter and leave. Returns the key, or 0 on failure. - kui_
option_ as_ alt_ get - Which Option keys the frame that just finished asked to act as Alt —
for hosts driving their own window.
KUI_OPTION_AS_ALT_NONEfor a frame that never asked, and on a bad context. - kui_
owed - Why the last frame wants another, as
KUI_OWED_*bits:kui_animatingtaken apart by kind. A host draws another frame for any of them; a test masksKUI_OWED_CYCLEoff to wait for transitions to settle under a keyframe cycle that never will. - kui_
path - A path — any outline — as
countfloats atopsin the flat op form (kui_path_parsemakes it from SVG path data): filled withspec’sbgbyfill_rule(KUI_FILL_NONZEROorKUI_FILL_EVENODD) and, whenwidthis positive, strokedwidthwide incolor(0 for the theme’s foreground) over the fill; turned byrotateturns aboutpivot(two floats in the path’s coordinates, NULL for the centre of its box) by the quad that draws it, so a path that only turns is rasterized once — 0 and NULL for no turn.dashcuts the stroke askui_polyline’s does, NULL for none. Placed like a stroke: a float sized to its own bounding box, in the parent’s box space.labelkeys the node (empty for a key from the tree position). The three payloads are consumed askui_open_withconsumes them; a path with one is hit by its outline under the fill rule. A NULLspecis a path with no fill, its payloads kept; ops that are not the flat form raisepath-malformedunder the node’s key and draw nothing. - kui_
path_ d kui_pathfrom SVG path data instead of the flat form:dgoes through the one parser every binding uses, and data that does not parse raisespath-malformedunder the node’s key and draws nothing — the same as<path d>in JSX andpath { d = }in Lua.- kui_
path_ parse - Parses SVG path data (
M L H V C S Q T A Z, absolute or relative) into the flat op formkui_pathtakes — aKUI_PATH_*code then its operands, every coordinate absolute — through the one parser every binding uses. Returns how many floats the form needs; they are written tooutwhencapholds them all, and not at all otherwise, so a host may call once withcap0 to size a buffer. Returns 0 for data that does not parse. - kui_
pause - Pauses a playback, fading out over
fade_ms. - kui_
play - Starts a playback; returns its id for kui_stop / kui_set_volume /
kui_pause / kui_resume.
optsmay be NULL (defaults). A non-NULLtag(consumed) asks for a{kind="sound", phase="ended", playback, tag}event when the playback finishes on its own. - kui_
poll_ event - Pops the next pending event into
out(start fromKUI_EVENT_INIT); false when the queue is empty. Call it after each input and each frame until it returns false. - kui_
polygon - A filled polygon through
countpoints atxy(x0, y0, x1, y1, …), at most eight (more are dropped with apolygon-points-truncatedwarning, fewer than three draw nothing), filled withspec’sbg. Placed like a stroke: a float sized to its own bounding box, in the parent’s box space.labelkeys the node (empty for a key from the tree position). The three payloads are consumed askui_open_withconsumes them; a fill with one is hit by its outline. A NULLspecis a polygon with no fill, so nothing is drawn. - kui_
polyline - A stroke through
countpoints atxy(x0, y0, x1, y1, …): a polyline, or withcurvea smooth curve through them.labelkeys the node (empty for a key from the tree position), for a stroke that transitions or exits. The three payloads are consumed askui_open_withconsumes them; a stroke with one is hit by its shape, not its bounding box.dashcuts the stroke into marks and gaps (backlog V2): five floats — a mark, a gap, a second mark, a second gap (the lengths seen, in logical px; repeat the pair for a plain dash) and the offset into the pattern the stroke starts at — or NULL for a solid stroke. - kui_
radio - The stock radio; see
kui_checkbox. Declare radios betweenkui_radio_group_openandkui_close. - kui_
radio_ group_ open - Opens a radio group named
label:spec’s box rows (NULL for a column), the group’s role and name, and the stock gap wherespechas none. Declare its radios, thenkui_close. Returns its key. - kui_
region - The focus region in effect; 0 for the main ring.
- kui_
release_ held_ keys - Lets go of every key the focused sink is holding, as if the user had released them. Hosts call it when the window loses the keyboard: the OS stops delivering key events to it, so the release of anything held over an app switch would never arrive. Focus moves do this by themselves.
- kui_
reply - Replies to the host from inside
kui_ext_on_event:evis the event the callback was handed,replyis copied (you keep ownership) and reaches the host’son_eventwith your origin and the event’s window and key. Call it as often as the event deserves. Outside the callback, or on an event that carries no sink (anything a host polled for itself), it does nothing and returns false. - kui_
request_ copy - Asks for the selection as text.
- kui_
request_ files - Asks for the platform’s Open, Save or folder dialog. The answer is a
{kind:"files", paths, tag}event —pathsempty when the user cancelled — to whoever asked.dialogNULL is an Open dialog for one file;tagmay be NULL and is consumed. False when one is already out (one dialog at a time) or the dialog is malformed. - kui_
request_ paste - Asks for what is on the clipboard, as a
KUI_MENU_ACTION_PASTEthe host drains and answers withkui_input_paste(the text and the pasteboard’sKUI_PASTE_*markers) orkui_input_commit: a focused editor takes the text as typing, a focusedon_keysink hears it as{kind:"text", text, tag}— so an app that owns its text inserts a paste the way it inserts a committed IME string, and the clipboard is read on the host’s side, where the permission lives. Underkui_runthe runner does both halves. - kui_
resume - Resumes a paused playback, fading in over
fade_ms. - kui_
reveal - Scrolls whatever contains
keyso the node shows — what Tab does to the control it lands on, asked for by name. The request resolves at the nextkui_frame_finish, against the frame it lays out (the one being built when called from a view callback, the one after it otherwise — a frame is requested, so one comes), so a row a view is about to declare for the first time reveals fine. A key that frame does not declare, or one with nothing scrollable above it, is a no-op and is not kept for a later frame; the last reveal before a frame wins. - kui_
rich_ text - A paragraph of
span_countstyled runs fromspans, set inbase(NULL for the default style) where a span says nothing. A NULL or empty array draws nothing. - kui_
root - Configures the frame’s root node from
spec: its direction, padding, gap, alignment and background. Everything else declared this frame is its child. Call it first afterkui_frame_begin; a NULLspecdoes nothing. - kui_
row_ count - Declares how many indexed rows the open node’s virtual list has, built
or not (
rowCount): what Select All inside aselectablevirtual list spans, since the rows the frame built are all the core can see. Call it inside the list’s container, after itskui_open_*. Does nothing outside any node. - kui_run
- Opens a window titled
titleand runs it to the end:view(user, ctx)is called once per frame with a context to build into, andon_event(user, ev)once per event, on this thread. Blocks until the window closes; returns false if the event loop could not start. Same askui_run_with(NULL, title, NULL, view, on_event, user). - kui_
run_ with kui_runwith a window of the host’s choosing and a context’s registrations.- kui_
scroll_ geometry - Everything the last layout resolved for the scroll container
key: its box, its content size and the clamped offset. Returns false, leavingoutuntouched, for a bad context, a NULLout, or a key no layout has ever resolved as a scroll container. - kui_
scroll_ offset - Reads that offset back, as the last layout clamped it — the number to
persist and hand to
kui_set_scrolllater. Writes 0,0 for a node that never scrolled; either out pointer may be NULL. - kui_
secure_ input_ get - Whether the frame that just finished asked for secure keyboard entry — for hosts driving their own window. False for a frame that never asked, and on a bad context.
- kui_
select - The stock select: a field showing the choice in force that, clicked,
opens the core’s own menu
of
countoptions read fromitems— the same rowskui_open_menutakes — under it, thecurrentth checked (-1for none). The host holds no open state: the choice arrives as the{kind:"menu", role, item}event a menu row posts, on the key this returns, and drawing the field again with the newcurrentis the whole loop; a host that shows menus itself sees the menu inkui_menuas any other. - kui_
select_ all_ in - Selects everything in the scope
keydeclared — every run of aselectablecontainer, or the whole screen of acellsgrid. False for a node that is not a scope, or drew nothing. - kui_
selection_ ends - The text selection’s two ends as the drag made them — the anchor
where the press landed, the focus where the pointer is — each as the
data index of the virtualised row it is in (
-1outside every virtualised row) and the byte inside that row’s own text. Directed, so a Shift-press that kept the anchor reads as one. False with no text selection; a grid’s iskui_cell_selection. Any out pointer may be NULL. - kui_
selection_ html - The same selection with the formatting the text declared — bold,
italic, a span’s own colour — for a host offering a second clipboard
flavour. False when there is no text selection or nothing to carry;
never a replacement for
kui_selection_text. - kui_
selection_ text - The window’s selected text — a
selectablescope’s, acellsgrid’s, or the focused editor’s, whichever the window holds. False when nothing is selected.outis borrowed until the next selection call on this context. - kui_
set_ always_ on_ top - Declares that this frame wants the window above every other app’s.
Cleared each
kui_frame_beginlike the title, but with a default of false rather than “leave as-is”: a frame that stops calling this is what lowers the window again. The host applies it afterkui_frame_finish(seekui_always_on_top_get) and reports what the platform did throughkui_env_set_always_on_top. - kui_
set_ caret_ visible - Sets the blink phase; see
kui_caret_visible. - kui_
set_ clipboard - Puts
texton the system clipboard, as aKUI_MENU_ACTION_SET_CLIPBOARDthe host drains: the action a menu’s Copy queues, callable from anon_keysink that hears the rawCtrl-c.htmlis a second flavour beside the text, never in place of it; an emptyhtmlis none. Underkui_runthe runner applies it after every input and every frame. - kui_
set_ clipboard_ secret - Puts a secret on the system clipboard, as a
KUI_MENU_ACTION_SET_CLIPBOARD_SECRETthe host drains and writes marked concealed and transient, the way a password manager does:org.nspasteboard.ConcealedTypeandTransientTypeon macOS, the exclusion formats on Windows — so no clipboard manager shows or keeps it. Underkui_runthe runner writes it. - kui_
set_ devtools - Turns the core’s devtools panel on or off: the event stream, the
runtime’s facts and the tree, drawn by the core beside the host’s tree
(where
kui_set_devtools_docksays). Its controls and itsCtrl+Shift+<letter>chords are handled inside thekui_input_*calls, so nothing of it reaches the host’s events.KUI_DEVTOOLS=1in the environment makes the same call for a windowkui_runopens; a headless context never reads it. - kui_
set_ devtools_ dock - Where the devtools panel sits:
"left","right","bottom","window"(one of its own, namedkui-devtools, opened through an ordinaryKUI_CMD_OPENthat the host builds nothing into) or"off"(hidden, chords still live);"side"means the right. Returns false for any other word. - kui_
set_ devtools_ key - Respells the chord that moves the keyboard into the devtools panel and
back out (and brings a hidden panel back) from its default
"ctrl+shift+i":"f12","mod+shift+d"(modis Command on macOS, Control elsewhere), any spelling aKuiMenuItem’sacceltakes. The panel’s other chords stayCtrl+Shift+<letter>. False for a spelling kui cannot parse, which leaves the chord as it was. - kui_
set_ devtools_ legend - The key legend the devtools facts tab shows:
countpairs, the keys inkeysand what each does inwhat, index for index. - kui_
set_ devtools_ pick - Raises the devtools picker from outside the panel (an inspector asking
“which node?”) or puts it away. While it is up the node under the
pointer is
kui_devtools_picked, and a press lands it inkui_devtools_selected. Raised while a declared tab is on show the pick leaves that tab up; otherwise it shows the tree tab. A hidden panel comes back docked. - kui_
set_ devtools_ selected - Selects a node in the devtools tree tab and reveals it there, as the picker does; 0 clears.
- kui_
set_ devtools_ tab - Shows the devtools tab named
name: one of the panel’s own (facts,events,tree) or a declared tab’s. A declared name the panel does not list yet is kept and shows once a frame declares it; the return says whether the panel lists it now (false on a bad context too). A hidden panel comes back docked;kui_set_devtoolsis still the host’s to call. Call it once, not every frame, or it pins the strip against the user’s own clicks. - kui_
set_ devtools_ theme - Seeds the devtools panel’s theme override, which its
TandAchords cycle from:baseis"light","dark"or empty for the app’s own;accenta0xRRGGBBAAcolour, or 0 for none. False for any other base word. - kui_
set_ diagnostics - Turns the diagnostic checks behind
kui_take_warningson or off. Off by default for a standalone context; a development build opts in. - kui_
set_ frame_ trace - Turns the trace of why frames run on or off: the digest
kui_frame_unchangedcompares.kui_frame_causeis kept either way. - kui_
set_ icon - Sets the icon every window of the next
kui_run/kui_run_withis created with. - kui_
set_ ime_ off - Declares that this window takes the keyboard as keys, with the
platform’s input method off — no composition, and on a Mac no dead
keys and no press-and-hold, so a held letter repeats. Cleared each
kui_frame_beginlikekui_set_always_on_top: a frame that stops calling this gives the window its input method back. Underkui_runthe runner applies it on change; a host driving its own window readskui_ime_off_getand does. - kui_
set_ inspect - Turns the per-frame node snapshot behind
kui_nodeson or off. Off by default: the copy costs a pass over every node each frame. - kui_
set_ key_ focus - Declares
keyfocused this frame (0 blurs at once). Edge-triggered: the node takes focus on the first frame it is declared, and a declaration repeated every frame does not clobber a Tab press or a click. Any focusable node (an editor, anon_keysink, a control, afocusablebox). To move focus at any time,kui_focus. - kui_
set_ lookup_ available - Tells the core this host can show the platform’s definition panel (macOS’s Look Up). The standard Look Up row is then offered where it means something, and a force click over text asks for one; without this the core neither offers nor asks, because a row that does nothing is worse than a row that is not there.
- kui_
set_ master_ volume - Sets the master volume every playback is scaled by (0..1), easing to
it over
tween_ms. - kui_
set_ native_ menu_ bar - Tells the core that the platform owns the menu bar, so
kui_menu_bardraws nothing and the host is the one that hands the declaration over (kui_menu_bar_menu_count/kui_menu_bar_itemread it back) and reports what was chosen withkui_activate_menu_bar_item. - kui_
set_ native_ menus - Tells the core that this host shows menus itself — the platform’s own,
however it draws them. The core then keeps the open menu as state and
draws none of it: read it with
kui_menu_items, show it, and report back withkui_activate_menu_itemorkui_close_menu. - kui_
set_ option_ as_ alt - Declares which Option keys act as Alt in this window on macOS
(
KUI_OPTION_AS_ALT_*), so a dead key like Option-U arrives as a key with Alt rather than composing an accent. Cleared eachkui_frame_beginlikekui_set_always_on_top: a frame that stops calling this gives the Option keys back to the layout. A number pastKUI_OPTION_AS_ALT_BOTH— a header from a later kui — isKUI_OPTION_AS_ALT_NONE, the Mac’s own behaviour. Underkui_runthe runner applies it on change; a host driving its own window readskui_option_as_alt_getand does. - kui_
set_ scroll - Sets a scroll container’s retained offset, the way the wheel would (positive = content moved up / left). Takes effect on the next frame, whose layout clamps it to that frame’s overflow: 0,0 is “jump to the top” and a huge value is “jump to the end” without knowing the content height. An offset written for a key that never scrolls is harmless.
- kui_
set_ secure_ input - Declares that this frame wants secure keyboard entry while the window
has the keyboard, as at a password prompt. Cleared each
kui_frame_beginlikekui_set_always_on_top: a frame that stops calling this is what turns it off. Underkui_runthe runner makes the platform call and keeps it balanced; a host driving its own window readskui_secure_input_getand does. - kui_
set_ subpixel_ text - Rasterizes outline glyphs as LCD subpixel coverage
(
KUI_QUAD_GLYPH_SUBPIXELquads, the atlas’s RGB being per-channel coverage) instead of alpha masks. Only for a renderer that blends per channel (dual-source blending); flipping it re-rasterizes every glyph. - kui_
set_ text_ cache_ budget - Byte budget for the shaped-text cache: past it the least recently drawn
entries are evicted at the start of the next frame, never what the last
frame drew. Default 64 MB (
DEFAULT_TEXT_CACHE_BYTES). - kui_
set_ time - The frame clock for transitions, in monotonic seconds from any origin.
Set it before each
kui_frame_begin; a host that never does sees transitions snap to their targets. - kui_
set_ volume - Sets a playback’s volume (linear amplitude, 0..1), easing to it over
tween_ms. - kui_
set_ window_ size - Asks the driver to resize
windowtowxhlogical px. A request and not a declaration:kui_window_declare’s config is read on the opening edge only, because the user owns a window’s size once it exists, so this is the only way an app moves a live window’s size. It is queued the waykui_revealqueues a scroll and comes back out of the host’s ownkui_take_window_commandasKUI_CMD_SET_SIZE, carryingwindowand the size inwidth/height, for the host to apply; a headless host that never drains ignores it.windowis the id events carry (KuiEvent.window),KUI_WINDOW_MAINfor the launcher’s. The size the window actually becomes arrives as the ordinaryresizeevent. - kui_
shift_ scroll - Moves a scroll container by the content that moved under it, on y:
drawnfor where its content is drawn (and an eased leg’s start),targetfor the retained offset. No ease is asked or ended and no frame is asked for — it corrects the frame being built. What a variable-height list does when the rows it measured came out another height than the estimate they stood at, so the row under the pointer stays put. Call it from the view, beforekui_frame_finish. - kui_
size_ clamp targetheld betweenloandhi,lowinning overhias CSS’sclamp()has it;KUI_FITwhen one is not a size.- kui_
size_ max - The largest of
nsizings;KUI_FITwhen one is not a size. - kui_
size_ min - The smallest of
nsizings (each a length, a percentage or a calc);KUI_FITwhen one is anything else. - kui_
size_ parse - A sizing’s spelling —
"fit","grow","120","50%","clamp(400px, 80%, 1000px)"— into*out; false (and*outuntouched) for one that is not. - kui_
size_ pct percentpercent of the room (80 for 80%):KUI_PERCENT.- kui_
size_ px pxlogical pixels:KUI_FIXED.- kui_
slider - The stock slider, named and keyed by
label. Reads the value fields (value_now/value_min/value_max/value_stepby theirKUI_VALUE_*bits,value_text),on_change,width/min_w/max_wwhere set,label(a name other than the key),description,tooltipanddisabledoffspec; every other field is its look’s. Withon_changethe core proposes values as{kind:"change", value, phase, tag}. Its key. - kui_
slot - Declares a slot named
nameat the cursor, withparams(may be NULL) for whatever fills it, and fills it then and there with the extension the name’s namespace belongs to.nameis the fullnamespace/slot: the namespace this context loaded the extension under withkui_ctx_add_extension, and the slot in the extension’s own vocabulary. - kui_
slot_ name - Which slot this context is a fill of; false (and
outuntouched) on a context that is not an extension’s — a standalone one, or a C host’s view callback. Borrowed for the duration ofkui_ext_view. - kui_
slot_ namespace - The namespace the host loaded this extension under — what makes the
slot’s full name, and what tells one instance of a plugin loaded twice
from the other. False (and
outuntouched) on a context that is not an extension’s. Borrowed for the duration ofkui_ext_view. - kui_
slot_ params - The parameters the host declared the slot with, or NULL when it passed
none (or this is not an extension’s context). Borrowed for the
duration of
kui_ext_view; read it withkui_value_getand friends. - kui_
sound_ add - Registers a sound from its encoded file bytes (wav/ogg/mp3/flac, copied);
returns its handle for
KuiSpec.click_sound/kui_audio/kui_play, 0 when empty. - kui_
sound_ remove - Forgets a registered sound and stops its playbacks.
- kui_
spec_ float_ preset - Fills a spec’s
float_*fields from a preset name — the same four names ("parent","viewport","below","above") the JSX and Luafloatprops take, resolved by the same core function. Returns false and leaves the spec alone for an unknown name. - kui_
stop - Stops a playback from
kui_play, fading out overfade_ms(0 for at once). - kui_
switch - The stock switch; see
kui_checkbox. - kui_
system_ fonts - Every family
kui_font_familiesnames, one per family and in its order, with what its faces say they are (monospaced, the weights, an italic), written intooutup tocapand the total returned, askui_font_familiesdoes. Read from what the font database recorded when it scanned each face: nothing is loaded or shaped. The names and weight arrays are borrowed until the next call on this context. What Node’ssystemFonts()answers. - kui_
take_ announcements - Drains queued announcements into
out(up tocap; the rest are dropped, so size it generously) and returns the count. The strings stay valid until the next call on this context. - kui_
take_ audio_ commands - Drains queued audio commands into
out(up tocap; the rest are dropped, so size it generously); returns the count. Only for hosts driving their own audio device — kui_run plays them itself. - kui_
take_ file_ request - Drains the dialog asked for, for a host that shows it itself (under
kui_runthe runner does): itsKUI_FILE_DIALOG_*mode, whether it picks several, its title, folder and suggested name (empty for none), and how many filters it offers — read each withkui_file_request_filter. Any out pointer may be NULL; the strings are borrowed until the next call on this context. False when nothing is asked. Answer withkui_input_files. - kui_
take_ menu_ action - Drains what choosing a menu row left for the host: the clipboard, which
is the host’s in this library.
KUI_MENU_ACTION_SET_CLIPBOARDcarries the text to put there — the core worked out what, which is the half only it can do — andKUI_MENU_ACTION_PASTEasks for what is there, which a host delivers back withkui_input_commit(an editor takes it as typing; a sink hears it as{kind:"text"}). - kui_
take_ warnings - Drains the warnings the core raised since the last call (silent
misconfigurations it noticed while finishing frames, each once) into
out, up tocap(the rest wait for the next call), and returns the count. The strings stay valid until the next call on this context. A standalone context starts with the checks off (kui_set_diagnosticsturns them on);kui_runprints them to stderr itself in debug builds. - kui_
take_ window_ command - Pops the next window command into
out: what chrome nodes asked for since the last drain, and theKUI_CMD_OPEN/KUI_CMD_CLOSEthe declared window set’s diff decided at the lastkui_frame_finish. Returns false, writing nothing, when there is none — or whenout’ssizeis below the layout this library knows (start fromKUI_WINDOW_COMMAND_INIT), in which case the command stays queued. Call after each input dispatch and each frame until it returns false, and apply each to the real window it names. - kui_
text - A paragraph of plain text in one style (NULL for the default style).
A text has no box of its own; wrap it in a
kui_openfor padding, a background or a click. - kui_
text_ cache_ bytes - What the shaped-text cache holds, in the estimated bytes the budget is charged against.
- kui_
text_ edit - An editable text node keyed by
label, seeded withinitialthe first time it is seen; the core keeps its buffer, caret and undo history across frames.flagsareKUI_EDIT_MULTILINE,KUI_EDIT_AUTOFOCUSandKUI_EDIT_WRAP;spec(required) is the box around it. Read the text withkui_edit_text;changedandsubmitevents carry the key. Returns the key, or 0 on failure. - kui_
text_ hit - Where a point (logical viewport px, as a click or drag event carries
it) lands in the text the node
keydrew: a byte offset into that text — across the node’s text runs in order, the way the access tree reads aline— and the visual line. False for a key that drew no text, a bad context or a NULLout. Answered from the frame that finished. - kui_
text_ input - Single-line input with chrome (background, focus ring). Returns the node
key; read it with
kui_edit_text, “changed”/“submit” events carry it. - kui_
theme - This window’s palette as of the current or last frame: one
0xRRGGBBAAper role, derived from whatkui_env_set_systemreported unless the host pinned something withkui_theme_set_accentorkui_theme_set. - kui_
theme_ set - Pins the whole palette to exactly these colours, following neither the OS’s appearance nor its accent; NULL goes back to deriving both.
- kui_
theme_ set_ accent - Keeps following the OS’s light or dark base but paints
accent(0xRRGGBBAA) instead of the OS’s accent; zero goes back to the OS’s. - kui_
titlebar - Adaptive titlebar: drag strip + standard title + window buttons, all
driven by the env facts (
kui_env_set_window). - kui_
titlebar_ with - Titlebar hosting custom content (tabs, search):
bodybuilds it between the OS-controls inset and the window buttons. - kui_
token_ color - A colour token by name, resolved for this frame’s appearance, as
0xRRGGBBAAthroughout. The calling origin’s table is tried first, then the host’s; a theme role’s name (surface) answers with the role. False for a name nothing declared or one that is a length, which also raisesunknown-tokenonce per name. - kui_
token_ length - A length token by name, in logical px; a metrics role’s name
(
radius) answers with the metric. False andunknown-tokenas forkui_token_color. - kui_
tokens_ derive - Adds derived colour tokens to the calling origin’s table, after
kui_tokens_set: each a name, the colour token or theme role it derives from, and a chain of ops applied in order. - kui_
tokens_ set - Declares the named colours and lengths of the calling origin: the
host’s outside a plugin’s view, the plugin’s own inside
kui_ext_view. - kui_
tooltip - A hint floated below the enclosing node. Gate it on
kui_is_hoveredof a hoverable parent. - kui_
tooltip_ with - Tooltip chrome around content built by
body. - kui_
value_ as_ bool - A payload’s boolean - a key event’s
shift/ctrl/alt/super/repeat, a modifiers event’s four. False - and*outuntouched - for anything that is not one; a bool is never coerced from a number. - kui_
value_ as_ float - The number a payload carries, as a double: a float as it is, an
integer widened. The reader for everything geometry-shaped an event
carries - a drag’s
x/dx, a layout’s rect, a resize’sscale- which kui_value_as_int would truncate. False for anything else. - kui_
value_ as_ int - The integer a value holds; false for anything that is not an integer
(a float is not coerced; see
kui_value_as_float). - kui_
value_ as_ str - Borrowed string view; valid as long as the value.
- kui_
value_ at - Borrowed entry
iof a list value (preedit’scursor, the two ends anaccessrequest carries); NULL past the end or on anything but a list. Valid as long as the list. - kui_
value_ bool - A new boolean value, owned by the caller.
- kui_
value_ entry - A map’s
ith entry, for walking one whose keys you do not know: the key into*keyand the borrowed value returned, NULL past the end or on anything but a map. Entries keep the order they were set in. - kui_
value_ float - A new float value, owned by the caller.
- kui_
value_ free - Frees a value the caller owns. Never call it on a borrowed value (an
event’s payload, a
kui_value_getresult); NULL is a no-op. - kui_
value_ get - Borrowed lookup on a map value; NULL if absent. Valid as long as the map.
- kui_
value_ int - A new integer value, owned by the caller.
- kui_
value_ is_ null - Whether the value is the null one: what a key event’s
textis on a release, and a missingtag. A NULL pointer answers true too, so akui_value_getmiss reads the same as an explicit null. - kui_
value_ len - How many entries a list or map holds; 0 for anything else, which a scalar reader tells apart from an empty one.
- kui_
value_ list - A new empty list, owned by the caller; fill it with
kui_value_list_push. - kui_
value_ list_ push - Appends to a list value. Consumes
val; on anything but a list it is dropped and nothing changes. - kui_
value_ map - A new empty map, owned by the caller; fill it with
kui_value_map_set. The usual shape of a tag is a map with akindstring. - kui_
value_ map_ set - Sets
keyon a map value, replacing an existing entry. Consumesval; on anything but a map it is dropped and nothing changes. - kui_
value_ null - A new null value, owned by the caller. Where a tag is taken it asks for the events without a tag.
- kui_
value_ str - A new string value holding a copy of
s, owned by the caller. - kui_
window_ buttons - The minimize/maximize/close cluster; draws nothing when the OS provides controls, so it is always safe to call.
- kui_
window_ closed - A host reports that the OS closed window
id— its close button, the window manager. The window stays closed while its name is still declared (seekui_window_declare), whatever only it declared closes with it, and the app gets{kind:"window", phase:"closed", name, id}fromkui_poll_event. Nothing happens forKUI_WINDOW_MAINor for a window already closed by the diff. - kui_
window_ declare - Declares that a window named
nameexists this frame: it opens on the first frame any window’s frame declares it —cfgis read then and never again, NULL meaningKUI_WINDOW_CONFIG_INIT— and closes on the first frame none does. TheOpen/Closearrive throughkui_take_window_command; the app sees{kind:"window", phase:"opened"|"closed", name, id}events. A window the user closed (kui_window_closed) stays closed while still declared: stop declaring it, then declare it again. Call betweenkui_frame_beginandkui_frame_finish. - kui_
window_ dismissed - A host reports that window
idwas asked to go away: a press landed outside it (KUI_DISMISS_OUTSIDE), or Escape reached it (KUI_DISMISS_ESCAPE). The app gets{kind:"dismiss", reason, name, id}fromkui_poll_eventand nothing closes — exactly what amodalnode’s dismissal does, one level up: only the app can stop declaring the window, and it does that on the frame it decides to. So a dropdown that graduates from a modal float to a popup window changes its declaration and keeps its handler. - kui_
window_ title - Declares this frame’s window title (cleared each kui_frame_begin).
- kui_
window_ title_ get - The title declared this frame, if any — for hosts driving their own window: diff and apply after kui_frame_finish. The view is valid until the next kui_frame_begin.