code cleanup, comments, more globals in Xctx context structure

This commit is contained in:
Stefan Frederik 2021-10-25 17:05:43 +02:00
parent 19f8939347
commit b81325ea00
22 changed files with 240 additions and 213 deletions

View File

@ -1,6 +1,6 @@
/*
scconfig - gui lib detection - lesstif
Copyright (C) 2015 Tibor Palinkas
Copyright (C) 2015,2021 Tibor Palinkas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -67,3 +67,36 @@ int find_lesstif2(const char *name, int logdepth, int fatal, const char *call, c
return try_fail(logdepth, node);
}
int find_lesstif2_exthi(const char *name, int logdepth, int fatal, const char *call, const char *arg)
{
const char *test_c =
NL "#include <Xm/MainW.h>"
NL "int main(int argc, char *argv[])"
NL "{"
NL " return XmEXTERNAL_HIGHLIGHT;"
NL "}"
NL;
const char *node = "libs/gui/lesstif2/exthi";
// char **cflags, *cflags_arr[] = {"", "-I/opt/X11/include", NULL};
// char **ldflags, *ldflags_arr[] = {"-lXm -lX11", "-lXm -lXt", "-L/opt/X11/lib -lXm -lXt -lX11", NULL}; /* note: -lXt must be after -lXm else lesstif fails to init with runtime error */
const char *cflags, *ldflags;
(void) call; /* not used */
(void) arg; /* not used */
if (require("cc/cc", logdepth, fatal) || require("libs/gui/lesstif2", logdepth, fatal))
return 1;
report("Checking for lesstif2 XmEXTERNAL_HIGHLIGHT... ");
logprintf(logdepth, "find_lesstif_exthi:\n");
logdepth++;
cflags = get("libs/gui/lesstif2/cflags");
ldflags = get("libs/gui/lesstif2/ldflags");
if (try_icl_norun(logdepth, node, test_c, NULL, cflags, ldflags) != 0)
return 0;
return try_fail(logdepth, node);
}

View File

@ -1,2 +1,2 @@
int find_lesstif2(const char *name, int logdepth, int fatal);
int find_lesstif2_exthi(const char *name, int logdepth, int fatal, const char *call, const char *arg);

View File

@ -26,6 +26,7 @@ void deps_gui_init()
dep_add("libs/gui/gtk2/key_prefix", find_gtk2_key_prefix);
dep_add("libs/gui/gtk2/modversion", find_gtk2_modversion);
dep_add("libs/gui/gtk3/*", find_gtk3);
dep_add("libs/gui/lesstif2/exthi/*", find_lesstif2_exthi);
dep_add("libs/gui/lesstif2/*", find_lesstif2);
dep_add("libs/gui/libstroke/*", find_libstroke);
dep_add("libs/gui/gd/gdImagePng/*", find_gdimagepng);

View File

