1: #include "tdef.h"
2: extern
3: #include "d.h"
4: extern
5: #include "v.h"
6: #ifdef NROFF
7: extern
8: #include "tw.h"
9: #endif
10:
11: /*
12: troff6.c
13:
14: width functions, sizes and fonts
15: */
16:
17: extern int eschar;
18: extern int widthp;
19: extern int ohc;
20: extern int xfont;
21: extern int smnt;
22: extern int setwdf;
23: extern char trtab[];
24: extern int chbits;
25: extern int nonumb;
26: extern int noscale;
27: extern int font;
28: extern int font1;
29: extern int pts;
30: extern int sps;
31: extern int nlflg;
32: extern int nform;
33: extern int dfact;
34: extern int dfactd;
35: extern int lss;
36: extern int lss1;
37: extern int vflag;
38: extern int ch0;
39: extern int level;
40: extern int ch;
41: extern int res;
42: extern int xxx;
43: int fontlab[] = {'R','I','B','S',0};
44:
45: width(c)
46: int c;
47: {
48: register i,j,k;
49:
50: j = c;
51: k = 0;
52: if(j & MOT){
53: if(j & VMOT)goto rtn;
54: k = j & ~MOTV;
55: if(j & NMOT)k = -k;
56: goto rtn;
57: }
58: if((i = (j & CMASK)) == 010){
59: k = -widthp;
60: goto rtn;
61: }
62: if(i == PRESC)i = eschar;
63: if((i == ohc) ||
64: (i >= 0370))goto rtn;
65: if(j & ZBIT)goto rtn;
66: i = trtab[i] & BMASK;
67: if(i < 040)goto rtn;
68: k = (*(t.codetab[i-32]) & 0177) * t.Char;
69: widthp = k;
70: rtn:
71: return(k);
72: }
73: setch(){
74: register i,*j,k;
75: extern int chtab[];
76:
77: if((i = getrq()) == 0)return(0);
78: for(j=chtab;*j != i;j++)if(*(j++) == 0)return(0);
79: k = *(++j) | chbits;
80: return(k);
81: }
82: find(i,j)
83: int i,j[];
84: {
85: register k;
86:
87: if(((k = i-'0') >= 1) && (k <= 4) && (k != smnt))return(--k);
88: for(k=0; j[k] != i; k++)if(j[k] == 0)return(-1);
89: return(k);
90: }
91: mchbits(){
92: chbits = (((pts)<<2) | font) << (BYTE + 1);
93: sps = width(' ' | chbits);
94: }
95: setps(){
96: register i,j;
97:
98: if((((i=getch() & CMASK) == '+') || (i == '-')) &&
99: (((j=(ch = getch() & CMASK) - '0') >= 0) && (j <= 9))){
100: ch = 0;
101: return;
102: }
103: if((i -= '0') == 0){
104: return;
105: }
106: if((i > 0) && (i <= 9)){
107: if((i <= 3) &&
108: ((j=(ch = getch() & CMASK) - '0') >= 0) && (j <= 9)){
109: i = 10*i +j;
110: ch = 0;
111: }
112: }
113: }
114: caseft(){
115: skip();
116: setfont(1);
117: }
118: setfont(a)
119: int a;
120: {
121: register i,j;
122:
123: if(a)i = getrq();
124: else i = getsn();
125: if(!i || (i == 'P')){
126: j = font1;
127: goto s0;
128: }
129: if(i == 'S')return;
130: if((j = find(i,fontlab)) == -1)return;
131: s0:
132: font1 = font;
133: font = j;
134: mchbits();
135: }
136: setwd(){
137: register i, base, wid;
138: int delim, em, k;
139: int savlevel, savhp, savfont, savfont1;
140:
141: base = v.st = v.sb = wid = v.ct = 0;
142: if((delim = getch() & CMASK) & MOT)return;
143: savhp = v.hp;
144: savlevel = level;
145: v.hp = level = 0;
146: savfont = font;
147: savfont1 = font1;
148: setwdf++;
149: while((((i = getch()) & CMASK) != delim) && !nlflg){
150: wid += width(i);
151: if(!(i & MOT)){
152: em = 2*t.Halfline;
153: }else if(i & VMOT){
154: k = i & ~MOTV;
155: if(i & NMOT)k = -k;
156: base -= k;
157: em = 0;
158: }else continue;
159: if(base < v.sb)v.sb = base;
160: if((k=base + em) > v.st)v.st = k;
161: }
162: nform = 0;
163: setn1(wid);
164: v.hp = savhp;
165: level = savlevel;
166: font = savfont;
167: font1 = savfont1;
168: mchbits();
169: setwdf = 0;
170: }
171: vmot(){
172: dfact = lss;
173: vflag++;
174: return(mot());
175: }
176: hmot(){
177: dfact = EM;
178: return(mot());
179: }
180: mot(){
181: register i, j;
182:
183: j = HOR;
184: getch(); /*eat delim*/
185: if(i = atoi()){
186: if(vflag)j = VERT;
187: i = makem(quant(i,j));
188: }
189: getch();
190: vflag = 0;
191: dfact = 1;
192: return(i);
193: }
194: sethl(k)
195: int k;
196: {
197: register i;
198:
199: i = t.Halfline;
200: if(k == 'u')i = -i;
201: else if(k == 'r')i = -2*i;
202: vflag++;
203: i = makem(i);
204: vflag = 0;
205: return(i);
206: }
207: makem(i)
208: int i;
209: {
210: register j;
211:
212: if((j = i) < 0)j = -j;
213: j = (j & ~MOTV) | MOT;
214: if(i < 0)j |= NMOT;
215: if(vflag)j |= VMOT;
216: return(j);
217: }
218: casefp(){
219: register i, j;
220:
221: skip();
222: if(((i = (getch() & CMASK) - '0' -1) < 0) || (i >3))return;
223: if(skip() || !(j = getrq()))return;
224: fontlab[i] = j;
225: }
226: casevs(){
227: register i;
228:
229: skip();
230: vflag++;
231: dfact = INCH; /*default scaling is points!*/
232: dfactd = 72;
233: res = VERT;
234: i = inumb(&lss);
235: if(nonumb)i = lss1;
236: if(i < VERT)i = VERT;
237: lss1 = lss;
238: lss = i;
239: }
240: xlss(){
241: register i, j;
242:
243: getch();
244: dfact = lss;
245: i = quant(atoi(),VERT);
246: dfact = 1;
247: getch();
248: if((j = i) < 0)j = -j;
249: ch0 = ((j & 03700)<<3) | HX;
250: if(i < 0)ch0 |= 040000;
251: return(((j & 077)<<9) | LX);
252: }
253: casefz(){}
254: caseps(){}
255: caselg(){}
256: casecs(){}
257: casebd(){}
258: casess(){}
259: getlg(i)
260: int i;
261: {
262: return(i);
263: }
Defined functions
find
defined in line
82; used 1 times
hmot
defined in line
176;
never used
mot
defined in line
180; used 2 times
setch
defined in line
73;
never used
setps
defined in line
95;
never used
vmot
defined in line
171;
never used
width
defined in line
45; used 2 times
xlss
defined in line
240;
never used
Defined variables