|
|
1.1 root 1: head 1.1;
2: access ;
3: symbols ;
4: locks ;
5: comment @ * @;
6:
7:
8: 1.1
9: date 91.02.04.16.45.55; author bin; state Exp;
10: branches ;
11: next ;
12:
13:
14: desc
15: @init ver prov by stevesf
16: @
17:
18:
19:
20: 1.1
21: log
22: @Initial revision
23: @
24: text
25: @/* (-lgl
26: * The information contained herein is a trade secret of Mark Williams
27: * Company, and is confidential information. It is provided under a
28: * license agreement, and may be copied or disclosed only under the
29: * terms of that agreement. Any reproduction or disclosure of this
30: * material without the express written authorization of Mark Williams
31: * Company or persuant to the license agreement is unlawful.
32: *
33: * troff-nroff Version 002
34: * Copyright (c) 1984-1986.
35: * An unpublished work by Mark Williams Company, Chicago.
36: * All rights reserved.
37: -lgl) */
38: /*
39: * Nroff/Troff.
40: * TTY driver.
41: */
42: #include <stdio.h>
43: #include <ctype.h>
44: #include "roff.h"
45: #include "code.h"
46: #include "char.h"
47: #include "env.h"
48: #include "font.h"
49:
50: /*
51: * Device parameters.
52: */
53: int ntroff = NROFF; /* Programme is NROFF type */
54: long sinmul = 120; /* Multiplier for inch */
55: long sindiv = 1; /* Divisor for inch */
56: long semmul = 3; /* Multiplier for em space */
57: long semdiv = 5; /* Divisor for em space */
58: long senmul = 3; /* Multiplier for en space */
59: long sendiv = 5; /* Divisor for en space */
60: long snrmul = 0; /* Narrow space (mul) */
61: long snrdiv = 1; /* Narrow space (div) */
62: long swdmul = 1; /* Multiplier for width tables */
63: long swddiv = 20; /* Divisor for width tables */
64: long shrmul = 12; /* Horizontal resolution (mul) */
65: long shrdiv = 1; /* Horizontal resolution (div) */
66: long svrmul = 20; /* Vertical resolution (mul) */
67: long svrdiv = 1; /* Vertical resolution (div) */
68:
69: /*
70: * For mapping user fonts to real fonts.
71: */
72: FTB fontab[] ={
73: { 'R', '\0', TRMED },
74: { 'I', '\0', TRITL },
75: { 'B', '\0', TRBLD },
76: { '\0' }
77: };
78:
79: /*
80: * Table to convert from the internal character set to ASCII.
81: */
82: char intasc[] ={
83: 0, '0', '1', '2', '3', '4', '5', '6', '7', '8',
84: '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
85: 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
86: 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
87: 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
88: 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
89: 'x', 'y', 'z', '!', '"', '#', '$', '%', '&', '(',
90: ')', '*', '+', ',', '-', '.', '/', ':', ';', '<',
91: '=', '>', '?', '@@', '[', '\\', ']', '^', '_', '{',
92: '|', '}', '~', '`', '\'', '\'', '`', '^', '-'
93: };
94:
95: /*
96: * Width table.
97: */
98: unsigned char widtab[] ={
99: 0, 12, 12, 12, 12, 12, 12, 12, 12, 12,
100: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
101: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
102: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
103: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
104: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
105: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
106: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
107: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
108: 12, 12, 12, 12, 12, 12, 12, 12, 12
109: };
110:
111: /*
112: * Set up the non constant parameters that are dependent on a
113: * particular device. Namely pointsize and font.
114: */
115: devparm()
116: {
117: devfont(TRMED);
118: }
119:
120: /*
121: * Given a font, consisting of the font number, set the new font
122: * to the one given.
123: */
124: devfont(font)
125: {
126: fonwidt = widtab;
127: newfont = font;
128: }
129:
130: /*
131: * Change the pointsize to the one specified.
132: */
133: devpsze(n)
134: {
135: psz = newpsz = unit(SMINCH, 6*SDINCH);
136: }
137:
138: /*
139: * Change the vertical spacing.
140: */
141: devvlsp(n)
142: {
143: vls = unit(SMINCH, 6*SDINCH);
144: }
145:
146: /*
147: * Given a pointer to a buffer containing stream directives
148: * and a pointer to the end of the buffer, print the buffer
149: * out.
150: */
151: flushl(buffer, bufend)
152: CODE *buffer;
153: CODE *bufend;
154: {
155: static int hpos, hres, vres, font;
156: register CODE *cp;
157: register int n;
158:
159: for (cp=buffer; cp<bufend; cp++) {
160: switch (cp->c_code) {
161: case DNULL:
162: case DHYPH:
163: continue;
164: case DHMOV:
165: case DPADC:
166: hres += cp->c_iarg;
167: if ((hpos+=cp->c_iarg)<0) {
168: hres -= hpos;
169: hpos = 0;
170: }
171: continue;
172: case DVMOV:
173: vres += cp->c_iarg;
174: continue;
175: case DFONT:
176: font = cp->c_iarg;
177: continue;
178: case DPSZE:
179: continue;
180: case DSPAR:
181: hpos = hres = 0;
182: vres += cp->c_iarg;
183: if (vres >= 0) {
184: n = (vres+10) / 20;
185: vres -= n*20;
186: while (n--)
187: putchar('\n');
188: } else {
189: putchar('\r');
190: n = (-vres+9)/20;
191: vres += n*20;
192: while (n--)
193: printf("\0337");
194: }
195: continue;
196: default:
197: if (vres >= 0) {
198: vres += 5;
199: n = (vres) / 20;
200: while (n--)
201: printf("\033B");
202: if (vres%20/10)
203: printf("\0339");
204: } else {
205: vres -= 5;
206: n = (-vres)/20;
207: while (n--)
208: printf("\0337");
209: if (-vres%20/10)
210: printf("\0338");
211: }
212: vres = 0;
213: if (hres >= 0) {
214: n = (hres+6) / 12;
215: hres -= n*12;
216: while (n--)
217: putchar(' ');
218: } else {
219: n = (-hres+5)/12;
220: hres += n*12;
221: while (n--)
222: putchar('\b');
223: }
224: if (cp->c_code==DHYPC)
225: n = CMINUS;
226: else
227: n = cp->c_code;
228: if (n<=0 || n>=sizeof intasc)
229: panic("Bad directive %d", n);
230: n = intasc[n];
231: if ((font != TRMED)
232: && (isascii(n))
233: && (isupper(n) || islower(n) || isdigit(n)))
234: switch (font) {
235: case TRBLD:
236: printf("%c\b", n);
237: break;
238: case TRITL:
239: printf("_\b");
240: break;
241: default:
242: panic("Bad font %d", font);
243: }
244: putchar(n);
245: hres += cp->c_move-12;
246: hpos += cp->c_move;
247: }
248: }
249: }
250:
251: /*
252: * Reset device before leaving. Unecessary in nroff.
253: *
254: */
255:
256: void
257: resetdev()
258: {
259: return;
260: }
261: @
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.