33
33
/*------------------------------------------------------------------------*/
35
35
extern Display *dpy;
36
extern Clientdata areastruct;
36
extern XCWindowData *areawin;
37
37
extern Globaldata xobjs;
38
38
extern short textpos, textend;
39
39
extern short fontcount;
40
40
extern fontinfo *fonts;
41
extern short eventmode;
42
41
extern int *appcolors;
43
42
extern colorindex *colorlist;
44
43
extern char _STR[150];
93
92
labelptr dest, source;
95
if (areastruct.selects < 2) {
94
if (areawin->selects < 2) {
96
95
Wprintf("Not enough labels selected for joining");
100
99
XcSetFunction(GXcopy);
101
XSetForeground(dpy, areastruct.gc, BACKGROUND);
100
XSetForeground(dpy, areawin->gc, BACKGROUND);
103
for (jl = areastruct.selectlist; jl < areastruct.selectlist +
104
areastruct.selects; jl++) {
102
for (jl = areawin->selectlist; jl < areawin->selectlist +
103
areawin->selects; jl++) {
105
104
if (SELECTTYPE(jl) == LABEL) {
106
105
dest = SELTOLABEL(jl);
107
UDrawString(dest, DOFORALL, areastruct.topinstance);
106
UDrawString(dest, DOFORALL, areawin->topinstance);
108
107
for (endpart = dest->string; endpart->nextpart != NULL; endpart =
109
108
endpart->nextpart);
114
for (++jl; jl < areastruct.selectlist + areastruct.selects; jl++) {
113
for (++jl; jl < areawin->selectlist + areawin->selects; jl++) {
115
114
if (SELECTTYPE(jl) == LABEL) {
116
115
source = SELTOLABEL(jl);
117
UDrawString(source, DOFORALL, areastruct.topinstance);
116
UDrawString(source, DOFORALL, areawin->topinstance);
118
117
endpart->nextpart = source->string;
119
118
for (; endpart->nextpart != NULL; endpart = endpart->nextpart);
122
reviseselect(areastruct.selectlist, areastruct.selects, jl);
121
reviseselect(areawin->selectlist, areawin->selects, jl);
126
XSetForeground(dpy, areastruct.gc, dest->color);
127
UDrawString(dest, dest->color, areastruct.topinstance);
125
XSetForeground(dpy, areawin->gc, dest->color);
126
UDrawString(dest, dest->color, areawin->topinstance);
129
128
incr_changes(topobject);
148
147
else { /* otherwise */
149
148
for(lastptr = *strhead; lastptr != NULL;) {
150
nextptr = nextstringpart(lastptr, areastruct.topinstance);
149
nextptr = nextstringpart(lastptr, areawin->topinstance);
151
150
if (nextptr == before) {
152
151
if (lastptr->type == PARAM_START) {
153
152
oparamptr obs = NULL;
154
153
char *key = lastptr->data.string;
155
obs = find_param(areastruct.topinstance, key);
154
obs = find_param(areawin->topinstance, key);
156
155
if (obs == NULL) {
157
156
Wprintf("Error: Bad parameter!");
204
203
/* Get the next string part, linking to a paramter if necessary */
205
204
/*----------------------------------------------------------------------*/
207
stringpart *nextstringpart(stringpart *strptr, objinstptr thisinst)
206
stringpart *nextstringpartrecompute(stringpart *strptr, objinstptr thisinst)
209
208
stringpart *nextptr = strptr->nextpart;
232
231
/* when encountered. Use the previously generated result. */
233
232
/*----------------------------------------------------------------------*/
235
stringpart *nextstringpartnorecompute(stringpart *strptr, objinstptr thisinst)
234
stringpart *nextstringpart(stringpart *strptr, objinstptr thisinst)
237
236
stringpart *nextptr = strptr->nextpart;
306
305
strptr->nextpart = dstr->nextpart;
308
if (dstr->type == TEXT_STRING) free(dstr->data.string);
307
if (dstr->type == TEXT_STRING)
308
free(dstr->data.string);
311
311
/* attempt to merge, if legal */
388
388
tmpptr = makesegment(&promote, NULL);
389
389
tmpptr->type = PARAM_END;
392
free(promote->data.string);
392
if (promote->data.string != NULL) {
393
free(promote->data.string);
394
promote->data.string = NULL;
394
398
/* Promote numerical type to string */
395
399
if (ops->type == XC_INT) {
407
411
if (!compute_exprs && (ips = match_instance_param(localinst, key))
408
412
!= NULL && (ips->type == XC_STRING)) {
409
413
nextptr = ips->parameter.string;
410
/* This could probably be done better. . . hack to keep */
411
/* free() from operating twice on the same memory block. */
412
promote->data.string = (char *)malloc(1);
414
promote->data.string = NULL;
415
417
promote->data.string = evaluate_expr(ops, localinst);
418
if (promote->data.string != NULL)
520
525
"Tab_Stop", "Tab_Forward", "Tab_Backward",
521
526
"Halfspace", "Quarterspace", "<Return>",
522
527
"Font", "Scale", "Color", "Kern",
523
"Parameter", ">", "Error"};
528
"Parameter", ">", "Net_Name", "Error"};
525
530
/*----------------------------------------------------------------------*/
526
531
/* charprint(): */
628
633
newstr = xcstringtostring(strtop, localinst, True);
629
634
if (subnet >= 0) {
630
busptr = strchr(newstr, areastruct.buschar);
635
busptr = strchr(newstr, areawin->buschar);
631
636
if (busptr != NULL) {
632
637
endptr = find_delimiter(busptr);
633
638
if (endptr != NULL) {
648
653
strcpy(substr, newstr);
650
655
while ((*endptr) != '\0') endptr++;
651
sprintf(endptr, "%c%d%c", areastruct.buschar, subnet,
652
standard_delimiter_end(areastruct.buschar));
656
sprintf(endptr, "%c%d%c", areawin->buschar, subnet,
657
standard_delimiter_end(areawin->buschar));
679
684
else { /* just make a comma-separated list */
680
685
newstr = (char *)malloc(strlen(prefix) + 20 + 3 * sublist->subnets);
681
686
sbus = sublist->net.list;
682
sprintf(newstr, "%s%d%c", prefix, sbus->netid, areastruct.buschar);
687
sprintf(newstr, "%s%d%c", prefix, sbus->netid, areawin->buschar);
683
688
for (i = 0; i < sublist->subnets; i++) {
684
689
sbus = sublist->net.list + i;
685
690
sptr = newstr + strlen(newstr);
688
693
sprintf(sptr, "%d", sbus->subnetid);
690
695
sptr = newstr + strlen(newstr);
691
sprintf(sptr, "%c", standard_delimiter_end(areastruct.buschar));
696
sprintf(sptr, "%c", standard_delimiter_end(areawin->buschar));
823
828
for (strptr = thislab->string; strptr != NULL; strptr =
824
829
nextstringpart(strptr, thisinst)) {
825
830
if (strptr->type == TEXT_STRING) {
826
if ((busptr = strchr(strptr->data.string, areastruct.buschar)) != NULL) {
831
if ((busptr = strchr(strptr->data.string, areawin->buschar)) != NULL) {
827
832
if (sscanf(++busptr, "%d", &busidx) == 1)
853
858
for (strptr = thislab->string; strptr != NULL; strptr =
854
859
nextstringpart(strptr, thisinst)) {
855
860
if (strptr->type == TEXT_STRING) {
856
if ((busptr = strchr(strptr->data.string, areastruct.buschar)) != NULL) {
861
if ((busptr = strchr(strptr->data.string, areawin->buschar)) != NULL) {
857
862
if (isdigit(*(++busptr)))
909
914
tptr = textprint(blab->string, thisinst);
910
915
tlen = strlen(tptr) + 1;
911
buspos = strchr(tptr, areastruct.buschar);
916
buspos = strchr(tptr, areawin->buschar);
913
918
/* The notation "(...)" with NO TEXT preceding the opening bus */
914
919
/* delimiter, is assumed to represent a numerical pin range. So */
1037
1042
switch (strptr1->type) {
1038
1043
case TEXT_STRING:
1039
1044
if (in_bus == 1) {
1040
char matchchar = areastruct.buschar;
1041
switch (areastruct.buschar) {
1045
char matchchar = areawin->buschar;
1046
switch (areawin->buschar) {
1042
1047
case '(': matchchar = ')'; break;
1043
1048
case '[': matchchar = ']'; break;
1044
1049
case '{': matchchar = '}'; break;
1067
1072
/* except between the bus notation delimiters (default */
1070
buspos = strchr(strptr1->data.string, areastruct.buschar);
1075
buspos = strchr(strptr1->data.string, areawin->buschar);
1071
1076
if (buspos != NULL) {
1073
1078
bpos = (int)(buspos - (char *)(strptr1->data.string)) + 1;
1353
1358
int defaultcolor, curcolor, scolor;
1354
1359
short oldx, oldfont, oldstyle;
1355
1360
float tmpscale = 1.0, natscale = 1.0;
1356
float tmpthick = xobjs.pagelist[areastruct.page]->wirewidth;
1361
float tmpthick = xobjs.pagelist[areawin->page]->wirewidth;
1357
1362
XPoint newpoint, bboxin[2], bboxout[2];
1359
1364
TextExtents tmpext;
1402
1407
/* them from the circuit point to which they attach. */
1404
1409
if (drawlabel->pin) {
1405
if (!areastruct.schemon)
1406
goto enddraw; /* Don't draw pins when schematic capture is off */
1408
pinadjust(tmpjust, &(newpoint.x), &(newpoint.y), 1);
1410
pinadjust(tmpjust, &(newpoint.x), &(newpoint.y), 1);
1411
1413
oldx = newpoint.x;
1421
1423
xm = (bboxout[0].x < bboxout[1].x) ? 0 : 1;
1422
1424
ym = (bboxout[0].y < bboxout[1].y) ? 0 : 1;
1424
if (bboxout[xm].x < areastruct.width && bboxout[ym].y < areastruct.height &&
1426
if (bboxout[xm].x < areawin->width && bboxout[ym].y < areawin->height &&
1425
1427
bboxout[1 - xm].x > 0 && bboxout[1 - ym].y > 0) {
1428
1430
for (strptr = drawlabel->string; strptr != NULL;
1429
strptr = nextstringpartnorecompute(strptr, localinst)) {
1431
strptr = nextstringpart(strptr, localinst)) {
1431
1433
/* All segments other than text cancel any */
1432
1434
/* existing overline/underline in effect. */
1563
1565
case TEXT_STRING:
1564
for (textptr = strptr->data.string; textptr && *textptr != '\0'; textptr++) {
1566
for (textptr = strptr->data.string; textptr && *textptr != '\0';
1567
1570
UPreMultCTM(DCTM, newpoint, tmpscale, 0);
1600
if (drawlabel->pin && areastruct.schemon) UDrawXDown(drawlabel);
1603
if (drawlabel->pin) UDrawXDown(drawlabel);
1602
1605
if ((defaultcolor != DOFORALL) && (passcolor != curcolor)) {
1603
1606
XTopSetForeground(passcolor);
1606
xobjs.pagelist[areastruct.page]->wirewidth = tmpthick;
1609
xobjs.pagelist[areawin->page]->wirewidth = tmpthick;
1609
1612
/*----------------------------------------------------------------------*/
1757
1760
void undrawtextsimple(labelptr settext)
1759
SetFunction(dpy, areastruct.gc, GXcopy);
1762
SetFunction(dpy, areawin->gc, GXcopy);
1760
1763
XTopSetForeground(BACKGROUND);
1761
UDrawString(settext, DOFORALL, areastruct.topinstance);
1764
UDrawString(settext, DOFORALL, areawin->topinstance);
1764
1767
/*----------------------------------------------------------------------*/
1766
1769
void redrawtextsimple(labelptr settext)
1768
UDrawString(settext, settext->color, areastruct.topinstance);
1771
UDrawString(settext, settext->color, areawin->topinstance);
1771
1774
/*----------------------------------------------------------------------*/
1856
1859
directory->parts = 0;
1858
1861
/* 0.5 is the default vscale; 16 is no. characters per line */
1859
del = min(areastruct.width, areastruct.height) / (0.5 * 16);
1862
del = min(areawin->width, areawin->height) / (0.5 * 16);
1860
1863
qdel = del >> 2;
1862
1865
for (i = 0; i < 256; i++) {
1930
1933
if (op != XCF_Cancel) {
1932
window_to_user(x, y, &areastruct.save);
1935
window_to_user(x, y, &areawin->save);
1934
chy = -areastruct.save.y / del + 1;
1935
chx = areastruct.save.x / del;
1937
chy = -areawin->save.y / del + 1;
1938
chx = areawin->save.x / del;
1937
1940
chx = min(15, chx);
1938
1941
chy = min(15, chy);