rip out SHELL_ESCAPE define
[unix-history] / usr / src / usr.bin / window / tth19.c
CommitLineData
60de5df9 1/*
46e9ea25
KB
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
5e8b0e60
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
60de5df9
EW
16 */
17
46e9ea25 18#ifndef lint
5e8b0e60 19static char sccsid[] = "@(#)tth19.c 3.19 (Berkeley) %G%";
46e9ea25
KB
20#endif /* not lint */
21
6869a338 22#include "ww.h"
e908bfac 23#include "tt.h"
6869a338
EW
24
25/*
26kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith:
27 cr=^M:nl=^J:bl=^G:al=1*\EL:am:le=^H:bs:cd=\EJ:ce=\EK:
28 cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:dl=1*\EM:do=\EB:
29 ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:ms:
30 ta=^I:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:
31 kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:
32 kn#8:k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:
33 l6=blue:l7=red:l8=white:k6=\EP:k7=\EQ:k8=\ER:
34 es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1:
35*/
36
3130283e
EW
37#define NCOL 80
38#define NROW 24
39
a830e8bb
EW
40#define G (WWM_GRP << WWC_MSHIFT)
41short h19_frame[16] = {
42 ' ', '`'|G, 'a'|G, 'e'|G,
43 '`'|G, '`'|G, 'f'|G, 'v'|G,
44 'a'|G, 'd'|G, 'a'|G, 'u'|G,
45 'c'|G, 't'|G, 's'|G, 'b'|G
6869a338
EW
46};
47
e1daf7d6
EW
48extern struct tt_str *gen_VS;
49extern struct tt_str *gen_VE;
3130283e 50
a830e8bb 51int h19_msp10c;
6869a338 52
b1189050 53#define pc(c) ttputc('c')
6869a338
EW
54#define esc() pc(\033)
55#define PAD(ms10) { \
56 register i; \
57 for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
58 pc(\0); \
59}
3130283e
EW
60#define ICPAD() PAD((NCOL - tt.tt_col) * 1) /* 0.1 ms per char */
61#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */
6869a338 62
c1a57462
EW
63#define H19_SETINSERT(m) (esc(), (tt.tt_insert = (m)) ? pc(@) : pc(O))
64
65h19_setinsert(new)
66{
67 H19_SETINSERT(new);
68}
a830e8bb
EW
69
70h19_setmodes(new)
71register new;
72{
73 register diff;
74
75 diff = new ^ tt.tt_modes;
76 if (diff & WWM_REV) {
77 esc();
78 if (new & WWM_REV)
79 pc(p);
80 else
81 pc(q);
82 }
83 if (diff & WWM_GRP) {
84 esc();
85 if (new & WWM_GRP)
86 pc(F);
87 else
88 pc(G);
89 }
90 tt.tt_modes = new;
91}
6869a338 92
6869a338
EW
93h19_insline()
94{
95 esc();
96 pc(L);
97 ILPAD();
98}
99
100h19_delline()
101{
102 esc();
103 pc(M);
104 ILPAD();
105}
106
107h19_putc(c)
108register char c;
109{
a830e8bb 110 if (tt.tt_nmodes != tt.tt_modes)
c1a57462 111 (*tt.tt_setmodes)(tt.tt_nmodes);
a830e8bb 112 if (tt.tt_ninsert != tt.tt_insert)
c1a57462 113 H19_SETINSERT(tt.tt_ninsert);
b1189050 114 ttputc(c);
3130283e 115 if (tt.tt_insert)
6869a338 116 ICPAD();
3130283e
EW
117 if (++tt.tt_col == NCOL)
118 tt.tt_col = NCOL - 1;
6869a338
EW
119}
120
3130283e
EW
121h19_write(p, n)
122register char *p;
123register n;
6869a338 124{
a830e8bb 125 if (tt.tt_nmodes != tt.tt_modes)
c1a57462 126 (*tt.tt_setmodes)(tt.tt_nmodes);
a830e8bb 127 if (tt.tt_ninsert != tt.tt_insert)
c1a57462 128 H19_SETINSERT(tt.tt_ninsert);
3130283e
EW
129 if (tt.tt_insert) {
130 while (--n >= 0) {
b1189050 131 ttputc(*p++);
6869a338 132 ICPAD();
3130283e 133 tt.tt_col++;
6869a338
EW
134 }
135 } else {
3130283e 136 tt.tt_col += n;
e1daf7d6 137 ttwrite(p, n);
6869a338 138 }
3130283e
EW
139 if (tt.tt_col == NCOL)
140 tt.tt_col = NCOL - 1;
6869a338
EW
141}
142
143h19_move(row, col)
144register char row, col;
145{
3130283e
EW
146 if (tt.tt_row == row) {
147 if (tt.tt_col == col)
6869a338 148 return;
16ea9636
EW
149 if (col == 0) {
150 pc(\r);
151 goto out;
152 }
3130283e 153 if (tt.tt_col == col - 1) {
6869a338
EW
154 esc();
155 pc(C);
156 goto out;
16ea9636
EW
157 }
158 if (tt.tt_col == col + 1) {
6869a338
EW
159 pc(\b);
160 goto out;
161 }
162 }
3130283e
EW
163 if (tt.tt_col == col) {
164 if (tt.tt_row == row + 1) {
6869a338
EW
165 esc();
166 pc(A);
167 goto out;
16ea9636
EW
168 }
169 if (tt.tt_row == row - 1) {
6869a338
EW
170 pc(\n);
171 goto out;
172 }
173 }
7aefc9fe 174 if (col == 0 && row == 0) {
6869a338
EW
175 esc();
176 pc(H);
177 goto out;
178 }
179 esc();
180 pc(Y);
b1189050
EW
181 ttputc(' ' + row);
182 ttputc(' ' + col);
6869a338 183out:
3130283e
EW
184 tt.tt_col = col;
185 tt.tt_row = row;
6869a338
EW
186}
187
188h19_init()
6869a338 189{
3130283e 190 if (gen_VS)
e1daf7d6 191 ttxputs(gen_VS);
6869a338 192 esc();
c3f80cb5 193 pc(w);
6869a338
EW
194 esc();
195 pc(E);
3130283e
EW
196 tt.tt_col = tt.tt_row = 0;
197 tt.tt_ninsert = tt.tt_insert = 0;
198 tt.tt_nmodes = tt.tt_modes = 0;
6869a338
EW
199}
200
e908bfac 201h19_end()
6869a338 202{
3130283e 203 if (gen_VE)
e1daf7d6 204 ttxputs(gen_VE);
6869a338
EW
205 esc();
206 pc(v);
207}
208
209h19_clreol()
210{
211 esc();
212 pc(K);
213}
214
215h19_clreos()
216{
217 esc();
218 pc(J);
219}
220
221h19_clear()
222{
223 esc();
224 pc(E);
225}
226
227h19_delchar()
228{
229 esc();
230 pc(N);
231}
232
16ea9636
EW
233h19_scroll_down()
234{
235 h19_move(NROW - 1, 0);
236 pc(\n);
237}
238
239h19_scroll_up()
240{
241 h19_move(0, 0);
242 esc();
243 pc(I);
244}
245
6869a338
EW
246tt_h19()
247{
e908bfac
EW
248 float cpms = (float) wwbaud / 10000; /* char per ms */
249
250 h19_msp10c = 10 / cpms; /* ms per 10 char */
b1189050
EW
251 gen_VS = ttxgetstr("vs");
252 gen_VE = ttxgetstr("ve");
3130283e
EW
253
254 tt.tt_init = h19_init;
255 tt.tt_end = h19_end;
256
6869a338
EW
257 tt.tt_insline = h19_insline;
258 tt.tt_delline = h19_delline;
259 tt.tt_delchar = h19_delchar;
6869a338
EW
260 tt.tt_clreol = h19_clreol;
261 tt.tt_clreos = h19_clreos;
262 tt.tt_clear = h19_clear;
263 tt.tt_move = h19_move;
6869a338
EW
264 tt.tt_write = h19_write;
265 tt.tt_putc = h19_putc;
16ea9636
EW
266 tt.tt_scroll_down = h19_scroll_down;
267 tt.tt_scroll_up = h19_scroll_up;
c1a57462
EW
268 tt.tt_setinsert = h19_setinsert;
269 tt.tt_setmodes = h19_setmodes;
3130283e
EW
270
271 tt.tt_ncol = NCOL;
272 tt.tt_nrow = NROW;
273 tt.tt_hasinsert = 1;
a830e8bb 274 tt.tt_availmodes = WWM_REV|WWM_GRP;
6869a338
EW
275 tt.tt_frame = h19_frame;
276 return 0;
277}