From 55fcf5d28e82a4990612634a7fc806ee37536f5f Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 12 Sep 2023 09:21:54 +0200 Subject: [PATCH] avoid doing a move_objects(RUBBER,...) if doing an "xschem paste xoffs yoffs" from script, to avoid graphical artifacts --- src/paste.c | 22 ++++++++++++++-------- src/scheduler.c | 4 +++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/paste.c b/src/paste.c index ddc30a71..32e56b9f 100644 --- a/src/paste.c +++ b/src/paste.c @@ -282,12 +282,16 @@ static void merge_inst(int k,FILE *fd) xctx->instances++; } -/* merge selection if selection_load=1, otherwise ask for filename */ -/* selection_load: */ -/* 0: ask filename to merge */ -/* if ext=="" else use ext as name ... 20071215 */ -/* 1: merge selection */ -/* 2: merge clipboard */ +/* merge selection if selection_load=1, otherwise ask for filename + * selection_load: + * 0: ask filename to merge + * if ext=="" else use ext as name + * 1: merge selection + * 2: merge clipboard + * if bit 3 is set do not start a move_objects(RUBBER,0,0,0) + * to avoid graphical artifacts if doing a xschem paste with x and y offsets + * from script + */ void merge_file(int selection_load, const char ext[]) { FILE *fd; @@ -298,8 +302,10 @@ void merge_file(int selection_load, const char ext[]) char tmp[256]; /* 20161122 overflow safe */ char *aux_ptr=NULL; int got_mouse, generator = 0; + int rubber = 1; - + rubber = !(selection_load & 8); + selection_load &= 7; if(selection_load==0) { if(!strcmp(ext,"")) { @@ -425,7 +431,7 @@ void merge_file(int selection_load, const char ext[]) move_objects(START,0,0,0); xctx->mousex_snap = xctx->mx_double_save; xctx->mousey_snap = xctx->my_double_save; - move_objects(RUBBER,0,0,0); + if(rubber) move_objects(RUBBER,0,0,0); } else { dbg(0, "merge_file(): can not open %s\n", name); } diff --git a/src/scheduler.c b/src/scheduler.c index 606c9b5f..b8eed6df 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -2464,11 +2464,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg * Paste clipboard. If 'x y' not given user should complete placement in the GUI */ else if(!strcmp(argv[1], "paste")) { - merge_file(2, ".sch"); if(argc > 3) { + merge_file(10, ".sch"); /* set bit 3 to avoid doing move_objects(RUBBER,...) */ xctx->deltax = atof(argv[2]); xctx->deltay = atof(argv[3]); move_objects(END, 0, 0.0, 0.0); + } else { + merge_file(2, ".sch"); } Tcl_ResetResult(interp); }