]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/window/tth19.c
This commit was generated by cvs2svn to compensate for changes in r68349,
[FreeBSD/FreeBSD.git] / usr.bin / window / tth19.c
1 /*
2  * Copyright (c) 1983, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Edward Wang at The University of California, Berkeley.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by the University of
19  *      California, Berkeley and its contributors.
20  * 4. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  */
36
37 #ifndef lint
38 static char sccsid[] = "@(#)tth19.c     8.1 (Berkeley) 6/6/93";
39 static char rcsid[] = "@(#)$FreeBSD$";
40 #endif /* not lint */
41
42 #include "ww.h"
43 #include "tt.h"
44 #include "char.h"
45
46 /*
47 kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith:
48         cr=^M:nl=^J:bl=^G:al=1*\EL:am:le=^H:bs:cd=\EJ:ce=\EK:
49         cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:dl=1*\EM:do=\EB:
50         ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:ms:
51         ta=^I:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:
52         kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:
53         kn#8:k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:
54         l6=blue:l7=red:l8=white:k6=\EP:k7=\EQ:k8=\ER:
55         es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1:
56 */
57
58 #define NCOL    80
59 #define NROW    24
60
61 #define G (WWM_GRP << WWC_MSHIFT)
62 short h19_frame[16] = {
63         ' ',    '`'|G,  'a'|G,  'e'|G,
64         '`'|G,  '`'|G,  'f'|G,  'v'|G,
65         'a'|G,  'd'|G,  'a'|G,  'u'|G,
66         'c'|G,  't'|G,  's'|G,  'b'|G
67 };
68
69 extern struct tt_str *gen_VS;
70 extern struct tt_str *gen_VE;
71
72 int h19_msp10c;
73
74 #define PAD(ms10) { \
75         register i; \
76         for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
77                 ttputc('\0'); \
78 }
79 #define ICPAD() PAD((NCOL - tt.tt_col) * 1)     /* 0.1 ms per char */
80 #define ILPAD() PAD((NROW - tt.tt_row) * 10)    /* 1 ms per char */
81
82 #define H19_SETINSERT(m) ttesc((tt.tt_insert = (m)) ? '@' : 'O')
83
84 h19_setmodes(new)
85 register new;
86 {
87         register diff;
88
89         diff = new ^ tt.tt_modes;
90         if (diff & WWM_REV)
91                 ttesc(new & WWM_REV ? 'p' : 'q');
92         if (diff & WWM_GRP)
93                 ttesc(new & WWM_REV ? 'F' : 'G');
94         tt.tt_modes = new;
95 }
96
97 h19_insline(n)
98 {
99         while (--n >= 0) {
100                 ttesc('L');
101                 ILPAD();
102         }
103 }
104
105 h19_delline(n)
106 {
107         while (--n >= 0) {
108                 ttesc('M');
109                 ILPAD();
110         }
111 }
112
113 h19_putc(c)
114 register char c;
115 {
116         if (tt.tt_nmodes != tt.tt_modes)
117                 (*tt.tt_setmodes)(tt.tt_nmodes);
118         if (tt.tt_insert)
119                 H19_SETINSERT(0);
120         ttputc(c);
121         if (++tt.tt_col == NCOL)
122                 tt.tt_col = NCOL - 1;
123 }
124
125 h19_write(p, n)
126 register char *p;
127 register n;
128 {
129         if (tt.tt_nmodes != tt.tt_modes)
130                 (*tt.tt_setmodes)(tt.tt_nmodes);
131         if (tt.tt_insert)
132                 H19_SETINSERT(0);
133         ttwrite(p, n);
134         tt.tt_col += n;
135         if (tt.tt_col == NCOL)
136                 tt.tt_col = NCOL - 1;
137 }
138
139 h19_move(row, col)
140 register char row, col;
141 {
142         if (tt.tt_row == row) {
143                 if (tt.tt_col == col)
144                         return;
145                 if (col == 0) {
146                         ttctrl('m');
147                         goto out;
148                 }
149                 if (tt.tt_col == col - 1) {
150                         ttesc('C');
151                         goto out;
152                 }
153                 if (tt.tt_col == col + 1) {
154                         ttctrl('h');
155                         goto out;
156                 }
157         }
158         if (tt.tt_col == col) {
159                 if (tt.tt_row == row + 1) {
160                         ttesc('A');
161                         goto out;
162                 }
163                 if (tt.tt_row == row - 1) {
164                         ttctrl('j');
165                         goto out;
166                 }
167         }
168         if (col == 0 && row == 0) {
169                 ttesc('H');
170                 goto out;
171         }
172         ttesc('Y');
173         ttputc(' ' + row);
174         ttputc(' ' + col);
175 out:
176         tt.tt_col = col;
177         tt.tt_row = row;
178 }
179
180 h19_start()
181 {
182         if (gen_VS)
183                 ttxputs(gen_VS);
184         ttesc('w');
185         ttesc('E');
186         tt.tt_col = tt.tt_row = 0;
187         tt.tt_insert = 0;
188         tt.tt_nmodes = tt.tt_modes = 0;
189 }
190
191 h19_end()
192 {
193         if (tt.tt_insert)
194                 H19_SETINSERT(0);
195         if (gen_VE)
196                 ttxputs(gen_VE);
197         ttesc('v');
198 }
199
200 h19_clreol()
201 {
202         ttesc('K');
203 }
204
205 h19_clreos()
206 {
207         ttesc('J');
208 }
209
210 h19_clear()
211 {
212         ttesc('E');
213 }
214
215 h19_inschar(c)
216 register char c;
217 {
218         if (tt.tt_nmodes != tt.tt_modes)
219                 (*tt.tt_setmodes)(tt.tt_nmodes);
220         if (!tt.tt_insert)
221                 H19_SETINSERT(1);
222         ttputc(c);
223         if (tt.tt_insert)
224                 ICPAD();
225         if (++tt.tt_col == NCOL)
226                 tt.tt_col = NCOL - 1;
227 }
228
229 h19_delchar(n)
230 {
231         while (--n >= 0)
232                 ttesc('N');
233 }
234
235 h19_scroll_down(n)
236 {
237         h19_move(NROW - 1, 0);
238         while (--n >= 0)
239                 ttctrl('j');
240 }
241
242 h19_scroll_up(n)
243 {
244         h19_move(0, 0);
245         while (--n >= 0)
246                 ttesc('I');
247 }
248
249 tt_h19()
250 {
251         float cpms = (float) wwbaud / 10000;    /* char per ms */
252
253         h19_msp10c = 10 / cpms;                 /* ms per 10 char */
254         gen_VS = ttxgetstr("vs");
255         gen_VE = ttxgetstr("ve");
256
257         tt.tt_start = h19_start;
258         tt.tt_end = h19_end;
259
260         tt.tt_insline = h19_insline;
261         tt.tt_delline = h19_delline;
262         tt.tt_inschar = h19_inschar;
263         tt.tt_delchar = h19_delchar;
264         tt.tt_clreol = h19_clreol;
265         tt.tt_clreos = h19_clreos;
266         tt.tt_clear = h19_clear;
267         tt.tt_move = h19_move;
268         tt.tt_write = h19_write;
269         tt.tt_putc = h19_putc;
270         tt.tt_scroll_down = h19_scroll_down;
271         tt.tt_scroll_up = h19_scroll_up;
272         tt.tt_setmodes = h19_setmodes;
273
274         tt.tt_ncol = NCOL;
275         tt.tt_nrow = NROW;
276         tt.tt_availmodes = WWM_REV|WWM_GRP;
277         tt.tt_frame = h19_frame;
278         return 0;
279 }