From 8429930aecec8f5714c9e956171002fbb9c4eba3 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Mon, 4 Aug 2025 21:46:18 +0200 Subject: Focus the N-th tab with Alt- Allows jumping directly to a given tab. It encourages a low number of tabs opened, otherwise it will exceed the 1 to 10 range. --- ChangeLog | 1 + doc/user_help.in.html | 4 ++++ src/keys.cc | 10 ++++++++++ src/keys.hh | 12 +++++++++++- src/keysrc | 12 ++++++++++++ src/ui.cc | 4 ++++ src/uicmd.cc | 21 +++++++++++++++++++++ src/uicmd.hh | 1 + 8 files changed, 64 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index aa5a07cd..b4c36ba4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ dillo-3.3.0 [Unreleased] - Control + left click opens links in new tab (emulates mouse middle button). - Ctrl+C copies selected text into the clipboard so Ctrl+V works as expected. - Enable IPv6 support by default if supported by the platform. + - Focus the N-th tab with the Alt+ shortcut. Patches: Rodrigo Arias Mallo +- Middle click on back or forward button opens page in new tab. Patches: Alex diff --git a/doc/user_help.in.html b/doc/user_help.in.html index 50a2b28d..aca3fa60 100644 --- a/doc/user_help.in.html +++ b/doc/user_help.in.html @@ -389,6 +389,10 @@ bookmarks page set the following line in dillorc:
 new_tab_page="dpi:/bm/"
 
+

+You can quickly focus the N-th tab by pressing Alt and the tab +number, for example Alt+3 will focus the third tab. Using +Alt+0 focuses the tenth tab, as they start counting at 1.

Bookmarks

diff --git a/src/keys.cc b/src/keys.cc index 2a97a160..d94e5918 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -144,6 +144,16 @@ static const KeyBinding_t default_keys[] = { { "zoom-in" , KEYS_ZOOM_IN , FL_CTRL , '=' /* US + */ }, { "zoom-out" , KEYS_ZOOM_OUT , FL_CTRL , '-' }, { "zoom-reset" , KEYS_ZOOM_RESET , FL_CTRL , '0' }, + { "focus-tab1" , KEYS_FOCUS_TAB1 , FL_ALT , '1' }, + { "focus-tab2" , KEYS_FOCUS_TAB2 , FL_ALT , '2' }, + { "focus-tab3" , KEYS_FOCUS_TAB3 , FL_ALT , '3' }, + { "focus-tab4" , KEYS_FOCUS_TAB4 , FL_ALT , '4' }, + { "focus-tab5" , KEYS_FOCUS_TAB5 , FL_ALT , '5' }, + { "focus-tab6" , KEYS_FOCUS_TAB6 , FL_ALT , '6' }, + { "focus-tab7" , KEYS_FOCUS_TAB7 , FL_ALT , '7' }, + { "focus-tab8" , KEYS_FOCUS_TAB8 , FL_ALT , '8' }, + { "focus-tab9" , KEYS_FOCUS_TAB9 , FL_ALT , '9' }, + { "focus-tab10" , KEYS_FOCUS_TAB10 , FL_ALT , '0' }, }; static Dlist *bindings; diff --git a/src/keys.hh b/src/keys.hh index 72b62d18..6a2c82c7 100644 --- a/src/keys.hh +++ b/src/keys.hh @@ -52,7 +52,17 @@ typedef enum { KEYS_COPY, KEYS_ZOOM_IN, KEYS_ZOOM_OUT, - KEYS_ZOOM_RESET + KEYS_ZOOM_RESET, + KEYS_FOCUS_TAB1, + KEYS_FOCUS_TAB2, + KEYS_FOCUS_TAB3, + KEYS_FOCUS_TAB4, + KEYS_FOCUS_TAB5, + KEYS_FOCUS_TAB6, + KEYS_FOCUS_TAB7, + KEYS_FOCUS_TAB8, + KEYS_FOCUS_TAB9, + KEYS_FOCUS_TAB10 } KeysCommand_t; class Keys { diff --git a/src/keysrc b/src/keysrc index 2d467fa2..a825f79c 100644 --- a/src/keysrc +++ b/src/keysrc @@ -95,6 +95,18 @@ # "zoom-reset" resets the zoom to 100%. #0 = zoom-reset +# "focus-tab" focus the N-th tab (starting in 1). +#1 = focus-tab1 +#2 = focus-tab2 +#3 = focus-tab3 +#4 = focus-tab4 +#5 = focus-tab5 +#6 = focus-tab6 +#7 = focus-tab7 +#8 = focus-tab8 +#9 = focus-tab9 +#0 = focus-tab10 + #-------------------------------------------------------------------- # MOTION COMMANDS #-------------------------------------------------------------------- diff --git a/src/ui.cc b/src/ui.cc index 30e0a2d5..9a01cdd5 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -794,6 +794,10 @@ int UI::handle(int event) const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw)); a_UIcmd_view_page_source(bw, url); ret = 1; + } else if (cmd >= KEYS_FOCUS_TAB1 && cmd <= KEYS_FOCUS_TAB10) { + int index = cmd - KEYS_FOCUS_TAB1; /* zero-based index */ + a_UIcmd_focus_tab(a_UIcmd_get_bw_by_widget(this), index); + ret = 1; } } else if (event == FL_RELEASE) { if (Fl::event_button() == FL_MIDDLE_MOUSE && diff --git a/src/uicmd.cc b/src/uicmd.cc index a46fd7c5..957bedd7 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -189,6 +189,7 @@ public: Fl_Wizard *wizard(void) { return Wizard; } int num_tabs() { return (Pack ? Pack->children() : 0); } void switch_tab(CustTabButton *cbtn); + void switch_tab(int index); void prev_tab(void); void next_tab(void); void set_tab_label(UI *ui, const char *title); @@ -486,6 +487,15 @@ void CustTabs::next_tab() switch_tab((CustTabButton*)Pack->child((idx+1= 0 && index < num_tabs()) + switch_tab((CustTabButton*)Pack->child(index)); +} + /** * Set this UI's tab button label. */ @@ -1684,3 +1694,14 @@ void a_UIcmd_focus_location(void *vbw) BW2UI(bw)->focus_location(); } +/* + * Focus the tab at index, starting from 0. + */ +void a_UIcmd_focus_tab(void *vbw, int index) +{ + BrowserWindow *bw = (BrowserWindow*)vbw; + UI *ui = BW2UI(bw); + CustTabs *tabs = ui->tabs(); + if (tabs) + tabs->switch_tab(index); +} diff --git a/src/uicmd.hh b/src/uicmd.hh index 581eac30..7ef676e9 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -74,6 +74,7 @@ void a_UIcmd_view_page_bugs(void *vbw); void a_UIcmd_bugmeter_popup(void *vbw); int *a_UIcmd_get_history(BrowserWindow *bw, int direction); void a_UIcmd_nav_jump(BrowserWindow *bw, int offset, int new_bw); +void a_UIcmd_focus_tab(void *vbw, int index); void a_UIcmd_close_bw(void *vbw); void a_UIcmd_close_all_bw(void *p); -- cgit v1.2.3