top: afford each window its own cpu/memory graph modes
When those new cpu/memory graphs modes were introduced
they had global impact. In other words, the modes that
were chosen for a 'current' window affect Summary Area
appearance for every other window as well, even though
each window sets unique View_STATES/View_MEMORY flags.
I do not know how widespread the use of top's separate
window provisions is, but I do know that documentation
promises every window (field group) provides "a unique
separately configurable summary area". And even though
that promise does not include memory scaling (separate
'E' command) the graph modes are integral to 't' & 'm'
and those were already observed on a per window basis.
So this patch just takes the cpu and memory graph mode
values out of global scope in the configuration file &
gives each window its own unique pair of graph values.
Reference(s):
commit 1d171ec741
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
805532ac32
commit
96c330e3b3
@ -2046,7 +2046,7 @@ Here is the general layout:
|
|||||||
global # line 1: the program name/alias notation
|
global # line 1: the program name/alias notation
|
||||||
" # line 2: id,altscr,irixps,delay,curwin
|
" # line 2: id,altscr,irixps,delay,curwin
|
||||||
per ea # line a: winname,fieldscur
|
per ea # line a: winname,fieldscur
|
||||||
window # line b: winflags,sortindx,maxtasks
|
window # line b: winflags,sortindx,maxtasks,graph modes
|
||||||
" # line c: summclr,msgsclr,headclr,taskclr
|
" # line c: summclr,msgsclr,headclr,taskclr
|
||||||
global # line 15: additional miscellaneous settings
|
global # line 15: additional miscellaneous settings
|
||||||
" # any remaining lines are devoted to the
|
" # any remaining lines are devoted to the
|
||||||
|
56
top/top.c
56
top/top.c
@ -3457,7 +3457,7 @@ static int config_cvt (WIN_t *q) {
|
|||||||
* line 2 : an id, Mode_altcsr, Mode_irixps, Delay_time, Curwin.
|
* line 2 : an id, Mode_altcsr, Mode_irixps, Delay_time, Curwin.
|
||||||
* For each of the 4 windows:
|
* For each of the 4 windows:
|
||||||
* line a: contains w->winname, fieldscur
|
* line a: contains w->winname, fieldscur
|
||||||
* line b: contains w->winflags, sortindx, maxtasks
|
* line b: contains w->winflags, sortindx, maxtasks, graph modes
|
||||||
* line c: contains w->summclr, msgsclr, headclr, taskclr
|
* line c: contains w->summclr, msgsclr, headclr, taskclr
|
||||||
* line 15 : miscellaneous additional global settings
|
* line 15 : miscellaneous additional global settings
|
||||||
* Any remaining lines are devoted to the 'Inspect Other' feature */
|
* Any remaining lines are devoted to the 'Inspect Other' feature */
|
||||||
@ -3511,8 +3511,9 @@ static void configs_read (void) {
|
|||||||
// too bad fscanf is not as flexible with his format string as snprintf
|
// too bad fscanf is not as flexible with his format string as snprintf
|
||||||
# error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
|
# error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
|
||||||
#endif
|
#endif
|
||||||
if (3 != fscanf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d\n"
|
// be tolerant of missing release 3.3.10 graph modes additions
|
||||||
, &w->rc.winflags, &w->rc.sortindx, &w->rc.maxtasks))
|
if (3 > fscanf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d, graph_cpus=%d, graph_mems=%d\n"
|
||||||
|
, &w->rc.winflags, &w->rc.sortindx, &w->rc.maxtasks, &w->rc.graph_cpus, &w->rc.graph_mems))
|
||||||
goto default_or_error;
|
goto default_or_error;
|
||||||
if (4 != fscanf(fp, "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n"
|
if (4 != fscanf(fp, "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n"
|
||||||
, &w->rc.summclr, &w->rc.msgsclr
|
, &w->rc.summclr, &w->rc.msgsclr
|
||||||
@ -3522,13 +3523,16 @@ static void configs_read (void) {
|
|||||||
switch (Rc.id) {
|
switch (Rc.id) {
|
||||||
case 'a': // 3.2.8 (former procps)
|
case 'a': // 3.2.8 (former procps)
|
||||||
if (config_cvt(w))
|
if (config_cvt(w))
|
||||||
goto default_or_error; // fall through !
|
goto default_or_error;
|
||||||
case 'f': // 3.3.0 thru 3.3.3 (procps-ng)
|
case 'f': // 3.3.0 thru 3.3.3 (ng)
|
||||||
SETw(w, Show_JRNUMS); // fall through !
|
SETw(w, Show_JRNUMS);
|
||||||
case 'g': // 3.3.4 thru 3.3.8
|
case 'g': // from 3.3.4 thru 3.3.8
|
||||||
scat(w->rc.fieldscur, RCF_PLUS_H); // fall through !
|
scat(w->rc.fieldscur, RCF_PLUS_H);
|
||||||
case 'h': // current RCF_VERSION_ID
|
case 'h': // this is release 3.3.9
|
||||||
default: // and future versions?
|
/* w->rc.graph_cpus = 0; */// for documentation only, since
|
||||||
|
/* w->rc.graph_mems = 0; */// DEF_RCFILE zeroes them for us
|
||||||
|
case 'i': // actual RCF_VERSION_ID
|
||||||
|
default: // and a future version?
|
||||||
if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1)
|
if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1)
|
||||||
goto default_or_error;
|
goto default_or_error;
|
||||||
for (x = 0; x < EU_MAXPFLGS; ++x)
|
for (x = 0; x < EU_MAXPFLGS; ++x)
|
||||||
@ -3542,9 +3546,8 @@ static void configs_read (void) {
|
|||||||
} // end: for (GROUPSMAX)
|
} // end: for (GROUPSMAX)
|
||||||
|
|
||||||
// any new addition(s) last, for older rcfiles compatibility...
|
// any new addition(s) last, for older rcfiles compatibility...
|
||||||
if (fscanf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d, Zero_suppress=%d, Graph_cpus=%d, Graph_mems=%d\n"
|
if (fscanf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d, Zero_suppress=%d\n"
|
||||||
, &Rc.fixed_widest, &Rc.summ_mscale, &Rc.task_mscale, &Rc.zero_suppress
|
, &Rc.fixed_widest, &Rc.summ_mscale, &Rc.task_mscale, &Rc.zero_suppress))
|
||||||
, &Rc.graph_cpus, &Rc.graph_mems))
|
|
||||||
; // avoid -Wunused-result
|
; // avoid -Wunused-result
|
||||||
|
|
||||||
try_inspect_entries:
|
try_inspect_entries:
|
||||||
@ -4349,18 +4352,17 @@ static void write_rcfile (void) {
|
|||||||
for (i = 0 ; i < GROUPSMAX; i++) {
|
for (i = 0 ; i < GROUPSMAX; i++) {
|
||||||
fprintf(fp, "%s\tfieldscur=%s\n"
|
fprintf(fp, "%s\tfieldscur=%s\n"
|
||||||
, Winstk[i].rc.winname, Winstk[i].rc.fieldscur);
|
, Winstk[i].rc.winname, Winstk[i].rc.fieldscur);
|
||||||
fprintf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d\n"
|
fprintf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d, graph_cpus=%d, graph_mems=%d\n"
|
||||||
, Winstk[i].rc.winflags, Winstk[i].rc.sortindx
|
, Winstk[i].rc.winflags, Winstk[i].rc.sortindx, Winstk[i].rc.maxtasks
|
||||||
, Winstk[i].rc.maxtasks);
|
, Winstk[i].rc.graph_cpus, Winstk[i].rc.graph_mems);
|
||||||
fprintf(fp, "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n"
|
fprintf(fp, "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n"
|
||||||
, Winstk[i].rc.summclr, Winstk[i].rc.msgsclr
|
, Winstk[i].rc.summclr, Winstk[i].rc.msgsclr
|
||||||
, Winstk[i].rc.headclr, Winstk[i].rc.taskclr);
|
, Winstk[i].rc.headclr, Winstk[i].rc.taskclr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// any new addition(s) last, for older rcfiles compatibility...
|
// any new addition(s) last, for older rcfiles compatibility...
|
||||||
fprintf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d, Zero_suppress=%d, Graph_cpus=%d, Graph_mems=%d\n"
|
fprintf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d, Zero_suppress=%d\n"
|
||||||
, Rc.fixed_widest, Rc.summ_mscale, Rc.task_mscale, Rc.zero_suppress
|
, Rc.fixed_widest, Rc.summ_mscale, Rc.task_mscale, Rc.zero_suppress);
|
||||||
, Rc.graph_cpus, Rc.graph_mems);
|
|
||||||
|
|
||||||
if (Inspect.raw)
|
if (Inspect.raw)
|
||||||
fputs(Inspect.raw, fp);
|
fputs(Inspect.raw, fp);
|
||||||
@ -4544,16 +4546,16 @@ static void keys_summary (int ch) {
|
|||||||
case 'm':
|
case 'm':
|
||||||
if (!CHKw(w, View_MEMORY))
|
if (!CHKw(w, View_MEMORY))
|
||||||
SETw(w, View_MEMORY);
|
SETw(w, View_MEMORY);
|
||||||
else if (++Rc.graph_mems > 2) {
|
else if (++w->rc.graph_mems > 2) {
|
||||||
Rc.graph_mems = 0;;
|
w->rc.graph_mems = 0;;
|
||||||
OFFw(w, View_MEMORY);
|
OFFw(w, View_MEMORY);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if (!CHKw(w, View_STATES))
|
if (!CHKw(w, View_STATES))
|
||||||
SETw(w, View_STATES);
|
SETw(w, View_STATES);
|
||||||
else if (++Rc.graph_cpus > 2) {
|
else if (++w->rc.graph_cpus > 2) {
|
||||||
Rc.graph_cpus = 0;;
|
w->rc.graph_cpus = 0;;
|
||||||
OFFw(w, View_STATES);
|
OFFw(w, View_STATES);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -5080,7 +5082,7 @@ static void summary_hlp (CPU_t *cpu, const char *pfx) {
|
|||||||
|
|
||||||
/* display some kinda' cpu state percentages
|
/* display some kinda' cpu state percentages
|
||||||
(who or what is explained by the passed prefix) */
|
(who or what is explained by the passed prefix) */
|
||||||
if (Rc.graph_cpus) {
|
if (Curwin->rc.graph_cpus) {
|
||||||
static struct {
|
static struct {
|
||||||
const char *user, *syst, *type;
|
const char *user, *syst, *type;
|
||||||
} gtab[] = {
|
} gtab[] = {
|
||||||
@ -5088,7 +5090,7 @@ static void summary_hlp (CPU_t *cpu, const char *pfx) {
|
|||||||
{ "%-.*s~4", "%-.*s~6", Graph_blks }
|
{ "%-.*s~4", "%-.*s~6", Graph_blks }
|
||||||
};
|
};
|
||||||
char user[SMLBUFSIZ], syst[SMLBUFSIZ], dual[MEDBUFSIZ];
|
char user[SMLBUFSIZ], syst[SMLBUFSIZ], dual[MEDBUFSIZ];
|
||||||
int ix = Rc.graph_cpus - 1;
|
int ix = Curwin->rc.graph_cpus - 1;
|
||||||
float pct_user = (float)(u_frme + n_frme) * scale,
|
float pct_user = (float)(u_frme + n_frme) * scale,
|
||||||
pct_syst = (float)s_frme * scale;
|
pct_syst = (float)s_frme * scale;
|
||||||
snprintf(user, sizeof(user), gtab[ix].user, (int)((pct_user * Graph_adj) + .5), gtab[ix].type);
|
snprintf(user, sizeof(user), gtab[ix].user, (int)((pct_user * Graph_adj) + .5), gtab[ix].type);
|
||||||
@ -5231,7 +5233,7 @@ numa_nope:
|
|||||||
}
|
}
|
||||||
kb_main_my_used = kb_main_used - kb_main_buffers - kb_main_cached;
|
kb_main_my_used = kb_main_used - kb_main_buffers - kb_main_cached;
|
||||||
|
|
||||||
if (Rc.graph_mems) {
|
if (w->rc.graph_mems) {
|
||||||
static struct {
|
static struct {
|
||||||
const char *used, *misc, *swap, *type;
|
const char *used, *misc, *swap, *type;
|
||||||
} gtab[] = {
|
} gtab[] = {
|
||||||
@ -5239,7 +5241,7 @@ numa_nope:
|
|||||||
{ "%-.*s~4", "%-.*s~6", "%-.*s~6", Graph_blks }
|
{ "%-.*s~4", "%-.*s~6", "%-.*s~6", Graph_blks }
|
||||||
};
|
};
|
||||||
char used[SMLBUFSIZ], util[SMLBUFSIZ], dual[MEDBUFSIZ];
|
char used[SMLBUFSIZ], util[SMLBUFSIZ], dual[MEDBUFSIZ];
|
||||||
int ix = Rc.graph_mems - 1;
|
int ix = w->rc.graph_mems - 1;
|
||||||
float pct_used = (float)kb_main_my_used * (100.0 / (float)kb_main_total),
|
float pct_used = (float)kb_main_my_used * (100.0 / (float)kb_main_total),
|
||||||
pct_misc = (float)(kb_main_buffers + kb_main_cached) * (100.0 / (float)kb_main_total),
|
pct_misc = (float)(kb_main_buffers + kb_main_cached) * (100.0 / (float)kb_main_total),
|
||||||
pct_swap = (float)kb_swap_used * (100.0 / (float)kb_swap_total);
|
pct_swap = (float)kb_swap_used * (100.0 / (float)kb_swap_total);
|
||||||
|
24
top/top.h
24
top/top.h
@ -343,15 +343,17 @@ enum warn_enum {
|
|||||||
|
|
||||||
/* This type helps support both a window AND the rcfile */
|
/* This type helps support both a window AND the rcfile */
|
||||||
typedef struct RCW_t { // the 'window' portion of an rcfile
|
typedef struct RCW_t { // the 'window' portion of an rcfile
|
||||||
int sortindx, // sort field, represented as a procflag
|
int sortindx, // sort field (represented as procflag)
|
||||||
winflags, // 'view', 'show' and 'sort' mode flags
|
winflags, // 'view', 'show' and 'sort' mode flags
|
||||||
maxtasks, // user requested maximum, 0 equals all
|
maxtasks, // user requested maximum, 0 equals all
|
||||||
summclr, // color num used in summ info
|
graph_cpus, // 't' - View_STATES supplementary vals
|
||||||
|
graph_mems, // 'm' - View_MEMORY supplememtary vals
|
||||||
|
summclr, // a colors 'number' used for summ info
|
||||||
msgsclr, // " in msgs/pmts
|
msgsclr, // " in msgs/pmts
|
||||||
headclr, // " in cols head
|
headclr, // " in cols head
|
||||||
taskclr; // " in task rows
|
taskclr; // " in task rows
|
||||||
char winname [WINNAMSIZ], // window name, user changeable
|
char winname [WINNAMSIZ], // name for the window, user changeable
|
||||||
fieldscur [PFLAGSSIZ]; // fields displayed and ordered
|
fieldscur [PFLAGSSIZ]; // the fields for display & their order
|
||||||
} RCW_t;
|
} RCW_t;
|
||||||
|
|
||||||
/* This represents the complete rcfile */
|
/* This represents the complete rcfile */
|
||||||
@ -366,8 +368,6 @@ typedef struct RCF_t {
|
|||||||
int summ_mscale; // 'E' - scaling of summary memory values
|
int summ_mscale; // 'E' - scaling of summary memory values
|
||||||
int task_mscale; // 'e' - scaling of process memory values
|
int task_mscale; // 'e' - scaling of process memory values
|
||||||
int zero_suppress; // '0' - suppress scaled zeros toggle
|
int zero_suppress; // '0' - suppress scaled zeros toggle
|
||||||
int graph_cpus; // 't' - View_STATES supplementary values
|
|
||||||
int graph_mems; // 'm' - View_MEMORY supplememtary values
|
|
||||||
} RCF_t;
|
} RCF_t;
|
||||||
|
|
||||||
/* This structure stores configurable information for each window.
|
/* This structure stores configurable information for each window.
|
||||||
@ -569,7 +569,7 @@ typedef struct WIN_t {
|
|||||||
/* Configuration files support */
|
/* Configuration files support */
|
||||||
#define SYS_RCFILESPEC "/etc/toprc"
|
#define SYS_RCFILESPEC "/etc/toprc"
|
||||||
#define RCF_EYECATCHER "Config File (Linux processes with windows)\n"
|
#define RCF_EYECATCHER "Config File (Linux processes with windows)\n"
|
||||||
#define RCF_VERSION_ID 'h'
|
#define RCF_VERSION_ID 'i'
|
||||||
#define RCF_PLUS_H "\\]^_`abcdefghij"
|
#define RCF_PLUS_H "\\]^_`abcdefghij"
|
||||||
|
|
||||||
/* The default fields displayed and their order, if nothing is
|
/* The default fields displayed and their order, if nothing is
|
||||||
@ -600,19 +600,19 @@ typedef struct WIN_t {
|
|||||||
/* The default values for the local config file */
|
/* The default values for the local config file */
|
||||||
#define DEF_RCFILE { \
|
#define DEF_RCFILE { \
|
||||||
RCF_VERSION_ID, 0, 1, DEF_DELAY, 0, { \
|
RCF_VERSION_ID, 0, 1, DEF_DELAY, 0, { \
|
||||||
{ EU_CPU, DEF_WINFLGS, 0, \
|
{ EU_CPU, DEF_WINFLGS, 0, 0, 0, \
|
||||||
COLOR_RED, COLOR_RED, COLOR_YELLOW, COLOR_RED, \
|
COLOR_RED, COLOR_RED, COLOR_YELLOW, COLOR_RED, \
|
||||||
"Def", DEF_FIELDS }, \
|
"Def", DEF_FIELDS }, \
|
||||||
{ EU_PID, DEF_WINFLGS, 0, \
|
{ EU_PID, DEF_WINFLGS, 0, 0, 0, \
|
||||||
COLOR_CYAN, COLOR_CYAN, COLOR_WHITE, COLOR_CYAN, \
|
COLOR_CYAN, COLOR_CYAN, COLOR_WHITE, COLOR_CYAN, \
|
||||||
"Job", JOB_FIELDS }, \
|
"Job", JOB_FIELDS }, \
|
||||||
{ EU_MEM, DEF_WINFLGS, 0, \
|
{ EU_MEM, DEF_WINFLGS, 0, 0, 0, \
|
||||||
COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLUE, COLOR_MAGENTA, \
|
COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLUE, COLOR_MAGENTA, \
|
||||||
"Mem", MEM_FIELDS }, \
|
"Mem", MEM_FIELDS }, \
|
||||||
{ EU_UEN, DEF_WINFLGS, 0, \
|
{ EU_UEN, DEF_WINFLGS, 0, 0, 0, \
|
||||||
COLOR_YELLOW, COLOR_YELLOW, COLOR_GREEN, COLOR_YELLOW, \
|
COLOR_YELLOW, COLOR_YELLOW, COLOR_GREEN, COLOR_YELLOW, \
|
||||||
"Usr", USR_FIELDS } \
|
"Usr", USR_FIELDS } \
|
||||||
}, 0, SK_Kb, SK_Kb, 0, 0, 0 }
|
}, 0, SK_Kb, SK_Kb, 0 }
|
||||||
|
|
||||||
/* Summary Lines specially formatted string(s) --
|
/* Summary Lines specially formatted string(s) --
|
||||||
see 'show_special' for syntax details + other cautions. */
|
see 'show_special' for syntax details + other cautions. */
|
||||||
|
Loading…
Reference in New Issue
Block a user