From 83c692caa9aa92de9465445630abe055538a118b Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 28 Nov 2023 18:41:38 +0100 Subject: [PATCH] copy between windows: allow to navigate between more than 2 windows --- src/callback.c | 17 ++++++++--------- src/globals.c | 1 + src/move.c | 6 +----- src/xinit.c | 5 ++++- src/xschem.h | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/callback.c b/src/callback.c index b68bf3f2..5dbad3f3 100644 --- a/src/callback.c +++ b/src/callback.c @@ -115,7 +115,6 @@ void abort_operation(void) xctx->ui_state &= ~PLACE_SYMBOL; xctx->ui_state &= ~PLACE_TEXT; } - return; } if(xctx->ui_state & STARTCOPY) { @@ -1202,25 +1201,25 @@ int rstate; /* (reduced state, without ShiftMask) */ tclvareval(xctx->top_path, ".drw configure -cursor none" , NULL); else tclvareval(xctx->top_path, ".drw configure -cursor {}" , NULL); - if(!xctx->sel_or_clip[0]) my_snprintf(xctx->sel_or_clip, S(xctx->sel_or_clip), "%s/%s", - user_conf_dir, ".selection.sch"); - /* xschem window *sending* selected objects when the pointer comes back in abort copy operation since it has been done in another xschem xctx->window; STARTCOPY set and selection file does not exist any more */ - if( stat(xctx->sel_or_clip, &buf) && (xctx->ui_state & STARTCOPY) ) + if( stat(sel_or_clip, &buf) && (xctx->ui_state & STARTCOPY) ) { copy_objects(ABORT); /* also unlinks sel_or_flip file */ unselect_all(1); } - /* xschem window *receiving* selected objects */ - /* no selected objects and selection file exists */ - if(xctx->lastsel == 0 && !stat(xctx->sel_or_clip, &buf)) { + /* xschem window *receiving* selected objects selection cleared --> abort */ + if(stat(sel_or_clip, &buf) && (xctx->ui_state & STARTMERGE)) { + abort_operation(); + } + /*xschem window *receiving* selected objects + * no selected objects and selection file exists --> start merge */ + if(xctx->lastsel == 0 && !stat(sel_or_clip, &buf)) { dbg(2, "callback(): Enter event\n"); xctx->mousex_snap = 490; xctx->mousey_snap = -340; merge_file(1, ".sch"); - xunlink(xctx->sel_or_clip); } break; diff --git a/src/globals.c b/src/globals.c index 8821d3c6..9519b918 100644 --- a/src/globals.c +++ b/src/globals.c @@ -174,6 +174,7 @@ int help=0; /* help option set to global scope, printing help is deferred */ FILE *errfp = NULL; char home_dir[PATH_MAX]; /* home dir obtained via getpwuid */ char user_conf_dir[PATH_MAX]; +char sel_or_clip[PATH_MAX]=""; char pwd_dir[PATH_MAX]; /* obtained via getcwd() */ int tcp_port = 0; int text_svg=1; /* use svg element for text instead of xschem's internal vector font */ diff --git a/src/move.c b/src/move.c index 9755860b..9c80ab1c 100644 --- a/src/move.c +++ b/src/move.c @@ -512,7 +512,6 @@ void copy_objects(int what) } if(what & ABORT) /* draw objects while moving */ { - char *str = NULL; /* 20161122 overflow safe */ draw_selection(xctx->gctiled,0); if(xctx->kissing) { @@ -523,11 +522,7 @@ void copy_objects(int what) xctx->move_rot = xctx->move_flip = 0; xctx->deltax = xctx->deltay = 0.; xctx->ui_state&=~STARTCOPY; - my_strdup(_ALLOC_ID_, &str, user_conf_dir); - my_strcat(_ALLOC_ID_, &str, "/.selection.sch"); - xunlink(str); update_symbol_bboxes(0, 0); - my_free(_ALLOC_ID_, &str); } if(what & RUBBER) /* draw objects while moving */ { @@ -553,6 +548,7 @@ void copy_objects(int what) { int l, firstw, firsti; + xunlink(sel_or_clip); set_first_sel(0, -1, 0); /* reset first selected object */ if(xctx->connect_by_kissing == 2) xctx->connect_by_kissing = 0; diff --git a/src/xinit.c b/src/xinit.c index 60714f77..c3018c05 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -498,7 +498,6 @@ static void alloc_xschem_data(const char *top_path, const char *win_path) xctx->modified = 0; xctx->semaphore = 0; xctx->current_name[0] = '\0'; - xctx->sel_or_clip[0] = '\0'; xctx->sch_to_compare[0] = '\0'; xctx->tok_size = 0; xctx->netlist_name[0] = '\0'; @@ -2425,6 +2424,10 @@ int Tcl_AppInit(Tcl_Interp *inter) } /* END SOURCING xschemrc */ + if(!sel_or_clip[0]) { + my_snprintf(sel_or_clip, S(sel_or_clip), "%s/%s", user_conf_dir, ".selection.sch"); + } + if(rainbow_colors) tclsetvar("rainbow_colors","1"); /* */ diff --git a/src/xschem.h b/src/xschem.h index 299d9fa4..c8065cbb 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -987,7 +987,6 @@ typedef struct { /* callback.c */ int already_selected; /* when clicking on an object that is already selected this will be 1 */ int mx_save, my_save, last_command; - char sel_or_clip[PATH_MAX]; int onetime; /* move.c */ double rx1, rx2, ry1, ry2; @@ -1168,6 +1167,7 @@ extern char *cad_icon[]; extern FILE *errfp; extern char home_dir[PATH_MAX]; /* home dir obtained via getpwuid */ extern char user_conf_dir[PATH_MAX]; /* usually ~/.xschem */ +extern char sel_or_clip[PATH_MAX]; extern char pwd_dir[PATH_MAX]; /* obtained via getcwd() */ extern int tcp_port; extern int text_svg;