top: preserved those new '4' and '!' toggles in rcfile
This patch will address Craig's feedback regarding the original implementation of top's two new toggles. It's likely other users would have questioned why they were not saved also, once they discover these new features. And, since the minimum terminal width was just lowered to 80 columns, the default for window #1 is also being changed to show the individual cpu graphs two abreast. [ assuming no '--disable-modern-top' for ./configure ] Reference(s): https://gitlab.com/procps-ng/procps/-/issues/172 https://www.freelists.org/post/procps/two-major-changes-to-top,1 Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
98ae31584b
commit
b46af6d213
@ -2228,7 +2228,7 @@ While not intended to be edited manually, here is the general layout:
|
||||
global # line 1: the program name/alias notation
|
||||
" # line 2: id,altscr,irixps,delay,curwin
|
||||
per ea # line a: winname,fieldscur
|
||||
window # line b: winflags,sortindx,maxtasks,graph modes
|
||||
window # line b: winflags,sortindx,maxtasks,etc
|
||||
" # line c: summclr,msgsclr,headclr,taskclr
|
||||
global # line 15: additional miscellaneous settings
|
||||
" # any remaining lines are devoted to optional
|
||||
|
59
top/top.c
59
top/top.c
@ -1777,8 +1777,8 @@ static void adj_geometry (void) {
|
||||
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->double_up = 0;
|
||||
if (Curwin->double_up) {
|
||||
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;
|
||||
if (Graph_len > GRAPH_actual) Graph_len = GRAPH_actual;
|
||||
}
|
||||
@ -3543,8 +3543,10 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) {
|
||||
#error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
|
||||
#endif
|
||||
// be tolerant of missing release 3.3.10 graph modes additions
|
||||
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))
|
||||
if (3 > fscanf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d, graph_cpus=%d, graph_mems=%d"
|
||||
", double_up=%d, combine_cpus=%d\n"
|
||||
, &w->rc.winflags, &w->rc.sortindx, &w->rc.maxtasks, &w->rc.graph_cpus, &w->rc.graph_mems
|
||||
, &w->rc.double_up, &w->rc.combine_cpus))
|
||||
return p;
|
||||
if (w->rc.sortindx < 0 || w->rc.sortindx >= EU_MAXPFLGS)
|
||||
return p;
|
||||
@ -3554,6 +3556,11 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) {
|
||||
return p;
|
||||
if (w->rc.graph_mems < 0 || w->rc.graph_mems > 2)
|
||||
return p;
|
||||
if (w->rc.double_up < 0 || w->rc.double_up > 1)
|
||||
return p;
|
||||
// can't check upper bounds until Cpu_cnt is known
|
||||
if (w->rc.combine_cpus < 0)
|
||||
return p;
|
||||
|
||||
if (4 != fscanf(fp, "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n"
|
||||
, &w->rc.summclr, &w->rc.msgsclr, &w->rc.headclr, &w->rc.taskclr))
|
||||
@ -3580,10 +3587,10 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) {
|
||||
// these next 2 are really global, but best documented here
|
||||
Rc.summ_mscale = Rc.task_mscale = SK_Kb;
|
||||
// fall through
|
||||
case 'i': // actual RCF_VERSION_ID
|
||||
case 'i': // from 3.3.10 thru 3.3.16
|
||||
scat(w->rc.fieldscur, RCF_PLUS_J);
|
||||
// fall through
|
||||
case 'j': // and the next version
|
||||
case 'j': // current RCF_VERSION_ID
|
||||
default:
|
||||
if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1)
|
||||
return p;
|
||||
@ -3657,7 +3664,7 @@ static int configs_path (const char *const fmts, ...) {
|
||||
* line 2 : an id, Mode_altcsr, Mode_irixps, Delay_time, Curwin.
|
||||
* For each of the 4 windows:
|
||||
* line a: contains w->winname, fieldscur
|
||||
* line b: contains w->winflags, sortindx, maxtasks, graph modes
|
||||
* line b: contains w->winflags, sortindx, maxtasks, etc
|
||||
* line c: contains w->summclr, msgsclr, headclr, taskclr
|
||||
* line 15 : miscellaneous additional global settings
|
||||
* Any remaining lines are devoted to the optional entries
|
||||
@ -4014,7 +4021,7 @@ static void win_reset (WIN_t *q) {
|
||||
// NOHISEL_xxx is redundant (already turned off by osel_clear)
|
||||
OFFw(q, NOHIFND_xxx | NOHISEL_xxx);
|
||||
#endif
|
||||
q->combine_cpus = 0;
|
||||
q->rc.combine_cpus = 0;
|
||||
} // end: win_reset
|
||||
|
||||
|
||||
@ -4261,6 +4268,8 @@ static void wins_stage_2 (void) {
|
||||
capsmk(&Winstk[i]);
|
||||
Winstk[i].findstr = alloc_c(FNDBUFSIZ);
|
||||
Winstk[i].findlen = 0;
|
||||
if (Winstk[i].rc.combine_cpus >= Cpu_cnt)
|
||||
Winstk[i].rc.combine_cpus = 0;
|
||||
}
|
||||
if (!Batch)
|
||||
putp((Cursor_state = Cap_curs_hide));
|
||||
@ -4664,9 +4673,11 @@ static void write_rcfile (void) {
|
||||
for (i = 0 ; i < GROUPSMAX; i++) {
|
||||
fprintf(fp, "%s\tfieldscur=%s\n"
|
||||
, Winstk[i].rc.winname, Winstk[i].rc.fieldscur);
|
||||
fprintf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d, graph_cpus=%d, graph_mems=%d\n"
|
||||
fprintf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d, graph_cpus=%d, graph_mems=%d"
|
||||
", double_up=%d, combine_cpus=%d\n"
|
||||
, Winstk[i].rc.winflags, Winstk[i].rc.sortindx, Winstk[i].rc.maxtasks
|
||||
, Winstk[i].rc.graph_cpus, Winstk[i].rc.graph_mems);
|
||||
, Winstk[i].rc.graph_cpus, Winstk[i].rc.graph_mems
|
||||
, Winstk[i].rc.double_up, Winstk[i].rc.combine_cpus);
|
||||
fprintf(fp, "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n"
|
||||
, Winstk[i].rc.summclr, Winstk[i].rc.msgsclr
|
||||
, Winstk[i].rc.headclr, Winstk[i].rc.taskclr);
|
||||
@ -4840,9 +4851,9 @@ static void keys_summary (int ch) {
|
||||
if (CHKw(w, View_CPUSUM) || CHKw(w, View_CPUNOD))
|
||||
show_msg(N_txt(XTRA_modebad_txt));
|
||||
else {
|
||||
if (!w->combine_cpus) w->combine_cpus = 1;
|
||||
else w->combine_cpus *= 2;
|
||||
if (w->combine_cpus >= Cpu_cnt) w->combine_cpus = 0;
|
||||
if (!w->rc.combine_cpus) w->rc.combine_cpus = 1;
|
||||
else w->rc.combine_cpus *= 2;
|
||||
if (w->rc.combine_cpus >= Cpu_cnt) w->rc.combine_cpus = 0;
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
@ -4850,7 +4861,7 @@ static void keys_summary (int ch) {
|
||||
else TOGw(w, View_CPUSUM);
|
||||
OFFw(w, View_CPUNOD);
|
||||
SETw(w, View_STATES);
|
||||
w->double_up = 0;
|
||||
w->rc.double_up = 0;
|
||||
break;
|
||||
case '2':
|
||||
if (!Numa_node_tot)
|
||||
@ -4860,7 +4871,7 @@ static void keys_summary (int ch) {
|
||||
if (!CHKw(w, View_CPUNOD)) SETw(w, View_CPUSUM);
|
||||
SETw(w, View_STATES);
|
||||
Numa_node_sel = -1;
|
||||
w->double_up = 0;
|
||||
w->rc.double_up = 0;
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
@ -4873,24 +4884,24 @@ static void keys_summary (int ch) {
|
||||
Numa_node_sel = num;
|
||||
SETw(w, View_CPUNOD | View_STATES);
|
||||
OFFw(w, View_CPUSUM);
|
||||
w->double_up = 0;
|
||||
w->rc.double_up = 0;
|
||||
} else
|
||||
show_msg(N_txt(NUMA_nodebad_txt));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
w->double_up = !w->double_up;
|
||||
if (w->double_up && Screen_cols < DOUBLE_limit) {
|
||||
w->rc.double_up = !w->rc.double_up;
|
||||
if (w->rc.double_up && Screen_cols < DOUBLE_limit) {
|
||||
show_msg(N_txt(XTRA_size2up_txt));
|
||||
w->double_up = 0;
|
||||
w->rc.double_up = 0;
|
||||
break;
|
||||
}
|
||||
#ifdef TOG4_NOFORCE
|
||||
if (CHKw(w, (View_CPUSUM | View_CPUNOD)))
|
||||
w->double_up = 0;
|
||||
w->rc.double_up = 0;
|
||||
#else
|
||||
if (w->double_up)
|
||||
if (w->rc.double_up)
|
||||
OFFw(w, (View_CPUSUM | View_CPUNOD));
|
||||
#endif
|
||||
break;
|
||||
@ -5305,7 +5316,7 @@ static inline int cpu_prt (const char *str, int nobuf) {
|
||||
char *p;
|
||||
|
||||
p = scat(row, str);
|
||||
if (nobuf || !Curwin->double_up)
|
||||
if (nobuf || !Curwin->rc.double_up)
|
||||
goto flush_it;
|
||||
if (!tog) {
|
||||
scat(p, Double_sp);
|
||||
@ -5405,7 +5416,7 @@ static int cpu_unify (struct stat_stack *this, int nobuf) {
|
||||
stack[stat_SUM_TOT].result.sl_int += rSv(stat_SUM_TOT, sl_int);
|
||||
|
||||
if (!ix) beg = rSv(stat_ID, s_int);
|
||||
if (nobuf || ix >= Curwin->combine_cpus) {
|
||||
if (nobuf || ix >= Curwin->rc.combine_cpus) {
|
||||
snprintf(pfx, sizeof(pfx), "%-7.7s:", fmtmk("%d-%d", beg, rSv(stat_ID, s_int)));
|
||||
n = cpu_tics(&accum, pfx, nobuf);
|
||||
memset(&stack, 0, sizeof(stack));
|
||||
@ -5565,7 +5576,7 @@ numa_nope:
|
||||
Msg_row += cpu_tics(Stat_reap->summary, N_txt(WORD_allcpus_txt), 1);
|
||||
} else {
|
||||
// display each cpu's states separately, screen height permitting...
|
||||
if (w->combine_cpus) {
|
||||
if (w->rc.combine_cpus) {
|
||||
for (i = 0; i < Cpu_cnt; i++) {
|
||||
#ifdef PRETEND48CPU
|
||||
Stat_reap->summary->head[stat_ID].result.s_int = i;
|
||||
|
17
top/top.h
17
top/top.h
@ -293,6 +293,8 @@ typedef struct RCW_t { // the 'window' portion of an rcfile
|
||||
maxtasks, // user requested maximum, 0 equals all
|
||||
graph_cpus, // 't' - View_STATES supplementary vals
|
||||
graph_mems, // 'm' - View_MEMORY supplememtary vals
|
||||
double_up, // '4' - show individual cpus 2 abreast
|
||||
combine_cpus, // '!' - keep combining additional cpus
|
||||
summclr, // a colors 'number' used for summ info
|
||||
msgsclr, // " in msgs/pmts
|
||||
headclr, // " in cols head
|
||||
@ -357,8 +359,6 @@ typedef struct WIN_t {
|
||||
int osel_tot; // total of other selection criteria
|
||||
char *findstr; // window's current/active search string
|
||||
int findlen; // above's strlen, without call overhead
|
||||
int double_up; // show individual cpus 2 abreast
|
||||
int combine_cpus; // keep combining additional cpus
|
||||
struct pids_stack **ppt; // this window's stacks ptr array
|
||||
struct WIN_t *next, // next window in window stack
|
||||
*prev; // prior window in window stack
|
||||
@ -477,13 +477,8 @@ typedef struct WIN_t {
|
||||
#define SYS_RCDEFAULTS "/etc/topdefaultrc"
|
||||
#define RCF_EYECATCHER "Config File (Linux processes with windows)\n"
|
||||
#define RCF_PLUS_H "\\]^_`abcdefghij"
|
||||
#ifdef VER_J_RCFILE
|
||||
#define RCF_PLUS_J "klmnopqrstuvwxyz"
|
||||
#define RCF_VERSION_ID 'j'
|
||||
#else
|
||||
#define RCF_VERSION_ID 'i'
|
||||
#define RCF_PLUS_J ""
|
||||
#endif
|
||||
|
||||
/* The default fields displayed and their order, if nothing is
|
||||
specified by the loser, oops user.
|
||||
@ -512,16 +507,16 @@ typedef struct WIN_t {
|
||||
/* The default values for the local config file */
|
||||
#define DEF_RCFILE { \
|
||||
RCF_VERSION_ID, 0, 1, DEF_DELAY, 0, { \
|
||||
{ EU_CPU, DEF_WINFLGS, 0, DEF_GRAPHS2, \
|
||||
{ EU_CPU, DEF_WINFLGS, 0, DEF_GRAPHS2, 1, 0, \
|
||||
COLOR_RED, COLOR_RED, COLOR_YELLOW, COLOR_RED, \
|
||||
"Def", DEF_FIELDS }, \
|
||||
{ EU_PID, ALT_WINFLGS, 0, ALT_GRAPHS2, \
|
||||
{ EU_PID, ALT_WINFLGS, 0, ALT_GRAPHS2, 0, 0, \
|
||||
COLOR_CYAN, COLOR_CYAN, COLOR_WHITE, COLOR_CYAN, \
|
||||
"Job", JOB_FIELDS }, \
|
||||
{ EU_MEM, ALT_WINFLGS, 0, ALT_GRAPHS2, \
|
||||
{ EU_MEM, ALT_WINFLGS, 0, ALT_GRAPHS2, 0, 0, \
|
||||
COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLUE, COLOR_MAGENTA, \
|
||||
"Mem", MEM_FIELDS }, \
|
||||
{ EU_UEN, ALT_WINFLGS, 0, ALT_GRAPHS2, \
|
||||
{ EU_UEN, ALT_WINFLGS, 0, ALT_GRAPHS2, 0, 0, \
|
||||
COLOR_YELLOW, COLOR_YELLOW, COLOR_GREEN, COLOR_YELLOW, \
|
||||
"Usr", USR_FIELDS } \
|
||||
}, 0, DEF_SCALES2, 0 }
|
||||
|
Loading…
Reference in New Issue
Block a user