version 1.1.1.2, 2014/07/30 07:55:27
|
version 1.1.1.3, 2019/10/21 14:58:35
|
Line 137 static void apply_layout(int layout)
|
Line 137 static void apply_layout(int layout)
|
attrset(cfg_layout[layout].l_attr); |
attrset(cfg_layout[layout].l_attr); |
} |
} |
|
|
char *float2str(double value, int width, int prec, char *buf, size_t len) | static char *float2str(double value, int width, int prec, char *buf, size_t len) |
{ |
{ |
snprintf(buf, len, "%'*.*f", width, value == 0.0f ? 0 : prec, value); |
snprintf(buf, len, "%'*.*f", width, value == 0.0f ? 0 : prec, value); |
|
|
Line 148 static void put_line(const char *fmt, ...)
|
Line 148 static void put_line(const char *fmt, ...)
|
{ |
{ |
va_list args; |
va_list args; |
char buf[2048]; |
char buf[2048]; |
int x, y; | int x, y __unused__; |
|
|
memset(buf, 0, sizeof(buf)); |
memset(buf, 0, sizeof(buf)); |
getyx(stdscr, y, x); |
getyx(stdscr, y, x); |
Line 172 static void center_text(const char *fmt, ...)
|
Line 172 static void center_text(const char *fmt, ...)
|
unsigned int col; |
unsigned int col; |
|
|
va_start(args, fmt); |
va_start(args, fmt); |
vasprintf(&str, fmt, args); | if (vasprintf(&str, fmt, args) < 0) { |
| fprintf(stderr, "vasprintf: Out of memory\n"); |
| exit(ENOMEM); |
| } |
va_end(args); |
va_end(args); |
|
|
col = (cols / 2) - (strlen(str) / 2); |
col = (cols / 2) - (strlen(str) / 2); |
Line 238 static void draw_attr_detail(struct element *e, struct
|
Line 241 static void draw_attr_detail(struct element *e, struct
|
int rxprec, txprec, ncol; |
int rxprec, txprec, ncol; |
struct detail_arg *da = arg; |
struct detail_arg *da = arg; |
|
|
double rx = unit_value2str(a->a_rx_rate.r_total, | double rx = unit_value2str(rate_get_total(&a->a_rx_rate), |
a->a_def->ad_unit, |
a->a_def->ad_unit, |
&rx_u, &rxprec); |
&rx_u, &rxprec); |
double tx = unit_value2str(a->a_tx_rate.r_total, | double tx = unit_value2str(rate_get_total(&a->a_tx_rate), |
a->a_def->ad_unit, |
a->a_def->ad_unit, |
&tx_u, &txprec); |
&tx_u, &txprec); |
|
|
Line 255 static void draw_attr_detail(struct element *e, struct
|
Line 258 static void draw_attr_detail(struct element *e, struct
|
if (ncol > 0) |
if (ncol > 0) |
addch(ACS_VLINE); |
addch(ACS_VLINE); |
|
|
put_line(" %-14.14s %8s%-3s %8s%-3s\n", | put_line(" %-14.14s %8s%-3s %8s%-3s", |
a->a_def->ad_description, |
a->a_def->ad_description, |
(a->a_flags & ATTR_RX_ENABLED) ? |
(a->a_flags & ATTR_RX_ENABLED) ? |
float2str(rx, 8, rxprec, buf1, sizeof(buf1)) : "-", rx_u, |
float2str(rx, 8, rxprec, buf1, sizeof(buf1)) : "-", rx_u, |
Line 389 static void draw_help(void)
|
Line 392 static void draw_help(void)
|
mvaddnstr(y+15, x+3, "H Start recording history data", -1); |
mvaddnstr(y+15, x+3, "H Start recording history data", -1); |
mvaddnstr(y+16, x+3, "TAB Switch time unit of graph", -1); |
mvaddnstr(y+16, x+3, "TAB Switch time unit of graph", -1); |
mvaddnstr(y+17, x+3, "<, > Change number of graphs", -1); |
mvaddnstr(y+17, x+3, "<, > Change number of graphs", -1); |
|
mvaddnstr(y+18, x+3, "r Reset counter of element", -1); |
|
|
attroff(A_STANDOUT); |
attroff(A_STANDOUT); |
|
|
Line 416 static void draw_header(void)
|
Line 420 static void draw_header(void)
|
move(row, COLS - strlen(PACKAGE_STRING) - 1); |
move(row, COLS - strlen(PACKAGE_STRING) - 1); |
put_line("%s", PACKAGE_STRING); |
put_line("%s", PACKAGE_STRING); |
move(row, 0); |
move(row, 0); |
|
apply_layout(LAYOUT_LIST); |
} |
} |
|
|
static int lines_required_for_statusbar(void) |
static int lines_required_for_statusbar(void) |
Line 427 static void draw_statusbar(void)
|
Line 432 static void draw_statusbar(void)
|
{ |
{ |
static const char *help_text = "Press ? for help"; |
static const char *help_text = "Press ? for help"; |
char s[27]; |
char s[27]; |
time_t t = time(0); | time_t t = time(NULL); |
|
|
apply_layout(LAYOUT_STATUSBAR); |
apply_layout(LAYOUT_STATUSBAR); |
|
|
Line 628 static void draw_element(struct element_group *g, stru
|
Line 633 static void draw_element(struct element_group *g, stru
|
|
|
static void draw_group(struct element_group *g, void *arg) |
static void draw_group(struct element_group *g, void *arg) |
{ |
{ |
|
apply_layout(LAYOUT_HEADER); |
int *line = arg; |
int *line = arg; |
|
|
if (line_visible(*line)) { |
if (line_visible(*line)) { |
Line 680 static void draw_graph_centered(struct graph *g, int r
|
Line 686 static void draw_graph_centered(struct graph *g, int r
|
|
|
static void draw_table(struct graph *g, struct graph_table *tbl, |
static void draw_table(struct graph *g, struct graph_table *tbl, |
struct attr *a, struct history *h, |
struct attr *a, struct history *h, |
const char *hdr, int ncol) | const char *hdr, int ncol, int layout) |
{ |
{ |
int i, save_row; |
int i, save_row; |
char buf[32]; |
char buf[32]; |
Line 705 static void draw_table(struct graph *g, struct graph_t
|
Line 711 static void draw_table(struct graph *g, struct graph_t
|
//move(row, ncol + g->g_cfg.gc_width - 3); |
//move(row, ncol + g->g_cfg.gc_width - 3); |
//put_line("[err %.2f%%]", rtiming.rt_variance.v_error); |
//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--) { |
for (i = (g->g_cfg.gc_height - 1); i >= 0; i--) { |
move(++row, ncol); |
move(++row, ncol); |
put_line("%'8.2f %s", | sprintf(buf, "%'8.2f ", tbl->gt_scale[i]); |
tbl->gt_scale[i], | addstr(buf); |
tbl->gt_table + (i * graph_row_size(&g->g_cfg))); | apply_layout(layout); |
| put_line("%s", tbl->gt_table + (i * graph_row_size(&g->g_cfg))); |
| apply_layout(LAYOUT_LIST); |
} |
} |
|
|
move(++row, ncol); |
move(++row, ncol); |
Line 743 static void draw_history_graph(struct attr *a, struct
|
Line 752 static void draw_history_graph(struct attr *a, struct
|
graph_refill(g, h); |
graph_refill(g, h); |
|
|
save_row = row; |
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) { |
if (graph_display == GRAPH_DISPLAY_SIDE_BY_SIDE) { |
ncol = cols / 2; |
ncol = cols / 2; |
row = save_row; |
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); |
graph_free(g); |
} |
} |
Line 1076 out:
|
Line 1085 out:
|
refresh(); |
refresh(); |
} |
} |
|
|
|
static void __reset_attr_counter(struct element *e, struct attr *a, void *arg) |
|
{ |
|
attr_reset_counter(a); |
|
} |
|
|
|
static void reset_counters(void) |
|
{ |
|
element_foreach_attr(current_element, __reset_attr_counter, NULL); |
|
} |
|
|
static int handle_input(int ch) |
static int handle_input(int ch) |
{ |
{ |
switch (ch) |
switch (ch) |
Line 1112 static int handle_input(int ch)
|
Line 1131 static int handle_input(int ch)
|
|
|
case '?': |
case '?': |
clear(); |
clear(); |
print_help = 1; | print_help = print_help ? 0 : 1; |
return 1; |
return 1; |
|
|
case KEY_TOGGLE_GRAPH: |
case KEY_TOGGLE_GRAPH: |
Line 1195 static int handle_input(int ch)
|
Line 1214 static int handle_input(int ch)
|
case '\t': |
case '\t': |
history_select_next(); |
history_select_next(); |
return 1; |
return 1; |
|
|
|
case 'r': |
|
reset_counters(); |
|
return 1; |
} |
} |
|
|
return 0; |
return 0; |
Line 1239 static void print_module_help(void)
|
Line 1262 static void print_module_help(void)
|
" nocolors Do not use colors\n" \ |
" nocolors Do not use colors\n" \ |
" graph Show graphical stats by default\n" \ |
" graph Show graphical stats by default\n" \ |
" details Show detailed stats by default\n" \ |
" details Show detailed stats by default\n" \ |
|
" info Show additional info screen by default\n" \ |
" minlist=INT Minimum item list length\n"); |
" minlist=INT Minimum item list length\n"); |
} |
} |
|
|
Line 1256 static void curses_parse_opt(const char *type, const c
|
Line 1280 static void curses_parse_opt(const char *type, const c
|
c_graph_cfg.gc_height = strtol(value, NULL, 0); |
c_graph_cfg.gc_height = strtol(value, NULL, 0); |
else if (!strcasecmp(type, "gwidth") && value) |
else if (!strcasecmp(type, "gwidth") && value) |
c_graph_cfg.gc_width = strtol(value, NULL, 0); |
c_graph_cfg.gc_width = strtol(value, NULL, 0); |
else if (!strcasecmp(type, "ngraph")) { | else if (!strcasecmp(type, "ngraph") && value) { |
c_ngraph = strtol(value, NULL, 0); |
c_ngraph = strtol(value, NULL, 0); |
c_show_graph = !!c_ngraph; |
c_show_graph = !!c_ngraph; |
} else if (!strcasecmp(type, "details")) |
} else if (!strcasecmp(type, "details")) |
c_show_details = 1; |
c_show_details = 1; |
|
else if (!strcasecmp(type, "info")) |
|
c_show_info = 1; |
else if (!strcasecmp(type, "nocolors")) |
else if (!strcasecmp(type, "nocolors")) |
c_use_colors = 0; |
c_use_colors = 0; |
else if (!strcasecmp(type, "minlist") && value) |
else if (!strcasecmp(type, "minlist") && value) |