summaryrefslogtreecommitdiff
path: root/ui.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-04-21 21:47:41 +0300
committerTobias Klauser <tklauser@distanz.ch>2016-04-22 15:29:48 +0200
commit0dd9388efcd966197bda65c131d176cf0ac63c60 (patch)
treea81e28ba18f02ecae073e511a3f2a09dd21ab080 /ui.c
parente6186a3285928bf6fb798a4685d294ef9f3d0686 (diff)
ui: Print empty rows when clearing table
Fill table with empty rows while clearing. It will allow to get rid of clear() & refresh() each time before print the flows list. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ui.c b/ui.c
index 5e52efd..46062d4 100644
--- a/ui.c
+++ b/ui.c
@@ -16,6 +16,7 @@ void ui_table_init(struct ui_table *tbl)
tbl->rows_y = tbl->y;
tbl->width = COLS;
+ tbl->height = LINES - 2;
tbl->col_pad = 1;
INIT_LIST_HEAD(&tbl->cols);
@@ -94,7 +95,13 @@ void ui_table_row_add(struct ui_table *tbl)
void ui_table_clear(struct ui_table *tbl)
{
+ int y;
+
tbl->rows_y = tbl->y;
+
+ for (y = tbl->y + 1; y < tbl->y + tbl->height; y++) {
+ mvprintw(y, tbl->x, "%*s", tbl->width, " ");
+ }
}
#define UI_ALIGN_COL(col) (((col)->align == UI_ALIGN_LEFT) ? "%-*.*s" : "%*.*s")
@@ -120,6 +127,11 @@ void ui_table_header_color_set(struct ui_table *tbl, int color)
tbl->hdr_color = color;
}
+void ui_table_height_set(struct ui_table *tbl, int height)
+{
+ tbl->height = height;
+}
+
void ui_table_header_print(struct ui_table *tbl)
{
struct ui_col *col;