* Copyright (c) 1989 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)ttzapple.c 3.2 (Berkeley) %G%";
zz|zapple|unorthodox apple:\
:am:pt:co#80:li#24:le=^H:nd=^F:up=^K:do=^J:\
:ho=^[0:ll=^[1:cm=^]%+ %+ =:ch=^\%+ <:cv=^\%+ >:\
:cl=^[4:ce=^[2:cd=^[3:rp=^]%.%+ @:\
:dc=^[c:DC=^\%+ C:ic=^[i:IC=^\%+ I:\
:al=^[a:AL=^\%+ A:dl=^[d:DL=^\%+ D:\
:sf=^[f:SF=^\%+ F:sr=^[r:SR=^\%+ R:cs=^]%+ %+ ?:
#define esc() pc(ctrl('['))
#define esc1() pc(ctrl('\\'))
#define esc2() pc(ctrl(']'))
extern short gen_frame
[];
* stuff for token compression
#define NCTOKEN (NTOKEN * 4)
static struct ctoken q1
, q2
;
static struct ctoken
*htab
[HSIZE
];
static struct ctoken
*line
[NCOL
];
static struct ctoken tokens
[NTOKEN
* 4];
static unsigned long tick
;
#define zc_eval(t) ((int) ((t)->count * 400 + (t)->time - tick))
#define zc_hash(h, c) ((((h) << 1 | (h) >> H - 1) ^ (c)) & HSIZE - 1)
#define zc_unhash(h, c) (((h) ^ (c) << N - 1 ^ (c) >> H - N + 1) & (HSIZE - 1))
#define zc_copy(f, t) bcopy(f, t, N)
#define zc_equal(f, t) (bcmp(f, t, N) == 0)
#define zc_copy(f, t) ((t)[0] = (f)[0], (t)[1] = (f)[1], \
(t)[2] = (f)[2], (t)[3] = (f)[3])
#define zc_equal(f, t) ((t)[0] == (f)[0] && (t)[1] == (f)[1] && \
(t)[2] == (f)[2] && (t)[3] == (f)[3])
if ((tt
.tt_modes
& WWM_REV
) == 0) {
if (tt
.tt_modes
& WWM_REV
) {
if (tt
.tt_nmodes
!= tt
.tt_modes
)
zz_setmodes(tt
.tt_nmodes
);
tt
.tt_col
= 0, tt
.tt_row
++;
if (tt
.tt_nmodes
!= tt
.tt_modes
)
zz_setmodes(tt
.tt_nmodes
);
tt
.tt_col
= 0, tt
.tt_row
++;
if (tt
.tt_col
== col
- 1) {
if (tt
.tt_col
== col
+ 1) {
if (tt
.tt_row
== row
+ 1) {
if (tt
.tt_row
== row
- 1) {
zz_setscroll(0, NROW
- 1);
tt
.tt_col
= tt
.tt_row
= 0;
} else if (tt
.tt_row
== tt
.tt_scroll_bot
)
register struct ctoken
*tp
;
for (i
= N
- 2, h
= zc_hash(0, *p
++); --i
>= 0; h
= zc_hash(h
, *p
++))
if ((tp
= htab
[h
]) == 0) {
zc_copy(p
- N
, tp
->string
);
} else if (!zc_equal(tp
->string
, p
- N
)) {
if (tp
->index
== 0 && zc_eval(tp
) < 0) {
zc_copy(p
- N
, tp
->string
);
h
= zc_unhash(h
, p
[- N
]);
register struct ctoken
*tp
;
if ((tp
= line
[i
]) == 0) {
} else if (tp
->index
> 0) {
pc(tp
->index
- 1 | 0x80);
} else if (tp
->index
< 0) {
} else if (tp
->count
> 1 && zc_eval(tp
) > zc_eval(q1
.back
)) {
tp
->index
= abs(q1
.back
->index
);
register struct ctoken
*tp
, *q
;
tp
->back
->forw
= tp
->forw
;
tp
->forw
->back
= tp
->back
;
register struct ctoken
*tp
;
for (tp
= tokens
; tp
< tokens
+ sizeof tokens
/ sizeof *tokens
; tp
++)
register struct ctoken
*tp
;
bzero((char *)htab
, sizeof htab
);
for (i
= 0, tp
= tokens
; i
< NTOKEN
; i
++, tp
++) {
for (; i
< sizeof tokens
/ sizeof *tokens
; i
++, tp
++) {
tt
.tt_inschar
= zz_inschar
;
tt
.tt_delchar
= zz_delchar
;
tt
.tt_insline
= zz_insline
;
tt
.tt_delline
= zz_delline
;
tt
.tt_clreol
= zz_clreol
;
tt
.tt_clreos
= zz_clreos
;
tt
.tt_scroll_down
= zz_scroll_down
;
tt
.tt_scroll_up
= zz_scroll_up
;
tt
.tt_setscroll
= zz_setscroll
;
tt
.tt_availmodes
= WWM_REV
;
tt
.tt_setmodes
= zz_setmodes
;