From 6e2754020b1ba15d8c23035c66fd9ef6deb7b642 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 3 Jun 2023 09:37:43 +0200 Subject: [PATCH] added function swap_tabs() (wip) --- src/scheduler.c | 1 + src/xinit.c | 33 +++++++++++++++++++++++++++++++++ src/xschem.h | 1 + 3 files changed, 35 insertions(+) diff --git a/src/scheduler.c b/src/scheduler.c index d91c7efc..cb9da7ae 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -3751,6 +3751,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg * testmode */ else if(!strcmp(argv[1], "test")) { + swap_tabs(0, 1); Tcl_ResetResult(interp); } diff --git a/src/xinit.c b/src/xinit.c index 67d797e7..9c32717f 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1179,6 +1179,39 @@ void preview_window(const char *what, const char *win_path, const char *fname) semaphore--; } + +void swap_tabs(int i, int j) +{ + int wc = window_count; + if(wc && j <=wc && i <= wc && j!=i) { + Xschem_ctx *ctx; + char *tmp; + + + tmp = save_xctx[i]->top_path; + save_xctx[i]->top_path = save_xctx[j]->top_path; + save_xctx[j]->top_path = tmp; + + tmp = save_xctx[i]->current_win_path; + save_xctx[i]->current_win_path = save_xctx[j]->current_win_path; + save_xctx[j]->current_win_path = tmp; + + ctx = save_xctx[i]; + save_xctx[i] = save_xctx[j]; + save_xctx[j] = ctx; + + /* update filenames on tab buttons */ + ctx = xctx; + xctx = save_xctx[i]; + set_modify(-1); + xctx = save_xctx[j]; + set_modify(-1); + xctx = ctx; + set_modify(-1); + } +} + + /* check if filename is already loaded into a tab or window */ /* caller should supply a win_path string for storing matching window path */ int check_loaded(const char *f, char *win_path) diff --git a/src/xschem.h b/src/xschem.h index 7b8ad4f7..f27ca91b 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1332,6 +1332,7 @@ extern void mem_delete_undo(void); extern void mem_clear_undo(void); extern void load_schematic(int load_symbol, const char *fname, int reset_undo, int alert); /* check if filename already in an open window/tab */ +extern void swap_tabs(int i, int j); extern int check_loaded(const char *f, char *win_path); extern char *get_window_path(int i); extern int get_window_count(void);