implement Alt-o and menu "File->Open in new window"

This commit is contained in:
stefan schippers 2025-09-13 10:46:14 +02:00
parent 17c5d229db
commit dbdfb3015e
5 changed files with 17 additions and 9 deletions

View File

@ -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;

View File

@ -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++;
}

View File

@ -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

View File

@ -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);

View File

@ -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}