ui
lib/ui.vklib/ui.vk
Curated .ui-gated native window surface, clipboard, and Hi-DPI wrapper over the Veko PAL window primitives
(ui/open, ui/poll-events, ui/present, ui/close, ui/clipboard-get, ui/clipboard-set, ui/dpi-scale)
+ ui/canvas framebuffer presentation.
- Windows x64: native Win32 window (StretchDIBits + Per-Monitor V2 Hi-DPI + Win32 clipboard), or headless under VEKO_HEADLESS=1
- Linux x64/arm64: zero-libc X11 wire-protocol window over AF_UNIX (chunked PutImage + .Xauthority), or headless
- macOS / VM / Wasm 3.0: deterministic surface (with shared-memory <canvas> bridge in browser Wasm) and .secret firewall enforcement
EV-CLOSE = fn [] i64
Window event kind constants matching the 5-element PAL event tuples [kind x y key btn].
EV-KEY = fn [] i64
EV-MOUSE-DOWN = fn [] i64
EV-MOUSE-UP = fn [] i64
EV-MOUSE-MOVE = fn [] i64
EV-RESIZE = fn [] i64
EV-TEXT = fn [] i64
EV-WHEEL = fn [] i64
EV-KEY-UP = fn [] i64
MOD-SHIFT = fn [] i64
Keyboard modifier bitmask constants (UiEvent.btn on EV-KEY / EV-KEY-UP or UiState.key_mods).
MOD-CTRL = fn [] i64
MOD-ALT = fn [] i64
KEY-BACKSPACE = fn [] i64
Standard cross-platform virtual key constants (UiEvent.key on EV-KEY / EV-KEY-UP).
KEY-TAB = fn [] i64
KEY-ENTER = fn [] i64
KEY-SHIFT = fn [] i64
KEY-CTRL = fn [] i64
KEY-ALT = fn [] i64
KEY-ESC = fn [] i64
KEY-SPACE = fn [] i64
KEY-PAGE-UP = fn [] i64
KEY-PAGE-DOWN = fn [] i64
KEY-END = fn [] i64
KEY-HOME = fn [] i64
KEY-LEFT = fn [] i64
KEY-UP = fn [] i64
KEY-RIGHT = fn [] i64
KEY-DOWN = fn [] i64
KEY-DELETE = fn [] i64
BTN-LEFT = fn [] i64
Mouse button constants carried in UiEvent.btn on EV-MOUSE-DOWN / EV-MOUSE-UP.
BTN-RIGHT = fn [] i64
UiEvent = struct { kind i64, x i64, y i64, key i64, btn i64 }
Structured window input event decoded from poll-events.
Window = struct { handle i64, width i64, height i64, title str }
Handle to an open native or offscreen window surface.
open-window = fn [title str, w i64, h i64] Window
Opens a window surface titled title with dimensions w x h.
use [ui, cv = ui/canvas]
win = ui/open-window 'Veko Window' 64 32
mut c = cv/new-canvas 64 32
cv/clear mut c (cv/color-bg-dark)
_ = ui/present-canvas win c
evs = ui/poll win
_ = ui/close-window win
if (len evs) < 0 [ err 'events' ] else [ .ok ]
poll = fn [win Window] block[UiEvent]
Polls all pending OS input events for win without blocking.
present-rgba = fn [win Window, rgba bytes, w i64, h i64]
Presents a raw RGBA32 byte buffer (w * h * 4 bytes) to win.
present-canvas = fn [win Window, c cv/Canvas]
Presents a ui/canvas Canvas directly to win.
window-dpi-scale = fn [win Window] i64
Queries the active Hi-DPI scaling percentage for win (100 = 96 DPI 1x, 150 = 1.5x, 200 = 2x Retina/4K).
clipboard-text = fn [] str
Reads UTF-8 plain text from the OS/session clipboard.
use [ui]
_ = ui/set-clipboard 'veko-clip-ok'
got = ui/clipboard-text
if got != 'veko-clip-ok' [ err 'clipboard mismatch' ] else [ .ok ]
clipboard-secret = fn [] secret str
Reads clipboard contents directly into a .secret-tainted str for pasting tokens/passwords without exposing plain str copies.
set-clipboard = fn [text str]
Writes plain text to the OS/session clipboard (.secret values are statically and dynamically rejected).