nandi/jolt-nativepublic Fork 0
e0d90292c3d0c00acad1fb5cdc100d728938759f
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.

Paint the tree ABI a third way: Zig and dvui 7289263 · on e0d90292c3d0c00acad1fb5cdc100d728938759f · nandi · 9d ago
zvui.h · 65 lines · 2.5 KBC Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* libjoltzvui — the retained-tree C ABI, painted by dvui.
 *
 * The shape crates/jolt-vidya exports on egui and crates/jolt-tui exports over
 * terminal cells. A caller builds a tree of nodes between frames, calls
 * zvui_frame() to paint it, and drains what the person did with
 * zvui_tree_poll_event().
 *
 * Node ids are small positive ints; 0 is "no node". Ids are reused after a
 * free, but widget identity is not — see src/tree.zig.
 *
 * Every `const char *` returned here points into one scratch slot and is valid
 * only until the next string-returning call. Copy it if you need it longer.
 * Nothing here calls back: events are queued and polled.
 */
#ifndef JOLTZVUI_H
#define JOLTZVUI_H

#ifdef __cplusplus
extern "C" {
#endif

/* The window. */
int   zvui_open(int width, int height, const char *title);
void  zvui_close(void);
int   zvui_should_close(void);   /* 1 once asked to quit, or with no window */
void  zvui_set_title(const char *title);
float zvui_screen_width(void);   /* points, not pixels; 0 before frame one */
float zvui_screen_height(void);
void  zvui_frame(void);          /* paint the whole tree once, and present */

/* The tree. */
int   zvui_tree_root(void);
int   zvui_node_new(const char *tag);
void  zvui_node_free(int node);  /* and everything under it */
int   zvui_node_exists(int node);
const char *zvui_node_tag(int node);
int   zvui_node_parent(int node);

void  zvui_node_set_str(int node, const char *key, const char *value);
void  zvui_node_set_num(int node, const char *key, double value);
void  zvui_node_set_bool(int node, const char *key, int value);
void  zvui_node_clear_props(int node);
const char *zvui_node_get_str(int node, const char *key);
double zvui_node_get_num(int node, const char *key);
int   zvui_node_get_bool(int node, const char *key);

int   zvui_node_child_count(int node);
int   zvui_node_child_at(int node, int index);
int   zvui_node_append(int parent, int child);
void  zvui_node_remove(int parent, int child);
int   zvui_node_insert_after(int parent, int child, int sibling);
int   zvui_node_replace(int parent, int old_child, int new_child);
const char *zvui_tree_dump(int node);

/* Events: poll until it answers 0, reading each with the accessors. */
int   zvui_tree_poll_event(void);
int   zvui_tree_event_node(void);
const char *zvui_tree_event_name(void); /* click | change | toggled | activate */
const char *zvui_tree_event_text(void);
double zvui_tree_event_num(void);

#ifdef __cplusplus
}
#endif
#endif /* JOLTZVUI_H */