summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Warner <james.warner@comcast.net>2012-09-20 01:01:01 -0500
committerCraig Small <csmall@enc.com.au>2012-10-02 20:56:40 +1000
commitc07be1d4925f627446cd28b73317f4c0c6641643 (patch)
treed005023fd424b57aa1c87ae4523a6b8f0e721363
parent0f61354bf758001bf49650cf970274981614e758 (diff)
downloadprocps-ng-c07be1d4925f627446cd28b73317f4c0c6641643.tar.gz
top: column alignment under user control
This commit affords user control over justification for both column headings and the subordinate data. Separate toggles are provided for control of numeric data and string data. Signed-off-by: Jim Warner <james.warner@comcast.net>
-rw-r--r--top/top.c44
-rw-r--r--top/top.h7
-rw-r--r--top/top_nls.c4
3 files changed, 35 insertions, 20 deletions
diff --git a/top/top.c b/top/top.c
index 0a0503d..3c4e604 100644
--- a/top/top.c
+++ b/top/top.c
@@ -1329,9 +1329,10 @@ end_justifies:
static FLD_t Fieldstab[] = {
// a temporary macro, soon to be undef'd...
#define SF(f) (QFP_t)SCB_NAME(f)
- // these identifiers reflect the default column alignment
- #define A_right 1
- #define A_left 0
+ // these identifiers reflect the default column alignment but they really
+ // contain the WIN_t flag used to check/change justification at run-time!
+ #define A_right Show_JRNUMS /* toggled with upper case 'J' */
+ #define A_left Show_JRSTRS /* toggled with lower case 'j' */
/* .width anomalies:
entries with a -1 .width represent variable width columns
@@ -2437,17 +2438,20 @@ static void configs_read (void) {
, &w->rc.headclr, &w->rc.taskclr))
goto default_or_error;
- if (RCF_VERSION_ID != Rc.id) {
- if (config_cvt(w))
- goto default_or_error;
- } else {
- if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1)
- goto default_or_error;
- for (x = 0; x < P_MAXPFLGS; ++x) {
- int f = FLDget(w, x);
- if (P_MAXPFLGS <= f)
+ switch (Rc.id) {
+ case 'f': // 3.3.0 thru 3.3.3 (procps-ng)
+ SETw(w, Show_JRNUMS); // fall through !
+ case 'g': // current RCF_VERSION_ID
+ if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1)
goto default_or_error;
- }
+ for (x = 0; x < P_MAXPFLGS; ++x)
+ if (P_MAXPFLGS <= FLDget(w, x))
+ goto default_or_error;
+ break;
+ default: // 3.2.8 (former procps)
+ if (config_cvt(w))
+ goto default_or_error;
+ break;
}
} // end: for (GROUPSMAX)
@@ -3211,6 +3215,12 @@ static void keys_task (int ch) {
case 'i':
VIZTOGw(w, Show_IDLEPS);
break;
+ case 'J':
+ VIZTOGw(w, Show_JRNUMS);
+ break;
+ case 'j':
+ VIZTOGw(w, Show_JRSTRS);
+ break;
case 'R':
#ifdef TREE_NORESET
if (!CHKw(w, Show_FOREST)) VIZTOGw(w, Qsrt_NORMAL);
@@ -3561,7 +3571,7 @@ static void do_key (int ch) {
{ keys_summary,
{ '1', 'C', 'l', 'm', 't', '\0' } },
{ keys_task,
- { '#', '<', '>', 'b', 'c', 'i', 'n', 'R', 'S'
+ { '#', '<', '>', 'b', 'c', 'i', 'J', 'j', 'n', 'R', 'S'
, 'U', 'u', 'V', 'x', 'y', 'z', '\0' } },
{ keys_window,
{ '+', '-', '=', '_', '&', 'A', 'a', 'G', 'L', 'w'
@@ -3599,6 +3609,8 @@ static void do_key (int ch) {
'g' - likely
'H' - likely
'I' - likely
+ 'J' - always
+ 'j' - always
'Z' - likely, if 'Curwin' changed when !Mode_altscr
'-' - likely (restricted to Mode_altscr)
'_' - likely (restricted to Mode_altscr)
@@ -3757,8 +3769,8 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
FLG_t i = q->procflgs[x];
#define S Fieldstab[i].scale
#define W Fieldstab[i].width
- #define Js 0 // left justify string data
- #define Jn 1 // right justify numeric data
+ #define Js CHKw(q, Show_JRSTRS)
+ #define Jn CHKw(q, Show_JRNUMS)
switch (i) {
#ifndef USE_X_COLHDR
diff --git a/top/top.h b/top/top.h
index a068a76..3b1c42e 100644
--- a/top/top.h
+++ b/top/top.h
@@ -285,13 +285,16 @@ typedef struct CPU_t {
#define Show_TASKON 0x000010 // '-' - tasks showable when Mode_altscr
#define Show_FOREST 0x000002 // 'V' - show cmd/cmdlines with ascii art
#define Qsrt_NORMAL 0x000004 // 'R' - reversed column sort (high to low)
+#define Show_JRSTRS 0x040000 // 'j' - right justify "string" data cols
+#define Show_JRNUMS 0x020000 // 'J' - right justify "numeric" data cols
// these flag(s) have no command as such - they're for internal use
#define INFINDS_xxx 0x010000 // build rows for find_string, not display
#define EQUWINS_xxx 0x000001 // rebalance all wins & tasks (off i,n,u/U)
// Default flags if there's no rcfile to provide user customizations
#define DEF_WINFLGS ( View_LOADAV | View_STATES | View_CPUSUM | View_MEMORY \
- | Show_HIBOLD | Show_HIROWS | Show_IDLEPS | Show_TASKON | Qsrt_NORMAL )
+ | Show_HIBOLD | Show_HIROWS | Show_IDLEPS | Show_TASKON | Show_JRNUMS \
+ | Qsrt_NORMAL )
/* These are used to direct wins_reflag */
enum reflag_enum {
@@ -506,7 +509,7 @@ typedef struct WIN_t {
/* Configuration files support */
#define SYS_RCFILESPEC "/etc/toprc"
#define RCF_EYECATCHER "Config File (Linux processes with windows)\n"
-#define RCF_VERSION_ID 'f'
+#define RCF_VERSION_ID 'g'
/* The default fields displayed and their order, if nothing is
specified by the loser, oops user.
diff --git a/top/top_nls.c b/top/top_nls.c
index 6c17b8b..f4a1087 100644
--- a/top/top_nls.c
+++ b/top/top_nls.c
@@ -413,8 +413,8 @@ static void build_uniq_nlstab (void) {
" f,F Manage Fields: add/remove; change order; select sort field\n"
"\n"
" L,&,<,> . Locate: '~1L~2'/'~1&~2' find/again; Move sort column: '~1<~2'/'~1>~2' left/right\n" \
- " R,H,V . Toggle: '~1R~2' norm/rev sort; '~1H~2' show threads; '~1V~2' forest view\n"
- " c,i,S . Toggle: '~1c~2' cmd name/line; '~1i~2' idle tasks; '~1S~2' cumulative time\n"
+ " R,H,V,J . Toggle: '~1R~2' Sort; '~1H~2' Threads; '~1V~2' Forest view; '~1J~2' Num justify\n"
+ " c,i,S,j . Toggle: '~1c~2' Cmd name/line; '~1i~2' Idle; '~1S~2' Time; '~1j~2' Str justify\n"
" x~5,~1y~5 . Toggle highlights: '~1x~2' sort field; '~1y~2' running tasks\n"
" z~5,~1b~5 . Toggle: '~1z~2' color/mono; '~1b~2' bold/reverse (only if 'x' or 'y')\n"
" u,U . Show: '~1u~2' effective user; '~1U~2' real, saved, file or effective user\n"