summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2024-09-22 12:26:18 +0200
committercos <cos>2024-09-25 14:46:32 +0200
commitb81b65d56fa711de75f171dd7b79279e344d6a8f (patch)
treecde2aea0d52f9aee8b82b61210c13909919c2b9a
parent8d76ef06d225c4d72db544b54ea1ef1a0e077967 (diff)
downloadiftop-ui-headers.zip
Add headers for intervals, source and destui-headers
-rw-r--r--ui.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/ui.c b/ui.c
index 2165071..ff2576b 100644
--- a/ui.c
+++ b/ui.c
@@ -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),