2 Copyright (c) 2020 Damjan Marion
4 Permission is hereby granted, free of charge, to any person obtaining
5 a copy of this software and associated documentation files (the
6 "Software"), to deal in the Software without restriction, including
7 without limitation the rights to use, copy, modify, merge, publish,
8 distribute, sublicense, and/or sell copies of the Software, and to
9 permit persons to whom the Software is furnished to do so, subject to
10 the following conditions:
12 The above copyright notice and this permission notice shall be
13 included in all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #ifndef __format_table_h__
25 #define __format_table_h__
29 TTAF_RESET = (1 << 0),
32 TTAF_UNDERLINE = (1 << 3),
33 TTAF_FG_COLOR_SET = (1 << 4),
34 TTAF_BG_COLOR_SET = (1 << 5),
35 TTAF_FG_COLOR_BRIGHT = (1 << 6),
36 TTAF_BG_COLOR_BRIGHT = (1 << 7),
37 } table_text_attr_flags_t;
49 } table_text_attr_color_t;
57 } table_text_attr_align_t;
61 table_text_attr_flags_t flags : 16;
62 table_text_attr_color_t fg_color : 4;
63 table_text_attr_color_t bg_color : 4;
64 table_text_attr_align_t align : 4;
69 table_text_attr_t attr;
84 __clib_export format_function_t format_table;
86 __clib_export void table_format_title (table_t *t, char *fmt, ...);
87 __clib_export void table_format_cell (table_t *t, int c, int r, char *fmt,
89 __clib_export void table_set_cell_align (table_t *t, int c, int r,
90 table_text_attr_align_t a);
91 __clib_export void table_set_cell_fg_color (table_t *t, int c, int r,
92 table_text_attr_color_t v);
93 __clib_export void table_set_cell_bg_color (table_t *t, int c, int r,
94 table_text_attr_color_t v);
95 __clib_export void table_free (table_t *t);
96 __clib_export void table_add_header_col (table_t *t, int n_strings, ...);
97 __clib_export void table_add_header_row (table_t *t, int n_strings, ...);