nandi/jolt-nativepublic Fork 0
c7d6ea8b8cda7e4ab2805c20463e0d0f770580c6
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

zvui.h · 65 lines · 2.5 KBC Blame HistoryRaw
Paint the tree ABI a third way: Zig and dvui 7289263 nandi 9d ago1/* libjoltzvui — the retained-tree C ABI, painted by dvui.
2 *
3 * The shape crates/jolt-vidya exports on egui and crates/jolt-tui exports over
4 * terminal cells. A caller builds a tree of nodes between frames, calls
5 * zvui_frame() to paint it, and drains what the person did with
6 * zvui_tree_poll_event().
7 *
8 * Node ids are small positive ints; 0 is "no node". Ids are reused after a
9 * free, but widget identity is not — see src/tree.zig.
10 *
11 * Every `const char *` returned here points into one scratch slot and is valid
12 * only until the next string-returning call. Copy it if you need it longer.
13 * Nothing here calls back: events are queued and polled.
14 */
15#ifndef JOLTZVUI_H
16#define JOLTZVUI_H
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/* The window. */
23int zvui_open(int width, int height, const char *title);
24void zvui_close(void);
25int zvui_should_close(void); /* 1 once asked to quit, or with no window */
26void zvui_set_title(const char *title);
27float zvui_screen_width(void); /* points, not pixels; 0 before frame one */
28float zvui_screen_height(void);
29void zvui_frame(void); /* paint the whole tree once, and present */
30
31/* The tree. */
32int zvui_tree_root(void);
33int zvui_node_new(const char *tag);
34void zvui_node_free(int node); /* and everything under it */
35int zvui_node_exists(int node);
36const char *zvui_node_tag(int node);
37int zvui_node_parent(int node);
38
39void zvui_node_set_str(int node, const char *key, const char *value);
40void zvui_node_set_num(int node, const char *key, double value);
41void zvui_node_set_bool(int node, const char *key, int value);
42void zvui_node_clear_props(int node);
43const char *zvui_node_get_str(int node, const char *key);
44double zvui_node_get_num(int node, const char *key);
45int zvui_node_get_bool(int node, const char *key);
46
47int zvui_node_child_count(int node);
48int zvui_node_child_at(int node, int index);
49int zvui_node_append(int parent, int child);
50void zvui_node_remove(int parent, int child);
51int zvui_node_insert_after(int parent, int child, int sibling);
52int zvui_node_replace(int parent, int old_child, int new_child);
53const char *zvui_tree_dump(int node);
54
55/* Events: poll until it answers 0, reading each with the accessors. */
56int zvui_tree_poll_event(void);
57int zvui_tree_event_node(void);
58const char *zvui_tree_event_name(void); /* click | change | toggled | activate */
59const char *zvui_tree_event_text(void);
60double zvui_tree_event_num(void);
61
62#ifdef __cplusplus
63}
64#endif
65#endif /* JOLTZVUI_H */