netsniff-ng: remove unnecessary zeroing of packet counters in init_ctx()
[netsniff-ng.git] / ui.h
blob40bf4f133015d8bb184b9cf8b3a4c1a76638be08
1 #ifndef UI_H
2 #define UI_H
4 #define _LGPL_SOURCE
5 #include <stdbool.h>
6 #include <inttypes.h>
7 #include <urcu/list.h>
9 enum ui_event_id {
10 UI_EVT_SCROLL_LEFT,
11 UI_EVT_SCROLL_RIGHT,
12 UI_EVT_SELECT_NEXT,
15 enum ui_align {
16 UI_ALIGN_LEFT,
17 UI_ALIGN_RIGHT,
20 struct ui_text {
21 chtype *str;
22 size_t slen;
23 size_t len;
26 struct ui_col {
27 struct cds_list_head entry;
28 uint32_t id;
29 const char *name;
30 uint32_t len;
31 int pos;
32 int color;
33 enum ui_align align;
36 struct ui_table {
37 int y;
38 int x;
39 int rows_y;
40 struct cds_list_head cols;
41 struct ui_text *row;
42 int hdr_color;
43 int col_pad;
44 int width;
45 int height;
46 int scroll_x;
47 const char *delim;
50 struct ui_tab;
52 enum ui_tab_event_t {
53 UI_TAB_EVT_OPEN,
54 UI_TAB_EVT_CLOSE,
57 typedef void (* ui_tab_event_cb) (struct ui_tab *tab, enum ui_tab_event_t evt,
58 uint32_t id);
60 struct ui_tab {
61 struct ui_col *active;
62 struct ui_table tbl;
63 int color;
65 ui_tab_event_cb on_tab_event;
68 extern void ui_table_init(struct ui_table *tbl);
69 extern void ui_table_uninit(struct ui_table *tbl);
70 extern void ui_table_clear(struct ui_table *tbl);
71 extern void ui_table_pos_set(struct ui_table *tbl, int y, int x);
72 extern void ui_table_height_set(struct ui_table *tbl, int height);
74 extern void ui_table_col_add(struct ui_table *tbl, uint32_t id, const char *name,
75 uint32_t len);
76 extern void ui_table_col_color_set(struct ui_table *tbl, int col_id, int color);
77 extern void ui_table_col_align_set(struct ui_table *tbl, int col_id, enum ui_align align);
78 extern void ui_table_col_delim_set(struct ui_table *tbl, const char *delim);
80 extern void ui_table_row_add(struct ui_table *tbl);
81 extern void ui_table_row_show(struct ui_table *tbl);
82 extern void ui_table_row_col_set(struct ui_table *tbl, uint32_t col_id,
83 const char *str);
85 extern void ui_table_header_color_set(struct ui_table *tbl, int color);
86 extern void ui_table_header_print(struct ui_table *tbl);
88 extern void ui_table_event_send(struct ui_table *tbl, enum ui_event_id id);
90 extern struct ui_tab *ui_tab_create(void);
91 extern void ui_tab_destroy(struct ui_tab *tab);
92 extern void ui_tab_pos_set(struct ui_tab *tab, int y, int x);
93 extern void ui_tab_event_cb_set(struct ui_tab *tab, ui_tab_event_cb cb);
94 extern void ui_tab_active_color_set(struct ui_tab *tab, int color);
95 extern void ui_tab_show(struct ui_tab *tab);
96 extern void ui_tab_entry_add(struct ui_tab *tab, uint32_t id, const char *name);
97 extern void ui_tab_event_send(struct ui_tab *tab, uint32_t id);
99 #endif /* UI_H */