Commit Graph

194 Commits

Author SHA1 Message Date
Jim Warner
ad4429ade0 top: eliminate a potential abend when exiting 'A' mode <=== port of newlib 80e2a7a6
______________________________ original newlib message
----------------------------------- ( minus git hash )

In that issue cited below, Tyson Nottingham identified
a potential abend which was associated with 'alternate
display mode' plus that troublesome 'mkVIZrow1' macro.
He also offered a perfectly adequate fix for that bug.

I refer to that macro as troublesome since it's now so
widely used and sometimes (by design) causes 'begtask'
to go negative (invalid). And now I found yet one more
place where it should have been used but wasn't ('f').

It's also troublesome as evidenced by some git history
listed below. Heck, there was even a commit addressing
the same symptoms (alternate display mode abend) which
Tyson suffered. Clearly, the current design is flawed.

So, with those two issues in mind, I've refactored the
approach to maintaining a visible task in the 1st row.
Henceforth, a 'mkVIZrow1' macro will be issued in only
two places: once at startup and after most keystrokes.

Such an approach likely results in additional calls to
the 'window_hlp' routine that aren't really necessary.
But, it provides a cleaner design less prone to errors
in the future. Besides, such additional overhead would
only be incurred when interacting with the user. Thus,
new costs are of no concern and will never be noticed.

Reference(s):
. Tyson Nottingham reported problem
https://gitlab.com/procps-ng/procps/-/issues/245
. Jun, 2018 - visible row 1 tasks first addressed
commit ........................................
. Jun, 2018 - adressed edge case, new bugs created
commit ........................................
. Sep, 2018 - additional edge case addressed
commit ........................................
. May, 2021 - some abends fixed, new error created
commit ........................................
. Jun, 2021 - try to prorect against future errors
commit ........................................
. Sep, 2021 - integrate mkVIZ & 'focused' tasks
commit ........................................

Discovered by: Tyson Nottingham
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-07-27 21:19:37 +10:00
Jim Warner
57389eab33 top: provide for visual hint when overtype mode active <=== port of newlib 970a3dc9
______________________________ original newlib message

Given that we won't always be able to alter the cursor
shapes (from underscore to block) if in input overtype
mode, this commit will at least provide a visual clue.

