allow multi-selections when loading a file; limit max line width in change_linewidth() to avoid strange artifacts at extreme zoom-ins

This commit is contained in:
stefan schippers 2025-03-09 02:46:58 +01:00
parent 2f1643368e
commit de6434c941
4 changed files with 65 additions and 17 deletions

View File

@ -3395,6 +3395,9 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
{
if(xctx->semaphore >= 2) return;
ask_new_file();
xctx->semaphore--;
tcleval("load_additional_files");
xctx->semaphore++;
return;
}
if(key=='S' && rstate == 0) /* change element order */

View File

@ -2941,6 +2941,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
first = i;
if(argc==2) {
ask_new_file();
tcleval("load_additional_files");
} else
for(i = first; i < argc; i++) {
char f[PATH_MAX + 100];
@ -3016,13 +3017,32 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
int cancel = 0;
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(argc > 2) {
if(!is_from_web(argv[2])) {
my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[2], home_dir);
tcleval(f);
/* tclvareval("file normalize {", tclresult(), "}", NULL); */
my_strncpy(f, abs_sym_path(tclresult(), ""), S(f));
} else {
my_strncpy(f, argv[2], S(f));
int i;
for(i = 2; i < argc; i++) {
if(!is_from_web(argv[i])) {
my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[i], home_dir);
tcleval(f);
/* tclvareval("file normalize {", tclresult(), "}", NULL); */
my_strncpy(f, abs_sym_path(tclresult(), ""), S(f));
} else {
my_strncpy(f, argv[i], S(f));
}
if(f[0]) {
char win_path[WINDOW_PATH_SIZE];
dbg(1, "f=%s\n", f);
if(check_loaded(f, win_path)) {
char msg[PATH_MAX + 100];
my_snprintf(msg, S(msg),
"tk_messageBox -type okcancel -icon warning -parent [xschem get topwindow] "
"-message {Warning: %s already open.}", f);
tcleval(msg);
if(strcmp(tclresult(), "ok")) continue;
}
new_schematic("create", "noconfirm", f, 1);
tclvareval("update_recent_file {", f, "}", NULL);
} else {
new_schematic("create", NULL, NULL, 1);
}
}
} else {
tcleval("load_file_dialog {Load file} *.\\{sch,sym,tcl\\} INITIALLOADDIR");
@ -3031,14 +3051,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
} else {
cancel = 1;
}
}
if(!cancel) {
if(f[0]) {
dbg(1, "f=%s\n", f);
new_schematic("create", "noconfirm", f, 1);
tclvareval("update_recent_file {", f, "}", NULL);
} else {
new_schematic("create", NULL, NULL, 1);
if(!cancel) {
if(f[0]) {
dbg(1, "f=%s\n", f);
new_schematic("create", "noconfirm", f, 1);
tclvareval("update_recent_file {", f, "}", NULL);
} else {
new_schematic("create", NULL, NULL, 1);
}
}
}
Tcl_ResetResult(interp);

View File

@ -2060,6 +2060,7 @@ void change_linewidth(double w)
double cs = tclgetdoublevar("cadsnap");
if(tclgetboolvar("change_lw")) {
xctx->lw=xctx->mooz * 0.09 * cs;
if(xctx->lw > 100.) xctx->lw = 100.;
xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 20. ? cs : 20.) / 10.;
}
/* explicitly set line width */

View File

@ -4369,8 +4369,10 @@ proc file_dialog_display_preview {f} {
proc file_dialog_right_listboxselect {dirselect} {
global file_dialog_yview file_dialog_dir1 file_dialog_dir2 file_dialog_retval file_dialog_sel
global OS file_dialog_loadfile file_dialog_index1 file_dialog_files1 file_dialog_globfilter
global file_dialog_others
set file_dialog_yview [.load.l.paneright.f.list yview]
set file_dialog_sel [.load.l.paneright.f.list curselection]
set file_dialog_sel [lindex [.load.l.paneright.f.list curselection] 0]
if { $file_dialog_sel ne {} } {
set curr_dir [abs_sym_path [lindex $file_dialog_files1 $file_dialog_index1]]
set curr_item [.load.l.paneright.f.list get $file_dialog_sel]
@ -4403,6 +4405,17 @@ proc file_dialog_right_listboxselect {dirselect} {
set file_dialog_dir1 $curr_dir
set file_dialog_dir2 $curr_item
set file_dialog_others {}
if {$file_dialog_loadfile == 1} {
foreach i [lrange [.load.l.paneright.f.list curselection] 1 end] {
set file_dialog_retval [.load.l.paneright.f.list get $i]
lappend file_dialog_others [file_dialog_getresult 1 0]
}
}
set file_dialog_retval {} ;# we used this variable above to communicate with file_dialog_getresult
if { [file isdirectory $file_dialog_d]} {
bind .load.l.paneright.draw <Expose> {}
bind .load.l.paneright.draw <Configure> {}
@ -4425,6 +4438,16 @@ proc file_dialog_right_listboxselect {dirselect} {
}
}
proc load_additional_files {} {
global file_dialog_others
if {$file_dialog_others ne {} } {
foreach i $file_dialog_others {
xschem load_new_window $i
}
}
}
# global_initdir: name of global variable containing the initial directory
# loadfile: set to 0 if calling for saving instead of loading a file
# set to 2 for non blocking operation (symbol insertion)
@ -4514,7 +4537,7 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}}
listbox .load.l.paneright.f.list -background {grey90} -listvariable file_dialog_files2 -width 20 -height 12\
-fg black -highlightcolor red -highlightthickness 2 \
-yscrollcommand ".load.l.paneright.f.yscroll set" -selectmode browse \
-yscrollcommand ".load.l.paneright.f.yscroll set" -selectmode extended \
-xscrollcommand ".load.l.paneright.f.xscroll set" -exportselection 0
scrollbar .load.l.paneright.f.yscroll -command ".load.l.paneright.f.list yview" -takefocus 0
scrollbar .load.l.paneright.f.xscroll -command ".load.l.paneright.f.list xview" -orient horiz -takefocus 0
@ -9348,6 +9371,7 @@ set_ne enable_stretch 0
set_ne constr_mv 0
set_ne unselect_partial_sel_wires 0
set_ne load_file_dialog_fullpath 1
set_ne file_dialog_others {} ;# contains 2nd, 3rd, ... selected filenames on mult. selections in load file
# if set show selected elements while dragging the selection rectangle.
# once selected these can not be unselected by retracting the selection rectangle