ctrl-Tab: toggle to previously active tab (only tabbed i/f)

This commit is contained in:
stefan schippers 2025-08-22 12:09:04 +02:00
parent 61517b388f
commit fc6fefff35
5 changed files with 28 additions and 8 deletions

View File

@ -1593,6 +1593,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> switch [window_path |schematic_name]</kbd></li><pre>
Switch context to indicated window path or schematic name
returns 0 if switch was successfull or 1 in case of errors
if "previous" given as window path switch to previously active tab
(only for tabbed interface)
(no tabs/windows present or no matching win_path / schematic name
found).</pre>
<li><kbd> symbols [n | 'derived_symbols']</kbd></li><pre>

View File

@ -3806,7 +3806,8 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
int save = xctx->semaphore;
if(xctx->semaphore >= 2) break;
xctx->semaphore = 0;
tcleval("next_tab");
/* tcleval("next_tab"); */
new_schematic("switch", "previous", "", 1);
xctx->semaphore = save;
}
break;

View File

@ -5959,6 +5959,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
/* switch [window_path |schematic_name]
* Switch context to indicated window path or schematic name
* returns 0 if switch was successfull or 1 in case of errors
* if "previous" given as window path switch to previously active tab
* (only for tabbed interface)
* (no tabs/windows present or no matching win_path / schematic name
* found).
*/

View File

@ -1527,6 +1527,9 @@ static int switch_window(int *window_count, const char *win_path, int tcl_ctx)
dbg(0, "switch_window(): no filename or window path given\n");
return 1;
}
if(win_path && !strcmp(win_path, "previous")) {
return 1; /* not used in window interface, only for tabbed interface */
}
if(!strcmp(win_path, xctx->current_win_path)) return 0; /* already there */
n = get_tab_or_window_number(win_path);
if(n == 0) my_snprintf(my_win_path, S(my_win_path), ".drw");
@ -1566,26 +1569,39 @@ static int switch_window(int *window_count, const char *win_path, int tcl_ctx)
static int switch_tab(int *window_count, const char *win_path, int dr)
{
int n;
static char previous_win_path[200] = "";
const char *new_path = win_path;
dbg(1, "switch_tab(): win_path=%s\n", win_path);
if(xctx->semaphore) return 1; /* some editing operation ongoing. do nothing */
if(!win_path) {
dbg(0, "switch_tab(): no filename or window path given\n");
return 1;
}
if(!strcmp(win_path, xctx->current_win_path)) return 0; /* already there */
n = get_tab_or_window_number(win_path);
if(win_path && !strcmp(win_path, "previous")) {
if(previous_win_path[0]) {
new_path = previous_win_path;
}
else return 1;
}
if(!strcmp(new_path, xctx->current_win_path)) return 0; /* already there */
n = get_tab_or_window_number(new_path);
if(n == -1) {
dbg(0, "new_schematic(\"switch_tab\"...): no tab to switch to found: %s\n", win_path);
dbg(0, "new_schematic(\"switch_tab\"...): no tab to switch to found: %s\n", new_path);
return 1;
}
if(*window_count) {
dbg(1, "new_schematic() switch_tab: %s\n", win_path);
dbg(1, "new_schematic() switch_tab: %s\n", new_path);
/* if no matching tab found --> do nothing */
if(n >= 0 && n < MAX_NEW_WINDOWS) {
if(xctx->current_win_path) {
my_strncpy(previous_win_path, xctx->current_win_path, sizeof(previous_win_path));
}
dbg(1, "switch_tab(): previous_win_path=%s\n", previous_win_path);
tclvareval("save_ctx ", xctx->current_win_path, NULL);
xctx = save_xctx[n];
tclvareval("restore_ctx ", win_path, NULL);
tclvareval("restore_ctx ", new_path, NULL);
tclvareval("housekeeping_ctx", NULL);
if(has_x) tclvareval("reconfigure_layers_button {}", NULL);
xctx->window = save_xctx[0]->window;

View File

@ -8171,7 +8171,6 @@ proc swap_tabs {x y what} {
raise .tabs.mm
}
}
} else {
bind .tabs <B1-Motion> {}
place forget .tabs.mm