xref: /original-bsd/usr.bin/window/tth29.c (revision 7ecb520c)
1 #ifndef lint
2 static char sccsid[] = "@(#)tth29.c	3.2 04/24/85";
3 #endif
4 
5 /*
6  * Copyright (c) 1983 Regents of the University of California,
7  * All rights reserved.  Redistribution permitted subject to
8  * the terms of the Berkeley Software License Agreement.
9  */
10 
11 #include "ww.h"
12 #include "tt.h"
13 
14 /*
15 kC|h29|heath-29|z29|zenith-29:\
16 	:am:bc=\ED:bt=\E-:cr=^M:do=^J:nl=^J:bl=^G:\
17 	:al=\EL:le=^H:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:\
18 	:dl=1*\EM:do=\EB:ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:\
19 	:ms:ta=^I:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:\
20 	:kb=^H:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:kn#1:k0=\E~:l0=HOME:\
21 	:k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:k6=\EP:k7=\EQ:k8=\ER:k9=\E01:\
22 	:es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1:us=\Es8:ue=\Es0:
23 */
24 
25 #define NCOL	80
26 #define NROW	24
27 
28 extern char *gen_VS;
29 extern char *gen_VE;
30 
31 extern int h19_msp10c;
32 
33 #define pc(c)	ttputc('c')
34 #define esc()	pc(\033)
35 #define PAD(ms10) { \
36 	register i; \
37 	for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
38 		pc(\0); \
39 }
40 #define ICPAD() PAD((NCOL - tt.tt_col) * 1)	/* 0.1 ms per char */
41 #define ILPAD() PAD((NROW - tt.tt_row) * 10)	/* 1 ms per char */
42 
43 #define h29_setinsert(m) (esc(), (tt.tt_insert = (m)) ? pc(@) : pc(O))
44 
45 h29_setmodes(new)
46 register new;
47 {
48 	register modes = '0';
49 
50 	if (new & WWM_REV)
51 		modes |= 1;
52 	if (new & WWM_BLK)
53 		modes |= 2;
54 	if (new & WWM_UL)
55 		modes |= 8;
56 	esc();
57 	pc(s);
58 	ttputc(modes);
59 	if (new & WWM_GRP) {
60 		if ((tt.tt_modes & WWM_GRP) == 0)
61 			esc(), pc(F);
62 	} else
63 		if (tt.tt_modes & WWM_GRP)
64 			esc(), pc(G);
65 	tt.tt_modes = new;
66 }
67 
68 h29_putc(c)
69 register char c;
70 {
71 	if (tt.tt_nmodes != tt.tt_modes)
72 		h29_setmodes(tt.tt_nmodes);
73 	if (tt.tt_ninsert != tt.tt_insert)
74 		h29_setinsert(tt.tt_ninsert);
75 	ttputc(c);
76 	if (tt.tt_insert)
77 		ICPAD();
78 	if (++tt.tt_col == NCOL)
79 		tt.tt_col = NCOL - 1;
80 }
81 
82 h29_write(p, n)
83 register char *p;
84 register n;
85 {
86 	if (tt.tt_nmodes != tt.tt_modes)
87 		h29_setmodes(tt.tt_nmodes);
88 	if (tt.tt_ninsert != tt.tt_insert)
89 		h29_setinsert(tt.tt_ninsert);
90 	if (tt.tt_insert) {
91 		while (--n >= 0) {
92 			ttputc(*p++);
93 			ICPAD();
94 			tt.tt_col++;
95 		}
96 	} else {
97 		tt.tt_col += n;
98 		while (--n >= 0)
99 			ttputc(*p++);
100 	}
101 	if (tt.tt_col == NCOL)
102 		tt.tt_col = NCOL - 1;
103 }
104 
105 h29_end()
106 {
107 	h29_setmodes(0);
108 	h29_setinsert(0);
109 	if (gen_VE)
110 		ttputs(gen_VE);
111 	esc();
112 	pc(v);
113 }
114 
115 tt_h29()
116 {
117 	if (tt_h19() < 0)
118 		return -1;
119 	tt.tt_putc = h29_putc;
120 	tt.tt_write = h29_write;
121 	tt.tt_end = h29_end;
122 	tt.tt_availmodes = WWM_BLK|WWM_UL|WWM_REV|WWM_GRP;
123 	return 0;
124 }
125