5 * INIT(...) : Set configs. (rowstep, totwidth, stdheight, stdwidth)
6 * SPOS(V,H) : Set current position.
8 * SCOL : Standard column, for a single column, increment position
9 * NEXT(V,H) : increment postion by standard + (V,H)
10 * COL(K,N) : X,Y position for col K of N (default 1of [same as last])
11 * SS : Standard size of last COL (using number of cols).
12 * ADJ(V,H) : Adjust next COL or SCOL by (V,H)
14 * CURX(H) : Current Xpos+H
15 * CURY(V) : Current Ypos+V
26 #define T_INIT 100 /* Init the style of the values */
27 #define T_SPOS 101 /* Set the current position */
28 #define T_SCOL 102 /* Standard column COL(1,1), SS NEXT */
29 #define T_NEXT 103 /* Next line */
30 #define T_COL 104 /* Multi-column */
31 #define T_SS 105 /* Standard Size */
32 #define T_ADJ 106 /* Adjust next COL/SCOL */
33 #define T_GRID 107 /* */
34 #define T_GAP 108 /* */
36 #define T_CURX 120 /* Current X + offset */
37 #define T_CURY 121 /* Current Y + offset */
39 #define T_SAVEPOSN 122 /* Save current status */
40 #define T_RESTOREPOSN 123 /* Restore current status */
58 {"SAVEPOSN", T_SAVEPOSN, },
59 {"RESTOREPOSN", T_RESTOREPOSN, },
82 int ar_count, ar_val[10];
90 ifd = stdin; ofd = stdout;
96 fprintf(stderr, "Error reading input file\n");
100 if (readword() < 0) break;
102 if (check_keys() < 0)
104 fprintf(ofd, "%s", wordbuf);
108 /* To get here we have found one of our keywords, some words will
109 * be followed by an argument.
114 while((ch = getc(ifd)) != EOF && isspace(ch) && ch != '\n')
121 ar_val[ar_count++] = get_number();
123 while((ch=getc(ifd)) != EOF && isspace(ch)) ;
124 if (ch != ',') break;
126 if (ch == EOF) break;
131 /* Ok got args, now doit */
137 /* This is the lexer - not using lex(1) because this will have to
138 * compile under windows.
145 try_again:; /* This is for "too big" words and strings. */
149 /* Find a word ... */
150 while((ch=getc(ifd)) != EOF && !isalpha(ch) && ch != '"')
157 while((ch=getc(ifd)) != EOF && ch != '"')
165 if (ch == EOF) return -1;
169 if (wp>=wordbuf+sizeof(wordbuf)-2)
172 fprintf(ofd, "%s", wordbuf);
174 while(ch!=EOF && isalpha(ch))
186 while(ch != EOF && (isalnum(ch) || ch == '_'));
200 while((ch=getc(ifd)) != EOF && isspace(ch)) ;
202 if( ch == '+' ) { sign=1; ch=getc(ifd); }
203 else if( ch == '-' ) { sign=-1; ch=getc(ifd); }
205 while(ch>='0' && ch<='9')
207 value = value * 10 + ch - '0';
212 if (sign < 0) value = -value;
221 for(p=keywords; p->name; p++)
223 if (strcmp(wordbuf, p->name) == 0 )
225 status.token = p->token;
234 if (status.cols < 1) status.cols = 1;
239 if (ar_count > 0) status.row_step = ar_val[0];
240 if (ar_count > 1) status.tot_width = ar_val[1];
241 if (ar_count > 2) status.con_height = ar_val[2];
242 else status.con_height = status.row_step;
243 if (ar_count > 3) status.con_width = ar_val[3];
244 else status.con_width = status.tot_width;
246 status.gutter = ( status.tot_width - status.con_width ) /2;
250 status.cury = status.curx = 0;
251 if (ar_count > 0) status.cury = ar_val[0];
252 if (ar_count > 1) status.curx = ar_val[1];
256 fprintf(ofd, "%d, %d", status.curx + status.hadjust,
257 status.cury + status.vadjust);
258 status.hadjust = status.vadjust = 0;
260 fprintf(ofd, ", %d, %d", status.con_width, status.con_height);
262 status.cury += status.row_step;
264 if (ar_count > 0) status.cury += ar_val[0];
265 if (ar_count > 1) status.curx += ar_val[1];
269 status.cury += status.row_step;
270 if (ar_count > 0) status.cury += ar_val[0];
271 if (ar_count > 1) status.curx += ar_val[1];
279 if (ar_count > 0) curcol = ar_val[0]; else curcol = 1;
280 if (ar_count > 1) status.cols = ar_val[1];
282 col_pos = (status.con_width+status.gutter) *(curcol-1) /status.cols;
284 fprintf(ofd, "%d, %d",
285 status.curx + status.hadjust + col_pos,
286 status.cury + status.vadjust);
287 status.hadjust = status.vadjust = 0;
295 if (ar_count > 0) wm = ar_val[0];
296 if (ar_count > 1) hm = ar_val[1];
298 width = (status.con_width+status.gutter) / status.cols;
300 width -= status.gutter;
302 fprintf(ofd, "%d, %d", width, hm*status.con_height);
307 if (ar_count > 0) status.vadjust = ar_val[0];
308 if (ar_count > 1) status.hadjust = ar_val[0];
312 if (ar_count > 0) status.cols = ar_val[0];
313 else status.cols = 1;
314 if (ar_count > 1) status.con_height = ar_val[1];
315 if (ar_count > 2) status.row_step = ar_val[2];
319 if (ar_count > 0) status.cury += ar_val[0];
320 else status.cury += 2;
325 fprintf(ofd, "%d", status.curx+ar_val[0]);
327 fprintf(ofd, "%d", status.curx);
331 fprintf(ofd, "%d", status.cury+ar_val[0]);
333 fprintf(ofd, "%d", status.cury);
337 saved_status = status;
340 status = saved_status;