1 #ifndef lint
2 static char sccsid[] = "@(#)savrstor.c 1.3 (CWI) 86/11/10";
3 #endif lint
4
5 #include "defs.h"
6 #include "ext.h"
7
8 /*
9 * remembers various things: fill mode, vs, ps in mac 35(SF)
10 */
savefill()11 savefill()
12 {
13 printf(".de %d\n", SF);
14 printf(".ps \\n(.s\n");
15 printf(".vs \\n(.vu\n");
16 printf(".in \\n(.iu\n");
17 printf(".if \\n(.u .fi\n");
18 printf(".if \\n(.j .ad\n");
19 printf(".if \\n(.j=0 .na\n");
20 printf("..\n");
21 printf(".nf\n");
22
23 /* #| and #~ give the offsets for hor. and vert. lines
24 (in hundredths of an n) */
25 switch(device){
26 case HARRIS:
27 printf(".nr #~ 24\n");
28 printf(".nr #| 46\n");
29 printf(".nr Tw 22.5c\n");
30 break;
31 case CAT:
32 case DEVVER:
33 default:
34 printf(".nr #~ 0\n");
35 printf(".nr #| 0\n");
36 printf(".nr Tw 7.65i\n");
37 break;
38 case DEVPSC:
39 printf(".nr #~ 0-5\n");
40 printf(".nr #| 8\n");
41 printf(".nr Tw 7.65i\n");
42 break;
43 }
44
45 /*
46 * This is the offset for the T450 boxes see drawvert()
47 */
48 printf(".if \\n(.T .if n .nr #~ 60\n");
49 }
50
51 /*
52 * Call the macro SF (35) to restore collected data
53 */
rstofill()54 rstofill()
55 {
56 printf(".%d\n", SF);
57 }
58
59 /*
60 * Clean up at end of file?
61 */
endoff()62 endoff()
63 {
64 register int i;
65 /*
66 * make some registers to be 0 ...
67 */
68 for(i = 0; i < MAXHEAD; i++)
69 if(linestop[i])
70 printf(".nr #%c 0\n", 'a' + i);
71 /*
72 * and remove used macros, strings (and diversions?)
73 */
74 for(i = 0; i < texct; i++)
75 printf(".rm %c+\n", texstr[i]);
76 printf("%s\n", last);
77 }
78
79 /*
80 * Let's check wether we are in a diversion
81 */
ifdivert()82 ifdivert()
83 {
84 /*
85 * #d hold current vertical place if in a diversion
86 */
87 printf(".ds #d .d\n");
88 /*
89 * if diversion doesn't exist, rememenber current vertical
90 * place (nl) in #d
91 */
92 printf(".if \\(ts\\n(.z\\(ts\\(ts .ds #d nl\n");
93 }
94
95 /*
96 * save current input line number (of troff), since we are going to add a lot of
97 * lines
98 *
99 * Note that register b. is never set to be auto incremeted, so this
100 * garanteed to fail!!! (jna)
101 *
102 * (should be replaced with a request for new troff)
103 */
saveline()104 saveline()
105 {
106 printf(".if \\n+(b.=1 .nr d. \\n(.c-\\n(c.-1\n");
107 linstart = iline;
108 }
109
110 /*
111 * rstore line count of troff
112 */
restline()113 restline()
114 {
115 printf(".if \\n-(b.=0 .nr c. \\n(.c-\\n(d.-%d\n", iline - linstart);
116 linstart = 0;
117 /*
118 * support for .lf request of troff (jna)
119 */
120 printf(".lf %d\n", iline);
121 }
122
123 /*
124 * Turn the field mechanism off
125 */
cleanfc()126 cleanfc()
127 {
128 printf(".fc\n");
129 }
130