added "PWD" button in file load/place component dialog box that brings back to the directory containing current schematic. Selecting a component before doing "place component" will make the file load dialog start from the directory containing the selected component

This commit is contained in:
Stefan Frederik 2020-12-05 05:18:35 +01:00
parent f138db5aba
commit f9f9de3371
3 changed files with 27 additions and 1 deletions

View File

@ -888,6 +888,13 @@ int callback(int event, int mx, int my, KeySym key,
{
if(xctx->semaphore >= 2) break;
last_command = 0;
#if 1 /* enable on request also in scheduler.c */
rebuild_selected_array();
if(xctx->lastsel && xctx->sel_array[0].type==ELEMENT) {
Tcl_VarEval(interp, "set INITIALINSTDIR [file dirname {",
abs_sym_path(xctx->inst[xctx->sel_array[0].n].name, ""), "}]", NULL);
}
#endif
unselect_all();
/* place_symbol(-1,NULL,xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL,3, 1);*/

View File

@ -1531,6 +1531,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
} else if(argc == 3) {
ret = place_symbol(-1,argv[2],xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1);
} else {
#if 1 /* enable on request also in callback.c */
rebuild_selected_array();
if(xctx->lastsel && xctx->sel_array[0].type==ELEMENT) {
Tcl_VarEval(interp, "set INITIALINSTDIR [file dirname {",
abs_sym_path(xctx->inst[xctx->sel_array[0].n].name, ""), "}]", NULL);
}
#endif
ret = place_symbol(-1,NULL,xctx->mousex_snap, xctx->mousey_snap, 0, 0, NULL, 4, 1);
}

View File

@ -1260,7 +1260,19 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}} {init
#.dialog.buttons.entry delete 0 end
}
}
pack .dialog.buttons.ok .dialog.buttons.up .dialog.buttons.cancel \
button .dialog.buttons.pwd -text PWD -command {
bind .dialog.l.paneright.pre <Expose> {}
.dialog.l.paneright.pre configure -background white
set d [xschem get current_dirname]
if { [file isdirectory $d]} {
myload_set_home $d
setglob $d
myload_set_colors2
set myload_dir1 $d
#.dialog.buttons.entry delete 0 end
}
}
pack .dialog.buttons.ok .dialog.buttons.cancel .dialog.buttons.pwd .dialog.buttons.up \
.dialog.buttons.home .dialog.buttons.label -side left
pack .dialog.buttons.entry -side left -fill x -expand true
pack .dialog.buttons.all .dialog.buttons.sym .dialog.buttons.sch -side left