[ while this libvte quirk will impact gnome-terminal ]
[ and likely others, we're able to change the cursor ]
[ shape from underscore to block at a linux console. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
da4dc7665b top: provides a new user 'message log' display ability <=== port of newlib 3901dcb9
______________________________ original newlib message

Messages issued by top will be displayed for only 1.25
seconds. And while this length of time would appear to
be acceptable (given the absence of complaints), there
will be times when a specific message might be missed.

So, this commit offers users the opportunity to recall
up to 10 of the most recent messages that were issued.

[ we'll just exploit top's new bottom window feature ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
53e72ccef0 top: the bottom 'window' headings are now translatable <=== port of newlib 20859f6f
______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
eeeb4ba52b top: remove the 'BOT_MENU_YES' prototype demonstration <=== port of newlib dedcfa76
______________________________ original newlib message

Now that a potential use of that bottom 'window' for a
menu has been demonstrated, we'll remove such clutter.

[ after all, the prior commit cautioned against text ]
[ made conditional which might also be translatable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
b4c17fd544 top: rework bottom 'window' logic to reduce redundancy <=== port of newlib ef1d82cf
______________________________ original newlib message

This patch attempts to reduce the proliferation of the
bottom window support routines by combining the 'misc'
with 'item' functions. Along the way we can now rename
those two 'pick' functions 'menu' while keeping proper
alphabetic order among all the bottom window routines.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
05fa17da19 top: apply a special emphasis with some focus elements <=== port of newlib 1dd27ba3
______________________________ original newlib message

Since top now uses string vectors for two items in the
new focus window (cmdline & environ), there is no real
use for that 'separator' specified at toggle time. So,
this commit will find a new use for what is the space.

Henceforth, when a user is navigating using the tab or
backtab keys, should a strv element with focus contain
embedded space(s), it will be emphasized & highlighted
using the current window's message color (capclr_msg).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
30ef314c36 top: extend 'focus' navigation to shift+tab (back_tab) <=== port pf newlib 434e2242
______________________________ original newlib message

Some of those bottom windows grow quite large, as with
the firefox environment. If one is navigating the data
using the tab key, it can be very inconvenient when an
element should be reexamined but that focus has moved.

Therefore, this commit will support the 'back_tab' key
which is a standard combination of the shift+tab keys.

Now a user can easily backup up to any missed element,
assuming a terminal emulator honors that terminfo key.

[ a gui emulator typically will honor the 'back_tab' ]
[ terminfo string, whereas a linux console does not. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
5b2cfd607b top: modify 'Ctrl' bottom window 'str' use with 'strv' <=== port of newlib 73b4f113
______________________________ original newlib message

After satisfying increased buffer size in the previous
patch, I decided to improve the highlight accuracy for
both the command lines plus the environment variables.

Since they both may contain elements which themselves
include embedded spaces, to accomplish this goal, one
must trade vanilla strings for string vectors instead.

[ at last such library items have now been justified ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
203d75e323 top: needed 'Ctrl' bottom window fixes were discovered <=== port of newlib da36ff2b
______________________________ original newlib message

As it turns out, some of the 'environ' strings are big
enough to overrun the initial buffer sizes. And, while
no real harm was done (other than to silently truncate
the output), this patch will increase the buffer size.

While we're at it. we will normalize a few more buffer
declarations along with correcting a couple typos too.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
a103b364f3 top: extend 'Ctrl' bottom window for 'memu' selections <=== port od newlib 659590b0
______________________________ original newlib message

This commit adds a prototype for a potential extension
of that tabbed bottom window capability. It introduces
a 'menu' which then provides for users' selections. It
does not actually do anything meaningful and will only
be enabled with the new #define called 'BOT_PICK_YES'.

[ since it's just a proof of concept, no attempt has ]
[ been made to add the usual NLS translation support ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
04d05b9f04 top: extend 'Ctrl' bottom window for focus via tab key <=== port of newlib de22afc4
______________________________ original newlib message

This commit introduces the 'tab' key which can be used
to highlight individual elements in that bottom 'Ctrl'
window. This can really help when reviewing such data.

[ note, normal ongoing monitoring continues unabated ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
2f683d3bcf top: expand 'Ctrl' bottom window to display other data <=== port of newlib c46a60d9
______________________________ original newlib message

This commit adds support for displaying the namespaces
in top's separate bottom 'Ctrl' window. Along the way,
the plumbing is now in place to extend this capability
to other data (if we don't run out of '^' keystrokes).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
df36fe4d54 top: rename 'Ctrl' bottom window routines and relocate <=== port of newlib ad17ffe6
______________________________ original newlib message

This patch will just set the stage for the next commit
where we'll be adding the capability to display things
that sometimes may necessitate multiple library items.

In that effort we will be adding several new routines.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
8c336e07c6 top: avoid library shame with refactored 'Ctrl' window <=== port of newlib bc4b499e
[ sorry, but under this master branch ]
       [ the whole next narrative is frankly ]
       [ mostly pure unadulterated bullshit. ]

______________________________ original newlib message

Well darn it, whoever wrote that new library caught me
with my pants down (again?). Shoot, they were not just
down but somehow missing altogether. Here's the story.

Any item from that library supported by dynamic memory
can only be represented in user's stacks exactly once.

Should any string based enumerator be duplicated among
the items array, for any instance beyond the first the
library will return '[ duplicate ENUM ]' for a result.

That's where I lost my pants. While command lines were
given special handling (and never duplicated) I failed
to turn on CGROUPS, SUPGRPS & ENVIRON when testing the
Ctrl-G, Ctrl-U & Ctrl-N keys. If any of those 3 are on
that's when a Ctrl window sees a 'duplicate' notation.

[ and who runs top with such fields displayed anyway ]

In responding to this oops, the internals were changed
quite dramatically & vastly simplified in the process.

More importantly, the 'duplicate' results are no more.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
f45992086c top: turn off the 'Ctrl' bottom window after some keys <=== port of newlib d66c1f39
______________________________ original newlib message

To complete the implementation of this new feature, we
must address the problem created by any commands which
offer their own full replacement displays. Should that
'Ctrl' bottom window be active, a return from any such
command leaves that lower portion of a terminal blank.

While we could issue a 'TAGGED_TOSS' macro right after
invoking any of those 4 (currently) affected commands,
it is wrong to make them aware of this 'tagged' stuff.

So, I'll opt for a more generalized solution whereby a
notice regarding a corrupted screen is broadcast. Then
the logic already aware of 'tagging' can deal with it.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
619d4936ee top: allow sticky 'Ctrl' bottom window code by #define <=== port of newlib 16e202d2
______________________________ original newlib message

After making that new bottom window more persistent, I
decided to offer a build choice for somebody who might
prefer to have the rug pulled out from under him while
reviewing window contents should some target task end.

If 'TAGGED_BRIEF' is defined old behavior is restored.

[ it should be noted, however, that when this define ]
[ is active we'll lose any benefit of onetime update ]
[ for the bottom window. just like with the original ]
[ behavior, it is repainted with every update cycle. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
9bd04df662 top: trade just 1 'Ctrl' bottom window key association <=== port of newlib 9ff5a4ff
______________________________ original newlib message

I grew tired of inadvertently causing a premature exit
from top when all I wanted was to review some process'
environment variables. That 'V' key was just too close
to the 'C' key so the '^V' attempt became one of '^C'.

Well, not any more. Should a user wish to see a task's
environment, it will now require the '^N' combination.

[ it also now places G/U & N/K on a similar diagonal ]

Along the way, lower case Ctrl key combinations on the
help screen were all changed into upper case versions.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
8d8eadef04 top: make the new 'Ctrl' bottom window behavior sticky <=== port of newlib 0f2a755b
______________________________ original newlib message

After using this new feature for awhile, I encountered
numerous times when that 'Ctrl' window would disappear
as I was studying the contents. This was caused by the
death of the target task but it made me think that the
window could/should persist until dismissed by a user.

Well, now it will persist until that same Ctrl key has
been struck a 2nd time or a different Ctrl key used to
target another process after positioning it on row #1.

So now, instead of that former 'moving target' type of
approach, this window is more of a 'snapshot' in time.

[ even more significant, perhaps, is the fact that a ]
[ Ctrl window will now be drawn exactly 1 time only, ]
[ instead of being repainted after each delay cycle. ]

[ this will remain true no matter how many intervals ]
[ might elapse while its contents were under review. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
49bb9f9ae4 top: add variable width data display without scrolling <=== port of newlib fb32021e
______________________________ original newlib message

There are times when one might want to see some task's
particular variable width data. However, prior to this
commit, the only way was to first turn on a field then
scroll through it via repeated right arrow keystrokes.

[ this also required that field to be displayed last ]

Needless to say, given the potential length of some of
that variable data this could be extremely cumbersome.

Now with this patch, a Ctrl keystroke combination will
create a separate window at the bottom of the terminal
screen where such variable width data is seen in full.

[ the targeted task is the 1st task displayed, which ]
[ is a convention employed in some existing commands ]

[ the targeted data was determined by these Ctrl key ]
[ combinations: CtrlG = ctrl group; CtrlK = cmdline; ]
[ CtrlU = supplementary groups; plus CtrlV = environ ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
d091a67854 top: remove those winflags which restricted 'x' toggle <=== port of newlib ef8d1cb6
______________________________ original newlib message

On occasion, even as the top author, I wonder why that
'x' toggle has stopped working. Of course, it actually
was working but a locate request ('L') or other filter
('O') operation was active and thus temporarily turned
if off. Such behavior is documented in top's man page.

Well, with this patch that 'x' suppression is no more.

[ the original justification, however, remains true. ]

[ but there's really only one character which causes ]
[ any potential trouble & i'm gonna' keep it secret. ]

[ besides, if a display is corrupted, there's always ]
[ that '=' key which restores things back to normal. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
40e9d0f299 top: ignore the SIGHUP signal if running in batch mode <=== port of newlib 6aec3ec9
______________________________ original newlib message

It would appear that openSUSE was the first to release
procps-ng version 4.0.0 (in the tumbleweed distro). As
a result I checked their source rpm and found a couple
of patches I'm porting to newlib for the next release.

This particulate commit was a refactor of the openSUSE
patch 'procps-ng-3.3.8-bnc634840.patch'. Unfortunately
their original patch did not have the intended effect.

That was because the amended signal handling logic was
performed well before the command line parameters were
parsed. So the global 'Batch' flag was in its 0 state.

. what follows is the original openSUSE commit message
------------------------------------------------------
Do not setup SIGHUP signal handler if we are in the batch mode

Top enables a signal handler for the SIGHUP signal (loss of terminal).  While
this makes sense for top's default interactive mode, it doesn't make any sense
for batch mode. If you run top in nohup just to collect data over time and
disconnect top finishes which is not what one would expect.
------------------------------------------------------

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-19 20:58:51 +10:00
Jim Warner
ed8dbd05e7 top: squashed catch-up of new scalable 'STARTED' field
[ the original newlib commit message(s) appear below ]
[ but 'cpu utilization' was not implemented to avoid ]
[ any library modifications and thus version impact! ]

--------------------------------- newlib patch #1 ---
top: added fields for 'start time' & 'cpu utilization'

This patch will exploit some new library capabilities.

[ one will raise eyebrows, the other likely will not ]

A new 'STARTED' field was added which shows the time a
process started after system boot. As such the largest
interval represents the most recently started process.

This is the field that will likely be questioned since
it's somewhat counterintuitive. But were we to instead
use TIME_ELAPSED, the value will change with every top
refresh. This will defeat any PUFF macro optimization.

The new '%CUU' field will probably be better received.
It represents the cpu usage over the life of the task.
When a process was showing high %CPU usage, this field
can be used to determine if it's an anomaly or normal.

[ and as with %CPU, %CUU shows a '?' when running in ]
[ a namespace when /proc was mounted with subset=pid ]

---------------------------------- newlib patch #2 ---
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 ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-15 22:13:44 +11:00
Jim Warner
953016291a top: squashed 'scale_tics' catch-up for Ctrl-E scaling
[ the original newlib commit message(s) appear below ]

---------------------------------- newlib patch #1 ---
top: refactor 'scale_tics' function for better scaling

This patch refactors the 'scale_tics' function to more
closely parallel uptime shown on the first line of the
summary area. The old logic has been preserved through
the header file's new  #define SCALE_FORMER provision.

However, the former logic was actually a big disaster.
These are some potential problems with that old logic:

1. With respect to our time fields top no longer deals
solely with cpu time. So, the old limits of '68 weeks'
could possibly be insufficient to reflect those times.

2. Given the widths of top's new time fields, the code
never got beyond scaling to hours. For example, with a
ridiculously large span of 19 years, the scaled result
would then be shown as '167832h'. We never reached the
days ('6993d') or even the weeks ('999w') equivalents.

3. Similarly, with that 'TIME+' field and a large tics
value, results would then appear as 'MMMMMM:SS' rather
than the more meaningful 'HH:MM:SS' or days and hours.

So henceforth we will adopt these scaling conventions:

  MMM:SS.hh ... minutes:seconds.hundredths
  MMM:SS ...... minutes:seconds
  HH,MM ....... hours,minutes
  D+H ......... days+hours (with 'd' & 'h' suffixes)
  D ........... days (with 'd' suffix)
  W+D ......... weeks+days (with 'w' & 'd' suffixes)
  W ........... weeks (with 'w' suffix)

Note that, unlike our former scaling logic, that 'MMM'
portion won't be allowed to grow unconditionally. It's
limited (arbitrarily?) to 360 total minutes (6 hours).
Additionally, the 'HH' guy will be limited to 96 hours
(4 days) while that 'D' limit was set at 14 (2 weeks).

Whenever a limit is hit, scaling will advance a level.

---------------------------------- newlib patch #2 ---
top: extended 'scale_tics' function for Ctrl-E scaling

That normalization of the 'scale_tics' function in the
prior commit convinced me that I won't please everyone
with my arbitrary choices for the scaling transitions.

So, this patch will provide the users with a means for
setting their own scaling transition points with a new
toggle. Ctrl-E was chosen since the 'e/E' toggles were
already present as a means of scaling (albeit memory).

[ this toggle will also serve an educational purpose ]
[ by allowing one to see all the scaling conventions ]

The scaling a user establishes is saved in the rcfile.

---------------------------------- newlib patch #3 ---
top: enhanced 'scale_tics' function for Ctrl-E scaling

When scale_tics was refactored and then Ctrl-E support
added to top, the complete range of scaling values was
not visible. Namely, a single 'd' (days) & 'w' (weeks)
was never seen with ^E. With this commit they will be.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-15 22:13:44 +11:00
Jim Warner
204194cdc4 top: trade that 'strncpy' for more efficient 'memccpy'
This patch was prompted by the merge request for pgrep
referenced below. In top's case, any performance gains
will be minimal since the now defunct strncpy was only
employed for termcap rebuilds after interacting with a
user (+ 1 other non-termcap related user interaction).

[ golly, strncpy always calls at least two functions ]
[ but usually calls a total of 3. on the other hand, ]
[ memccpy will only call a maximum of two functions. ]

And thanks to Baruch Siach for these strncpy insights.

Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/148

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-02-17 18:24:55 +11:00
Jim Warner
292e831418 top: add visual clue when focus toggle ('F') is active
When in forest view mode, that focus toggle ('F') is a
useful tool occasionally. But, if a focused parent has
enough cloned siblings to exceed screen rows, it could
be hard to remember that such a toggle remains active.

So, this patch will provide a subtle visual clue added
to the leftmost position in the COMMAND column. Now if
the focus toggle was active, regardless of total tasks
affected, the users will always know when it's active.

Reference(s):
. 07/28/21, introduced new focus toggle ('F')
commit bdd50fa2fc
. 09/23/21, ensure focused tasks stay focused
commit d7e6c27a79

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:21 +11:00
Jim Warner
376d44d580 top: eliminate warnings for '-Wmisleading-indentation'
Reference(s):
. 01/08/22, newlib branch equivalent commit
commit 68995bee95d145f84c27849c47e4512da3f77a7e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:21 +11:00
Jim Warner
169761e186 top: eliminate every warning for '-Wformat-truncation'
Reference(s):
. 01/08/22, newlib branch equivalent commit
commit f05c78d174d3383afc3f71956c23e3e1e75bb2ed

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:21 +11:00
Jim Warner
d23a920d76 top: repair several inconsistencies in email addresses
[ you wouldn't believe how many back-and-forths were ]
[ involved in Craig convincing me there were several ]
[ inconsistencies. i am so dense sometimes (often?). ]

Reference(s):
. 01/2022, newlib branch equivalent commits
commit 91ffe81734
commit c83cd6e6c0

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:21 +11:00
Jim Warner
1f30c205d7 top: bust up that overly large 'summary_show' function
Over the years the summary_show function has increased
from around 77 lines of code & comments to its current
size of 195 lines. This is well beyond an ideal length
of available screen rows. So this patch will split it.

We'll take the cpu and memory duties and make separate
functions out of them. Of course, this will incur some
additional call overhead but, given current cpu/memory
logic, any such increase really becomes insignificant.

Now summary_show's a svelte 31 lines of code/comments.

[ this is like what was done to that do_key function ]
[ a decade ago except overhead of new function calls ]
[ plus table lookup was even less of a concern since ]
[ a human was involved, not normal iterative output. ]

Reference(s):
. 01/03/22, newlib branch equivalent commit
commit cbff1d;d10645cb8c7fc55dda08b06fbafed05932

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:21 +11:00
Jim Warner
99ec6247ec top: provide for avoiding task focus ('F') distortions
In the patch referenced below the focus task logic was
improved to ensure that newly cloned tasks 'above' the
focused task did not force an effect like the up arrow
key. That commit also acknowledged that when some task
'above' ended, it *would* act like the down arrow key.

Well, with this commit a task ending 'above' a focused
task no longer distorts the focus. That's assuming the
new '#define FOCUS_HARD_Y' is specified plus the total
focused tasks does not exceed the current screen rows.

Thus, the manual scrolling with up and down arrow keys
is allowed when the total focused exceeds screen rows.

[ but keep in mind that when a focused task has been ]
[ hardened some otherwise useful toggles will not be ]
[ available. keystrokes like 'v' and even 'F' itself ]
[ can not be applied to another task with no scroll. ]

    Reference(s):
. 01/03/22, newlib branch equivalent commit
commit 0e744d3656
. 09/24/21, master branch 'focus' logic improved
commit d7e6c27a79

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:20 +11:00
Jim Warner
6ba099a4d6 top: update the man page & source file copyright dates
This just updates the copyright dates in the documents
within the top subdirectory only. Others are unchanged.

Reference(s):
. 01/01/22, newlib branch equivalent commit
commit afdd4690fc

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:20 +11:00
Jim Warner
9105ce0e6c top: justify those header #define description comments
This commit is an example of what can happen when this
author is waiting around for the release of our newlib
& otherwise runs out of legitimate changes to be made.

[ on the other hand, such changes surely make us run ]
[ quite a bit more efficiently, if i am not mistaken ]

Reference(s):
. 09/14/21, newlib branch equivalent commit
commit 6049c13b4d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:20 +11:00
Jim Warner
4b54518721 top: enabled arbitrarily large numbers in 'scale' guys
While experimenting with a new feature, wherein select
fields display the total upon request, the capacity of
the 'num' passed to some 'scale' guys became an issue.

So this commit will, with the compiler's help, put the
responsibility for converting the integer into a float
within the calling code (instead of the called logic).

Reference(s):
. 03/08/21, newlib branch equivalent commit
commit 62928cf461

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:20 +11:00
Jim Warner
5ae84fac6e top: allow setting variable width col scroll (1 vs. 8)
The Inspection feature already offered an INSP_SLIDE_1
provision. This patch now offers similar extensions to
variable width column scrolling (assuming SCROLLVAR_NO
isn't defined). Such a provision was useful during the
development of some recent library UTF-8 enhancements.

Reference(s):
. 12/30/20, newlib branch equivalent commit
commit edce9ed612

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:20 +11:00
Jim Warner
016ddc6bff top: utilize getopt and introduce long cmdline options
For quite some time now, top has stood out like a sore
thumb regarding the approach to cmdline options & help
text.  Only short options were used and that same help
text was displayed for '-h' (help) plus 'v' (version).

[ also, top 'rolled his own' when it came to parsing ]
[ options while avoiding that getopt implementation. ]

Well, with this commit all of that has changed and top
now has added a long form of his options. Additionally
he employs getopt_long() for the bulk of that parsing.

[ however, top will still avoid separate fputs calls ]
[ characteristic of other procps-ng programs when it ]
[ comes to help. rather all such text is one string. ]

Along the way, the following major getopt deficiencies
were addressed, assuming the absence of a new #define:

* an equals sign ('=') is allowed on both option forms

* whitespace is allowed before & after the equals sign

* optional arguments needn't abut their related option
for short form nor is an '=' required with either form

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-09-07 08:01:25 +10:00
Jim Warner
7a30fd0f51 top: added a new #define to test absence of numa nodes
Catch-up with newlib, original commit message follows:
------------------------------------------------------

This new #define will produce top results identical to
the results achieved for './configure --disable-numa'.

However it keeps the change entirely local to our top.

[ it has been introduced to test the following patch ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-24 20:53:27 +10:00
Jim Warner
8ef60b84af top: allow the summary memory lines to print 2 abreast
The commit shown below introduced two abreast printing
for %Cpu statistics. But, the Memory & Swap lines have
always been printed on separate lines when '4' was on.

With this commit, those lines will now be treated just
like %Cpu stats, either separate lines or two abreast.

Reference(s):
. May 2020, added '4' toggle for 2 abreast
commit fca48e7e99

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-06 20:19:18 +10:00
Jim Warner
c725207c44 top: add a visual separator to lines printed 2 abreast
When the '4' toggle is on, and Summary Area %Cpu lines
are shown two abreast, it's not always clear where the
separation is between the two processors. So with this
patch we'll now print a vertical bar separator between
them (looking similar to the existing field headings).

We will also reduce that 'GRAPH_suffix' constant to 1,
reflecting the the trailing ']' bracket only, so as to
maximize top's exploitation of available screen width.

[ plus a superfluous double '+ +' has now been fixed ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-06 20:19:18 +10:00
Jim Warner
d19ee838a6 top: new #define added for focus ('F') toggle tweaking
Just to see if I could, the new #define will force the
indentation of a parent task to be reset to zero while
maintaining the proper child indentation relationship.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-01 20:39:46 +10:00
Jim Warner
bdd50fa2fc top: introduced new focus toggle ('F'), program source
Sometimes, it might be useful to isolate a parent task
and its forked children from other system activity. As
an example, a user might want to examine workload in a
specific lxc container. Or maybe there is some need to
question what's happening under the same tmux session.

Since forest view mode tends to be a relatively stable
display, it will sometimes satisfy the above need. But
that mode can't currently guarantee the target process
always remains as the topmost task or even is visible.

So, this patch will enable focusing on any parent task
and keeping it as the topmost process while displaying
it and its forked children only. It then appears as if
there is no other activity in that system by virtue of
the blank lines which follow that final child process.

To implement this new feature, top's redundant 'F' key
has been repurposed. It made little sense devoting two
keys to the Fields Management screen (especially since
the key we've taken required two separate keystrokes).

[ and while we're at it, i also added punctuation to ]
[ that prologue for 'forest_display' since all other ]
[ forest functions used punctuation. And, instead of ]
[ a pointer to a proc_t he will now get a ppt index. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-01 20:39:46 +10:00
Jim Warner
dc8137f85b top: refactor 'mkVIZ' support to avoid future problems
In the patch referenced below, 2 potential abends were
fixed both of which involved 'alternate display mode'.

The root cause of those abends was a negative value in
the 'begnext' field for other than the current window.

And while that potential is fixed for now the existing
code almost invites such problems again in the future.

So, this patch will remove any temptation to name some
other window in the 'mkVIZrow1' macro. And, since that
macro is not the only source of 'begnext' changes, the
'mkVizrowX' is being added to identify such occasions.

[ and for symmetry i've added a 'mkVIZyes' macro and ]
[ ameliorated an otherwise surreptitious assignment! ]

Reference(s):
commit 84e85611c3

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-06-17 16:46:33 +10:00
Jim Warner
7086e99067 top: eliminate the #define VER_J_RCFILE as superfluous
With that commit referenced below, which preserved the
'4' and + '!' toggles in the rcfile, this VER_J_RCFILE
macro was made superfluous. But, it was never removed.

Reference(s):
commit f858e563b7

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-06-02 20:06:32 +10:00
Jim Warner
072a850761 top: more useless cosemetic changes (chiefly comments)
All of these changes are self-explanatory, so I'll not
provide any more comments thus avoiding further shame.

[ everything's perfectly justified and right margins ]
[ are filled entirely, but of course it must be luck ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-09-13 10:28:50 +10:00
Jim Warner
f858e563b7 top: preserved those new '4' and '!' toggles in rcfile
This patch will address Craig's feedback regarding the
original implementation of top's two new toggles. It's
likely other users would have questioned why they were
not saved also, once they discover these new features.

And, since the minimum terminal width was just lowered
to 80 columns, the default for window #1 is also being
changed to show the individual cpu graphs two abreast.

[ assuming no '--disable-modern-top' for ./configure ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172
https://www.freelists.org/post/procps/two-major-changes-to-top,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-31 21:59:57 +10:00
Jim Warner
6db0d5eab6 top: reduce minimum terminal width with 2 abreast mode
For the original implementation of the '4' toggle, the
minimum width was set at 165 columns. This was done to
avoid truncations when detailed cpu statistics (versus
graphs) were being displayed. Those can not be scaled.

Upon reflection, it seems more appropriate to give the
user the choice of whether or not to truncate. And, by
reducing that minimum width requirement to 80 columns,
we'll vastly expand potential use of two abreast mode.

[ we'll keep that original as '#define TOG4_NOTRUNC' ]

The patch also updates the man document appropriately.
Along the way, we will trade the potentially confusing
word 'adjacent' for the more natural 'additional' when
detailing the '!' toggle in 4b. Summary-Area-Commands.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172
https://www.freelists.org/post/procps/two-major-changes-to-top

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-31 21:59:57 +10:00
Jim Warner
a8a6005d32 top: bump up that PRETEND8CPUS #define to PRETEND48CPU
This patch simply allows for better testing of our two
new toggles: '4' (2 abreast) plus '!' (combined cpus).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-28 19:37:58 +10:00
Jim Warner
5e1e14b019 top: add '!' toggle for combined cpus display, program
When implementing that earlier '4' toggle, in response
to the issue referenced below, I got to thinking about
those environments with massively parallel processors.

Such environments may not benefit from the '4' toggle.

So, I decided to implement a feature that could enable
use of those '1' and/or '4' toggles no matter how many
active processors top may have ultimately encountered.

With the new '!' toggle, adjacent cpus can be combined
to any degree, represented as a single cpu group/line.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-28 19:37:58 +10:00
Jim Warner
fca48e7e99 top: add '4' toggle for 2 abreast cpu display, program
In the back of my mind, I've always wanted to enable a
two abreast cpu display. Folks with massively parallel
machines must surely have been frustrated with the '1'
toggle when Off (individual cpus in the Summary Area).

So, I'll use that recently raised issue shown below as
a justification for finally implementing this feature.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-28 19:37:58 +10:00
Jim Warner
43a8d0328d top: eliminate a long standing extraneous comment line
Wow, hard to believe the extraneous comment line dates
all way back to an introduction of NLS support (2011).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-28 19:37:58 +10:00