#define OSEL_FILTER "filter="
static const char Osel_filterO_fmt[] = "\ttype=%d,\t" OSEL_FILTER "%s\n";
static const char Osel_filterI_fmt[] = "\ttype=%d,\t" OSEL_FILTER "%*s\n";
+
+ /* Support for 2 abreast Cpu display (if terminal is wide enough) */
+static char Double_sp[] = " ";
+#define DOUBLE_space (sizeof(Double_sp) - 1)
+#define DOUBLE_limit (160 + DOUBLE_space)
\f
/*###### Sort callbacks ################################################*/
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) {
+ Graph_len = (Screen_cols - DOUBLE_space - (2 * (GRAPH_prefix + + GRAPH_suffix))) / 2;
+ if (Graph_len > GRAPH_actual) Graph_len = GRAPH_actual;
+ }
Graph_adj = (float)Graph_len / 100.0;
fflush(stdout);
else TOGw(w, View_CPUSUM);
OFFw(w, View_CPUNOD);
SETw(w, View_STATES);
+ w->double_up = 0;
break;
case '2':
if (!Numa_node_tot)
if (!CHKw(w, View_CPUNOD)) SETw(w, View_CPUSUM);
SETw(w, View_STATES);
Numa_node_sel = -1;
+ w->double_up = 0;
}
break;
case '3':
Numa_node_sel = num;
SETw(w, View_CPUNOD | View_STATES);
OFFw(w, View_CPUSUM);
+ w->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) {
+ show_msg(N_txt(XTRA_size2up_txt));
+ w->double_up = 0;
+ break;
+ }
+#ifdef TOG4_NOFORCE
+ if (CHKw(w, (View_CPUSUM | View_CPUNOD)))
+ w->double_up = 0;
+#else
+ if (w->double_up)
+ OFFw(w, (View_CPUSUM | View_CPUNOD));
+#endif
+ break;
case 'C':
VIZTOGw(w, View_SCROLL);
break;
, 'I', 'k', 'r', 's', 'X', 'Y', 'Z', '0'
, kbd_ENTER, kbd_SPACE, '\0' } },
{ keys_summary,
- { '1', '2', '3', 'C', 'l', 'm', 't', '\0' } },
+ { '1', '2', '3', '4', 'C', 'l', 'm', 't', '\0' } },
{ keys_task,
{ '#', '<', '>', 'b', 'c', 'i', 'J', 'j', 'n', 'O', 'o'
, 'R', 'S', 'U', 'u', 'V', 'v', 'x', 'y', 'z'
} // end: do_key
+ /*
+ * Cpu *Helper* function to combine and or show the state
+ * percentages for 1 cpu or 2 adjacent cpus (one single line). */
+static inline int sum_cpu (const char *str, int nobuf) {
+ static char row[ROWMINSIZ];
+ static int tog;
+ char *p;
+
+ p = scat(row, str);
+ if (nobuf || !Curwin->double_up)
+ goto flush_it;
+ if (!tog) {
+ scat(p, Double_sp);
+ tog = 1;
+ return 0;
+ }
+flush_it:
+ scat(p, "\n");
+ show_special(0, row);
+ row[0] = '\0';
+ tog = 0;
+ return 1;
+} // end: sum_cpu
+
+
/*
* State display *Helper* function to calc and display the state
* percentages for a single cpu. In this way, we can support
* 2) modest smp boxes with room for each cpu's percentages
* 3) massive smp guys leaving little or no room for process
* display and thus requiring the cpu summary toggle */
-static void summary_hlp (CPU_t *cpu, const char *pfx) {
+static int summary_hlp (CPU_t *cpu, const char *pfx, int nobuf) {
/* we'll trim to zero if we get negative time ticks,
which has happened with some SMP kernels (pre-2.4?)
and when cpus are dynamically added or removed */
// user syst nice idle wait hirg sirq steal
SIC_t u_frme, s_frme, n_frme, i_frme, w_frme, x_frme, y_frme, z_frme, tot_frme, tz;
float scale;
+ int n;
u_frme = TRIMz(cpu->cur.u - cpu->sav.u);
s_frme = TRIMz(cpu->cur.s - cpu->sav.s);
snprintf(syst, sizeof(syst), gtab[ix].syst, (int)((pct_syst * Graph_adj) + .4), gtab[ix].type);
#endif
snprintf(dual, sizeof(dual), "%s%s", user, syst);
- show_special(0, fmtmk("%%%s ~3%#5.1f~2/%-#5.1f~3 %3.0f[~1%-*s]~1\n"
- , pfx, pct_user, pct_syst, pct_user + pct_syst, Graph_len +4, dual));
+ n = sum_cpu(fmtmk("%%%s ~3%#5.1f~2/%-#5.1f~3 %3.0f[~1%-*s]~1"
+ , pfx, pct_user, pct_syst, pct_user + pct_syst, Graph_len +4, dual), nobuf);
} else {
- show_special(0, fmtmk(Cpu_States_fmts, pfx
+ n = sum_cpu(fmtmk(Cpu_States_fmts, pfx
, (float)u_frme * scale, (float)s_frme * scale
, (float)n_frme * scale, (float)i_frme * scale
, (float)w_frme * scale, (float)x_frme * scale
- , (float)y_frme * scale, (float)z_frme * scale));
+ , (float)y_frme * scale, (float)z_frme * scale), nobuf);
}
+ return n;
#undef TRIMz
} // end: summary_hlp
if (CHKw(w, View_CPUNOD)) {
if (Numa_node_sel < 0) {
// display the 1st /proc/stat line, then the nodes (if room)
- summary_hlp(&Cpu_tics[smp_num_cpus], N_txt(WORD_allcpus_txt));
- Msg_row += 1;
+ Msg_row += summary_hlp(&Cpu_tics[smp_num_cpus], N_txt(WORD_allcpus_txt), 1);
// display each cpu node's states
for (i = 0; i < Numa_node_tot; i++) {
CPU_t *nod_ptr = &Cpu_tics[1 + smp_num_cpus + i];
if (nod_ptr->id) {
#endif
snprintf(tmp, sizeof(tmp), N_fmt(NUMA_nodenam_fmt), i);
- summary_hlp(nod_ptr, tmp);
- Msg_row += 1;
+ Msg_row += summary_hlp(nod_ptr, tmp, 1);
#ifndef OFF_NUMASKIP
}
#endif
} else {
// display the node summary, then the associated cpus (if room)
snprintf(tmp, sizeof(tmp), N_fmt(NUMA_nodenam_fmt), Numa_node_sel);
- summary_hlp(&Cpu_tics[1 + smp_num_cpus + Numa_node_sel], tmp);
- Msg_row += 1;
+ Msg_row += summary_hlp(&Cpu_tics[1 + smp_num_cpus + Numa_node_sel], tmp, 1);
for (i = 0; i < Cpu_faux_tot; i++) {
if (Numa_node_sel == Cpu_tics[i].node) {
if (!isROOM(anyFLG, 1)) break;
snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), Cpu_tics[i].id);
- summary_hlp(&Cpu_tics[i], tmp);
- Msg_row += 1;
+ Msg_row += summary_hlp(&Cpu_tics[i], tmp, 1);
}
}
}
numa_nope:
if (CHKw(w, View_CPUSUM)) {
// display just the 1st /proc/stat line
- summary_hlp(&Cpu_tics[smp_num_cpus], N_txt(WORD_allcpus_txt));
- Msg_row += 1;
-
+ Msg_row += summary_hlp(&Cpu_tics[smp_num_cpus], N_txt(WORD_allcpus_txt), 1);
} else {
// display each cpu's states separately, screen height permitting...
for (i = 0; i < Cpu_faux_tot; i++) {
snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), Cpu_tics[i].id);
- summary_hlp(&Cpu_tics[i], tmp);
- Msg_row += 1;
+ Msg_row += summary_hlp(&Cpu_tics[i], tmp, (i+1 >= Cpu_faux_tot));
if (!isROOM(anyFLG, 1)) break;
}
}
Norm_nlstab[WORD_abv_swp_txt] = _("Swap");
Norm_nlstab[BAD_memscale_fmt] = _("bad memory scaling arg '%c'");
Norm_nlstab[XTRA_vforest_fmt] = _("PID to collapse/expand [default pid = %d]");
+ Norm_nlstab[XTRA_size2up_txt] = _("terminal is not wide enough");
}
"Window ~1%s~6: ~1Cumulative mode ~3%s~2. ~1System~6: ~1Delay ~3%.1f secs~2; ~1Secure mode ~3%s~2.\n"
"\n"
" Z~5,~1B~5,E,e Global: '~1Z~2' colors; '~1B~2' bold; '~1E~2'/'~1e~2' summary/task memory scale\n"
- " l,t,m Toggle Summary: '~1l~2' load avg; '~1t~2' task/cpu stats; '~1m~2' memory info\n"
- " 0,1,2,3,I Toggle: '~10~2' zeros; '~11~2/~12~2/~13~2' cpus or numa node views; '~1I~2' Irix mode\n"
+ " l,t,m,I Toggle: '~1l~2' load avg; '~1t~2' task/cpu; '~1m~2' memory; '~1I~2' Irix mode\n"
+ " 0,1,2,3,4 Toggle: '~10~2' zeros; '~11~2/~12~2/~13~2' cpu/numa views; '~14~2' cpus two abreast\n"
" f,F,X Fields: '~1f~2'/'~1F~2' add/remove/order/sort; '~1X~2' increase fixed-width\n"
"\n"
" L,&,<,> . Locate: '~1L~2'/'~1&~2' find/again; Move sort column: '~1<~2'/'~1>~2' left/right\n"
" %3u ~2total,~3 %3u ~2running,~3 %3u ~2sleeping,~3 %3u ~2stopped,~3 %3u ~2zombie~3\n");
Uniq_nlstab[STATE_lin2x4_fmt] = _("%%%s~3"
- " %#5.1f ~2user,~3 %#5.1f ~2system,~3 %#5.1f ~2nice,~3 %#5.1f ~2idle~3\n");
+ " %#5.1f ~2user,~3 %#5.1f ~2system,~3 %#5.1f ~2nice,~3 %#5.1f ~2idle~3");
Uniq_nlstab[STATE_lin2x5_fmt] = _("%%%s~3"
- " %#5.1f ~2user,~3 %#5.1f ~2system,~3 %#5.1f ~2nice,~3 %#5.1f ~2idle,~3 %#5.1f ~2IO-wait~3\n");
+ " %#5.1f ~2user,~3 %#5.1f ~2system,~3 %#5.1f ~2nice,~3 %#5.1f ~2idle,~3 %#5.1f ~2IO-wait~3");
/* Translation Hint: Only the following abbreviations need be translated
. us = user, sy = system, ni = nice, id = idle, wa = wait,
. hi hardware interrupt, si = software interrupt */
Uniq_nlstab[STATE_lin2x6_fmt] = _("%%%s~3"
- " %#5.1f ~2us,~3 %#5.1f ~2sy,~3 %#5.1f ~2ni,~3 %#5.1f ~2id,~3 %#5.1f ~2wa,~3 %#5.1f ~2hi,~3 %#5.1f ~2si~3\n");
+ " %#5.1f ~2us,~3 %#5.1f ~2sy,~3 %#5.1f ~2ni,~3 %#5.1f ~2id,~3 %#5.1f ~2wa,~3 %#5.1f ~2hi,~3 %#5.1f ~2si~3");
/* Translation Hint: Only the following abbreviations need be translated
. us = user, sy = system, ni = nice, id = idle, wa = wait,
. hi hardware interrupt, si = software interrupt, st = steal time */
Uniq_nlstab[STATE_lin2x7_fmt] = _("%%%s~3"
- "%#5.1f ~2us,~3%#5.1f ~2sy,~3%#5.1f ~2ni,~3%#5.1f ~2id,~3%#5.1f ~2wa,~3%#5.1f ~2hi,~3%#5.1f ~2si,~3%#5.1f ~2st~3\n");
+ "%#5.1f ~2us,~3%#5.1f ~2sy,~3%#5.1f ~2ni,~3%#5.1f ~2id,~3%#5.1f ~2wa,~3%#5.1f ~2hi,~3%#5.1f ~2si,~3%#5.1f ~2st~3");
/* Translation Hint: this must be translated as 2 lines with words above & below aligned */
Uniq_nlstab[MEMORY_lines_fmt] = _(""