top: optional wider non-scalable cols

This commit accommodates those fields which may have
suffered truncation due to these default limits:
  . 5 digits for uid/gid type fields
  . 8 characters for user/group type fields

With a new interactive command, users can increase the
width of all such fields, or return to the defaults.

Note:
   There are no restrictions on the amount added to
   the defaults.  The user is free to vastly exceed
   screen limits which simply means such fields can
   never be displayed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2012-09-21 01:01:01 -05:00 committed by Craig Small
parent 46bd0085b0
commit 384afa494a
4 changed files with 37 additions and 13 deletions

View File

@ -1892,6 +1892,14 @@ static void zap_fieldstab (void) {
}
#endif
/* and accommodate optional wider non-scalable columns... */
Fieldstab[P_UED].width = Fieldstab[P_URD].width
= Fieldstab[P_USD].width = Fieldstab[P_GID].width
= Rc.fixed_widest ? 5 + Rc.fixed_widest : 5;
Fieldstab[P_UEN].width = Fieldstab[P_URN].width
= Fieldstab[P_USN].width = Fieldstab[P_GRP].width
= Rc.fixed_widest ? 8 + Rc.fixed_widest : 8;
// lastly, ensure we've got proper column headers...
calibrate_fields();
} // end: zap_fieldstab
@ -2375,15 +2383,14 @@ static int config_cvt (WIN_t *q) {
* 'SYS_RCFILESPEC' contains two lines consisting of the secure
* mode switch and an update interval. It's presence limits what
* ordinary users are allowed to do.
* 'Rc_name' contains multiple lines - 2 global + 3 per window.
* line 1: an eyecatcher and creating program/alias name
* line 2: an id, Mode_altcsr, Mode_irixps, Delay_time and Curwin.
* If running in secure mode via the /etc/rcfile,
* the 'delay time' will be ignored except for root.
* For each of the 4 windows:
* line a: contains w->winname, fieldscur
* line b: contains w->winflags, sortindx, maxtasks
* line c: contains w->summclr, msgsclr, headclr, taskclr */
* 'Rc_name' contains multiple lines - 3 global + 3 per window.
* line 1 : an eyecatcher and creating program/alias name
* 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
* line c: contains w->summclr, msgsclr, headclr, taskclr
* line 15 : Fixed_widest */
static void configs_read (void) {
float tmp_delay = DEF_DELAY;
char fbuf[LRGBUFSIZ];
@ -2455,6 +2462,10 @@ static void configs_read (void) {
}
} // end: for (GROUPSMAX)
// any new addition(s) last, for older rcfiles compatibility...
fscanf(fp, "Fixed_widest=%d\n", &Rc.fixed_widest);
if (0 > Rc.fixed_widest) Rc.fixed_widest = 0;
fclose(fp);
} // end: if (fp)
@ -2954,6 +2965,10 @@ static void file_writerc (void) {
, Winstk[i].rc.summclr, Winstk[i].rc.msgsclr
, Winstk[i].rc.headclr, Winstk[i].rc.taskclr);
}
// any new addition(s) last, for older rcfiles compatibility...
fprintf(fp, "Fixed_widest=%d\n", Rc.fixed_widest);
fclose(fp);
show_msg(fmtmk(N_fmt(WRITE_rcfile_fmt), Rc_name));
} // end: file_writerc
@ -3101,6 +3116,12 @@ static void keys_global (int ch) {
, pid, val, strerror(errno)));
}
break;
case 'X':
{ int wide = get_int(fmtmk(N_fmt(XTRA_fixwide_fmt), Rc.fixed_widest));
if (-1 < wide) Rc.fixed_widest = wide;
else if (INT_MIN < wide && 0 > wide) show_msg(N_txt(BAD_integers_txt));
}
break;
case 'Z':
wins_colors();
break;
@ -3566,7 +3587,7 @@ static void do_key (int ch) {
char keys[SMLBUFSIZ];
} key_tab[] = {
{ keys_global,
{ '?', 'B', 'd', 'F', 'f', 'g', 'H', 'h', 'I', 'k', 'r', 's', 'Z'
{ '?', 'B', 'd', 'F', 'f', 'g', 'H', 'h', 'I', 'k', 'r', 's', 'X', 'Z'
, kbd_ENTER, kbd_SPACE, '\0' } },
{ keys_summary,
{ '1', 'C', 'l', 'm', 't', '\0' } },

View File

@ -327,6 +327,7 @@ typedef struct RCF_t {
float delay_time; // 'd'/'s' - How long to sleep twixt updates
int win_index; // Curwin, as index
RCW_t win [GROUPSMAX]; // a 'WIN_t.rc' for each window
int fixed_widest; // 'X' - wider non-scalable col addition
} RCF_t;
/* This structure stores configurable information for each window.
@ -551,7 +552,7 @@ typedef struct WIN_t {
{ P_UEN, DEF_WINFLGS, 0, \
COLOR_YELLOW, COLOR_YELLOW, COLOR_GREEN, COLOR_YELLOW, \
"Usr", USR_FIELDS } \
} }
}, 0 }
/* Summary Lines specially formatted string(s) --
see 'show_special' for syntax details + other cautions. */

View File

@ -299,7 +299,7 @@ static void build_norm_nlstab (void) {
Norm_nlstab[OFF_one_word_txt] = _("Off");
/* Translation Hint: Only the following words should be translated
. delay, limit, user, cols (abbreviation for columns)*/
Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcHiSs -d delay -n limit -u|U user | -p pid[,pid] -w [cols]");
Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcHiSs -d delay -n limit -u|U user -p pid[,pid] -w [cols]");
Norm_nlstab[FAIL_statget_txt] = _("failed /proc/stat read");
Norm_nlstab[FOREST_modes_fmt] = _("Forest mode %s");
Norm_nlstab[FAIL_tty_get_txt] = _("failed tty get");
@ -367,6 +367,7 @@ static void build_norm_nlstab (void) {
Norm_nlstab[FIND_no_next_txt] = _("Locate next inactive, use \"L\"");
Norm_nlstab[GET_find_str_txt] = _("Locate string");
Norm_nlstab[FIND_no_find_fmt] = _("%s\"%s\" not found");
Norm_nlstab[XTRA_fixwide_fmt] = _("fixed-width incr is %d, change to (0 = default)");
#ifndef WARN_CFG_OFF
Norm_nlstab[XTRA_warncfg_txt] = _("Overwrite existing old style rcfile?");
#endif
@ -410,7 +411,7 @@ static void build_uniq_nlstab (void) {
" Z~5,~1B~5 Global: '~1Z~2' change color mappings; '~1B~2' disable/enable bold\n"
" l,t,m Toggle Summaries: '~1l~2' load avg; '~1t~2' task/cpu stats; '~1m~2' mem info\n"
" 1,I Toggle SMP view: '~11~2' single/separate states; '~1I~2' Irix/Solaris mode\n"
" f,F Manage Fields: add/remove; change order; select sort field\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" \
" R,H,V,J . Toggle: '~1R~2' Sort; '~1H~2' Threads; '~1V~2' Forest view; '~1J~2' Num justify\n"

View File

@ -80,6 +80,7 @@ enum norm_nls {
THREADS_show_fmt, TIME_accumed_fmt, UNKNOWN_cmds_txt, UNKNOWN_opts_fmt,
USAGE_abbrev_txt, WORD_allcpus_txt, WORD_another_txt, WORD_eachcpu_fmt,
WORD_process_txt, WORD_threads_txt, WRITE_rcfile_fmt, WRONG_switch_fmt,
XTRA_fixwide_fmt,
#ifndef WARN_CFG_OFF
XTRA_warncfg_txt,
#endif