@ -112,7 +112,7 @@ void set_snap(double newsnap) /* 20161212 set new snap factor and just notify n
static double default_snap = -1.0;
if(default_snap == -1.0) {
default_snap = atof(tclgetvar("snap"));
default_snap = atof(tclgetvar("cadsnap"));
if(default_snap==0.0) default_snap = CADSNAP;
}
cadsnap = newsnap ? newsnap : default_snap;
@ -122,7 +122,7 @@ void set_snap(double newsnap) /* 20161212 set new snap factor and just notify n
} else {
tcleval(".statusbar.3 configure -background OrangeRed");
}
tclsetvar("snap", str);
tclsetvar("cadsnap", str);
}
void set_grid(double newgrid)
@ -131,7 +131,7 @@ void set_grid(double newgrid)
static double default_grid = -1.0;
if(default_grid == -1.0) {
default_grid = atof(tclgetvar("grid"));
default_grid = atof(tclgetvar("cadgrid"));
if(default_grid==0.0) default_grid = CADGRID;
}
cadgrid = newgrid ? newgrid : default_grid;
@ -142,7 +142,7 @@ void set_grid(double newgrid)
} else {
tcleval(".statusbar.5 configure -background OrangeRed");
}
tclsetvar("grid", str);
tclsetvar("cadgrid", str);
}
int set_netlist_dir(int force, char *dir)
@ -246,7 +246,7 @@ void toggle_fullscreen()
} else {
window_state(display , parent_of_topwindow,normal);
}
pending_fullzoom=1;
xctx->pending_fullzoom=1;
}
#ifdef __unix__
@ -578,15 +578,15 @@ void enable_layers(void)
{
int i;
char tmp[50];
n_active_layers = 0;
xctx->n_active_layers = 0;
for(i = 0; i< cadlayers; i++) {
my_snprintf(tmp, S(tmp), "enable_layer(%d)",i);
if(tclgetvar(tmp)[0] == '0') enable_layer[i] = 0;
else {
enable_layer[i] = 1;
if(i>=7) {
active_layer[n_active_layers] = i;
n_active_layers++;
xctx->active_layer[xctx->n_active_layers] = i;
xctx->n_active_layers++;
}
}
}
@ -861,7 +861,7 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot
dbg(1, "place_symbol() :all inst_ptr members set\n"); /* 03-02-2000 */
if(first_call) hash_all_names(n);
if(inst_props) {
new_prop_string(n, inst_props,!first_call, dis_uniq_names); /* 20171214 first_call */
new_prop_string(n, inst_props,!first_call, disable_unique_names); /* 20171214 first_call */
}
else {
set_inst_prop(n); /* no props, get from sym template, also calls new_prop_string() */
@ -1615,7 +1615,7 @@ void new_wire(int what, double mx_snap, double my_snap)
if( (what & PLACE) ) {
if( (xctx->ui_state & STARTWIRE) && (xctx->nl_x1!=xctx->nl_x2 || xctx->nl_y1!=xctx->nl_y2) ) {
push_undo();
if(manhattan_lines==1) {
if(xctx->manhattan_lines==1) {
if(xctx->nl_xx2!=xctx->nl_xx1) {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
@ -1632,7 +1632,7 @@ void new_wire(int what, double mx_snap, double my_snap)
hash_wire(XINSERT, xctx->wires-1, 1);
drawline(WIRELAYER,NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2, 0);
}
} else if(manhattan_lines==2) {
} else if(xctx->manhattan_lines==2) {
if(xctx->nl_yy2!=xctx->nl_yy1) {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
@ -1683,7 +1683,7 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_yy1=xctx->nl_y1;
xctx->nl_xx2=xctx->mousex_snap;
xctx->nl_yy2=xctx->mousey_snap;
if(manhattan_lines==1) {
if(xctx->manhattan_lines==1) {
xctx->nl_x2 = mx_snap; xctx->nl_y2 = my_snap;
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
@ -1693,7 +1693,7 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
} else if(manhattan_lines==2) {
} else if(xctx->manhattan_lines==2) {
xctx->nl_x2 = mx_snap; xctx->nl_y2 = my_snap;
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
@ -1717,7 +1717,7 @@ void new_wire(int what, double mx_snap, double my_snap)
xctx->ui_state &= ~STARTWIRE;
}
if( (what & RUBBER) ) {
if(manhattan_lines==1) {
if(xctx->manhattan_lines==1) {
xctx->nl_xx1=xctx->nl_x1;xctx->nl_yy1=xctx->nl_y1;
xctx->nl_xx2=xctx->nl_x2;xctx->nl_yy2=xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
@ -1738,7 +1738,7 @@ void new_wire(int what, double mx_snap, double my_snap)
ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
} else if(manhattan_lines==2) {
} else if(xctx->manhattan_lines==2) {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);
@ -1878,7 +1878,7 @@ void new_line(int what)
if( (xctx->nl_x1!=xctx->nl_x2 || xctx->nl_y1!=xctx->nl_y2) && (xctx->ui_state & STARTLINE) )
{
push_undo();
if(manhattan_lines==1) {
if(xctx->manhattan_lines==1) {
if(xctx->nl_xx2!=xctx->nl_xx1) {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
@ -1893,7 +1893,7 @@ void new_line(int what)
storeobject(-1, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2,LINE,xctx->rectcolor,0,NULL);
drawline(xctx->rectcolor,NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2, 0);
}
} else if(manhattan_lines==2) {
} else if(xctx->manhattan_lines==2) {
if(xctx->nl_yy2!=xctx->nl_yy1) {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
@ -1926,7 +1926,7 @@ void new_line(int what)
if(what & RUBBER)
{
if(manhattan_lines==1) {
if(xctx->manhattan_lines==1) {
xctx->nl_xx1=xctx->nl_x1;xctx->nl_yy1=xctx->nl_y1;
xctx->nl_xx2=xctx->nl_x2;xctx->nl_yy2=xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1);
@ -1947,7 +1947,7 @@ void new_line(int what)
ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2);
}
} else if(manhattan_lines==2) {
} else if(xctx->manhattan_lines==2) {
xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1;
xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2;
ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2);

View File

@ -304,14 +304,14 @@ int callback(int event, int mx, int my, KeySym key,
if(key==' ') {
if(xctx->ui_state & STARTWIRE) { /* & instead of == 20190409 */
new_wire(RUBBER|CLEAR, xctx->mousex_snap, xctx->mousey_snap);
manhattan_lines++;
manhattan_lines %=3;
xctx->manhattan_lines++;
xctx->manhattan_lines %=3;
new_wire(RUBBER, xctx->mousex_snap, xctx->mousey_snap);
} else if(xctx->ui_state==STARTLINE) {
new_line(RUBBER|CLEAR);
manhattan_lines++;
manhattan_lines %=3;
xctx->manhattan_lines++;
xctx->manhattan_lines %=3;
new_line(RUBBER);
} else {
if(xctx->semaphore<2) {
@ -480,17 +480,17 @@ int callback(int event, int mx, int my, KeySym key,
if(key == '=' && (state &ControlMask)) /* toggle fill rectangles */
{
int x;
fill++;
if(fill==3) fill=0;
xctx->fill_pattern++;
if(xctx->fill_pattern==3) xctx->fill_pattern=0;
if(fill==1) {
if(xctx->fill_pattern==1) {
tcleval("alert_ { Stippled pattern fill} {}");
for(x=0;x<cadlayers;x++) {
if(fill_type[x]==1) XSetFillStyle(display,gcstipple[x],FillSolid);
else XSetFillStyle(display,gcstipple[x],FillStippled);
}
}
else if(fill==2) {
else if(xctx->fill_pattern==2) {
tcleval("alert_ { solid pattern fill} {}");
for(x=0;x<cadlayers;x++)
XSetFillStyle(display,gcstipple[x],FillSolid);
@ -568,7 +568,7 @@ int callback(int event, int mx, int my, KeySym key,
tcleval("set constrained_move 0" );
constrained_move=0;
xctx->last_command=0;
manhattan_lines = 0;
xctx->manhattan_lines = 0;
dbg(1, "callback(): Escape: ui_state=%ld\n", xctx->ui_state);
if(xctx->ui_state & STARTMOVE)
{
@ -646,7 +646,7 @@ int callback(int event, int mx, int my, KeySym key,
char n[30];
xctx->rectcolor = key - '0'+4;
my_snprintf(n, S(n), "%d", xctx->rectcolor);
Tcl_VarEval(interp, "xschem set xctx->rectcolor ", n, "; reconfigure_layers_button", NULL);
Tcl_VarEval(interp, "xschem set rectcolor ", n, NULL);
dbg(1, "callback(): new color: %d\n",color_index[xctx->rectcolor]);
break;
}
@ -958,7 +958,7 @@ int callback(int event, int mx, int my, KeySym key,
/* with 'propag=' prop set on pins */
{
if(xctx->semaphore >= 2) break;
enable_drill=1;
xctx->enable_drill=1;
hilight_net(0);
redraw_hilights(0);
/* draw_hilight_net(1); */
@ -967,7 +967,7 @@ int callback(int event, int mx, int my, KeySym key,
if(key=='k' && state==0) /* hilight net */
{
if(xctx->semaphore >= 2) break;
enable_drill=0;
xctx->enable_drill=0;
hilight_net(0);
redraw_hilights(0);
/* draw_hilight_net(1); */
@ -978,7 +978,7 @@ int callback(int event, int mx, int my, KeySym key,
xRect boundbox;
int big = xctx->wires> 2000 || xctx->instances > 2000 ;
if(xctx->semaphore >= 2) break;
enable_drill=0;
xctx->enable_drill=0;
if(!big) calc_drawing_bbox(&boundbox, 2);
clear_all_hilights();
/* undraw_hilight_net(1); */
@ -1000,7 +1000,7 @@ int callback(int event, int mx, int my, KeySym key,
if(xctx->semaphore >= 2) break;
tcleval("info exists sim");
if(tclresult()[0] == '1') exists = 1;
enable_drill = 0;
xctx->enable_drill = 0;
if(exists) {
tool = atol(tclgetvar("sim(spicewave,default)"));
my_snprintf(str, S(str), "sim(spicewave,%d,name)", tool);

View File

@ -1130,7 +1130,7 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b,
XDrawArc(display, xctx->save_pixmap, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
}
if(fill && fill_type[c]){
if(xctx->fill_pattern && fill_type[c]){
if(arc_fill) {
if(draw_window)
XFillArc(display, xctx->window, gcstipple[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
@ -1160,7 +1160,7 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl
double x1,y1,x2,y2;
if(!has_x) return;
if(!fill || !fill_type[c]) return;
if(!xctx->fill_pattern || !fill_type[c]) return;
if(what & NOW)
{
x1=X_TO_SCREEN(rectx1);
@ -1314,7 +1314,7 @@ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fil
if(draw_window) XDrawLines(display, xctx->window, gc[c], p, points, CoordModeOrigin);
if(draw_pixmap)
XDrawLines(display, xctx->save_pixmap, gc[c], p, points, CoordModeOrigin);
if(fill && fill_type[c]){
if(xctx->fill_pattern && fill_type[c]){
if(poly_fill && (x[0] == x[points-1]) && (y[0] == y[points-1])) {
if(draw_window) XFillPolygon(display, xctx->window, gcstipple[c], p, points, Polygontype, CoordModeOrigin);
if(draw_pixmap)

View File

@ -388,7 +388,7 @@ void set_inst_prop(int i)
my_strdup2(70, &xctx->inst[i].instname, get_tok_value(ptr, "name",0));
if(xctx->inst[i].instname[0]) {
my_strdup(101, &tmp, xctx->inst[i].prop_ptr);
new_prop_string(i, tmp, 0, dis_uniq_names);
new_prop_string(i, tmp, 0, disable_unique_names);
my_free(724, &tmp);
}
}
@ -1031,7 +1031,7 @@ void update_symbol(const char *result, int x)
/* set name of current inst */
if(!pushed) { push_undo(); pushed=1;}
if(!k) hash_all_names(i);
new_prop_string(i, ptr, k, dis_uniq_names); /* set new prop_ptr */
new_prop_string(i, ptr, k, disable_unique_names); /* set new prop_ptr */
}
my_strdup2(90, &xctx->inst[i].instname, get_tok_value(xctx->inst[i].prop_ptr, "name",0));

View File

@ -131,9 +131,9 @@ double cadsnap = CADSNAP;
int draw_grid=1;
int big_grid_points=0;
int rainbow_colors=0;
int dis_uniq_names=0; /* if set allow instances with duplicate names */
int disable_unique_names=0; /* if set allow instances with duplicate names */
int persistent_command=0; /* remember last command 20181022 */
int autotrim_wires=0;
int autotrim_wires = 0;
int color_ps=-1;
int transparent_svg=-1;
int only_probes=0;
@ -164,7 +164,6 @@ int en_hilight_conn_inst = 0;
int help=0; /* help option set to global scope, printing help is deferred */
/* when configuration ~/.schem has been read 20140406 */
int no_draw=0;
int manhattan_lines=0;
FILE *errfp;
char *filename=NULL; /* filename given on cmdline */
char user_conf_dir[PATH_MAX];
@ -185,7 +184,6 @@ int debug_var=-10; /* will be set to 0 in xinit.c */
int tcp_port = 0;
int do_print=0;
int no_readline=0;
int fill=1; /* filled rectangles */
int draw_pixmap=1; /* use pixmap for double buffer */
int draw_window=0;
int text_svg=1; /* use <text> svg element for text instead of xschem's internal vector font */
@ -197,9 +195,7 @@ int draw_dots=1;
int draw_single_layer=-1;
int yyparse_error = 0;
int *enable_layer;
int n_active_layers=0;
int *active_layer;
int depth;
int screendepth;
int *fill_type; /* for every layer: 0: no fill, 1, solid fill, 2: stipple fill */
char **color_array;
char *xschem_executable=NULL;
@ -209,13 +205,9 @@ int do_netlist=0; /* set by process_options if user wants netllist from cmdline
int do_simulation=0;
int do_waves=0;
int netlist_count=0; /* netlist counter incremented at any cell being netlisted */
char hiersep[20]=".";
char bus_char[3] = {0, 0, 0};
int pending_fullzoom=0;
int constrained_move = 0;
double color_dim=0.0;
int no_undo=0;
int enable_drill=0; /* pass net hilights through components with 'propag=' property set on pins */
int batch_mode = 0; /* no tcl console if set; batch mode */
int show_erc=1;

View File

@ -97,22 +97,22 @@ void free_hilight_hash(void) /* remove the whole hash table */
}
/* by default:
* active_layer[0] = 7
* active_layer[1] = 8
* active_layer[2] = 10 if 9 is disabled it is skipped
* xctx->active_layer[0] = 7
* xctx->active_layer[1] = 8
* xctx->active_layer[2] = 10 if 9 is disabled it is skipped
* ...
* if a layer is disabled (not viewable) it is skipped
* n_active_layers is the total number of layers for hilights.
* standard xschem conf: cadlayers=22, n_active_layers=15 if no disabled layers.
* xctx->n_active_layers is the total number of layers for hilights.
* standard xschem conf: cadlayers=22, xctx->n_active_layers=15 if no disabled layers.
*/
int get_color(int value)
{
int x;
if(value < 0) return (-value) % cadlayers ;
if(n_active_layers) {
x = value%(n_active_layers);
return active_layer[x];
if(xctx->n_active_layers) {
x = value%(xctx->n_active_layers);
return xctx->active_layer[x];
} else {
return cadlayers > 5 ? 5 : cadlayers -1; /* desperate attempt to return a decent color */
}
@ -121,7 +121,7 @@ int get_color(int value)
void incr_hilight_color(void)
{
xctx->hilight_color = (xctx->hilight_color + 1) % (n_active_layers * cadlayers);
xctx->hilight_color = (xctx->hilight_color + 1) % (xctx->n_active_layers * cadlayers);
}
/* print all highlight signals which are not ports (in/out/inout). */
@ -148,7 +148,7 @@ void create_plot_cmd(void)
my_strncpy(rawfile, tclresult(), S(rawfile));
tcleval("info exists sim");
if(tclresult()[0] == '1') exists = 1;
enable_drill = 0;
xctx->enable_drill = 0;
if(exists) {
viewer = atol(tclgetvar("sim(spicewave,default)"));
my_snprintf(tcl_str, S(tcl_str), "sim(spicewave,%d,name)", viewer);
@ -296,14 +296,12 @@ struct hilight_hashentry *hilight_lookup(const char *token, int value, int what)
struct hilight_hashentry *entry, *saveptr, **preventry;
char *ptr;
int s ;
int depth=0;
if(token==NULL) return NULL;
hashcode=hi_hash(token);
index=hashcode % HASHSIZE;
entry=xctx->hilight_table[index];
preventry=&xctx->hilight_table[index];
depth=0;
while(1) {
if( !entry ) { /* empty slot */
int lent = (strlen(token) + 8) & ~(size_t) 0x7; /* align to 8 byte boundaries */
@ -341,7 +339,6 @@ struct hilight_hashentry *hilight_lookup(const char *token, int value, int what)
}
preventry=&entry->next; /* descend into the list. */
entry = entry->next;
depth++;
}
}
@ -1082,7 +1079,7 @@ void propagate_hilights(int set, int clear, int mode)
}
}
xctx->hilight_nets = there_are_hilights();
if(xctx->hilight_nets && enable_drill && set) drill_hilight(mode);
if(xctx->hilight_nets && xctx->enable_drill && set) drill_hilight(mode);
}
/* use negative values to bypass the normal hilight color enumeration */

View File

@ -198,7 +198,7 @@ void push_undo(void)
{
int slot, i, c;
if(no_undo)return;
if(xctx->no_undo)return;
if(!initialized) {
initialized=1;
init_undo();
@ -316,7 +316,7 @@ void pop_undo(int redo)
{
int slot, i, c;
if(no_undo)return;
if(xctx->no_undo)return;
if(redo) {
if(xctx->cur_undo_ptr < xctx->head_undo_ptr) {
xctx->cur_undo_ptr++;

View File

@ -932,7 +932,7 @@ void copy_objects(int what)
/* the newpropcnt argument is zero for the 1st call and used in */
/* new_prop_string() for cleaning some internal caches. */
if(!newpropcnt) hash_all_names(xctx->instances);
new_prop_string(xctx->instances, xctx->inst[n].prop_ptr,newpropcnt++, dis_uniq_names);
new_prop_string(xctx->instances, xctx->inst[n].prop_ptr,newpropcnt++, disable_unique_names);
my_strdup2(235, &xctx->inst[xctx->instances].instname,
get_tok_value(xctx->inst[xctx->instances].prop_ptr, "name", 0));
xctx->instances++;

View File

@ -407,7 +407,7 @@ void netlist_options(int i)
str = get_tok_value(xctx->inst[i].prop_ptr, "hiersep", 0);
if(str[0]) {
my_snprintf(hiersep, S(hiersep), "%s", str);
my_snprintf(xctx->hiersep, S(xctx->hiersep), "%s", str);
}
}

View File

@ -263,7 +263,7 @@ void merge_inst(int k,FILE *fd)
ptr[i].node=NULL;
load_ascii_string(&prop_ptr,fd);
if(!k) hash_all_names(i);
new_prop_string(i, prop_ptr, k, dis_uniq_names);
new_prop_string(i, prop_ptr, k, disable_unique_names);
/* the final tmp argument is zero for the 1st call and used in */
/* new_prop_string() for cleaning some internal caches. */
my_strdup2(306, &xctx->inst[i].instname, get_tok_value(xctx->inst[i].prop_ptr, "name", 0));
@ -313,7 +313,7 @@ void merge_file(int selection_load, const char ext[])
{
my_snprintf(name, S(name), "%s/.clipboard.sch", user_conf_dir);
}
if( (fd=fopen(name,"r"))!= NULL) {
if( (fd=fopen(name, fopen_read_mode))!= NULL) {
xctx->prep_hi_structs=0;
xctx->prep_net_structs=0;
xctx->prep_hash_inst=0;

View File

@ -118,7 +118,7 @@ static void set_ps_colors(unsigned int pixel)
static void ps_xdrawarc(int layer, int fillarc, double x, double y, double r, double a, double b)
{
if(fill && fillarc)
if(xctx->fill_pattern && fillarc)
fprintf(fd, "%g %g %g %g %g A %g %g LT C F S\n", x, y, r, -a, -a-b, x, y);
else
fprintf(fd, "%g %g %g %g %g A S\n", x, y, r, -a, -a-b);
@ -140,7 +140,7 @@ static void ps_xfillrectange(int layer, double x1, double y1, double x2,
double y2)
{
fprintf(fd, "%g %g %g %g R\n", x1,y1,x2-x1,y2-y1);
if( (fill_type[layer] == 1) && fill) {
if( (fill_type[layer] == 1) && xctx->fill_pattern) {
fprintf(fd, "%g %g %g %g RF\n", x1,y1,x2-x1,y2-y1);
/* fprintf(fd,"fill\n"); */
}
@ -174,7 +174,7 @@ static void ps_drawpolygon(int c, int what, double *x, double *y, int points, in
if(i==0) fprintf(fd, "NP\n%g %g MT\n", xx, yy);
else fprintf(fd, "%g %g LT\n", xx, yy);
}
if(fill && fill_type[c] && poly_fill) {
if(xctx->fill_pattern && fill_type[c] && poly_fill) {
fprintf(fd, "C F S\n");
} else {
fprintf(fd, "S\n");

View File

@ -1143,7 +1143,7 @@ void push_undo(void)
FILE *fd;
char diff_name[PATH_MAX+100]; /* overflow safe 20161122 */
if(no_undo)return;
if(xctx->no_undo)return;
dbg(1, "push_undo(): cur_undo_ptr=%d tail_undo_ptr=%d head_undo_ptr=%d\n",
xctx->cur_undo_ptr, xctx->tail_undo_ptr, xctx->head_undo_ptr);
@ -1153,7 +1153,7 @@ void push_undo(void)
fd = popen(diff_name,"w");
if(!fd) {
fprintf(errfp, "push_undo(): failed to open write pipe %s\n", diff_name);
no_undo=1;
xctx->no_undo=1;
return;
}
#elif HAS_PIPE==1
@ -1190,7 +1190,7 @@ void push_undo(void)
fd = fopen(diff_name,"w");
if(!fd) {
fprintf(errfp, "push_undo(): failed to open undo file %s\n", diff_name);
no_undo=1;
xctx->no_undo=1;
return;
}
#endif
@ -1218,7 +1218,7 @@ void pop_undo(int redo)
FILE *diff_fd;
#endif
if(no_undo)return;
if(xctx->no_undo)return;
if(redo) {
if(xctx->cur_undo_ptr < xctx->head_undo_ptr) {
dbg(1, "pop_undo(): redo; cur_undo_ptr=%d tail_undo_ptr=%d head_undo_ptr=%d\n",
@ -1247,7 +1247,7 @@ void pop_undo(int redo)
fd=popen(diff_name, "r");
if(!fd) {
fprintf(errfp, "pop_undo(): failed to open read pipe %s\n", diff_name);
no_undo=1;
xctx->no_undo=1;
return;
}
#elif HAS_PIPE==1
@ -1281,7 +1281,7 @@ void pop_undo(int redo)
fd=fopen(diff_name, "r");
if(!fd) {
fprintf(errfp, "pop_undo(): failed to open read pipe %s\n", diff_name);
no_undo=1;
xctx->no_undo=1;
return;
}
#endif

View File

@ -316,7 +316,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
cmd_found = 1;
if(argc==3) {
debug_var=atoi(argv[2]);
tclsetvar("tcl_debug",argv[2]);
tclsetvar("debug_var",argv[2]);
}
Tcl_ResetResult(interp);
}
@ -702,7 +702,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
change_to_unix_fn(s);
int slen = strlen(s);
if(s[slen - 1] == '/') s[slen - 1] = '\0';
strcpy(win_temp_dir, s);
my_strncpy(win_temp_dir, s, S(win_temp_dir));
dbg(2, "scheduler(): win_temp_dir is %s\n", win_temp_dir);
Tcl_SetResult(interp, s, TCL_VOLATILE);
}
@ -1064,8 +1064,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"hilight"))
{
cmd_found = 1;
enable_drill = 0;
if(argc >=3 && !strcmp(argv[2], "drill")) enable_drill = 1;
xctx->enable_drill = 0;
if(argc >=3 && !strcmp(argv[2], "drill")) xctx->enable_drill = 1;
hilight_net(0);
/* draw_hilight_net(1); */
redraw_hilights(0);
@ -1946,7 +1946,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
my_strdup(371, &ptr,subst_token(xctx->inst[inst].prop_ptr, "name", name) );
hash_all_names(inst);
new_prop_string(inst, ptr,0, dis_uniq_names); /* set new prop_ptr */
new_prop_string(inst, ptr,0, disable_unique_names); /* set new prop_ptr */
my_strdup2(517, &newname, get_tok_value(xctx->inst[inst].prop_ptr, "name",0));
my_strdup2(372, &xctx->inst[inst].instname, newname);
@ -2142,7 +2142,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
cmd_found = 1;
tcleval("info exists sim");
if(tclresult()[0] == '1') exists = 1;
enable_drill = 0;
xctx->enable_drill = 0;
if(exists) {
viewer = atol(tclgetvar("sim(spicewave,default)"));
my_snprintf(tcl_str, S(tcl_str), "sim(spicewave,%d,name)", viewer);
@ -2179,7 +2179,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
#endif
if(!strcmp(argv[2],"no_undo")) {
int s = atoi(argv[3]);
no_undo=s;
xctx->no_undo=s;
}
else if(!strcmp(argv[2],"no_draw")) {
int s = atoi(argv[3]);
@ -2252,9 +2252,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
else if(!strcmp(argv[2],"disable_unique_names")) {
if(!strcmp(argv[3],"1")) {
dis_uniq_names=1;
disable_unique_names=1;
} else {
dis_uniq_names=0;
disable_unique_names=0;
}
}
else if(!strcmp(argv[2],"incr_hilight")) {
@ -2399,9 +2399,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
xctx->prep_hi_structs=0;
if(!strcmp(argv[3], "name")) hash_all_names(inst);
if(argc >= 5) {
new_prop_string(inst, subst_token(xctx->inst[inst].prop_ptr, argv[3], argv[4]),fast, dis_uniq_names);
new_prop_string(inst, subst_token(xctx->inst[inst].prop_ptr, argv[3], argv[4]),fast, disable_unique_names);
} else {/* assume argc == 4 , delete attribute */
new_prop_string(inst, subst_token(xctx->inst[inst].prop_ptr, argv[3], NULL),fast, dis_uniq_names);
new_prop_string(inst, subst_token(xctx->inst[inst].prop_ptr, argv[3], NULL),fast, disable_unique_names);
}
my_strdup2(367, &xctx->inst[inst].instname, get_tok_value(xctx->inst[inst].prop_ptr, "name",0));
@ -2520,7 +2520,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
xRect boundbox;
int big = xctx->wires> 2000 || xctx->instances > 2000 ;
cmd_found = 1;
enable_drill=0;
xctx->enable_drill=0;
if(!big) calc_drawing_bbox(&boundbox, 2);
clear_all_hilights();
/* undraw_hilight_net(1); */

View File

@ -129,7 +129,7 @@ void global_spice_netlist(int global) /* netlister driver */
top_subckt = 0;
spiceprefix=1;
bus_char[0] = bus_char[1] = '\0';
hiersep[0]='.'; hiersep[1]='\0';
xctx->hiersep[0]='.'; xctx->hiersep[1]='\0';
str_tmp = tclgetvar("bus_replacement_char");
if(str_tmp && str_tmp[0] && str_tmp[1]) {
bus_char[0] = str_tmp[0];

View File

@ -40,7 +40,7 @@ void global_tedax_netlist(int global) /* netlister driver */
statusmsg("",2); /* clear infowindow */
record_global_node(2, NULL, NULL); /* delete list of global nodes */
bus_char[0] = bus_char[1] = '\0';
hiersep[0]='.'; hiersep[1]='\0';
xctx->hiersep[0]='.'; xctx->hiersep[1]='\0';
str_tmp = tclgetvar("bus_replacement_char");
if(str_tmp && str_tmp[0] && str_tmp[1]) {
bus_char[0] = str_tmp[0];
@ -130,7 +130,7 @@ void global_tedax_netlist(int global) /* netlister driver */
/* print globals nodes found in netlist 28032003 */
record_global_node(0,fd,NULL);
fprintf(fd, "__HIERSEP__ %s\n", hiersep);
fprintf(fd, "__HIERSEP__ %s\n", xctx->hiersep);
dbg(1, "global_tedax_netlist(): starting awk on netlist!\n");

View File

@ -194,7 +194,7 @@ void check_unique_names(int rename)
if(xctx->hilight_nets) {
xRect boundbox;
if(!big) calc_drawing_bbox(&boundbox, 2);
enable_drill=0;
xctx->enable_drill=0;
clear_all_hilights();
/* undraw_hilight_net(1); */
if(!big) {
@ -500,7 +500,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
if(!escape) quote=!quote;
}
if(state==TOK_TOKEN) {
if(!cmp) { /* previous token matched search and was without value, return get_tok_size */
if(!cmp) { /* previous token matched search and was without value, return xctx->get_tok_size */
result[0] = '\0';
return result;
}
@ -659,7 +659,7 @@ char *get_pin_attr_from_inst(int inst, int pin, const char *attr)
return pin_attr_value; /* caller is responsible for freeing up storage for pin_attr_value */
}
void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
void new_prop_string(int i, const char *old_prop, int fast, int disable_unique_names)
{
/* given a old_prop property string, return a new */
/* property string in xctx->inst[i].prop_ptr such that the element name is */
@ -697,7 +697,7 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
}
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 ||
if(disable_unique_names || (entry = inst_hash_lookup(table, old_name, i, XLOOKUP, old_name_len))==NULL ||
entry->value == i)
{
inst_hash_lookup(table, old_name, i, XINSERT, old_name_len);
@ -2786,7 +2786,7 @@ const char *translate(int inst, const char* s)
result[0]='\0';
dbg(1, "translate(): substituting props in <%s>, instance <%s>\n",
s?s:"NULL",xctx->inst[inst].instname?xctx->inst[inst].instname:"NULL");
s ? s : "NULL" , xctx->inst[inst].instname ? xctx->inst[inst].instname : "NULL");
while(1)
{

View File

@ -364,6 +364,7 @@ void free_xschem_data()
for(i=0;i<CADMAXHIER;i++) my_free(1139, &xctx->sch_path[i]);
my_free(1099, &xctx->gridpoint);
my_free(1214, &xctx->biggridpoint);
my_free(1121, &xctx->active_layer);
my_free(269, &xctx);
}
@ -446,6 +447,7 @@ void alloc_xschem_data()
xctx->rx1 = xctx->rx2 = xctx->ry1 = xctx->ry2 = 0.0;
xctx->move_rot = 0;
xctx->move_flip = 0;
xctx->manhattan_lines = 0;
xctx->x1 = xctx->y_1 = xctx->x2 = xctx->y_2 = xctx->deltax = xctx->deltay = 0.0;
xctx->movelastsel = 0;
xctx->rotatelocal=0;
@ -521,6 +523,13 @@ void alloc_xschem_data()
xctx->sel_array=my_calloc(619, xctx->maxsel, sizeof(Selected));
xctx->biggridpoint=(XSegment*)my_calloc(1213, CADMAXGRIDPOINTS,sizeof(XSegment));
xctx->gridpoint=(XPoint*)my_calloc(608, CADMAXGRIDPOINTS,sizeof(XPoint));
xctx->n_active_layers = 0;
xctx->active_layer=my_calloc(563, cadlayers, sizeof(int));
xctx->enable_drill = 0;
xctx->pending_fullzoom = 0;
my_strncpy(xctx->hiersep, ".", S(xctx->hiersep));
xctx->no_undo = 0;
xctx->fill_pattern = 1;
}
void alloc_data()
@ -533,7 +542,6 @@ void alloc_data()
gc=my_calloc(638, cadlayers, sizeof(GC));
gcstipple=my_calloc(639, cadlayers, sizeof(GC));
fill_type=my_calloc(640, cadlayers, sizeof(int));
active_layer=my_calloc(563, cadlayers, sizeof(int));
pixdata=my_calloc(641, cadlayers, sizeof(char*));
for(i=0;i<cadlayers;i++)
{
@ -591,7 +599,6 @@ void xwin_exit(void)
my_free(1102, &pixdata[i]);
}
my_free(1120, &fill_type);
my_free(1121, &active_layer);
my_free(1122, &pixdata);
my_free(1123, &enable_layer);
my_free(1135, &gc);
@ -1035,9 +1042,9 @@ void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h)
}
if(create_pixmap) {
#ifdef __unix__
xctx->save_pixmap = XCreatePixmap(display, xctx->window, xctx->xschem_w, xctx->xschem_h, depth);
xctx->save_pixmap = XCreatePixmap(display, xctx->window, xctx->xschem_w, xctx->xschem_h, screendepth);
#else
xctx->save_pixmap = Tk_GetPixmap(display, xctx->window, xctx->xschem_w, xctx->xschem_h, depth);
xctx->save_pixmap = Tk_GetPixmap(display, xctx->window, xctx->xschem_w, xctx->xschem_h, screendepth);
#endif
xctx->gctiled = XCreateGC(display,xctx->window,0L, NULL);
XSetTile(display,xctx->gctiled, xctx->save_pixmap);
@ -1048,9 +1055,9 @@ void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h)
}
}
}
if(pending_fullzoom) {
if(xctx->pending_fullzoom) {
zoom_full(0, 0, 1, 0.97);
pending_fullzoom=0;
xctx->pending_fullzoom=0;
}
dbg(1, "resetwin(): Window reset\n");
} /* end if(has_x) */
@ -1380,8 +1387,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
init_pixdata();
init_color_array(0.0);
my_snprintf(tmp, S(tmp), "%d",debug_var);
tclsetvar("tcl_debug",tmp );
tclsetvar("menu_tcl_debug",debug_var ? "1" : "0" );
tclsetvar("debug_var",tmp );
tclsetvar("menu_debug_var",debug_var ? "1" : "0" );
if(flat_netlist) tclsetvar("flat_netlist","1");
xctx->xschem_w = CADWIDTH;
@ -1472,8 +1479,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
screen_number = Tk_ScreenNumber(mainwindow);
colormap = Tk_Colormap(mainwindow);
depth = Tk_Depth(mainwindow);
dbg(1, "Tcl_AppInit(): screen depth: %d\n",depth);
screendepth = Tk_Depth(mainwindow);
dbg(1, "Tcl_AppInit(): screen depth: %d\n",screendepth);
visual = Tk_Visual(mainwindow);
/*
@ -1615,7 +1622,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
zoom_full(0, 0, 1, 0.97); /* Necessary to tell xschem the
* initial area to display
*/
pending_fullzoom=1;
xctx->pending_fullzoom=1;
if(do_netlist) {
if(debug_var>=1) {
if(flat_netlist)

View File

@ -245,7 +245,7 @@ extern char win_temp_dir[PATH_MAX];
#define ABORT 512 /* used in move/copy_objects for aborting without unselecting */
#define THICK 1024 /* used to draw thick lines (buses) */
#define ROTATELOCAL 2048 /* rotate each selected object around its own anchor point 20171208 */
#define CLEAR 4096 /* used in new_wire to clear previous rubber when switching manhattan_lines */
#define CLEAR 4096 /* used in new_wire to clear previous rubber when switching xctx->manhattan_lines */
/* #define DRAW 8192 */ /* was used in bbox() to draw things by using XCopyArea after setting clip rectangle */
#define HILIGHT 8192 /* used when calling draw_*symbol_outline() for hilighting instead of normal draw */
#define FONTWIDTH 20
@ -605,6 +605,7 @@ typedef struct {
double rx1, rx2, ry1, ry2;
short move_rot;
short move_flip;
int manhattan_lines;
double x1, y_1, x2, y_2, deltax, deltay;
int movelastsel;
short rotatelocal;
@ -625,6 +626,13 @@ typedef struct {
XSegment *biggridpoint;
XPoint *gridpoint;
char plotfile[PATH_MAX];
int *active_layer;
int n_active_layers;
int enable_drill;
int pending_fullzoom;
char hiersep[20];
int no_undo;
int fill_pattern; /* fill rectangles */
} Xschem_ctx;
struct Lcc { /* used for symbols containing schematics as instances (LCC, Local Custom Cell) */
@ -702,18 +710,55 @@ struct instentry {
/* GLOBAL VARIABLES */
extern Xschem_ctx *xctx;
/*********** Variables backed in xschem.tcl ***********/
extern int cadlayers;
extern int has_x;
extern int rainbow_colors;
extern int persistent_command;
extern int autotrim_wires;
extern int disable_unique_names;
extern int change_lw; /* allow change line width*/
extern int incr_hilight;
extern int auto_hilight;
extern int big_grid_points;
extern int draw_grid;
extern double cadgrid;
extern double cadsnap;
extern int draw_window;
extern unsigned short enable_stretch;
extern int split_files;
extern char *netlist_dir;
extern int sym_txt;
extern int fullscreen;
extern int en_hilight_conn_inst;
extern int transparent_svg;
extern int color_ps;
extern int only_probes;
extern int unzoom_nodrift;
extern int spiceprefix;
extern int netlist_show;
extern double nocairo_vert_correct;
extern double nocairo_font_xscale;
extern double nocairo_font_yscale;
extern char svg_font_name[80];
extern int top_subckt;
extern int constrained_move;
extern int netlist_type;
extern int dark_colorscheme;
extern int flat_netlist;
extern int hide_symbols; /* draw only a bounding box for component instances and @symname, @name texts */
extern int show_pin_net_names;
extern int *enable_layer;
extern double cairo_font_scale; /* default: 1.0, allows to adjust font size */
extern char cairo_font_name[80];
extern double cairo_font_line_spacing; /* allows to change line spacing: default: 1.0 */
extern double cairo_vert_correct;
extern int debug_var;
/*********** End of variables backed in xschem.tcl ***********/
extern int help;
extern char *cad_icon[];
extern int manhattan_lines;
extern int cadlayers;
extern int *active_layer;
extern int *enable_layer;
extern int n_active_layers;
extern int do_print;
extern int has_x;
extern int no_draw;
extern int sym_txt;
extern int rainbow_colors;
extern FILE *errfp;
extern int no_readline;
extern char *filename;
@ -724,36 +769,18 @@ extern int load_initfile;
extern char rcfile[PATH_MAX];
extern char *tcl_command;
extern char tcl_script[PATH_MAX];
extern int persistent_command;
extern int autotrim_wires;
extern int dis_uniq_names;
extern int tcp_port;
extern int debug_var;
extern char **color_array;
extern unsigned int color_index[];
extern int change_lw; /* allow change line width */
extern int thin_text;
extern int incr_hilight;
extern int auto_hilight;
extern int fill; /* fill rectangles */
extern int draw_grid;
extern int big_grid_points;
extern int text_svg;
extern int text_ps;
extern double cadgrid;
extern double cadhalfdotsize;
extern int draw_pixmap; /* pixmap used as 2nd buffer */
extern int draw_window;
extern int draw_pixmap; /* pixmap used as 2nd buffer */
extern XEvent xev;
extern KeySym key;
extern unsigned short enable_stretch;
extern unsigned int button;
extern unsigned int state; /* status of shift,ctrl etc.. */
extern int currentsch;
extern char *xschem_version_string;
extern int split_files;
extern char *netlist_dir;
extern char initial_netlist_name[PATH_MAX];
extern char bus_char[];
extern int max_undo;
@ -761,49 +788,19 @@ extern int draw_dots;
extern int draw_single_layer;
extern int yyparse_error;
extern char *xschem_executable;
extern int depth;
extern int screendepth;
extern int *fill_type; /* 20171117 for every layer: 0: no fill, 1, solid fill, 2: stipple fill */
extern Tcl_Interp *interp;
extern double cadsnap;
extern double *character[256];
extern int constrained_move;
extern int netlist_show;
extern int flat_netlist;
extern int netlist_type;
extern int do_netlist;
extern int do_simulation;
extern int do_waves;
extern int netlist_count;
extern int top_subckt;
extern int spiceprefix;
extern char hiersep[20];
extern int quit;
extern int show_erc;
extern int color_ps;
extern int transparent_svg;
extern int only_probes;
extern int pending_fullzoom;
extern int fullscreen;
extern int unzoom_nodrift;
extern int dark_colorscheme;
extern double color_dim;
extern int no_undo;
extern int enable_drill;
extern size_t get_tok_size;
extern int batch_mode; /* no TCL console */
extern int hide_symbols; /* draw only a bounding box for component instances and @symname, @name texts */
extern int show_pin_net_names;
extern int en_hilight_conn_inst;
extern char svg_font_name[80];
/* CAIRO specific global variables */
extern char cairo_font_name[80];
extern double cairo_font_scale; /* default: 1.0, allows to adjust font size */
extern double nocairo_font_xscale;
extern double nocairo_font_yscale;
extern double cairo_font_line_spacing; /* allows to change line spacing: default: 1.0 */
extern double cairo_vert_correct;
extern double nocairo_vert_correct;
extern const char fopen_read_mode[];
extern const char fopen_read_mode[]; /* "r" on unix, "rb" on windows */
/* X11 specific globals */
extern Colormap colormap;
@ -1099,7 +1096,7 @@ extern void *my_calloc(int id, size_t nmemb, size_t size);
extern void my_free(int id, void *ptr);
extern size_t my_strcat(int id, char **, const char *);
extern const char *subst_token(const char *s, const char *tok, const char *new_val);
extern void new_prop_string(int i, const char *old_prop,int fast, int dis_uniq_names);
extern void new_prop_string(int i, const char *old_prop,int fast, int disable_unique_names);
extern void hash_name(char *token, int remove);
extern void hash_all_names(int n);
extern void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2);

View File

@ -131,10 +131,10 @@ proc execute {status args} {
proc netlist {source_file show netlist_file} {
global XSCHEM_SHAREDIR flat_netlist hspice_netlist netlist_dir
global verilog_2001 netlist_type tcl_debug
global verilog_2001 netlist_type debug_var
simuldir
if {$tcl_debug <= -1} { puts "netlist: source_file=$source_file, netlist_type=$netlist_type" }
if {$debug_var <= -1} { puts "netlist: source_file=$source_file, netlist_type=$netlist_type" }
if {$netlist_type eq {spice}} {
if { $hspice_netlist == 1 } {
set simulator {-hspice}
@ -216,7 +216,7 @@ proc convert_to_pdf {filename dest} {
# 20161121
proc convert_to_png {filename dest} {
global to_png tcl_debug
global to_png debug_var
# puts "---> $to_png $filename $dest"
set cmd "exec $to_png \$filename png:\$dest"
if {$::OS == "Windows"} {
@ -1010,7 +1010,7 @@ proc waves {} {
# ============================================================
proc utile_translate {schname} {
global netlist_dir netlist_type tcl_debug XSCHEM_SHAREDIR
global netlist_dir netlist_type debug_var XSCHEM_SHAREDIR
global utile_gui_path utile_cmd_path
simuldir
@ -1020,7 +1020,7 @@ proc utile_translate {schname} {
}
proc utile_gui {schname} {
global netlist_dir netlist_type tcl_debug XSCHEM_SHAREDIR
global netlist_dir netlist_type debug_var XSCHEM_SHAREDIR
global utile_gui_path utile_cmd_path
simuldir
@ -1030,7 +1030,7 @@ proc utile_gui {schname} {
}
proc utile_edit {schname} {
global netlist_dir netlist_type tcl_debug editor XSCHEM_SHAREDIR
global netlist_dir netlist_type debug_var editor XSCHEM_SHAREDIR
global utile_gui_path utile_cmd_path
simuldir
@ -1040,7 +1040,7 @@ proc utile_edit {schname} {
}
proc get_shell { curpath } {
global netlist_dir netlist_type tcl_debug
global netlist_dir netlist_type debug_var
global terminal
simuldir
@ -1048,7 +1048,7 @@ proc get_shell { curpath } {
}
proc edit_netlist {schname } {
global netlist_dir netlist_type tcl_debug
global netlist_dir netlist_type debug_var
global editor terminal
simuldir
@ -2111,7 +2111,7 @@ proc property_search {} {
button .dialog.but.ok -text OK -command {
set search_value [.dialog.val.e get]
set custom_token [.dialog.custom.e get]
if {$tcl_debug<=-1} { puts stderr "|$custom_token|" }
if {$debug_var<=-1} { puts stderr "|$custom_token|" }
set token $custom_token
if { $search_exact==1 } {
set search_found [xschem searchmenu exact $search_select $token $search_value]
@ -2163,12 +2163,12 @@ proc property_search {} {
#
proc tclpropeval {s instname symname} {
# puts "tclpropeval: $s $instname $symname"
global env tcl_debug
if {$tcl_debug <=-1} {puts "tclpropeval: $s"}
global env debug_var
if {$debug_var <=-1} {puts "tclpropeval: $s"}
regsub {^@tcleval\(} $s {} s
regsub {\)([ \t\n]*)$} $s {\1} s
if { [catch {eval $s} res] } {
if { $tcl_debug<=-1 } { puts "tclpropeval warning: $res"}
if { $debug_var<=-1 } { puts "tclpropeval warning: $res"}
set res ?\n
}
return $res
@ -2176,21 +2176,21 @@ proc tclpropeval {s instname symname} {
# this hook is called in translate() if whole string is contained in a tcleval(...) construct
proc tclpropeval2 {s} {
global tcl_debug env netlist_type path
global debug_var env netlist_type path
# puts "tclpropeval2: s=|$s|"
if {$tcl_debug <=-1} {puts "tclpropeval2: $s"}
if {$debug_var <=-1} {puts "tclpropeval2: $s"}
set path [string range [xschem get sch_path] 1 end]
if { $netlist_type eq {spice} } {
regsub {^([^xX])} $path {x\1} path
while { [regsub {\.([^xX])} $path {.x\1} path] } {}
}
if { $tcl_debug<=-1 } { puts "---> path=$path" }
if { $debug_var<=-1 } { puts "---> path=$path" }
regsub {^tcleval\(} $s {} s
regsub {\)([ \n\t]*)$} $s {\1} s
# puts "tclpropeval2: s=|$s|"
# puts "tclpropeval2: subst $s=|[subst $s]|"
if { [catch {uplevel #0 "subst \{$s\}"} res] } {
if { $tcl_debug<=-1 } { puts "tclpropeval2 warning: $res"}
if { $debug_var<=-1 } { puts "tclpropeval2 warning: $res"}
set res ?\n
}
# puts "tclpropeval2: res=|$res|"
@ -2292,7 +2292,7 @@ proc ask_save { {ask {save file?}} } {
proc edit_vi_prop {txtlabel} {
global XSCHEM_TMP_DIR retval symbol prev_symbol rcode tcl_debug netlist_type editor
global XSCHEM_TMP_DIR retval symbol prev_symbol rcode debug_var netlist_type editor
global user_wants_copy_cell
set user_wants_copy_cell 0
@ -2303,14 +2303,14 @@ proc edit_vi_prop {txtlabel} {
write_data $retval $XSCHEM_TMP_DIR/$filename
# since $editor can be an executable with options (gvim -f) I *need* to use eval
eval execute_wait 0 $editor $XSCHEM_TMP_DIR/$filename ;# 20161119
if {$tcl_debug<=-1} {puts "edit_vi_prop{}:\n--------\nretval=$retval\n---------\n"}
if {$tcl_debug<=-1} {puts "edit_vi_prop{}:\n--------\nsymbol=$symbol\n---------\n"}
if {$debug_var<=-1} {puts "edit_vi_prop{}:\n--------\nretval=$retval\n---------\n"}
if {$debug_var<=-1} {puts "edit_vi_prop{}:\n--------\nsymbol=$symbol\n---------\n"}
set tmp [read_data $XSCHEM_TMP_DIR/$filename]
file delete $XSCHEM_TMP_DIR/$filename
if {$tcl_debug<=-1} {puts "edit_vi_prop{}:\n--------\n$tmp\n---------\n"}
if {$debug_var<=-1} {puts "edit_vi_prop{}:\n--------\n$tmp\n---------\n"}
if [string compare $tmp $retval] {
set retval $tmp
if {$tcl_debug<=-1} {puts "modified"}
if {$debug_var<=-1} {puts "modified"}
set rcode ok
return $rcode
} else {
@ -2320,7 +2320,7 @@ proc edit_vi_prop {txtlabel} {
}
proc edit_vi_netlist_prop {txtlabel} {
global XSCHEM_TMP_DIR retval rcode tcl_debug netlist_type editor
global XSCHEM_TMP_DIR retval rcode debug_var netlist_type editor
global user_wants_copy_cell
set user_wants_copy_cell 0
@ -2333,15 +2333,15 @@ proc edit_vi_netlist_prop {txtlabel} {
if { [regexp vim $editor] } { set ftype "\{-c :set filetype=$netlist_type\}" } else { set ftype {} }
# since $editor can be an executable with options (gvim -f) I *need* to use eval
eval execute_wait 0 $editor $ftype $XSCHEM_TMP_DIR/$filename
if {$tcl_debug <= -1} {puts "edit_vi_prop{}:\n--------\n$retval\n---------\n"}
if {$debug_var <= -1} {puts "edit_vi_prop{}:\n--------\n$retval\n---------\n"}
set tmp [read_data $XSCHEM_TMP_DIR/$filename]
file delete $XSCHEM_TMP_DIR/$filename
if {$tcl_debug <= -1} {puts "edit_vi_prop{}:\n--------\n$tmp\n---------\n"}
if {$debug_var <= -1} {puts "edit_vi_prop{}:\n--------\n$tmp\n---------\n"}
if [string compare $tmp $retval] {
set retval $tmp
regsub -all {(["\\])} $retval {\\\1} retval ;#" editor is confused by the previous quote
set retval \"${retval}\"
if {$tcl_debug <= -1} {puts "modified"}
if {$debug_var <= -1} {puts "modified"}
set rcode ok
return $rcode
} else {
@ -2386,12 +2386,12 @@ proc change_color {} {
proc edit_prop {txtlabel} {
global edit_prop_size infowindow_text selected_tok edit_symbol_prop_new_sel edit_prop_pos
global prev_symbol retval symbol rcode no_change_attrs preserve_unchanged_attrs copy_cell tcl_debug
global prev_symbol retval symbol rcode no_change_attrs preserve_unchanged_attrs copy_cell debug_var
global user_wants_copy_cell editprop_sympath retval_orig old_selected_tok
set user_wants_copy_cell 0
set rcode {}
set retval_orig $retval
if {$tcl_debug <= -1} {puts " edit_prop{}: retval=$retval"}
if {$debug_var <= -1} {puts " edit_prop{}: retval=$retval"}
if { [winfo exists .dialog] } return
toplevel .dialog -class Dialog
wm title .dialog {Edit Properties}
@ -2609,11 +2609,11 @@ proc write_data {data f} {
proc text_line {txtlabel clear {preserve_disabled disabled} } {
global text_line_default_geometry preserve_unchanged_attrs
global retval rcode tcl_debug selected_tok retval_orig old_selected_tok
global retval rcode debug_var selected_tok retval_orig old_selected_tok
set retval_orig $retval
if $clear==1 then {set retval ""}
if {$tcl_debug <= -1} {puts " text_line{}: clear=$clear"}
if {$tcl_debug <= -1} {puts " text_line{}: retval=$retval"}
if {$debug_var <= -1} {puts " text_line{}: clear=$clear"}
if {$debug_var <= -1} {puts " text_line{}: retval=$retval"}
set rcode {}
if { [winfo exists .dialog] } return
toplevel .dialog -class Dialog
@ -3410,8 +3410,8 @@ proc build_windows {} {
pack .menubar -anchor n -side top -fill x -before .drw
toolbar_show
pack .statusbar -after .drw -anchor sw -fill x
bind .statusbar.5 <Leave> { xschem set cadgrid $grid; focus .drw}
bind .statusbar.3 <Leave> { xschem set cadsnap $snap; focus .drw}
bind .statusbar.5 <Leave> { xschem set cadgrid $cadgrid; focus .drw}
bind .statusbar.3 <Leave> { xschem set cadsnap $cadsnap; focus .drw}
set_bindings {.drw}
}
}
@ -3558,9 +3558,9 @@ if {$::OS == "Windows"} {
# used in C code
set_ne xschem_libs {}
set_ne noprint_libs {}
set_ne tcl_debug 0
set_ne debug_var 0
# used to activate debug from menu
set_ne menu_tcl_debug 0
set_ne menu_debug_var 0
set textwindow_wcounter 1
set viewdata_wcounter 1
set retval ""
@ -3609,8 +3609,8 @@ set_ne enable_stretch 0
set_ne constrained_move 0
set_ne draw_grid 1
set_ne big_grid_points 0
set_ne snap 10
set_ne grid 20
set_ne cadsnap 10
set_ne cadgrid 20
set_ne persistent_command 0
set_ne autotrim_wires 0
set_ne disable_unique_names 0
@ -3897,9 +3897,9 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ]
-command {
if { $transparent_svg==1 } {xschem set transparent_svg 1} else { xschem set transparent_svg 0}
}
.menubar.option.menu add checkbutton -label "Debug mode" -variable menu_tcl_debug \
.menubar.option.menu add checkbutton -label "Debug mode" -variable menu_debug_var \
-command {
if { $menu_tcl_debug==1 } {xschem debug 1} else { xschem debug 0}
if { $menu_debug_var==1 } {xschem debug 1} else { xschem debug 0}
}
.menubar.option.menu add checkbutton -label "Enable stretch" -variable enable_stretch \
-accelerator Y \
@ -4083,7 +4083,7 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ]
}
.menubar.zoom.menu add command -label "Set grid spacing" \
-command {
input_line "Enter grid spacing (float):" "xschem set cadgrid" $grid
input_line "Enter grid spacing (float):" "xschem set cadgrid" $cadgrid
}
.menubar.zoom.menu add checkbutton -label "View only Probes" -variable only_probes \
-accelerator {5} \
@ -4302,10 +4302,10 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ]
frame .statusbar
label .statusbar.1 -text "STATUS BAR 1"
label .statusbar.2 -text "SNAP:"
entry .statusbar.3 -textvariable snap -relief sunken -bg white \
entry .statusbar.3 -textvariable cadsnap -relief sunken -bg white \
-width 10 -foreground black -takefocus 0
label .statusbar.4 -text "GRID:"
entry .statusbar.5 -textvariable grid -relief sunken -bg white \
entry .statusbar.5 -textvariable cadgrid -relief sunken -bg white \
-width 10 -foreground black -takefocus 0
label .statusbar.6 -text "NETLIST MODE:"
entry .statusbar.7 -textvariable netlist_type -relief sunken -bg white \