From 1b3d0dd9f639f382d2c03d5e64a03d62df181ca0 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 12 Sep 2025 12:16:47 +0200 Subject: [PATCH] add xschemrc variable open_in_new_window_or_tab (default: 0) to let File->Open open in a new tab/window --- src/actions.c | 39 ++++++++++++++++++++++----------------- src/callback.c | 2 +- src/xschem.tcl | 14 ++++++++++++-- src/xschemrc | 8 ++++++++ 4 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/actions.c b/src/actions.c index d4fc3fdf..f468d399 100644 --- a/src/actions.c +++ b/src/actions.c @@ -610,7 +610,7 @@ void ask_new_file(void) char f[PATH_MAX]; /* overflow safe 20161125 */ if(!has_x) return; - if(xctx->modified) { + if(!tclgetboolvar("open_in_new_window_or_tab") && 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,22 +629,27 @@ void ask_new_file(void) if(strcmp(tclresult(), "ok")) skip = 1; } if(!skip) { - dbg(1, "ask_new_file(): load file: %s\n", f); - clear_all_hilights(); - xctx->currsch = 0; - unselect_all(1); - remove_symbols(); - xctx->zoom=CADINITIALZOOM; - xctx->mooz=1/CADINITIALZOOM; - xctx->xorigin=CADINITIALX; - xctx->yorigin=CADINITIALY; - load_schematic(1, f, 1, 1); - tclvareval("update_recent_file {", f, "}", NULL); - if(xctx->portmap[xctx->currsch].table) str_hash_free(&xctx->portmap[xctx->currsch]); - my_strdup(_ALLOC_ID_, &xctx->sch_path[xctx->currsch],"."); - xctx->sch_path_hash[xctx->currsch] = 0; - xctx->sch_inst_number[xctx->currsch] = 1; - zoom_full(1, 0, 1 + 2 * tclgetboolvar("zoom_full_center"), 0.97); + if(!tclgetboolvar("open_in_new_window_or_tab")) { + dbg(1, "ask_new_file(): load file: %s\n", f); + clear_all_hilights(); + xctx->currsch = 0; + unselect_all(1); + remove_symbols(); + xctx->zoom=CADINITIALZOOM; + xctx->mooz=1/CADINITIALZOOM; + xctx->xorigin=CADINITIALX; + xctx->yorigin=CADINITIALY; + load_schematic(1, f, 1, 1); + tclvareval("update_recent_file {", f, "}", NULL); + if(xctx->portmap[xctx->currsch].table) str_hash_free(&xctx->portmap[xctx->currsch]); + my_strdup(_ALLOC_ID_, &xctx->sch_path[xctx->currsch],"."); + xctx->sch_path_hash[xctx->currsch] = 0; + xctx->sch_inst_number[xctx->currsch] = 1; + zoom_full(1, 0, 1 + 2 * tclgetboolvar("zoom_full_center"), 0.97); + } else { /* load in new window/tab */ + tclvareval("update_recent_file {", f, "}", NULL); + tclvareval("xschem load_new_window {", f, "}", NULL); + } } } } diff --git a/src/callback.c b/src/callback.c index d1328689..d0b2b315 100644 --- a/src/callback.c +++ b/src/callback.c @@ -3206,8 +3206,8 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m "insert_symbol $new_file_browser_paths $new_file_browser_depth $new_file_browser_ext load" ); } else { - ask_new_file(); xctx->semaphore--; + ask_new_file(); tcleval("load_additional_files"); xctx->semaphore++; } diff --git a/src/xschem.tcl b/src/xschem.tcl index e1254c42..168abe7e 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -5048,7 +5048,7 @@ proc insert_symbol_filelist {} { proc insert_symbol_place {action} { # puts insert_symbol_place - global insert_symbol + global insert_symbol open_in_new_window_or_tab set sel [.ins.center.left.l curselection] if {$sel eq {}} { set sel [.ins.center.left.l index active] @@ -5065,7 +5065,11 @@ proc insert_symbol_place {action} { if {$action eq {symbol}} { xschem place_symbol $f } elseif {$action eq {load}} { - xschem load -gui $f + if {$open_in_new_window_or_tab} { + xschem load_new_window $f + } else { + xschem load -gui $f + } } } } @@ -8533,6 +8537,7 @@ set tctx::global_list { keep_symbols launcher_default_program light_colors line_width live_cursor2_backannotate local_netlist_dir lvs_ignore lvs_netlist measure_text netlist_dir netlist_show netlist_type no_ask_save no_ask_simulate no_change_attrs nolist_libs noprint_libs only_probes + open_in_new_window_or_tab orthogonal_wiring path pathlist persistent_command preserve_unchanged_attrs prev_symbol ps_colors ps_paper_size rainbow_colors recentfile rotated_text search_case search_exact search_found search_schematic search_select search_value select_touch @@ -10178,6 +10183,11 @@ set_ne undo_type disk ## show tab bar (tabbed interface) set_ne tabbed_interface 1 + +## File->Open will open in a new window/tab instead of replacing content in current one +## if enabled. +set_ne open_in_new_window_or_tab 0 + ## case insensitive symbol lookup (on case insensitive filesystems only!) set_ne case_insensitive 0 diff --git a/src/xschemrc b/src/xschemrc index 309673af..1cac0487 100644 --- a/src/xschemrc +++ b/src/xschemrc @@ -612,6 +612,14 @@ #### or tab is open. # set tabbed_interface 0 +########################################################################### +#### OPEN FILES IN NEW WINDOW OR TAB +########################################################################### +#### if enabled a File->Open action will open in a new window or tab +#### instead of replacing content in current window/tab +#### default: disabled (0) +# set open_in_new_window_or_tab 1 + ########################################################################### #### ALTERNATE SYMBOL PLACEMENT BROWSER ###########################################################################