blob: 878886746bfc69b236eca8543fa3a9f0103f1f4c (
plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#ifndef UI_H
#define UI_H 1
#include <ncurses.h>
#include <stdint.h>
#define UICB_OK 0
#define UICB_ERR_UNDEF 1
#define UICB_ERR_CB 2
#define UICB_ERR_BUF 3
#define DOUI_OK 0
#define DOUI_ERR 4
#define DOUI_TMOUT 5
#define DOUI_NINIT 6
#define DOUI_KEY 7
#define UILOOP_TIMEOUT 1000
#define UIKEY_ACTIVATE 0
#define UIKEY_ENTER 10
#define UIKEY_BACKSPACE 7
#define UIKEY_ESC 27
#define UIKEY_DOWN 2
#define UIKEY_UP 3
#define UIKEY_LEFT 4
#define UIKEY_RIGHT 5
typedef int (*uicb_base)(WINDOW *, void *, bool);
typedef int (*uicb_input)(WINDOW *, void *, int);
typedef int (*uicb_update)(bool);
struct ui_callbacks {
uicb_base ui_element;
uicb_input ui_input;
};
struct nask_ui {
struct ui_callbacks cbs;
WINDOW *wnd;
void *data;
struct nask_ui *next;
};
void
register_ui_elt(struct ui_callbacks *cbs, void *data, WINDOW *wnd);
void
unregister_ui_elt(void *data);
unsigned int
ui_get_maxx(void);
unsigned int
ui_get_maxy(void);
void
ui_set_cur(unsigned int x, unsigned int y);
unsigned int
ui_get_curx(void);
unsigned int
ui_get_cury(void);
int
activate_ui_input(void *data);
int
deactivate_ui_input(void *data);
bool
process_key(char key);
void
ui_thrd_force_update(bool force_all, bool timedout);
void
ui_thrd_suspend(void);
void
ui_thrd_resume(void);
int
run_ui_thrd(void);
int
stop_ui_thrd(void);
char ui_wgetch(int timeout);
int ui_wgetchtest(int timeout, char testchar);
WINDOW *
init_ui(uicb_update on_update_callback, uicb_update on_postupdate_callback);
void
free_ui(void);
#endif
|