From dbdfb3015ea67a6b52c7ebf80ce44cf9d869c16f Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 13 Sep 2025 10:46:14 +0200 Subject: [PATCH] implement Alt-o and menu "File->Open in new window" --- src/actions.c | 6 +++--- src/callback.c | 10 ++++++++-- src/scheduler.c | 2 +- src/xschem.h | 2 +- src/xschem.tcl | 6 ++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/actions.c b/src/actions.c index dd7446ad..b28c33a9 100644 --- a/src/actions.c +++ b/src/actions.c @@ -605,12 +605,12 @@ void saveas(const char *f, int type) /* changed name from ask_save_file to save return; } -void ask_new_file(void) +void ask_new_file(int in_new_window) { char f[PATH_MAX]; /* overflow safe 20161125 */ if(!has_x) return; - if(!tclgetboolvar("open_in_new_window") && xctx->modified) { + if(!(in_new_window || tclgetboolvar("open_in_new_window")) && xctx->modified) { if(save(1, 0) == -1 ) return; /* user cancels save, so do nothing. */ } tcleval("load_file_dialog {Load file} *.\\{sch,sym,tcl\\} INITIALLOADDIR"); @@ -629,7 +629,7 @@ void ask_new_file(void) if(strcmp(tclresult(), "ok")) skip = 1; } if(!skip) { - if(!tclgetboolvar("open_in_new_window")) { + if(!(in_new_window || tclgetboolvar("open_in_new_window"))) { dbg(1, "ask_new_file(): load file: %s\n", f); clear_all_hilights(); xctx->currsch = 0; diff --git a/src/callback.c b/src/callback.c index d0b2b315..84bd5920 100644 --- a/src/callback.c +++ b/src/callback.c @@ -3199,7 +3199,13 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m break; case 'o': - if(rstate == ControlMask) { /* load */ + if(EQUAL_MODMASK) { /* load in new tab/window */ + xctx->semaphore--; + ask_new_file(1); + tcleval("load_additional_files"); + xctx->semaphore++; + } + else if(rstate == ControlMask) { /* load */ if(xctx->semaphore >= 2) break; if(tclgetboolvar("new_file_browser")) { tcleval( @@ -3207,7 +3213,7 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m ); } else { xctx->semaphore--; - ask_new_file(); + ask_new_file(0); tcleval("load_additional_files"); xctx->semaphore++; } diff --git a/src/scheduler.c b/src/scheduler.c index 5122520b..7d321aab 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -3009,7 +3009,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg "insert_symbol $new_file_browser_paths $new_file_browser_depth $new_file_browser_ext load" ); } else { - ask_new_file(); + ask_new_file(0); tcleval("load_additional_files"); } } else diff --git a/src/xschem.h b/src/xschem.h index 587b51db..1da329d8 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1325,7 +1325,7 @@ extern int copy_hierarchy_data(const char *from_win_path, const char *to_win_pat extern int schematic_in_new_window(int new_process, int dr, int force); extern void symbol_in_new_window(int new_process); extern void new_xschem_process(const char *cell, int symbol); -extern void ask_new_file(void); +extern void ask_new_file(int in_new_window); extern void saveas(const char *f, int type); extern const char *get_file_path(char *f); extern int save(int confirm, int fast); diff --git a/src/xschem.tcl b/src/xschem.tcl index 3ef63233..2083470b 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -9058,6 +9058,8 @@ proc build_widgets { {topwin {} } } { } } $topwin.menubar.file add command -label "Open" -command "xschem load" -accelerator {Ctrl+O} + $topwin.menubar.file add command -label "Open in new window" -command "xschem load_new_window" \ + -accelerator {Alt+O} $topwin.menubar.file add command -label "Open Most Recent" \ -command {xschem load -gui [lindex "$recentfile" 0]} -accelerator {Ctrl+Shift+O} $topwin.menubar.file add cascade -label "Open recent" -menu $topwin.menubar.file.recent @@ -9065,10 +9067,10 @@ proc build_widgets { {topwin {} } } { setup_recent_menu $topwin $topwin.menubar.file add command -label {Create new window/tab} -command "xschem new_schematic create" - $topwin.menubar.file add command -label "Open schematic in new window/tab" \ + $topwin.menubar.file add command -label "Open selected schematic in new window" \ -command "open_sub_schematic" -accelerator Alt+E # -command "xschem schematic_in_new_window" -accelerator Alt+E - $topwin.menubar.file add command -label "Open symbol in new window/tab" \ + $topwin.menubar.file add command -label "Open selected symbol in new window" \ -command "xschem symbol_in_new_window" -accelerator Alt+I $topwin.menubar.file add command -label "Delete files" -command "xschem delete_files" -accelerator {Shift-D}