improve preview_window, to redraw current schematic just use `xschem preview_window draw` (no filename -> use current loaded one)

This commit is contained in:
stefan schippers 2024-04-14 23:55:47 +02:00
parent 3d20b44ced
commit 260256afb9
2 changed files with 15 additions and 13 deletions

View File

@ -3361,8 +3361,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1], "preview_window"))
{
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(argc == 3) preview_window(argv[2], "{}", "{}");
else if(argc == 4) preview_window(argv[2], argv[3], "{}");
if(argc == 3) preview_window(argv[2], "", NULL);
else if(argc == 4) preview_window(argv[2], argv[3], NULL);
else if(argc == 5) {
char f[PATH_MAX + 100];
my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[4], home_dir);

View File

@ -1206,7 +1206,7 @@ void preview_window(const char *what, const char *win_path, const char *fname)
dbg(1, "preview_window() draw\n");
save_xctx = xctx; /* save current schematic */
xctx = preview_xctx;
if(!current_file || strcmp(fname, current_file) ) {
if(fname && fname[0] && (!current_file || strcmp(fname, current_file)) ) {
if(current_file) {
delete_schematic_data(1);
}
@ -1229,21 +1229,23 @@ void preview_window(const char *what, const char *win_path, const char *fname)
xctx = save_xctx;
}
else if(!strcmp(what, "destroy") || !strcmp(what, "close")) {
dbg(1, "preview_window() destroy\n");
save_xctx = xctx; /* save current schematic */
xctx = preview_xctx;
if(current_file) {
delete_schematic_data(1);
preview_xctx = NULL;
dbg(1, "preview_window(): %s\n", what);
if(preview_xctx) {
save_xctx = xctx; /* save current schematic */
xctx = preview_xctx;
if(current_file) {
delete_schematic_data(1);
preview_xctx = NULL;
}
my_free(_ALLOC_ID_, &current_file);
xctx = save_xctx; /* restore schematic */
save_xctx = NULL;
set_modify(-1);
}
if(!strcmp(what, "destroy")) {
Tk_DestroyWindow(tkpre_window);
tkpre_window = NULL;
}
my_free(_ALLOC_ID_, &current_file);
xctx = save_xctx; /* restore schematic */
save_xctx = NULL;
set_modify(-1);
}
tclvareval("restore_ctx ", xctx->current_win_path, NULL);
semaphore--;