-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcom_show.c
151 lines (137 loc) · 2.8 KB
/
com_show.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include "db.h"
#include "xwin.h"
#include "token.h"
#include "rlgetc.h"
#define UNUSED(x) (void)(x)
/*
SHOW {+|-|#}[EACILN0PRT]<layer>
+ : make it visible
- : turn it off
# : visible and modifiable
E : everything
A : arc
C : circle
I : instances
L : lines
N : notes
O : oval
P : polygons
R : rectangles
T : text
layer : layer number, "0" or omitted for all layers.
*/
int com_show(LEXER *lp, char *arg) /* define which kinds of things to display */
{
UNUSED(arg);
TOKEN token;
int done=0;
char *word;
int visible=0;
int modifiable=0;
int comp=0;
int show_layer=0;
if (lp->mode != EDI) {
printf("No cell currently being edited!\n");
token_flush_EOL(lp);
return(1);
}
while(!done && (token=token_get(lp, &word)) != EOF) {
switch(token) {
case OPT: /* option */
switch(toupper((unsigned char)word[0])) {
case '-':
visible=0;
modifiable=0;
break;
case '+':
visible=1;
modifiable=0;
break;
case '#':
visible=1;
modifiable=1;
break;
default:
printf("SHOW: options start with one of {+-#}: %s\n", word);
done++;
token_flush_EOL(lp);
break;
}
if (!done && strlen(word) > 1) {
switch(toupper((unsigned char)word[1])) {
case 'E':
comp=ALL;
break;
case 'A':
comp=ARC;
break;
case 'C':
comp=CIRC;
break;
case 'I':
comp=INST;
break;
case 'L':
comp=LINE;
break;
case 'N':
comp=NOTE;
break;
case 'O':
comp=OVAL;
break;
case 'P':
comp=POLY;
break;
case 'R':
comp=RECT;
break;
case 'T':
comp=TEXT;
break;
default:
printf("SHOW: bad component designator: %s\n", word);
done++;
token_flush_EOL(lp);
break;
}
}
if (!done) {
if ((strlen(word) >= 3)) {
if(sscanf(&word[2], "%d", &show_layer) != 1 ||
show_layer > MAX_LAYER) {
printf("SHOW: bad layer number: %s\n", word);
done++;
token_flush_EOL(lp);
}
} else {
show_layer=0;
}
}
if (!done) {
/* printf("setting comp %d, layer %d, visible %d, modify %d\n", comp,
show_layer, visible, modifiable); */
show_set_visible(currep, comp, show_layer, visible);
show_set_modify(currep, comp, show_layer, modifiable);
}
break;
case CMD: /* command */
token_unget(lp, token, word);
done++;
break;
case EOC: /* end of command */
done++;
break;
case EOL: /* newline or carriage return */
break;
default:
printf("SHOW: expected OPT, got %s %s\n", tok2str(token), word);
done++;
break;
}
}
return (0);
}