]> granicus.if.org Git - procps-ng/commitdiff
top: apply a special emphasis with some focus elements
authorJim Warner <james.warner@comcast.net>
Wed, 18 May 2022 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Fri, 20 May 2022 06:23:19 +0000 (16:23 +1000)
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>
top/top.c
top/top.h

index a9d4eb2295ab05856b4c751adcb69824d8475733..748db6f79066d70a2c1d19722b3b41a29cb94dd4 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -4922,11 +4922,16 @@ static inline const char *forest_display (const WIN_t *q, int idx) {
          * This guy actually draws the parsed strings |
          * including adding a highlight if necessary. | */
 static void bot_do (const char *str, int focus) {
+   char *cap = Cap_norm;
+
    while (*str == ' ') putchar(*(str++));
-   putp(fmtmk("%s%s%s"
-      , focus ? Cap_reverse : Cap_norm
-      , str
-      , Cap_norm));
+   if (focus)
+#ifdef BOT_STRV_OFF
+      cap = Cap_reverse;
+#else
+      cap = strchr(str, Bot_sep) ? Curwin->capclr_msg : Cap_reverse;
+#endif
+   putp(fmtmk("%s%s%s", cap, str, Cap_norm));
 } // end: bot_do
 
 
@@ -5592,9 +5597,11 @@ static void keys_global (int ch) {
          }
          break;
       case kbd_CtrlK:
+         // with string vectors, the 'separator' may serve a different purpose
          bot_item_toggle(eu_CMDLINE_V, "command line", BOT_SEP_SPC);
          break;
       case kbd_CtrlN:
+         // with string vectors, the 'separator' may serve a different purpose
          bot_item_toggle(eu_ENVIRON_V, "environment", BOT_SEP_SPC);
          break;
       case kbd_CtrlP:
index bcca7e3599b79d606d2db929eda895f7d5bd0687..f9313899b05a5a8afa09834ddc7010885af8eeeb 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -28,6 +28,7 @@
 //#define ATEOJ_RPTSTD            /* report on some miscellany at end-of-job */
 //#define BOT_DEAD_ZAP            /* zap Ctrl bottom window when target dies */
 //#define BOT_MENU_YES            /* enable bottom window for menu prototype */
+//#define BOT_STRV_OFF            /* don't emphasize strv w/ focus if spaces */
 //#define CASEUP_HEXES            /* show all those hex values in upper case */
 //#define CASEUP_SUFIX            /* show time/mem/cnts suffix in upper case */
 //#define EQUCOLHDRYES            /* yes, equalize the column header lengths */