symbol_in_new_window(): if no symbol selected build file name for symbol of current schematic and open it in a new tab. If opening a non existing xxxx.sym file euristically set netlist_type to symbol. proc open_sub_schematic: if no symbol selected for subcircuit to open, open the corresponsing schematic of the symbol we are editing

This commit is contained in:
stefan schippers 2025-01-21 02:57:46 +01:00
parent 6adee35b89
commit 5d52d322b5
4 changed files with 29 additions and 4 deletions

View File

@ -1604,7 +1604,11 @@ void symbol_in_new_window(int new_process)
rebuild_selected_array();
if(xctx->lastsel !=1 || xctx->sel_array[0].type!=ELEMENT) {
my_strncpy(filename, xctx->sch[xctx->currsch], S(filename));
if(tclgetboolvar("search_schematic")) {
my_strncpy(filename, abs_sym_path(xctx->current_name, ".sym"), S(filename));
} else {
my_strncpy(filename, add_ext(xctx->sch[xctx->currsch], ".sym"), S(filename));
}
if(new_process) new_xschem_process(filename, 1);
else new_schematic("create", NULL, filename, 1);
}

View File

@ -3523,6 +3523,8 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler
}
else fd=fopen(name,fopen_read_mode);
if( fd == NULL) {
size_t len;
char *ptr;
ret = 0;
if(alert) {
fprintf(errfp, "load_schematic(): unable to open file: %s, fname=%s\n", name, fname );
@ -3531,6 +3533,14 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler
tcleval(msg);
}
}
len = strlen(name);
ptr = strstr(name, ".sym");
if(ptr && ptr - name == len - 4) {
xctx->save_netlist_type = xctx->netlist_type;
xctx->netlist_type = CAD_SYMBOL_ATTRS;
set_tcl_netlist_type();
xctx->loaded_symbol = 1;
}
clear_drawing();
if(reset_undo) set_modify(0);
} else {

View File

@ -4350,6 +4350,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
int e_b = xctx->rect[c][n].ellipse_b;
save = xctx->draw_window; xctx->draw_window = 1;
drawrect(xctx->rectcolor,NOW, x1,y1,x2,y2, 0, e_a, e_b);
filledrect(xctx->rectcolor, NOW, x1, y1, x2, y2, 1, -1, -1);
xctx->draw_window = save;
}
set_modify(1);

View File

@ -3818,9 +3818,19 @@ proc save_file_dialog { msg ext global_initdir {initialf {}} {overwrt 1} } {
# opens indicated instance (or selected one) into a separate tab/window
# keeping the hierarchy path, as it was descended into (as with 'e' key).
proc open_sub_schematic {{inst {}} {inst_number 0}} {
global search_schematic
set rawfile {}
set one_sel [expr {[xschem get lastsel] == 1}]
if { $inst eq {} && $one_sel} {
set n_sel [xschem get lastsel]
if { $inst eq {} && $n_sel == 0} {
if {$search_schematic == 1} {
set f [abs_sym_path [xschem get current_name] {.sch}]
} else {
set f [file rootname [xschem get schname]].sch
}
xschem new_schematic create {} $f
return 1
} elseif { $inst eq {} && $n_sel == 1} {
set inst [lindex [xschem selected_set] 0]
xschem unselect_all
} else {
@ -7084,10 +7094,10 @@ proc tab_ctx_cmd {tab_but what} {
}
# puts $filename
}
proc tab_context_menu {tab_but} {
global retval search_schematic
# find filename associated with tab button
set win_path [lindex [$tab_but cget -command] 3] ;# xschem new_schematic switch .x1.drw
set tablist [xschem tab_list] ;# .drw filename0 .x1.drw filename1 ...