diff --git a/src/actions.c b/src/actions.c index 64c92f4d..97e394ba 100644 --- a/src/actions.c +++ b/src/actions.c @@ -32,14 +32,13 @@ void here(int i) void set_modify(int mod) { - static int prev = -1; char *top_path; top_path = xctx->top_path[0] ? xctx->top_path : "."; xctx->modified = mod; dbg(1, "set_modify(): %d\n", mod); - if(mod != prev) { - prev = mod; + if(mod != xctx->prev_set_modify) { + xctx->prev_set_modify = mod; if(has_x && strcmp(get_cell(xctx->sch[xctx->currsch],1), "systemlib/font")) { if(mod == 1) { Tcl_VarEval(interp, "wm title ", top_path, " \"xschem - [file tail [xschem get schname]]*\"", NULL); @@ -201,14 +200,12 @@ const char *add_ext(const char *f, const char *ext) void toggle_only_probes() { - static double save_lw; - xctx->only_probes = tclgetboolvar("only_probes"); if(xctx->only_probes) { - save_lw = xctx->lw; + xctx->save_lw = xctx->lw; xctx->lw=3.0; } else { - xctx->lw= save_lw; + xctx->lw= xctx->save_lw; } change_linewidth(xctx->lw); draw(); @@ -218,7 +215,6 @@ void toggle_fullscreen(const char *topwin) { char fullscr[]="add,fullscreen"; char normal[]="remove,fullscreen"; - static int menu_removed = 0; unsigned int topwin_id; Window rootwindow, parent_id; Window *framewin_child_ptr; @@ -246,13 +242,13 @@ void toggle_fullscreen(const char *topwin) dbg(1, "toggle_fullscreen(): fullscreen=%d\n", fs); if(fs==2) { Tcl_VarEval(interp, "pack forget ", xctx->top_path, ".menubar ", xctx->top_path, ".statusbar; update", NULL); - menu_removed = 1; + xctx->menu_removed = 1; } - if(fs !=2 && menu_removed) { + if(fs !=2 && xctx->menu_removed) { Tcl_VarEval(interp, "pack ", xctx->top_path, ".menubar -anchor n -side top -fill x -before ", xctx->top_path, ".drw; pack ", xctx->top_path, ".statusbar -after ", xctx->top_path, ".drw -anchor sw -fill x; update", NULL); - menu_removed=0; + xctx->menu_removed=0; } @@ -1447,8 +1443,8 @@ void set_viewport_size(int w, int h, double lw) void save_restore_zoom(int save) { - static int savew, saveh; - static double savexor, saveyor, savezoom, savelw; + static int savew, saveh; /* safe to keep even with multiple schematics */ + static double savexor, saveyor, savezoom, savelw; /* safe to keep even with multiple schematics */ if(save) { savew = xctx->xschem_w; @@ -2349,53 +2345,48 @@ int place_text(int draw_text, double mx, double my) void pan2(int what, int mx, int my) { int dx, dy, ddx, ddy; - static int mx_s, my_s; - static int mmx_s, mmy_s; - static double xorig_save, yorig_save; if(what & START) { - mmx_s = mx_s = mx; - mmy_s = my_s = my; - xorig_save = xctx->xorigin; - yorig_save = xctx->yorigin; + xctx->mmx_s = xctx->mx_s = mx; + xctx->mmy_s = xctx->my_s = my; + xctx->xorig_save = xctx->xorigin; + xctx->yorig_save = xctx->yorigin; } else if(what == RUBBER) { - dx = mx - mx_s; - dy = my - my_s; - ddx = abs(mx -mmx_s); - ddy = abs(my -mmy_s); + dx = mx - xctx->mx_s; + dy = my - xctx->my_s; + ddx = abs(mx -xctx->mmx_s); + ddy = abs(my -xctx->mmy_s); if(ddx>5 || ddy>5) { - xctx->xorigin = xorig_save + dx*xctx->zoom; - xctx->yorigin = yorig_save + dy*xctx->zoom; + xctx->xorigin = xctx->xorig_save + dx*xctx->zoom; + xctx->yorigin = xctx->yorig_save + dy*xctx->zoom; draw(); - mmx_s = mx; - mmy_s = my; + xctx->mmx_s = mx; + xctx->mmy_s = my; } } } void pan(int what) { - static double xpan,ypan,xpan2,ypan2; - static double xx1,xx2,yy1,yy2; if(what & RUBBER) { - xx1=xpan;yy1=ypan;xx2=xpan2;yy2=ypan2; - ORDER(xx1,yy1,xx2,yy2); - drawtempline(xctx->gctiled, NOW, xx1,yy1,xx2,yy2); - xpan2=xctx->mousex_snap;ypan2=xctx->mousey_snap; - xx1=xpan;yy1=ypan;xx2=xpan2;yy2=ypan2; - ORDER(xx1,yy1,xx2,yy2); - drawtempline(xctx->gc[SELLAYER], NOW, xx1,yy1,xx2,yy2); + xctx->p_xx1 = xctx->xpan; xctx->p_yy1 = xctx->ypan; xctx->p_xx2 = xctx->xpan2; xctx->p_yy2 = xctx->ypan2; + ORDER(xctx->p_xx1, xctx->p_yy1, xctx->p_xx2, xctx->p_yy2); + drawtempline(xctx->gctiled, NOW, xctx->p_xx1, xctx->p_yy1, xctx->p_xx2, xctx->p_yy2); + xctx->xpan2 = xctx->mousex_snap; xctx->ypan2 = xctx->mousey_snap; + xctx->p_xx1 = xctx->xpan; xctx->p_yy1 = xctx->ypan; xctx->p_xx2 = xctx->xpan2; xctx->p_yy2 = xctx->ypan2; + ORDER(xctx->p_xx1, xctx->p_yy1, xctx->p_xx2, xctx->p_yy2); + drawtempline(xctx->gc[SELLAYER], NOW, xctx->p_xx1, xctx->p_yy1, xctx->p_xx2, xctx->p_yy2); } if(what & START) { xctx->ui_state |= STARTPAN; - xpan=xctx->mousex_snap;ypan=xctx->mousey_snap;xpan2=xpan;ypan2=ypan; + xctx->xpan=xctx->mousex_snap;xctx->ypan=xctx->mousey_snap;xctx->xpan2=xctx->xpan;xctx->ypan2=xctx->ypan; } if(what & END) { xctx->ui_state &= ~STARTPAN; - xctx->xorigin+=-xpan+xctx->mousex_snap;xctx->yorigin+=-ypan+xctx->mousey_snap; + xctx->xorigin+=-xctx->xpan+xctx->mousex_snap;xctx->yorigin+=-xctx->ypan+xctx->mousey_snap; draw(); } } diff --git a/src/callback.c b/src/callback.c index b8819aa7..38add77c 100644 --- a/src/callback.c +++ b/src/callback.c @@ -326,17 +326,16 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, !(xctx->ui_state & STARTPAN2) && !(state & Mod1Mask) && !(state & ShiftMask) && !(xctx->ui_state & (PLACE_SYMBOL | PLACE_TEXT))) { - static int onetime=0; if(mx != xctx->mx_save || my != xctx->my_save) { if( !(xctx->ui_state & STARTSELECT)) { select_rect(START,1); - onetime=1; + xctx->onetime=1; } if(abs(mx-xctx->mx_save) > 8 || abs(my-xctx->my_save) > 8 ) { /* set reasonable threshold before unsel */ - if(onetime) { + if(xctx->onetime) { unselect_all(); /* 20171026 avoid multiple calls of unselect_all() */ - onetime=0; + xctx->onetime=0; } xctx->ui_state|=STARTSELECT; /* set it again cause unselect_all() clears it... */ } diff --git a/src/check.c b/src/check.c index 7d2732ca..b5ce712f 100644 --- a/src/check.c +++ b/src/check.c @@ -121,6 +121,7 @@ void update_conn_cues(int draw_cues, int dr_win) * start = 2: return total time from initialize */ double timer(int start) { + /* used only for test mode. No problem with switching schematic context */ static double st, cur, lap; if(start == 0) return lap = st = (double) clock() / CLOCKS_PER_SEC; else if(start == 1) { @@ -140,7 +141,7 @@ void trim_wires(void) int j, i, changed; int includes, breaks; struct wireentry *wptr; - static unsigned short *wireflag=NULL; + unsigned short *wireflag=NULL; doloops = 0; xctx->prep_hash_wires = 0; diff --git a/src/draw.c b/src/draw.c index 274c8fc7..bb25c934 100644 --- a/src/draw.c +++ b/src/draw.c @@ -30,8 +30,6 @@ #define xDashType LineOnOffDash #endif -static double textx1,textx2,texty1,texty2; - int textclip(int x1,int y1,int x2,int y2, double xa,double ya,double xb,double yb) /* check if some of (xa,ya-xb,yb) is inside (x1,y1-x2,y2) */ @@ -187,6 +185,7 @@ static void cairo_draw_string_line(cairo_t *c_ctx, char *s, void draw_string(int layer, int what, const char *str, short rot, short flip, int hcenter, int vcenter, double x, double y, double xscale, double yscale) { + double textx1,textx2,texty1,texty2; char *tt, *ss, *sss=NULL; char c; int lineno=0; @@ -266,6 +265,7 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in void draw_string(int layer, int what, const char *str, short rot, short flip, int hcenter, int vcenter, double x1,double y1, double xscale, double yscale) { + double textx1,textx2,texty1,texty2; double a=0.0,yy; register double rx1=0,rx2=0,ry1=0,ry2=0; double curr_x1,curr_y1,curr_x2,curr_y2; @@ -329,6 +329,7 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in void draw_temp_string(GC gctext, int what, const char *str, short rot, short flip, int hcenter, int vcenter, double x1,double y1, double xscale, double yscale) { + double textx1,textx2,texty1,texty2; int tmp; if(!has_x) return; dbg(2, "draw_string(): string=%s\n",str); diff --git a/src/editprop.c b/src/editprop.c index 497c2f76..e58b52a1 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -857,32 +857,28 @@ void edit_text_property(int x) my_free(890, &oldprop); } -static char *old_prop=NULL; -static int i=-1; -static int netlist_commands; - /* x=0 use text widget x=1 use vim editor */ void edit_symbol_property(int x) { char *result=NULL; - i=xctx->sel_array[0].n; - netlist_commands = 0; - if ((xctx->inst[i].ptr + xctx->sym)->type!=NULL) - netlist_commands = !strcmp( (xctx->inst[i].ptr+ xctx->sym)->type, "netlist_commands"); - - if(xctx->inst[i].prop_ptr!=NULL) { - if(netlist_commands && x==1) { - tclsetvar("retval",get_tok_value( xctx->inst[i].prop_ptr,"value",0)); + xctx->edit_sym_i=xctx->sel_array[0].n; + xctx->netlist_commands = 0; + if ((xctx->inst[xctx->edit_sym_i].ptr + xctx->sym)->type!=NULL) + xctx->netlist_commands = + !strcmp( (xctx->inst[xctx->edit_sym_i].ptr+ xctx->sym)->type, "xctx->netlist_commands"); + if(xctx->inst[xctx->edit_sym_i].prop_ptr!=NULL) { + if(xctx->netlist_commands && x==1) { + tclsetvar("retval",get_tok_value( xctx->inst[xctx->edit_sym_i].prop_ptr,"value",0)); } else { - tclsetvar("retval",xctx->inst[i].prop_ptr); + tclsetvar("retval",xctx->inst[xctx->edit_sym_i].prop_ptr); } } else { tclsetvar("retval",""); } - my_strdup(91, &old_prop, xctx->inst[i].prop_ptr); - tclsetvar("symbol",xctx->inst[i].name); + my_strdup(91, &xctx->old_prop, xctx->inst[xctx->edit_sym_i].prop_ptr); + tclsetvar("symbol",xctx->inst[xctx->edit_sym_i].name); if(x==0) { tcleval("edit_prop {Input property:}"); @@ -892,7 +888,7 @@ void edit_symbol_property(int x) /* edit_vi_netlist_prop will replace \" with " before editing, replace back " with \" when done and wrap the resulting text with quotes ("text") when done */ - if(netlist_commands && x==1) tcleval("edit_vi_netlist_prop {Input property:}"); + if(xctx->netlist_commands && x==1) tcleval("edit_vi_netlist_prop {Input property:}"); else if(x==1) tcleval("edit_vi_prop {Input property:}"); else if(x==2) tcleval("viewdata $::retval"); my_strdup(78, &result, tclresult()); @@ -901,7 +897,7 @@ void edit_symbol_property(int x) update_symbol(result, x); my_free(728, &result); dbg(1, "edit_symbol_property(): done update_symbol, modified=%d\n", xctx->modified); - i=-1; + xctx->edit_sym_i=-1; } /* x=0 use text widget x=1 use vim editor */ @@ -921,16 +917,16 @@ void update_symbol(const char *result, int x) s_pnetname = tclgetboolvar("show_pin_net_names"); dbg(1, "update_symbol(): entering\n"); - i=xctx->sel_array[0].n; + xctx->edit_sym_i=xctx->sel_array[0].n; if(!result) { dbg(1, "update_symbol(): edit symbol prop aborted\n"); - my_free(1289, &old_prop); + my_free(1289, &xctx->old_prop); return; } /* create new_prop updated attribute string */ - if(netlist_commands && x==1) { + if(xctx->netlist_commands && x==1) { my_strdup(79, &new_prop, - subst_token(old_prop, "value", (char *) tclgetvar("retval") ) + subst_token(xctx->old_prop, "value", (char *) tclgetvar("retval") ) ); dbg(1, "update_symbol(): new_prop=%s\n", new_prop); dbg(1, "update_symbol(): tcl retval==%s\n", tclgetvar("retval")); @@ -957,7 +953,7 @@ void update_symbol(const char *result, int x) to use for inst name (from symbol template) */ prefix=0; sym_number = -1; - if(strcmp(symbol, xctx->inst[i].name)) { + if(strcmp(symbol, xctx->inst[xctx->edit_sym_i].name)) { set_modify(1); sym_number=match_symbol(symbol); /* check if exist */ if(sym_number>=0) { @@ -967,14 +963,14 @@ void update_symbol(const char *result, int x) for(k=0;klastsel;k++) { dbg(1, "update_symbol(): for k loop: k=%d\n", k); if(xctx->sel_array[k].type!=ELEMENT) continue; - i=xctx->sel_array[k].n; + xctx->edit_sym_i=xctx->sel_array[k].n; if(s_pnetname || xctx->hilight_nets) { int j; prepare_netlist_structs(0); - for(j = 0; j < (xctx->inst[i].ptr + xctx->sym)->rects[PINLAYER]; j++) { - if( xctx->inst[i].node && xctx->inst[i].node[j]) { - int_hash_lookup(xctx->node_redraw_table, xctx->inst[i].node[j], 0, XINSERT_NOREPLACE); + for(j = 0; j < (xctx->inst[xctx->edit_sym_i].ptr + xctx->sym)->rects[PINLAYER]; j++) { + if( xctx->inst[xctx->edit_sym_i].node && xctx->inst[xctx->edit_sym_i].node[j]) { + int_hash_lookup(xctx->node_redraw_table, xctx->inst[xctx->edit_sym_i].node[j], 0, XINSERT_NOREPLACE); } } find_inst_to_be_redrawn(); @@ -982,17 +978,19 @@ void update_symbol(const char *result, int x) /* 20171220 calculate bbox before changes to correctly redraw areas */ /* must be recalculated as cairo text extents vary with zoom factor. */ - symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2); + symbol_bbox(xctx->edit_sym_i, &xctx->inst[xctx->edit_sym_i].x1, &xctx->inst[xctx->edit_sym_i].y1, + &xctx->inst[xctx->edit_sym_i].x2, &xctx->inst[xctx->edit_sym_i].y2); if(sym_number>=0) /* changing symbol ! */ { if(!pushed) { push_undo(); pushed=1;} - delete_inst_node(i); /* 20180208 fix crashing bug: delete node info if changing symbol */ - /* if number of pins is different we must delete these data *before* */ - /* changing ysmbol, otherwise i might end up deleting non allocated data. */ - my_strdup(82, &xctx->inst[i].name, rel_sym_path(symbol)); - xctx->inst[i].ptr=sym_number; /* update instance to point to new symbol */ + delete_inst_node(xctx->edit_sym_i); /* 20180208 fix crashing bug: delete node info if changing symbol */ + /* if number of pins is different we must delete these data *before* */ + /* changing ysmbol, otherwise xctx->edit_sym_i might end up deleting non allocated data. */ + my_strdup(82, &xctx->inst[xctx->edit_sym_i].name, rel_sym_path(symbol)); + xctx->inst[xctx->edit_sym_i].ptr=sym_number; /* update instance to point to new symbol */ } - bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2); + bbox(ADD, xctx->inst[xctx->edit_sym_i].x1, xctx->inst[xctx->edit_sym_i].y1, + xctx->inst[xctx->edit_sym_i].x2, xctx->inst[xctx->edit_sym_i].y2); /* update property string from tcl dialog */ if(!no_change_props) @@ -1000,54 +998,59 @@ void update_symbol(const char *result, int x) dbg(1, "update_symbol(): no_change_props=%d\n", no_change_props); if(only_different) { char * ss=NULL; - my_strdup(119, &ss, xctx->inst[i].prop_ptr); - if( set_different_token(&ss, new_prop, old_prop, 0, 0) ) { + my_strdup(119, &ss, xctx->inst[xctx->edit_sym_i].prop_ptr); + if( set_different_token(&ss, new_prop, xctx->old_prop, 0, 0) ) { if(!pushed) { push_undo(); pushed=1;} - my_strdup(111, &xctx->inst[i].prop_ptr, ss); + my_strdup(111, &xctx->inst[xctx->edit_sym_i].prop_ptr, ss); set_modify(1); } my_free(729, &ss); } else { if(new_prop) { - if(!xctx->inst[i].prop_ptr || strcmp(xctx->inst[i].prop_ptr, new_prop)) { - dbg(1, "update_symbol(): changing prop: |%s| -> |%s|\n", xctx->inst[i].prop_ptr, new_prop); + if(!xctx->inst[xctx->edit_sym_i].prop_ptr || strcmp(xctx->inst[xctx->edit_sym_i].prop_ptr, new_prop)) { + dbg(1, "update_symbol(): changing prop: |%s| -> |%s|\n", + xctx->inst[xctx->edit_sym_i].prop_ptr, new_prop); if(!pushed) { push_undo(); pushed=1;} - my_strdup(84, &xctx->inst[i].prop_ptr, new_prop); + my_strdup(84, &xctx->inst[xctx->edit_sym_i].prop_ptr, new_prop); set_modify(1); } } else { if(!pushed) { push_undo(); pushed=1;} - my_strdup(86, &xctx->inst[i].prop_ptr, ""); + my_strdup(86, &xctx->inst[xctx->edit_sym_i].prop_ptr, ""); set_modify(1); } } } /* if symbol changed ensure instance name (with new prefix char) is unique */ /* preserve backslashes in name ----------------------------------->. */ - my_strdup(152, &name, get_tok_value(xctx->inst[i].prop_ptr, "name", 1)); + my_strdup(152, &name, get_tok_value(xctx->inst[xctx->edit_sym_i].prop_ptr, "name", 1)); if(name && name[0] ) { dbg(1, "update_symbol(): prefix!='\\0', name=%s\n", name); /* 20110325 only modify prefix if prefix not NUL */ if(prefix) name[0]=prefix; /* change prefix if changing symbol type; */ - dbg(1, "update_symbol(): name=%s, inst[i].prop_ptr=%s\n", name, xctx->inst[i].prop_ptr); - my_strdup(89, &ptr,subst_token(xctx->inst[i].prop_ptr, "name", name) ); + dbg(1, "update_symbol(): name=%s, inst[xctx->edit_sym_i].prop_ptr=%s\n", + name, xctx->inst[xctx->edit_sym_i].prop_ptr); + my_strdup(89, &ptr,subst_token(xctx->inst[xctx->edit_sym_i].prop_ptr, "name", name) ); /* set name of current inst */ if(!pushed) { push_undo(); pushed=1;} - if(!k) hash_all_names(i); - new_prop_string(i, ptr, k, tclgetboolvar("disable_unique_names")); /* set new prop_ptr */ + if(!k) hash_all_names(xctx->edit_sym_i); + new_prop_string(xctx->edit_sym_i, ptr, k, tclgetboolvar("disable_unique_names")); /* set new prop_ptr */ } - my_strdup2(90, &xctx->inst[i].instname, get_tok_value(xctx->inst[i].prop_ptr, "name",0)); + my_strdup2(90, &xctx->inst[xctx->edit_sym_i].instname, + get_tok_value(xctx->inst[xctx->edit_sym_i].prop_ptr, "name",0)); - type=xctx->sym[xctx->inst[i].ptr].type; + type=xctx->sym[xctx->inst[xctx->edit_sym_i].ptr].type; cond= !type || !IS_LABEL_SH_OR_PIN(type); - if(cond) xctx->inst[i].flags |= 2; /* bit 1: flag for different textlayer for pin/labels */ + if(cond) xctx->inst[xctx->edit_sym_i].flags |= 2; /* bit 1: flag for different textlayer for pin/labels */ else { - xctx->inst[i].flags &= ~2; - my_strdup(880, &xctx->inst[i].lab, get_tok_value(xctx->inst[i].prop_ptr, "lab",0)); + xctx->inst[xctx->edit_sym_i].flags &= ~2; + my_strdup(880, &xctx->inst[xctx->edit_sym_i].lab, + get_tok_value(xctx->inst[xctx->edit_sym_i].prop_ptr, "lab",0)); } - if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"highlight",0), "true")) xctx->inst[i].flags |= 4; - else xctx->inst[i].flags &= ~4; + if(!strcmp(get_tok_value(xctx->inst[xctx->edit_sym_i].prop_ptr,"highlight",0), "true")) + xctx->inst[xctx->edit_sym_i].flags |= 4; + else xctx->inst[xctx->edit_sym_i].flags &= ~4; } /* end for(k=0;klastsel;k++) */ /* new symbol bbox after prop changes (may change due to text length) */ if(xctx->modified) { @@ -1058,14 +1061,17 @@ void update_symbol(const char *result, int x) if(s_pnetname || xctx->hilight_nets) prepare_netlist_structs(0); for(k=0;klastsel;k++) { if(xctx->sel_array[k].type!=ELEMENT) continue; - i=xctx->sel_array[k].n; - type=xctx->sym[xctx->inst[i].ptr].type; - symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2); - bbox(ADD, xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2); + xctx->edit_sym_i=xctx->sel_array[k].n; + type=xctx->sym[xctx->inst[xctx->edit_sym_i].ptr].type; + symbol_bbox(xctx->edit_sym_i, &xctx->inst[xctx->edit_sym_i].x1, &xctx->inst[xctx->edit_sym_i].y1, + &xctx->inst[xctx->edit_sym_i].x2, &xctx->inst[xctx->edit_sym_i].y2); + bbox(ADD, xctx->inst[xctx->edit_sym_i].x1, xctx->inst[xctx->edit_sym_i].y1, + xctx->inst[xctx->edit_sym_i].x2, xctx->inst[xctx->edit_sym_i].y2); if((s_pnetname || xctx->hilight_nets) && type && IS_LABEL_OR_PIN(type)) { - for(j = 0; j < (xctx->inst[i].ptr + xctx->sym)->rects[PINLAYER]; j++) { /* <<< only .node[0] ? */ - if( xctx->inst[i].node && xctx->inst[i].node[j]) { - int_hash_lookup(xctx->node_redraw_table, xctx->inst[i].node[j], 0, XINSERT_NOREPLACE); + /* <<< do only .node[0] ? */ + for(j = 0; j < (xctx->inst[xctx->edit_sym_i].ptr + xctx->sym)->rects[PINLAYER]; j++) { + if( xctx->inst[xctx->edit_sym_i].node && xctx->inst[xctx->edit_sym_i].node[j]) { + int_hash_lookup(xctx->node_redraw_table, xctx->inst[xctx->edit_sym_i].node[j], 0, XINSERT_NOREPLACE); } } } @@ -1083,7 +1089,7 @@ void update_symbol(const char *result, int x) my_free(731, &name); my_free(732, &ptr); my_free(733, &new_prop); - my_free(734, &old_prop); + my_free(734, &xctx->old_prop); } void change_elem_order(void) @@ -1148,7 +1154,6 @@ void edit_property(int x) rebuild_selected_array(); /* from the .sel field in objects build */ if(xctx->lastsel==0 ) /* the array of selected objs */ { - char *old_prop = NULL; char *new_prop = NULL; if(xctx->netlist_type==CAD_SYMBOL_ATTRS) { @@ -1181,7 +1186,6 @@ void edit_property(int x) else tclsetvar("retval",""); } - my_strdup(660, &old_prop, tclgetvar("retval")); if(x==0) tcleval("text_line {Global schematic property:} 0"); else if(x==1) { @@ -1194,7 +1198,6 @@ void edit_property(int x) my_strdup(650, &new_prop, (char *) tclgetvar("retval")); tclsetvar("retval", new_prop); - my_free(892, &old_prop); my_free(893, &new_prop); diff --git a/src/globals.c b/src/globals.c index 8377bd84..ec9f3904 100644 --- a/src/globals.c +++ b/src/globals.c @@ -138,7 +138,7 @@ int debug_var=-10; /* will be set to 0 in xinit.c */ /* -------------------------------------------- */ int help=0; /* help option set to global scope, printing help is deferred */ /* when configuration ~/.schem has been read 20140406 */ -FILE *errfp; +FILE *errfp = NULL; int no_readline=0; char *filename=NULL; /* filename given on cmdline */ char home_dir[PATH_MAX]; /* home dir obtained via getpwuid */ diff --git a/src/save.c b/src/save.c index 937e3ba2..3890a297 100644 --- a/src/save.c +++ b/src/save.c @@ -1041,8 +1041,6 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2 static char msg[PATH_MAX+100]; struct stat buf; int i; - static int save_netlist_type = 0; - static int loaded_symbol = 0; char *top_path; top_path = xctx->top_path[0] ? xctx->top_path : "."; @@ -1078,16 +1076,16 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2 if(reset_undo) { Tcl_VarEval(interp, "is_xschem_file ", xctx->sch[xctx->currsch], NULL); if(!strcmp(tclresult(), "SYMBOL")) { - save_netlist_type = xctx->netlist_type; + xctx->save_netlist_type = xctx->netlist_type; xctx->netlist_type = CAD_SYMBOL_ATTRS; set_tcl_netlist_type(); - loaded_symbol = 1; + xctx->loaded_symbol = 1; } else { - if(loaded_symbol) { - xctx->netlist_type = save_netlist_type; + if(xctx->loaded_symbol) { + xctx->netlist_type = xctx->save_netlist_type; set_tcl_netlist_type(); } - loaded_symbol = 0; + xctx->loaded_symbol = 0; } } } diff --git a/src/scheduler.c b/src/scheduler.c index 0ee89105..af6f1f81 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1407,10 +1407,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else if(!strcmp(argv[1],"log")) { - static int opened=0; cmd_found = 1; - if(argc==3 && opened==0 ) { errfp = fopen(argv[2], "w");opened=1; } /* added check to avoid multiple open */ - else if(argc==2 && opened==1) { fclose(errfp); errfp=stderr;opened=0; } + if(argc==3 && errfp == stderr ) { errfp = fopen(argv[2], "w"); } /* added check to avoid multiple open */ + else if(argc==2 && errfp != stderr) { fclose(errfp); errfp=stderr; } } else if(!strcmp(argv[1],"logic_set")) { diff --git a/src/select.c b/src/select.c index 5c9dfa20..0cc3ebb3 100644 --- a/src/select.c +++ b/src/select.c @@ -22,10 +22,6 @@ #include "xschem.h" -static short select_rot = 0; -static short select_flip = 0; -static double xx1,yy1,xx2,yy2; - /* select all nets and pins/labels that are *physically* connected to current selected wire segments */ /* stop_at_junction==1 --> stop selecting wires at 'T' junctions */ /* Recursive routine */ @@ -320,10 +316,12 @@ static void del_rect_line_arc_poly(void) void delete(int to_push_undo) { int i, j, n, tmp; + int select_rot = 0, select_flip = 0; #if HAS_CAIRO==1 int customfont; #endif int s_pnetname; + double xx1,yy1,xx2,yy2; s_pnetname = tclgetboolvar("show_pin_net_names"); dbg(3, "delete(): start\n"); @@ -499,32 +497,29 @@ void delete_only_rect_line_arc_poly(void) void bbox(int what,double x1,double y1, double x2, double y2) { int i; - static int bbx1, bbx2, bby1, bby2; - static int savew, saveh, savex1, savex2, savey1, savey2; - static int sem=0; /* fprintf(errfp, "bbox: what=%d\n", what); */ switch(what) { case START: - if(sem==1) { + if(xctx->sem==1) { fprintf(errfp, "ERROR: rentrant bbox() call\n"); tcleval("alert_ {ERROR: reentrant bbox() call} {}"); } - bbx1 = 300000000; /* screen coordinates */ - bbx2 = 0; - bby1 = 300000000; - bby2 = 0; - savex1 = xctx->areax1; - savex2 = xctx->areax2; - savey1 = xctx->areay1; - savey2 = xctx->areay2; - savew = xctx->areaw; - saveh = xctx->areah; - sem=1; + xctx->bbx1 = 300000000; /* screen coordinates */ + xctx->bbx2 = 0; + xctx->bby1 = 300000000; + xctx->bby2 = 0; + xctx->savex1 = xctx->areax1; + xctx->savex2 = xctx->areax2; + xctx->savey1 = xctx->areay1; + xctx->savey2 = xctx->areay2; + xctx->savew = xctx->areaw; + xctx->saveh = xctx->areah; + xctx->sem=1; break; case ADD: - if(sem==0) { + if(xctx->sem==0) { fprintf(errfp, "ERROR: bbox(ADD) call before bbox(START)\n"); tcleval("alert_ {ERROR: bbox(ADD) call before bbox(START)} {}"); } @@ -532,24 +527,24 @@ void bbox(int what,double x1,double y1, double x2, double y2) y1=Y_TO_SCREEN(y1); x2=X_TO_SCREEN(x2); y2=Y_TO_SCREEN(y2); - x1=CLIP(x1,savex1,savex2); - x2=CLIP(x2,savex1,savex2); - y1=CLIP(y1,savey1,savey2); - y2=CLIP(y2,savey1,savey2); - if(x1 < bbx1) bbx1 = (int) x1; - if(x2 > bbx2) bbx2 = (int) x2; - if(y1 < bby1) bby1 = (int) y1; - if(y2 > bby2) bby2 = (int) y2; - if(y2 < bby1) bby1 = (int) y2; - if(y1 > bby2) bby2 = (int) y1; + x1=CLIP(x1,xctx->savex1,xctx->savex2); + x2=CLIP(x2,xctx->savex1,xctx->savex2); + y1=CLIP(y1,xctx->savey1,xctx->savey2); + y2=CLIP(y2,xctx->savey1,xctx->savey2); + if(x1 < xctx->bbx1) xctx->bbx1 = (int) x1; + if(x2 > xctx->bbx2) xctx->bbx2 = (int) x2; + if(y1 < xctx->bby1) xctx->bby1 = (int) y1; + if(y2 > xctx->bby2) xctx->bby2 = (int) y2; + if(y2 < xctx->bby1) xctx->bby1 = (int) y2; + if(y1 > xctx->bby2) xctx->bby2 = (int) y1; break; case END: - xctx->areax1 = savex1; - xctx->areax2 = savex2; - xctx->areay1 = savey1; - xctx->areay2 = savey2; - xctx->areaw = savew; - xctx->areah = saveh; + xctx->areax1 = xctx->savex1; + xctx->areax2 = xctx->savex2; + xctx->areay1 = xctx->savey1; + xctx->areay2 = xctx->savey2; + xctx->areaw = xctx->savew; + xctx->areah = xctx->saveh; xctx->xrect[0].x = 0; xctx->xrect[0].y = 0; xctx->xrect[0].width = xctx->areaw-4*INT_WIDTH(xctx->lw); @@ -567,24 +562,24 @@ void bbox(int what,double x1,double y1, double x2, double y2) cairo_reset_clip(xctx->cairo_save_ctx); #endif } - sem=0; + xctx->sem=0; break; case SET: - if(sem==0) { + if(xctx->sem==0) { fprintf(errfp, "ERROR: bbox(SET) call before bbox(START)\n"); tcleval("alert_ {ERROR: bbox(SET) call before bbox(START)} {}"); } - xctx->areax1 = bbx1-2*INT_WIDTH(xctx->lw); - xctx->areax2 = bbx2+2*INT_WIDTH(xctx->lw); - xctx->areay1 = bby1-2*INT_WIDTH(xctx->lw); - xctx->areay2 = bby2+2*INT_WIDTH(xctx->lw); + xctx->areax1 = xctx->bbx1-2*INT_WIDTH(xctx->lw); + xctx->areax2 = xctx->bbx2+2*INT_WIDTH(xctx->lw); + xctx->areay1 = xctx->bby1-2*INT_WIDTH(xctx->lw); + xctx->areay2 = xctx->bby2+2*INT_WIDTH(xctx->lw); xctx->areaw = (xctx->areax2-xctx->areax1); xctx->areah = (xctx->areay2-xctx->areay1); - xctx->xrect[0].x = bbx1-INT_WIDTH(xctx->lw); - xctx->xrect[0].y = bby1-INT_WIDTH(xctx->lw); - xctx->xrect[0].width = bbx2-bbx1+2*INT_WIDTH(xctx->lw); - xctx->xrect[0].height = bby2-bby1+2*INT_WIDTH(xctx->lw); + xctx->xrect[0].x = xctx->bbx1-INT_WIDTH(xctx->lw); + xctx->xrect[0].y = xctx->bby1-INT_WIDTH(xctx->lw); + xctx->xrect[0].width = xctx->bbx2-xctx->bbx1+2*INT_WIDTH(xctx->lw); + xctx->xrect[0].height = xctx->bby2-xctx->bby1+2*INT_WIDTH(xctx->lw); if(has_x) { for(i=0;iinst[i].prop_ptr, old_prop); /* changed to copy old props if no name */ return; } - prefix=old_name[0]; + xctx->prefix=old_name[0]; /* don't change old_prop if name does not conflict. */ if(dis_uniq_names || (entry = inst_hash_lookup(table, old_name, i, XLOOKUP, old_name_len))==NULL || entry->value == i) @@ -708,17 +707,17 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names) n = sscanf(old_name, "%[^[0-9]",old_name_base); tmp=find_bracket(old_name); my_realloc(448, &new_name, old_name_len + 40); /* strlen(old_name)+40); */ - qq=fast ? last[(int)prefix] : 1; + qq=fast ? last[(int)xctx->prefix] : 1; for(q=qq;;q++) { if(n >= 1 ) { new_name_len = my_snprintf(new_name, old_name_len + 40, "%s%d%s", old_name_base, q, tmp); } else { - new_name_len = my_snprintf(new_name, old_name_len + 40, "%c%d%s", prefix,q, tmp); /* added new_name_len */ + new_name_len = my_snprintf(new_name, old_name_len + 40, "%c%d%s", xctx->prefix,q, tmp); /* added new_name_len */ } if((entry = inst_hash_lookup(table, new_name, i, XLOOKUP, new_name_len)) == NULL || entry->value == i) { - last[(int)prefix]=q+1; + last[(int)xctx->prefix]=q+1; break; } } diff --git a/src/xinit.c b/src/xinit.c index ab1aa42f..7d7aa970 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -548,13 +548,23 @@ void alloc_xschem_data(const char *top_path) xctx->biggridpoint=(XSegment*)my_calloc(1213, CADMAXGRIDPOINTS,sizeof(XSegment)); xctx->gridpoint=(XPoint*)my_calloc(608, CADMAXGRIDPOINTS,sizeof(XPoint)); xctx->enable_drill = 0; + xctx->prev_set_modify = -1; xctx->pending_fullzoom = 0; my_strncpy(xctx->hiersep, ".", S(xctx->hiersep)); xctx->no_undo = 0; xctx->draw_single_layer = -1; xctx->draw_dots = 1; xctx->only_probes = 0; + xctx->menu_removed = 0; /* fullscreen pervious setting */ + xctx->save_lw = 0.0; /* used to save linewidth when selecting 'only_probes' view */ + xctx->onetime = 0; /* callback() static var */ + xctx->save_netlist_type = 0; + xctx->loaded_symbol = 0; xctx->no_draw = 0; + xctx->sem = 0; /* bbox */ + xctx->old_prop = NULL; + xctx->edit_sym_i = -1; + xctx->netlist_commands = 0; xctx->draw_pixmap = 1; xctx->gc=my_calloc(638, cadlayers, sizeof(GC)); xctx->gcstipple=my_calloc(639, cadlayers, sizeof(GC)); diff --git a/src/xschem.h b/src/xschem.h index 2ad7ae55..e626f10e 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -606,6 +606,7 @@ typedef struct { /* callback.c */ int mx_save, my_save, last_command; char sel_or_clip[PATH_MAX]; + int onetime; /* move.c */ struct int_hashentry *node_redraw_table[HASHSIZE]; double rx1, rx2, ry1, ry2; @@ -628,6 +629,29 @@ typedef struct { int nl_points, nl_maxpoints; /* select_rect */ double nl_xr, nl_yr, nl_xr2, nl_yr2; + /* pan */ + double xpan,ypan,xpan2,ypan2; + double p_xx1,p_xx2,p_yy1,p_yy2; + /* set_modify */ + int prev_set_modify; + /* pan2 */ + int mx_s, my_s; + int mmx_s, mmy_s; + double xorig_save, yorig_save; + /* load_schematic */ + int save_netlist_type; + int loaded_symbol; + /* bbox */ + int bbx1, bbx2, bby1, bby2; + int savew, saveh, savex1, savex2, savey1, savey2; + int sem; + /* new_prop_string */ + char prefix; + /* edit_symbol_property, update_symbol */ + char *old_prop; + int edit_sym_i; + int netlist_commands; + /* */ int nl_sel, nl_sem; XSegment *biggridpoint; XPoint *gridpoint; @@ -639,6 +663,8 @@ typedef struct { int draw_single_layer; int draw_dots; int only_probes; + int menu_removed; /* fullscreen pervious setting */ + double save_lw; /* used to save linewidth when selecting 'only_probes' view */ int no_draw; int draw_pixmap; /* pixmap used as 2nd buffer */ int netlist_count; /* netlist counter incremented at any cell being netlisted */