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>
This commit is contained in:
Jim Warner 2012-09-20 01:01:01 -05:00 committed by Craig Small
parent 0f61354bf7
commit c07be1d492
3 changed files with 35 additions and 20 deletions

View File

@ -1329,9 +1329,10 @@ end_justifies:
static FLD_t Fieldstab[] = { static FLD_t Fieldstab[] = {
// a temporary macro, soon to be undef'd... // a temporary macro, soon to be undef'd...
#define SF(f) (QFP_t)SCB_NAME(f) #define SF(f) (QFP_t)SCB_NAME(f)
// these identifiers reflect the default column alignment // these identifiers reflect the default column alignment but they really
#define A_right 1 // contain the WIN_t flag used to check/change justification at run-time!
#define A_left 0 #define A_right Show_JRNUMS /* toggled with upper case 'J' */
#define A_left Show_JRSTRS /* toggled with lower case 'j' */
/* .width anomalies: /* .width anomalies:
entries with a -1 .width represent variable width columns entries with a -1 .width represent variable width columns
@ -2437,17 +2438,20 @@ static void configs_read (void) {
, &w->rc.headclr, &w->rc.taskclr)) , &w->rc.headclr, &w->rc.taskclr))
goto default_or_error; goto default_or_error;
if (RCF_VERSION_ID != Rc.id) { switch (Rc.id) {
if (config_cvt(w)) case 'f': // 3.3.0 thru 3.3.3 (procps-ng)
goto default_or_error; SETw(w, Show_JRNUMS); // fall through !
} else { case 'g': // current RCF_VERSION_ID
if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1) 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)
goto default_or_error; 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) } // end: for (GROUPSMAX)
@ -3211,6 +3215,12 @@ static void keys_task (int ch) {
case 'i': case 'i':
VIZTOGw(w, Show_IDLEPS); VIZTOGw(w, Show_IDLEPS);
break; break;
case 'J':
VIZTOGw(w, Show_JRNUMS);
break;
case 'j':
VIZTOGw(w, Show_JRSTRS);
break;
case 'R': case 'R':
#ifdef TREE_NORESET #ifdef TREE_NORESET
if (!CHKw(w, Show_FOREST)) VIZTOGw(w, Qsrt_NORMAL); if (!CHKw(w, Show_FOREST)) VIZTOGw(w, Qsrt_NORMAL);
@ -3561,7 +3571,7 @@ static void do_key (int ch) {
{ keys_summary, { keys_summary,
{ '1', 'C', 'l', 'm', 't', '\0' } }, { '1', 'C', 'l', 'm', 't', '\0' } },
{ keys_task, { keys_task,
{ '#', '<', '>', 'b', 'c', 'i', 'n', 'R', 'S' { '#', '<', '>', 'b', 'c', 'i', 'J', 'j', 'n', 'R', 'S'
, 'U', 'u', 'V', 'x', 'y', 'z', '\0' } }, , 'U', 'u', 'V', 'x', 'y', 'z', '\0' } },
{ keys_window, { keys_window,
{ '+', '-', '=', '_', '&', 'A', 'a', 'G', 'L', 'w' { '+', '-', '=', '_', '&', 'A', 'a', 'G', 'L', 'w'
@ -3599,6 +3609,8 @@ static void do_key (int ch) {
'g' - likely 'g' - likely
'H' - likely 'H' - likely
'I' - likely 'I' - likely
'J' - always
'j' - always
'Z' - likely, if 'Curwin' changed when !Mode_altscr 'Z' - likely, if 'Curwin' changed when !Mode_altscr
'-' - likely (restricted to Mode_altscr) '-' - likely (restricted to 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]; FLG_t i = q->procflgs[x];
#define S Fieldstab[i].scale #define S Fieldstab[i].scale
#define W Fieldstab[i].width #define W Fieldstab[i].width
#define Js 0 // left justify string data #define Js CHKw(q, Show_JRSTRS)
#define Jn 1 // right justify numeric data #define Jn CHKw(q, Show_JRNUMS)
switch (i) { switch (i) {
#ifndef USE_X_COLHDR #ifndef USE_X_COLHDR

View File

@ -285,13 +285,16 @@ typedef struct CPU_t {
#define Show_TASKON 0x000010 // '-' - tasks showable when Mode_altscr #define Show_TASKON 0x000010 // '-' - tasks showable when Mode_altscr
#define Show_FOREST 0x000002 // 'V' - show cmd/cmdlines with ascii art #define Show_FOREST 0x000002 // 'V' - show cmd/cmdlines with ascii art
#define Qsrt_NORMAL 0x000004 // 'R' - reversed column sort (high to low) #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 // 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 INFINDS_xxx 0x010000 // build rows for find_string, not display
#define EQUWINS_xxx 0x000001 // rebalance all wins & tasks (off i,n,u/U) #define EQUWINS_xxx 0x000001 // rebalance all wins & tasks (off i,n,u/U)
// Default flags if there's no rcfile to provide user customizations // Default flags if there's no rcfile to provide user customizations
#define DEF_WINFLGS ( View_LOADAV | View_STATES | View_CPUSUM | View_MEMORY \ #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 */ /* These are used to direct wins_reflag */
enum reflag_enum { enum reflag_enum {
@ -506,7 +509,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 'f' #define RCF_VERSION_ID 'g'
/* The default fields displayed and their order, if nothing is /* The default fields displayed and their order, if nothing is
specified by the loser, oops user. specified by the loser, oops user.

View File

@ -413,8 +413,8 @@ static void build_uniq_nlstab (void) {
" f,F Manage Fields: add/remove; change order; select sort field\n" " f,F Manage Fields: add/remove; change order; select sort field\n"
"\n" "\n"
" L,&,<,> . Locate: '~1L~2'/'~1&~2' find/again; Move sort column: '~1<~2'/'~1>~2' left/right\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" " R,H,V,J . Toggle: '~1R~2' Sort; '~1H~2' Threads; '~1V~2' Forest view; '~1J~2' Num justify\n"
" c,i,S . Toggle: '~1c~2' cmd name/line; '~1i~2' idle tasks; '~1S~2' cumulative time\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" " 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" " 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" " u,U . Show: '~1u~2' effective user; '~1U~2' real, saved, file or effective user\n"