]> granicus.if.org Git - procps-ng/commitdiff
top: extend 'focus' navigation to shift+tab (back_tab) <=== port pf newlib 434e2242
authorJim Warner <james.warner@comcast.net>
Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Sun, 19 Jun 2022 10:58:51 +0000 (20:58 +1000)
______________________________ 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>
top/top.c
top/top.h

index 49016f40d24eba5ca4383d9872dce07493289176..5a145707b2b67538e61bb812fe45bef9f40a6fd1 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -1208,9 +1208,9 @@ static int iokey (int action) {
       const char *str;
       int key;
    } tinfo_tab[] = {
-      { NULL, kbd_BKSP  }, { NULL, kbd_INS   }, { NULL, kbd_DEL   },
-      { NULL, kbd_LEFT  }, { NULL, kbd_DOWN  }, { NULL, kbd_UP    }, { NULL, kbd_RIGHT },
-      { NULL, kbd_HOME  }, { NULL, kbd_PGDN  }, { NULL, kbd_PGUP  }, { NULL, kbd_END   },
+      { NULL, kbd_BKSP  }, { NULL, kbd_INS   }, { NULL, kbd_DEL   }, { NULL, kbd_LEFT  },
+      { NULL, kbd_DOWN  }, { NULL, kbd_UP    }, { NULL, kbd_RIGHT }, { NULL, kbd_HOME  },
+      { NULL, kbd_PGDN  }, { NULL, kbd_PGUP  }, { NULL, kbd_END   }, { NULL, kbd_BTAB  },
          // remainder are alternatives for above, just in case...
          // ( the h,j,k,l entries are the vim cursor motion keys )
       { "\033h",    kbd_LEFT  }, { "\033j",    kbd_DOWN  }, /* meta+      h,j */
@@ -1244,6 +1244,7 @@ static int iokey (int action) {
       tinfo_tab[8].str  = tOk(key_npage);
       tinfo_tab[9].str  = tOk(key_ppage);
       tinfo_tab[10].str = tOk(key_end);
+      tinfo_tab[11].str = tOk(back_tab);
       // next is critical so returned results match bound terminfo keys
       putp(tOk(keypad_xmit));
       // ( converse keypad_local issued at pause/pgm end, just in case )
@@ -5771,6 +5772,14 @@ static void keys_global (int ch) {
       case kbd_CtrlU:
          bot_item_toggle((L_SUPGRP), "supplementary groups", ',');
          break;
+      case kbd_BTAB:
+         if (Bot_what) {
+            --Bot_indx;
+            num = Bot_focus_func(NULL, NULL);
+            if (Bot_indx <= BOT_UNFOCUS)
+               Bot_indx = num + 1;
+         }
+         break;
       case kbd_ENTER:             // fall through
 #ifdef BOT_MENU_YES
          if (Bot_what == BOT_MENU_ON && Bot_indx != BOT_UNFOCUS)
@@ -6588,11 +6597,12 @@ static void do_key (int ch) {
       { keys_global,
          { '?', 'B', 'd', 'E', 'e', 'f', 'g', 'H', 'h'
          , 'I', 'k', 'r', 's', 'X', 'Y', 'Z', '0'
-         , kbd_CtrlE, kbd_CtrlG, kbd_CtrlI, kbd_CtrlK, kbd_CtrlN, kbd_CtrlP, kbd_CtrlU
+         , kbd_CtrlE, kbd_CtrlG, kbd_CtrlI, kbd_CtrlK
+         , kbd_CtrlN, kbd_CtrlP, kbd_CtrlU
 #ifdef BOT_MENU_YES
          , kbd_CtrlH
 #endif
-         , kbd_ENTER, kbd_SPACE, '\0' } },
+         , kbd_ENTER, kbd_SPACE, kbd_BTAB, '\0' } },
       { keys_summary,
          { '!', '1', '2', '3', '4', 'C', 'l', 'm', 't', '\0' } },
       { keys_task,
index 5451fc287830dae8bbb51c30aeac071269289d5f..e38fcf26c7790d424204d8875938d2ee25e35c51 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -187,6 +187,7 @@ char *strcasestr(const char *haystack, const char *needle);
 #define kbd_BKSP   137
 #define kbd_INS    138
 #define kbd_DEL    139
+#define kbd_BTAB   140
 #define kbd_CtrlE  '\005'
 #define kbd_CtrlG  '\007'
 #ifdef BOT_MENU_YES