diff options
author | blastmaster <blastmaster@tuxcode.org> | 2016-07-16 01:53:42 +0200 |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2016-07-19 22:57:37 +0200 |
commit | 828b5b5368bc5054b16a2504fcbb7a7e77087598 (patch) | |
tree | ff274a541dd3184bcc879d6d26a434a21c6c1bff /src/out_curses.c | |
parent | 1c25eacc95d209716084d9fb28db4c7340b74471 (diff) |
enabling colors for bmon
This commit enables colors in bmon. It adds configuration options to
let the user decide, which colors should be used. Therefor the graph_rx and graph_tx
layouts are introduced and applied respectively.
* Add graph_rx, graph_tx and layout_cfg fields.
* Setting default colors if colorized output is enabled.
* draw_table accept additional layout parameter and apply the given layout for
the table graph.
* Apply layouts for rx, tx graph and header and statusbar.
* Add include/layout.h, which provides functions to parse, color and attribute
strings and set the layout.
* Adding a default layout-config example in examples/bmon.conf.
[Edit: Based on original work by eri!, #PR23]
Diffstat (limited to 'src/out_curses.c')
-rw-r--r-- | src/out_curses.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/out_curses.c b/src/out_curses.c index 7b8bc7a..5724121 100644 --- a/src/out_curses.c +++ b/src/out_curses.c @@ -420,6 +420,7 @@ static void draw_header(void) move(row, COLS - strlen(PACKAGE_STRING) - 1); put_line("%s", PACKAGE_STRING); move(row, 0); + apply_layout(LAYOUT_LIST); } static int lines_required_for_statusbar(void) @@ -632,6 +633,7 @@ static void draw_element(struct element_group *g, struct element *e, static void draw_group(struct element_group *g, void *arg) { + apply_layout(LAYOUT_HEADER); int *line = arg; if (line_visible(*line)) { @@ -684,7 +686,7 @@ static void draw_graph_centered(struct graph *g, int row, int ncol, static void draw_table(struct graph *g, struct graph_table *tbl, struct attr *a, struct history *h, - const char *hdr, int ncol) + const char *hdr, int ncol, int layout) { int i, save_row; char buf[32]; @@ -709,11 +711,14 @@ static void draw_table(struct graph *g, struct graph_table *tbl, //move(row, ncol + g->g_cfg.gc_width - 3); //put_line("[err %.2f%%]", rtiming.rt_variance.v_error); + memset(buf, 0, strlen(buf)); for (i = (g->g_cfg.gc_height - 1); i >= 0; i--) { move(++row, ncol); - put_line("%'8.2f %s", - tbl->gt_scale[i], - tbl->gt_table + (i * graph_row_size(&g->g_cfg))); + sprintf(buf, "%'8.2f ", tbl->gt_scale[i]); + addstr(buf); + apply_layout(layout); + put_line("%s", tbl->gt_table + (i * graph_row_size(&g->g_cfg))); + apply_layout(LAYOUT_LIST); } move(++row, ncol); @@ -747,14 +752,14 @@ static void draw_history_graph(struct attr *a, struct history *h) graph_refill(g, h); save_row = row; - draw_table(g, &g->g_rx, a, h, "RX", ncol); + draw_table(g, &g->g_rx, a, h, "RX", ncol, LAYOUT_RX_GRAPH); if (graph_display == GRAPH_DISPLAY_SIDE_BY_SIDE) { ncol = cols / 2; row = save_row; } - draw_table(g, &g->g_tx, a, h, "TX", ncol); + draw_table(g, &g->g_tx, a, h, "TX", ncol, LAYOUT_TX_GRAPH); graph_free(g); } |