diff options
author | Damjan Marion <damarion@cisco.com> | 2020-11-27 20:15:17 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-12-18 17:20:28 +0000 |
commit | 8b60fb0fe6e29aac1847c0b381c0f84165b27b61 (patch) | |
tree | 0d805a148109bad0906a3570b2d22767ec50f95d /src/plugins/perfmon/table.h | |
parent | f5b27cbcc7cae5279aac512f805be73591f58eaa (diff) |
perfmon: new perfmon plugin
Type: feature
Change-Id: I2c14f82393d11fc05c6d229f5c58603ab5c0f14d
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/perfmon/table.h')
-rw-r--r-- | src/plugins/perfmon/table.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/plugins/perfmon/table.h b/src/plugins/perfmon/table.h new file mode 100644 index 00000000000..93102a033f0 --- /dev/null +++ b/src/plugins/perfmon/table.h @@ -0,0 +1,98 @@ +/* + Copyright (c) 2020 Damjan Marion + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __table_h__ +#define __table_h__ + +typedef enum +{ + TTAF_RESET = (1 << 0), + TTAF_BOLD = (1 << 1), + TTAF_DIM = (1 << 2), + TTAF_UNDERLINE = (1 << 3), + TTAF_FG_COLOR_SET = (1 << 4), + TTAF_BG_COLOR_SET = (1 << 5), + TTAF_FG_COLOR_BRIGHT = (1 << 6), + TTAF_BG_COLOR_BRIGHT = (1 << 7), +} table_text_attr_flags_t; + +typedef enum +{ + TTAC_BLACK = 0, + TTAC_RED = 1, + TTAC_GREEN = 2, + TTAC_YELLOW = 3, + TTAC_BLUE = 4, + TTAC_MAGENTA = 5, + TTAC_CYAN = 6, + TTAC_WHITE = 7, +} table_text_attr_color_t; + +typedef enum +{ + TTAA_DEFAULT = 0, + TTAA_LEFT = 1, + TTAA_RIGHT = 2, + TTAA_CENTER = 3, +} table_text_attr_align_t; + +typedef struct +{ + table_text_attr_flags_t flags : 16; + table_text_attr_color_t fg_color : 4; + table_text_attr_color_t bg_color : 4; + table_text_attr_align_t align : 4; +} table_text_attr_t; + +typedef struct +{ + table_text_attr_t attr; + u8 *text; +} table_cell_t; + +typedef struct +{ + u8 no_ansi : 1; + u8 *title; + table_cell_t **cells; + int *row_sizes; + int n_header_cols; + int n_header_rows; + int n_footer_cols; +} table_t; + +format_function_t format_table; + +void table_format_title (table_t *t, char *fmt, ...); +void table_format_cell (table_t *t, int c, int r, char *fmt, ...); +void table_set_cell_align (table_t *t, int c, int r, + table_text_attr_align_t a); +void table_set_cell_fg_color (table_t *t, int c, int r, + table_text_attr_color_t v); +void table_set_cell_bg_color (table_t *t, int c, int r, + table_text_attr_color_t v); +void table_free (table_t *t); +void table_add_header_col (table_t *t, int n_strings, ...); +void table_add_header_row (table_t *t, int n_strings, ...); + +#endif |