From 6ca06347b6b72584e7fc0a2cc21125a0d23cba95 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 23 Sep 2025 02:08:17 +0200 Subject: [PATCH] when switching to a different tab/window the related schematic will be marked as dirty (asterisk) if underlying file is changed. --- src/xinit.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/xinit.c b/src/xinit.c index 464d31f1..53982f6f 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1552,6 +1552,8 @@ static int switch_window(int *window_count, const char *win_path, int tcl_ctx) } /* if window was closed then tkwin == 0 --> do nothing */ if(tkwin && n >= 0 && n < MAX_NEW_WINDOWS) { + struct stat buf; + if(tcl_ctx) tclvareval("save_ctx ", xctx->current_win_path, NULL); xctx = save_xctx[n]; if(tcl_ctx) { @@ -1559,7 +1561,12 @@ static int switch_window(int *window_count, const char *win_path, int tcl_ctx) tclvareval("housekeeping_ctx", NULL); } if(tcl_ctx && has_x) tclvareval("reconfigure_layers_button {}", NULL); - set_modify(-1); /* sets window title */ + if(!stat( xctx->sch[xctx->currsch], &buf) && xctx->time_last_modify && + xctx->time_last_modify != buf.st_mtime) { + set_modify(1); + } else { + set_modify(-1); /* sets window title */ + } return 0; } else return 1; } @@ -1596,6 +1603,7 @@ static int switch_tab(int *window_count, const char *win_path, int dr) dbg(1, "new_schematic() switch_tab: %s\n", new_path); /* if no matching tab found --> do nothing */ if(n >= 0 && n < MAX_NEW_WINDOWS) { + struct stat buf; if(xctx->current_win_path) { my_strncpy(previous_win_path, xctx->current_win_path, sizeof(previous_win_path)); } @@ -1607,7 +1615,13 @@ static int switch_tab(int *window_count, const char *win_path, int dr) if(has_x) tclvareval("reconfigure_layers_button {}", NULL); xctx->window = save_xctx[0]->window; if(dr) resetwin(1, 1, 1, 0, 0); - set_modify(-1); /* sets window title */ + /* file exists and modification time on disk has changed since file loaded ... */ + if(!stat( xctx->sch[xctx->currsch], &buf) && xctx->time_last_modify && + xctx->time_last_modify != buf.st_mtime) { + set_modify(1); + } else { + set_modify(-1); /* sets window title */ + } if(dr) draw(); return 0; } else return 1;