diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2016-04-21 21:47:39 +0300 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2016-04-22 15:29:03 +0200 |
commit | aef19410e1346cea962d838894785eef96182312 (patch) | |
tree | 6e52cbf4dd5ae027afd701dcd299cbb3cf236f7c /ui.h | |
parent | 627b1d172d19372dc43248cfe680521743efd826 (diff) |
ui: Implement UI table for flows printing
Add new module ui.c which is responsible to render
different kinds of UI widgets - tables, etc.
Implemented generic API for print table-like list of elements.
This table API might be used for print flows in curses or text mode.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: change bug_on(true) to bug(), whitespace fix]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ui.h')
-rw-r--r-- | ui.h | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -0,0 +1,51 @@ +#ifndef UI_H +#define UI_H + +#include <stdbool.h> +#include <inttypes.h> + +#include "list.h" + +enum ui_align { + UI_ALIGN_LEFT, + UI_ALIGN_RIGHT, +}; + +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; + int hdr_color; + int col_pad; + int width; +}; + +extern void ui_table_init(struct ui_table *tbl); +extern void ui_table_uninit(struct ui_table *tbl); +extern void ui_table_pos_set(struct ui_table *tbl, int y, int x); +extern void ui_table_clear(struct ui_table *tbl); + +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_print(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); + +#endif /* UI_H */ |