From f9f9de3371a439634858fc53bea6da420ac7e282 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Sat, 5 Dec 2020 05:18:35 +0100 Subject: [PATCH] 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 --- src/callback.c | 7 +++++++ src/scheduler.c | 7 +++++++ src/xschem.tcl | 14 +++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/callback.c b/src/callback.c index d7553358..171e2e8c 100644 --- a/src/callback.c +++ b/src/callback.c @@ -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);*/ diff --git a/src/scheduler.c b/src/scheduler.c index c8247c63..5f62cfec 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -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); } diff --git a/src/xschem.tcl b/src/xschem.tcl index 039a13dc..9a5095fb 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -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 {} + .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