diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index b1730bba..2475f0de 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -608,6 +608,14 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" if descended into a vector instance change inst number we are into to 'n', (same rules as 'descend' command) without going up and descending again if 'draw' string is given redraw screen +
+ check if schematic / symbol file is already opened and return window path + the loaded schematic is in. + for <filename> use absolute path or use [abs_sym_path filename] + window_path[0] == ".drw" + window_path[1] == ".x1.drw" + ... + else return empty string
List all used symbols in current schematic and warn if some symbol is newer
diff --git a/src/callback.c b/src/callback.c
index 228c02ed..3f0c0da7 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -3938,7 +3938,7 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
/* load last opened file */
char f[PATH_MAX];
xctx->semaphore--;
- my_strncpy(f, tcleval("lindex $tctx::recentfile 0"), S(f));
+ my_strncpy(f, tcleval("get_lastopened"), S(f));
ask_new_file(1, f);
xctx->semaphore++;
}
diff --git a/src/scheduler.c b/src/scheduler.c
index 306cbc33..86cc139f 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -494,6 +494,24 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
}
+ /* check_loaded n
+ * check if schematic / symbol file is already opened and return window path
+ * the loaded schematic is in.
+ * for use absolute path or use [abs_sym_path filename]
+ * window_path[0] == ".drw"
+ * window_path[1] == ".x1.drw"
+ * ...
+ * else return empty string */
+ else if(!strcmp(argv[1], "check_loaded"))
+ {
+ char win_path[WINDOW_PATH_SIZE] = "";
+ if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
+ if(argc > 2) {
+ check_loaded(argv[2], win_path);
+ }
+ Tcl_SetResult(interp, win_path, TCL_VOLATILE);
+ }
+
/* check_symbols
* List all used symbols in current schematic and warn if some symbol is newer */
else if(!strcmp(argv[1], "check_symbols"))
@@ -3037,7 +3055,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
i--;
lastclosed = 0;
} else if(lastopened) {
- my_strncpy(f, tcleval("lindex $tctx::recentfile 0"), S(f));
+ my_strncpy(f, tcleval("get_lastopened"), S(f));
i--;
lastopened = 0;
} else {
@@ -3122,7 +3140,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(!strcmp(argv[i], "-lastclosed")) {
my_strncpy(f, tcleval("get_lastclosed"), S(f));
} else if(!strcmp(argv[i], "-lastopened")) {
- my_strncpy(f, tcleval("lindex $tctx::recentfile 0"), S(f));
+ my_strncpy(f, tcleval("get_lastopened"), S(f));
} else if(!is_from_web(argv[i])) {
my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[i], home_dir);
tcleval(f);
diff --git a/src/xinit.c b/src/xinit.c
index f6fbe8b6..b2ba87c5 100644
--- a/src/xinit.c
+++ b/src/xinit.c
@@ -1490,15 +1490,17 @@ int check_loaded(const char *f, char *win_path)
int i;
Xschem_ctx *ctx;
int found = 0;
+ my_strncpy(win_path, "", S(window_path[i]));
for(i = 0; i < MAX_NEW_WINDOWS; ++i) {
- ctx = save_xctx[i];
dbg(1, "window_count=%d i=%d\n", window_count, i);
/* if only one schematic it is not yet saved in save_xctx */
if(window_count == 0 && i == 0) {
ctx = xctx;
my_snprintf(window_path[0], S(window_path[0]), ".drw" );
+ } else {
+ ctx = save_xctx[i];
}
- if(ctx) {
+ if(ctx && ctx->sch[ctx->currsch]) {
dbg(1, "%s <--> %s\n", ctx->sch[ctx->currsch], f);
if(!strcmp(ctx->sch[ctx->currsch], f)) {
dbg(1, "check_loaded(): f=%s, sch=%s\n", f, ctx->sch[ctx->currsch]);
@@ -3112,7 +3114,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
}
if(cli_opt_lastopened) {
- my_strncpy(cli_opt_filename, tcleval("lindex $tctx::recentfile 0"), S(cli_opt_filename));
+ my_strncpy(cli_opt_filename, tcleval("get_lastopened"), S(cli_opt_filename));
}
if(cli_opt_filename[0]) {
diff --git a/src/xschem.tcl b/src/xschem.tcl
index 3f43be51..913c4d0f 100644
--- a/src/xschem.tcl
+++ b/src/xschem.tcl
@@ -8610,6 +8610,9 @@ proc get_lastclosed {} {
if {$ret eq [abs_sym_path untitled.sch]} {
continue
}
+ if {[xschem check_loaded $ret] ne {}} {
+ continue
+ }
if { $ret ne {}} {
break
}
@@ -8619,6 +8622,16 @@ proc get_lastclosed {} {
return $ret
}
+proc get_lastopened {} {
+ set f {}
+ foreach f $tctx::recentfile {
+ if {[xschem check_loaded $f] eq {}} {
+ break
+ }
+ }
+ return $f
+}
+
proc quit_xschem { {force {}}} {
global tabbed_interface