top: better graphic scaling in cpu/mem summary display <=== port of newlib 8c69e66a
______________________________ original newlib message This program has always been sensitive to the width of a terminal/console. The detailed cpu/memory statistics plus all of those full screen replacement windows were designed to fit within some 80 column, 24 row display. When a user narrowed a gui terminal to less than those dimensions, top would simply truncate the data to fit. However, when displaying cpu/mem graphs instead of the detailed statistics such truncation was not justified. After all, such graphs were already scaled to 80 cols. Henceforth, when in graph mode, truncation won't occur until the graphs will no longer fit within 10 columns. [ can you keep a secret? this change is really being ] [ made in anticipation of showing more than just two ] [ cpu graphs in the summary area on each screen row! ] Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
737e6f5b59
commit
f07eea2898
19
top/top.c
19
top/top.c
@ -253,8 +253,10 @@ static int Numa_node_sel = -1;
|
||||
|
||||
/* Support for Graphing of the View_STATES ('t') and View_MEMORY ('m')
|
||||
commands -- which are now both 4-way toggles */
|
||||
|
||||
#define GRAPH_prefix 25 // beginning text + opening '['
|
||||
#define GRAPH_actual 100 // the actual bars or blocks
|
||||
#define GRAPH_minlen 10 // the actual bars or blocks
|
||||
#define GRAPH_suffix 2 // ending ']' + trailing space
|
||||
static float Graph_adj; // bars/blocks scaling factor
|
||||
static int Graph_len; // scaled length (<= GRAPH_actual)
|
||||
@ -2137,16 +2139,16 @@ static void adj_geometry (void) {
|
||||
PSU_CLREOS(0);
|
||||
|
||||
// prepare to customize potential cpu/memory graphs
|
||||
Graph_len = Screen_cols - GRAPH_prefix - GRAPH_actual - GRAPH_suffix;
|
||||
if (Graph_len >= 0) Graph_len = GRAPH_actual;
|
||||
else if (Screen_cols > 80) Graph_len = Screen_cols - GRAPH_prefix - GRAPH_suffix;
|
||||
else Graph_len = 80 - GRAPH_prefix - GRAPH_suffix;
|
||||
if (Screen_cols < DOUBLE_limit) Curwin->rc.double_up = 0;
|
||||
if (Curwin->rc.double_up) {
|
||||
Graph_len = (Screen_cols - DOUBLE_space - (2 * (GRAPH_prefix + GRAPH_suffix))) / 2;
|
||||
Graph_len += (Screen_cols % 2) ? 0 : 1;
|
||||
if (Graph_len > GRAPH_actual) Graph_len = GRAPH_actual;
|
||||
} else {
|
||||
Graph_len = Screen_cols - (GRAPH_prefix + GRAPH_actual + GRAPH_suffix);
|
||||
if (Graph_len >= 0) Graph_len = GRAPH_actual;
|
||||
else Graph_len = Screen_cols - GRAPH_prefix - GRAPH_suffix;
|
||||
}
|
||||
if (Graph_len < GRAPH_minlen) Graph_len = GRAPH_minlen;
|
||||
if (Graph_len > GRAPH_actual) Graph_len = GRAPH_actual;
|
||||
Graph_adj = (float)Graph_len / 100.0;
|
||||
|
||||
fflush(stdout);
|
||||
@ -5837,10 +5839,7 @@ static void keys_summary (int ch) {
|
||||
break;
|
||||
case '4':
|
||||
w->rc.double_up = !w->rc.double_up;
|
||||
if (w->rc.double_up && Screen_cols < DOUBLE_limit)
|
||||
w->rc.double_up = 0;
|
||||
if (w->rc.double_up)
|
||||
OFFw(w, (View_CPUSUM | View_CPUNOD));
|
||||
OFFw(w, (View_CPUSUM | View_CPUNOD));
|
||||
break;
|
||||
case 'C':
|
||||
VIZTOGw(w, View_SCROLL);
|
||||
|
Loading…
Reference in New Issue
Block a user