top: tweaked the recently introduced 'STARTED' support

When the 'STARTED' field was added, the width was made
the same as the 'TIME+' field. Thus, a full time could
be shown (which then included hundredths of a second).

That kind of granularity is totally unnecessary. After
all, this column is potentially confusing enough since
it is so counterintuitive. So, this commit will reduce
the width of the field with some help from scale_tics.

Henceforth it will not include those ol' centiseconds.

[ along the way let's expand the man document with a ]
[ a remainder about content representation & scaling ]

Reference(s):
. introduced 'start time' field
commit 7647e96b0a

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2022-02-27 00:00:00 -06:00 committed by Craig Small
parent c89421e83a
commit a749414f16
4 changed files with 15 additions and 10 deletions

View File

@ -980,10 +980,15 @@ member of the session, called the session leader, which is usually the
login shell.
.TP 4
\fBSTARTED \*(Em Start Time \fR
\fBSTARTED \*(Em Start Time Interval\fR
The length of time since system boot when a process started.
Thus, the most recently started task will display the largest time interval.
The value will be expressed as 'MM:SS' (minutes:sceonds) until the
interval becomes too great to fit column width.
At that point it will be scaled to 'HH,MM' (hours,minutes) and possibly
beyond.
.TP 4
\fBSUID \*(Em Saved User Id \fR
The\fI saved\fR user ID.

View File

@ -1633,7 +1633,7 @@ end_justifies:
/*
* Do some scaling stuff.
* Format 'tics' to fit 'width', then justify it. */
static const char *scale_tics (TIC_t tics, int width, int justr) {
static const char *scale_tics (TIC_t tics, int width, int justr, int abrv) {
#ifdef CASEUP_SUFIX
#define HH "%uH" // nls_maybe
#define DD "%uD"
@ -1656,7 +1656,7 @@ static const char *scale_tics (TIC_t tics, int width, int justr) {
nt /= 100; // total seconds
nn = nt % 60; // seconds past the minute
nt /= 60; // total minutes
if (width >= snprintf(buf, sizeof(buf), "%lu:%02u.%02u", nt, nn, cc))
if (!abrv && width >= snprintf(buf, sizeof(buf), "%lu:%02u.%02u", nt, nn, cc))
goto end_justifies;
if (width >= snprintf(buf, sizeof(buf), "%lu:%02u", nt, nn))
goto end_justifies;
@ -1776,7 +1776,7 @@ static struct {
{ 5, -1, A_right, PIDS_IO_WRITE_OPS }, // ul_int EU_IWO
{ 5, -1, A_right, PIDS_AUTOGRP_ID }, // s_int EU_AGI
{ 4, -1, A_right, PIDS_AUTOGRP_NICE }, // s_int EU_AGN
{ 9, -1, A_right, PIDS_TICS_BEGAN }, // ull_int EU_TM3
{ 7, -1, A_right, PIDS_TICS_BEGAN }, // ull_int EU_TM3
{ 6, -1, A_right, PIDS_UTILIZATION } // real EU_CUU
#define eu_LAST EU_CUU
// xtra Fieldstab 'pseudo pflag' entries for the newlib interface . . . . . . .
@ -6236,18 +6236,18 @@ static const char *task_show (const WIN_t *q, int idx) {
case EU_FLG: // PIDS_FLAGS
cp = make_str(hex_make(rSv(EU_FLG, ul_int), 1), W, Js, AUTOX_NO);
break;
/* ull_int, scale_tics */
/* ull_int, scale_tics (try centiseconds) */
case EU_TM2: // PIDS_TICS_ALL
case EU_TME: // PIDS_TICS_ALL
{ TIC_t t;
if (CHKw(q, Show_CTIMES)) t = rSv(eu_TICS_ALL_C, ull_int);
else t = rSv(i, ull_int);
cp = scale_tics(t, W, Jn);
cp = scale_tics(t, W, Jn, 0);
}
break;
/* ull_int, scale_time */
/* ull_int, scale_tics (try seconds) */
case EU_TM3: // PIDS_TICS_BEGAN
cp = scale_tics(rSv(EU_TM3, ull_int), W, Jn);
cp = scale_tics(rSv(EU_TM3, ull_int), W, Jn, 1);
break;
/* str, make_str (all AUTOX yes) */
case EU_LXC: // PIDS_LXCNAME

View File

@ -624,7 +624,7 @@ typedef struct WIN_t {
//atic const char *scale_mem (int target, float num, int width, int justr);
//atic const char *scale_num (float num, int width, int justr);
//atic const char *scale_pcnt (float num, int width, int justr, int xtra);
//atic const char *scale_tics (TIC_t tics, int width, int justr);
//atic const char *scale_tics (TIC_t tics, int width, int justr, int abrv);
/*------ Fields Management support -------------------------------------*/
/*atic struct Fieldstab[] = { ... } */
//atic void adj_geometry (void);

View File

@ -350,7 +350,7 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum 'AGNI' = 4 */
Head_nlstab[EU_AGN] = _("AGNI");
Desc_nlstab[EU_AGN] = _("Autogroup Nice Value");
/* Translation Hint: maximum 'STARTED' = 9 */
/* Translation Hint: maximum 'STARTED' = 7 */
Head_nlstab[EU_TM3] = _("STARTED");
Desc_nlstab[EU_TM3] = _("Start Time from boot");
/* Translation Hint: maximum '%CUU' = 6 */