]>
git.saurik.com Git - apple/shell_cmds.git/blob - window/ttzapple.c
1 /* $NetBSD: ttzapple.c,v 1.4 1997/11/21 08:36:42 lukem Exp $ */
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Edward Wang at The University of California, Berkeley.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 #include <sys/cdefs.h>
42 static char sccsid
[] = "@(#)ttzapple.c 8.1 (Berkeley) 6/6/93";
44 __RCSID("$NetBSD: ttzapple.c,v 1.4 1997/11/21 08:36:42 lukem Exp $");
54 zz|zapple|perfect apple:\
55 :am:pt:co#80:li#24:le=^H:nd=^F:up=^K:do=^J:\
56 :ho=\E0:ll=\E1:cm=\E=%+ %+ :ch=\E<%+ :cv=\E>%+ :\
57 :cl=\E4:ce=\E2:cd=\E3:rp=\E@%.%+ :\
59 :dc=\Ec:DC=\EC%+ :ic=\Ei:IC=\EI%+ :\
60 :al=\Ea:AL=\EA%+ :dl=\Ed:DL=\ED%+ :\
61 :sf=\Ef:SF=\EF%+ :sr=\Er:SR=\ER%+ :cs=\E?%+ %+ :\
69 extern short gen_frame
[];
71 /* for error correction */
75 /* for checkpointing */
78 void zz_checkpoint
__P((void));
79 void zz_checksum
__P((char *, int));
80 void zz_clear
__P((void));
81 void zz_clreol
__P((void));
82 void zz_clreos
__P((void));
83 void zz_compress
__P((int));
84 void zz_delchar
__P((int));
85 void zz_delline
__P((int));
86 void zz_end
__P((void));
87 void zz_insline
__P((int));
88 void zz_insspace
__P((int));
89 void zz_move
__P((int, int));
90 void zz_put_token
__P((int, char *, int));
91 void zz_putc
__P((char));
92 void zz_reset
__P((void));
93 int zz_rint
__P((char *, int));
94 void zz_scroll_down
__P((int));
95 void zz_scroll_up
__P((int));
96 void zz_setmodes
__P((int));
97 void zz_setscroll
__P((int, int));
98 void zz_set_token
__P((int, char *, int));
99 void zz_start
__P((void));
100 void zz_write
__P((char *, int));
107 if ((tt
.tt_modes
& WWM_REV
) == 0)
110 if (tt
.tt_modes
& WWM_REV
)
143 if (tt
.tt_nmodes
!= tt
.tt_modes
)
144 zz_setmodes(tt
.tt_nmodes
);
146 if (++tt
.tt_col
== NCOL
)
147 tt
.tt_col
= 0, tt
.tt_row
++;
155 if (tt
.tt_nmodes
!= tt
.tt_modes
)
156 zz_setmodes(tt
.tt_nmodes
);
159 if (tt
.tt_col
== NCOL
)
160 tt
.tt_col
= 0, tt
.tt_row
++;
169 if (tt
.tt_row
== row
) {
171 if ((x
= col
- tt
.tt_col
) == 0)
189 if ((col
& 7) == 0 && x
> 0 && x
<= 16) {
199 if (tt
.tt_col
== col
) {
200 switch (row
- tt
.tt_row
) {
228 if (row
== tt
.tt_row
+ 1) {
230 * Do newline first to match the sequence
231 * for scroll down and return
237 if (row
== NROW
- 1) {
243 /* favor local motion for better compression */
244 if (row
== tt
.tt_row
+ 1) {
248 if (row
== tt
.tt_row
- 1) {
264 ttputc(TOKEN_MAX
+ ' ');
272 zz_setscroll(0, NROW
- 1);
280 zz_setscroll(0, NROW
- 1);
281 tt
.tt_modes
= WWM_REV
;
283 tt
.tt_col
= tt
.tt_row
= -10;
312 tt
.tt_col
= tt
.tt_row
= 0;
344 if (tt
.tt_row
== NROW
- 1)
367 zz_setscroll(top
, bot
)
373 tt
.tt_scroll_top
= top
;
374 tt
.tt_scroll_bot
= bot
;
380 zz_set_token(t
, s
, n
)
385 if (tt
.tt_nmodes
!= tt
.tt_modes
)
386 zz_setmodes(tt
.tt_nmodes
);
389 zz_setmodes(WWM_REV
);
390 (void) sprintf(buf
, "%02x=", t
);
402 zz_put_token(t
, s
, n
)
407 if (tt
.tt_nmodes
!= tt
.tt_modes
)
408 zz_setmodes(tt
.tt_nmodes
);
411 zz_setmodes(WWM_REV
);
412 (void) sprintf(buf
, "%02x>", t
);
429 for (i
= n
, q
= p
; --i
>= 0;) {
430 int c
= (unsigned char) *p
++;
438 case 1: /* start input ecc */
443 case 2: /* ack checkpoint */
448 case 3: /* nack checkpoint */
457 } else if (zz_ecc
== 1) {
465 } else if (zz_lastc
== c
) {
485 zz_sum
= c
<< 1 | (c
>> 11 & 1);
496 tt
.tt_checksum
= zz_checksum
;
502 static char x
[] = { ctrl('['), 'V', 0, 0 };
504 zz_checksum(x
, sizeof x
);
506 ttputc(' ' + (zz_sum
& 0x3f));
507 ttputc(' ' + (zz_sum
>> 6 & 0x3f));
515 tt
.tt_insspace
= zz_insspace
;
516 tt
.tt_delchar
= zz_delchar
;
517 tt
.tt_insline
= zz_insline
;
518 tt
.tt_delline
= zz_delline
;
519 tt
.tt_clreol
= zz_clreol
;
520 tt
.tt_clreos
= zz_clreos
;
521 tt
.tt_scroll_down
= zz_scroll_down
;
522 tt
.tt_scroll_up
= zz_scroll_up
;
523 tt
.tt_setscroll
= zz_setscroll
;
524 tt
.tt_availmodes
= WWM_REV
;
529 tt
.tt_start
= zz_start
;
530 tt
.tt_reset
= zz_reset
;
532 tt
.tt_write
= zz_write
;
533 tt
.tt_putc
= zz_putc
;
534 tt
.tt_move
= zz_move
;
535 tt
.tt_clear
= zz_clear
;
536 tt
.tt_setmodes
= zz_setmodes
;
537 tt
.tt_frame
= gen_frame
;
538 tt
.tt_padc
= TT_PADC_NONE
;
540 tt
.tt_set_token
= zz_set_token
;
541 tt
.tt_put_token
= zz_put_token
;
543 tt
.tt_token_max
= TOKEN_MAX
;
544 tt
.tt_set_token_cost
= 2;
545 tt
.tt_put_token_cost
= 1;
546 tt
.tt_compress
= zz_compress
;
547 tt
.tt_checksum
= zz_checksum
;
548 tt
.tt_checkpoint
= zz_checkpoint
;
549 tt
.tt_reset
= zz_reset
;
550 tt
.tt_rint
= zz_rint
;