summaryrefslogtreecommitdiff
path: root/ui.h
blob: 07248ac8b93c84631ce545d26d32dd82f0737fd7 (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
#ifndef UI_H
#define UI_H

#include <stdbool.h>
#include <inttypes.h>

#include "list.h"

enum ui_event_id {
	UI_EVT_SCROLL_LEFT,
	UI_EVT_SCROLL_RIGHT,
};

enum ui_align {
	UI_ALIGN_LEFT,
	UI_ALIGN_RIGHT,
};

struct ui_text {
	chtype *str;
	size_t slen;
	size_t len;
};

struct ui_col {
	struct list_head entry;
	uint32_t id;
	char *name;
	uint32_t len;
	int pos;
	int color;
	enum ui_align align;
};

struct ui_table {
	int y;
	int x;
	int rows_y;
	struct list_head cols;
	struct ui_text *row;
	int hdr_color;
	int col_pad;
	int width;
	int height;
	int scroll_x;
};

extern void ui_table_init(struct ui_table *tbl);
extern void ui_table_uninit(struct ui_table *tbl);
extern void ui_table_clear(struct ui_table *tbl);
extern void ui_table_pos_set(struct ui_table *tbl, int y, int x);
extern void ui_table_height_set(struct ui_table *tbl, int height);

extern void ui_table_col_add(struct ui_table *tbl, uint32_t id, char *name,
			     uint32_t len);
extern void ui_table_col_color_set(struct ui_table *tbl, int col_id, int color);
extern void ui_table_col_align_set(struct ui_table *tbl, int col_id, enum ui_align align);

extern void ui_table_row_add(struct ui_table *tbl);
extern void ui_table_row_show(struct ui_table *tbl);
extern void ui_table_row_col_set(struct ui_table *tbl, uint32_t col_id,
				 const char *str);

extern void ui_table_header_color_set(struct ui_table *tbl, int color);
extern void ui_table_header_print(struct ui_table *tbl);

extern void ui_table_event_send(struct ui_table *tbl, enum ui_event_id id);

#endif /* UI_H */