From 30ef314c3630e3b2bd75bf17079c0253a0079337 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 15 Jun 2022 00:00:00 -0500 Subject: [PATCH] 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 --- top/top.c | 20 +++++++++++++++----- top/top.h | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/top/top.c b/top/top.c index 49016f40..5a145707 100644 --- 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, diff --git a/top/top.h b/top/top.h index 5451fc28..e38fcf26 100644 --- 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