diff options
-rw-r--r-- | ui.c | 39 |
1 files changed, 31 insertions, 8 deletions
@@ -57,6 +57,7 @@ extern hash_type* history; extern int history_pos; extern int history_len; +extern int history_divs[]; extern options_t options ; @@ -171,6 +172,7 @@ static void draw_bar_scale(int* y) { } } mvaddch(*y + 1, 0, ACS_LLCORNER); + *y += 2; } else { @@ -179,6 +181,25 @@ static void draw_bar_scale(int* y) { } } +static void draw_headers(int* y, int L) { + if(options.showbars) { + mvhline(*y + 1, 0, 0, COLS); + int x = (COLS - 8 * HISTORY_DIVISIONS - 2); + mvaddstr(*y, 0, "source"); + mvaddstr(*y, L + 4, "dest"); + + for(int j = 0; j < HISTORY_DIVISIONS; j++) { + char *header = malloc(8); + snprintf(header, 8, "%ds", history_divs[j]*2); + x += 8-strlen(header); + mvaddstr(*y, x, header); + x += strlen(header); + free(header); + } + *y += 2; + } +} + void draw_line_total(float sent, float recv, int y, int x, option_linedisplay_t linedisplay, option_bw_unit_t unit) { char buf[10]; float n = 0; @@ -281,6 +302,15 @@ void ui_print() { erase(); draw_bar_scale(&y); + int L; + L = (COLS - 8 * HISTORY_DIVISIONS - 4) / 2; + if(options.show_totals) { + L -= 4; + } + if(L > HOSTNAME_LENGTH) { + L = HOSTNAME_LENGTH; + } + draw_headers(&y, L); if(options.showhelp) { mvaddstr(y,0,HELP_MESSAGE); @@ -298,19 +328,12 @@ void ui_print() { if(i == 0 || nn != NULL) { while((y < LINES - 5) && ((nn = sorted_list_next_item(&screen_list, nn)) != NULL)) { - int x = 0, L; + int x = 0; host_pair_line* screen_line = (host_pair_line*)nn->data; if(y < LINES - 5) { - L = (COLS - 8 * HISTORY_DIVISIONS - 4) / 2; - if(options.show_totals) { - L -= 4; - } - if(L > HOSTNAME_LENGTH) { - L = HOSTNAME_LENGTH; - } sprint_host(host1, screen_line->ap.af, &(screen_line->ap.src6), |