From 07e79908f128076ccf8040ebb80091af0327ec96 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 21 Aug 2025 10:23:58 +0200 Subject: [PATCH] add Ctrl-Tab and Ctrl-Shift-Tab as aliases to ctrl-Right and ctrl-Left (switch tabs), also add wrap around (last->first or first->last). --- doc/xschem_man/commands.html | 2 ++ src/callback.c | 20 ++++++++++++++++++++ src/keys.help | 2 ++ src/xschem.tcl | 18 ++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/doc/xschem_man/commands.html b/doc/xschem_man/commands.html index 84500785..2ff54b54 100644 --- a/doc/xschem_man/commands.html +++ b/doc/xschem_man/commands.html @@ -128,6 +128,8 @@ ctrl Enter Confirm closing dialog boxes - Up Move up ctrl Left Previous tab (if tabbed interface enabled) ctrl Right Next tab (if tabbed interface enabled) +ctrl+shift Tab Previous tab (if tabbed interface enabled) +ctrl Tab Next tab (if tabbed interface enabled) - ':' Toggle flat netlist - '\' Toggle fullscreen - '!' Break selected wires at any wire or component pin diff --git a/src/callback.c b/src/callback.c index 6f8abe39..54ae0254 100644 --- a/src/callback.c +++ b/src/callback.c @@ -3799,6 +3799,26 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m } break; + case XK_Tab: + if(state == ControlMask) { + int save = xctx->semaphore; + if(xctx->semaphore >= 2) break; + xctx->semaphore = 0; + tcleval("next_tab"); + xctx->semaphore = save; + } + break; + + case XK_ISO_Left_Tab: + if(state == (ControlMask | ShiftMask)) { + int save = xctx->semaphore; + if(xctx->semaphore >= 2) break; + xctx->semaphore = 0; + tcleval("prev_tab"); + xctx->semaphore = save; + } + break; + case XK_Right: if(state == ControlMask) { int save = xctx->semaphore; diff --git a/src/keys.help b/src/keys.help index f703f449..66fe81cf 100644 --- a/src/keys.help +++ b/src/keys.help @@ -69,6 +69,8 @@ ctrl Enter Confirm closing dialog boxes - Up Move up ctrl Left Previous tab (if tabbed interface enabled) ctrl Right Next tab (if tabbed interface enabled) +ctrl+shift Tab Previous tab (if tabbed interface enabled) +ctrl Tab Next tab (if tabbed interface enabled) - ':' Toggle flat netlist - '\' Toggle fullscreen - '!' Break selected wires at any wire or component pin diff --git a/src/xschem.tcl b/src/xschem.tcl index 5d616933..192f0411 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -8195,19 +8195,28 @@ proc prev_tab {} { regsub {\.drw} $currwin {} tabname if {$tabname eq {}} { set tabname .x0} regsub {\.x} $tabname {} number + set found 0 set next_tab $number + set wrap_tab $number set highest -10000000 + set highest_all -10000000 set xcoord [winfo rootx .tabs$tabname] for {set i 0} {$i < $tctx::max_new_windows} { incr i} { if { $i == $number} { continue} if { [winfo exists .tabs.x$i] } { set tab_coord [winfo rootx .tabs.x$i] if {$tab_coord < $xcoord && $tab_coord > $highest} { + set found 1 set next_tab $i set highest $tab_coord } + if {$tab_coord > $highest_all} { + set highest_all $tab_coord + set wrap_tab $i + } } } + if {$found == 0} { set next_tab $wrap_tab} .tabs.x$next_tab invoke } @@ -8218,19 +8227,28 @@ proc next_tab {} { regsub {\.drw} $currwin {} tabname if {$tabname eq {}} { set tabname .x0} regsub {\.x} $tabname {} number + set found 0 set next_tab $number + set wrap_tab $number set lowest 10000000 + set lowest_all 10000000 set xcoord [winfo rootx .tabs$tabname] for {set i 0} {$i < $tctx::max_new_windows} { incr i} { if { $i == $number} { continue} if { [winfo exists .tabs.x$i] } { set tab_coord [winfo rootx .tabs.x$i] if {$tab_coord > $xcoord && $tab_coord < $lowest} { + set found 1 set next_tab $i set lowest $tab_coord } + if {$tab_coord < $lowest_all} { + set lowest_all $tab_coord + set wrap_tab $i + } } } + if {$found == 0} { set next_tab $wrap_tab} .tabs.x$next_tab invoke }