1 #ifndef lint
2 static char sccsid[] = "@(#)textblocks.c 1.2 (CWI) 85/10/02";
3 #endif lint
4
5 #include "defs.h"
6 #include "ext.h"
7
8 /*
9 * Get a section of text
10 *
11 * Note that this doen't work after MAXLIN lines (see over200.c)
12 *
13 */
14
15 /*
16 * This returns an int with the name of the diversion,
17 * in maktab we test later in wide() whether the table entry is a
18 * pointer to a string, or a character.
19 * If it is a character, we now it is a diversion, and know it its width
20 * to be in <diversionname>-
21 *
22 * Very ugly, (looks like we need unions in declaration of structure colstr ?)
23 */
24
gettext(sp,ilin,icol,fn,sz)25 gettext(sp, ilin, icol, fn, sz)
26 char *sp, *fn, *sz;
27 {
28 char line[BUFSIZ];
29 char *vs;
30 int oname;
31
32 dprint(".\\\" -- gettext\n");
33 if(texname == 0)
34 error("Too many text block diversions");
35 if(textflg == 0){
36 printf(".nr %d \\n(.lu\n", SL);
37 /*
38 * remember old line length
39 */
40 textflg = 1;
41 }
42 printf(".eo\n");
43 printf(".am %2s\n", reg(icol, CRIGHT));
44 printf(".br\n");
45 printf(".di %c+\n", texname);
46 rstofill();
47 if(fn && *fn)
48 printf(".nr %d \\n(.f\n.ft %s\n", S1, fn);
49 /*
50 * protect font
51 */
52 printf(".ft \\n(.f\n");
53 vs = vsize[stynum[ilin]][icol];
54 if((sz && *sz) || (vs && *vs)){
55 printf(".nr %d \\n(.v\n", S2);
56 if(vs == 0 || *vs == 0)
57 vs = "\\n(.s+2";
58 if(sz && *sz)
59 printf(".ps %s\n", sz);
60 printf(".vs %s\n", vs);
61 printf(".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n",
62 S2, S2);
63 }
64 if(cll[icol][0])
65 printf(".ll %sn\n", cll[icol]);
66 else
67 printf(".ll \\n(%du*%du/%du\n", SL, ctspan(ilin, icol),
68 ncol + 1);
69 printf(".if \\n(.l<\\n(%2s .ll \\n(%2su\n", reg(icol, CRIGHT),
70 reg(icol, CRIGHT));
71 if(ctype(ilin, icol) == 'a')
72 printf(".ll -2n\n");
73 printf(".in 0\n");
74 while(gets1(line)){
75 if(line[0] == 'T' && line[1] == '}' && line[2] == tab)
76 break;
77 if(strcmp("T}", line) == 0)
78 break;
79 printf("%s\n", line);
80 }
81 if(fn && *fn)
82 printf(".ft \\n(%d\n", S1);
83 if(sz && *sz)
84 printf(".br\n.ps\n.vs\n");
85 printf(".br\n");
86 printf(".di\n");
87 /*
88 * Height of last complete diversion in register <diversionname>|
89 */
90 printf(".nr %c| \\n(dn\n", texname);
91 /*
92 * width of last complete diversion in register <diversionname>-
93 */
94 printf(".nr %c- \\n(dl\n", texname);
95 printf("..\n");
96 printf(".ec \\\n");
97 /*
98 * copy remainder of line
99 */
100 if(line[2])
101 strcpy(sp, line + 3);
102 else
103 *sp = 0;
104 oname = texname;
105 texname = texstr[++texct];
106 return(oname);
107 }
108
untext()109 untext(){
110 rstofill();
111 printf(".nf\n");
112 printf(".ll \\n(%du\n", SL);
113 }
114