From 2d152f42eb9bb7cd21eebc07f48875d958f638d0 Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Fri, 12 May 1989 00:02:13 -0800 Subject: [PATCH] the xx layer added, handle "ic" differently, compression added to zapple SCCS-vsn: usr.bin/window/wwinschar.c 3.17 SCCS-vsn: usr.bin/window/wwscroll.c 3.22 SCCS-vsn: usr.bin/window/lcmd2.c 3.17 SCCS-vsn: usr.bin/window/wwdelchar.c 3.14 SCCS-vsn: usr.bin/window/tth29.c 3.7 SCCS-vsn: usr.bin/window/ttgeneric.c 3.38 SCCS-vsn: usr.bin/window/tth19.c 3.20 SCCS-vsn: usr.bin/window/tttermcap.c 3.10 SCCS-vsn: usr.bin/window/wwtty.c 3.13 SCCS-vsn: usr.bin/window/wwredraw.c 3.10 SCCS-vsn: usr.bin/window/tt.h 3.21 SCCS-vsn: usr.bin/window/wwend.c 3.12 SCCS-vsn: usr.bin/window/ww.h 3.53 SCCS-vsn: usr.bin/window/wwupdate.c 3.24 SCCS-vsn: usr.bin/window/wwinit.c 3.33 SCCS-vsn: usr.bin/window/Makefile 5.4 SCCS-vsn: usr.bin/window/ttzapple.c 3.2 --- usr/src/usr.bin/window/Makefile | 6 +- usr/src/usr.bin/window/lcmd2.c | 10 +- usr/src/usr.bin/window/tt.h | 4 +- usr/src/usr.bin/window/ttgeneric.c | 71 +++++-- usr/src/usr.bin/window/tth19.c | 94 +++++---- usr/src/usr.bin/window/tth29.c | 14 +- usr/src/usr.bin/window/tttermcap.c | 9 +- usr/src/usr.bin/window/ttzapple.c | 316 +++++++++++++++++++++-------- usr/src/usr.bin/window/ww.h | 3 +- usr/src/usr.bin/window/wwdelchar.c | 6 +- usr/src/usr.bin/window/wwend.c | 4 +- usr/src/usr.bin/window/wwinit.c | 6 +- usr/src/usr.bin/window/wwinschar.c | 13 +- usr/src/usr.bin/window/wwredraw.c | 3 +- usr/src/usr.bin/window/wwscroll.c | 63 +----- usr/src/usr.bin/window/wwtty.c | 4 +- usr/src/usr.bin/window/wwupdate.c | 22 +- 17 files changed, 413 insertions(+), 235 deletions(-) diff --git a/usr/src/usr.bin/window/Makefile b/usr/src/usr.bin/window/Makefile index b7cdccc0e6..66e327c7f5 100644 --- a/usr/src/usr.bin/window/Makefile +++ b/usr/src/usr.bin/window/Makefile @@ -14,7 +14,7 @@ # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # -# @(#)Makefile 5.3 (Berkeley) %G% +# @(#)Makefile 5.4 (Berkeley) %G% # CFLAGS= -O -R LIBC= /lib/libc.a @@ -30,7 +30,7 @@ SRCS= char.c cmd.c cmd1.c cmd2.c cmd3.c cmd4.c cmd5.c cmd6.c cmd7.c \ wwiomux.c wwlabel.c wwmisc.c wwmove.c wwopen.c wwprintf.c wwpty.c \ wwputc.c wwputs.c wwredraw.c wwredrawwin.c wwrint.c wwscroll.c \ wwsize.c wwspawn.c wwsuspend.c wwtty.c wwunframe.c wwupdate.c \ - wwwrite.c + wwwrite.c xx.c OBJS= char.o cmd.o cmd1.o cmd2.o cmd3.o cmd4.o cmd5.o cmd6.o cmd7.o \ context.o error.o lcmd.o lcmd1.o lcmd2.o main.o mloop.o parser1.o \ parser2.o parser3.o parser4.o parser5.o scanner.o startup.o string.o \ @@ -43,7 +43,7 @@ OBJS= char.o cmd.o cmd1.o cmd2.o cmd3.o cmd4.o cmd5.o cmd6.o cmd7.o \ wwiomux.o wwlabel.o wwmisc.o wwmove.o wwopen.o wwprintf.o wwpty.o \ wwputc.o wwputs.o wwredraw.o wwredrawwin.o wwrint.o wwscroll.o \ wwsize.o wwspawn.o wwsuspend.o wwtty.o wwunframe.o wwupdate.o \ - wwwrite.o + wwwrite.o xx.o MAN= window.0 all: window diff --git a/usr/src/usr.bin/window/lcmd2.c b/usr/src/usr.bin/window/lcmd2.c index d734c2c6b1..9f1df38593 100644 --- a/usr/src/usr.bin/window/lcmd2.c +++ b/usr/src/usr.bin/window/lcmd2.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)lcmd2.c 3.16 (Berkeley) %G%"; +static char sccsid[] = "@(#)lcmd2.c 3.17 (Berkeley) %G%"; #endif /* not lint */ #include "defs.h" @@ -33,13 +33,19 @@ struct value *v, *a; { register struct ww *w; - if ((w = openiwin(14, "IO Statistics")) == 0) { + if ((w = openiwin(16, "IO Statistics")) == 0) { error("Can't open statistics window: %s.", wwerror()); return; } wwprintf(w, "ttflush\twrite\terror\tzero\tchar\n"); wwprintf(w, "%d\t%d\t%d\t%d\t%d\n", wwnflush, wwnwr, wwnwre, wwnwrz, wwnwrc); + wwprintf(w, "token\tuse\tsaving\ttotal\tbaud\n"); + wwprintf(w, "%d\t%d\t%d\t%d\t%d/%d\n", + wwzc0, wwzc1, wwzcsave, wwzctotal, + wwzctotal - wwzcsave ? + wwbaud * wwzctotal / (wwzctotal - wwzcsave) : wwbaud, + wwnwrc ? wwbaud * (wwnwrc + wwzcsave) / wwnwrc : wwbaud); wwprintf(w, "wwwrite\tattempt\tchar\n"); wwprintf(w, "%d\t%d\t%d\n", wwnwwr, wwnwwra, wwnwwrc); diff --git a/usr/src/usr.bin/window/tt.h b/usr/src/usr.bin/window/tt.h index db4a349318..0cae050996 100644 --- a/usr/src/usr.bin/window/tt.h +++ b/usr/src/usr.bin/window/tt.h @@ -14,7 +14,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#)tt.h 3.20 (Berkeley) %G% + * @(#)tt.h 3.21 (Berkeley) %G% */ /* @@ -29,6 +29,7 @@ struct tt { int (*tt_move)(); int (*tt_insline)(); int (*tt_delline)(); + int (*tt_inschar)(); int (*tt_delchar)(); int (*tt_write)(); /* write a whole block */ int (*tt_putc)(); /* write one character */ @@ -54,7 +55,6 @@ struct tt { /* terminal info */ int tt_nrow; /* number of display rows */ int tt_ncol; /* number of display columns */ - char tt_hasinsert; /* has insert character */ char tt_availmodes; /* the display modes supported */ char tt_wrap; /* has auto wrap around */ char tt_retain; /* can retain below (db flag) */ diff --git a/usr/src/usr.bin/window/ttgeneric.c b/usr/src/usr.bin/window/ttgeneric.c index b64b54c6a7..390f06d380 100644 --- a/usr/src/usr.bin/window/ttgeneric.c +++ b/usr/src/usr.bin/window/ttgeneric.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)ttgeneric.c 3.37 (Berkeley) %G%"; +static char sccsid[] = "@(#)ttgeneric.c 3.38 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -49,11 +49,15 @@ struct tt_str *gen_PC; struct tt_str *gen_CM; struct tt_str *gen_IM; struct tt_str *gen_IC; +struct tt_str *gen_ICn; struct tt_str *gen_IP; struct tt_str *gen_EI; struct tt_str *gen_DC; +struct tt_str *gen_DCn; struct tt_str *gen_AL; +struct tt_str *gen_ALn; struct tt_str *gen_DL; +struct tt_str *gen_DLn; struct tt_str *gen_CE; struct tt_str *gen_CD; struct tt_str *gen_CL; @@ -78,7 +82,9 @@ struct tt_str *gen_AE; struct tt_str *gen_XS; struct tt_str *gen_XE; struct tt_str *gen_SF; +struct tt_str *gen_SFn; struct tt_str *gen_SR; +struct tt_str *gen_SRn; struct tt_str *gen_CS; char gen_MI; char gen_MS; @@ -147,20 +153,26 @@ register new; tt.tt_modes = new; } -gen_insline() +gen_insline(n) { if (tt.tt_modes) /* for concept 100 */ gen_setmodes(0); - if (gen_AL) - tttputs(gen_AL, gen_LI - tt.tt_row); + if (gen_ALn) + ttpgoto(gen_ALn, 0, n, gen_LI - tt.tt_row); + else + while (--n >= 0) + tttputs(gen_AL, gen_LI - tt.tt_row); } -gen_delline() +gen_delline(n) { if (tt.tt_modes) /* for concept 100 */ gen_setmodes(0); - if (gen_DL) - tttputs(gen_DL, gen_LI - tt.tt_row); + if (gen_DLn) + ttpgoto(gen_DLn, 0, n, gen_LI - tt.tt_row); + else + while (--n >= 0) + tttputs(gen_DL, gen_LI - tt.tt_row); } gen_putc(c) @@ -307,21 +319,42 @@ gen_clear() ttxputs(gen_CL); } -gen_delchar() +gen_inschar(n) +{ + if (gen_ICn) + ttpgoto(gen_ICn, 0, n, gen_CO - tt.tt_col); + else + while (--n >= 0) + tttputs(gen_IC, gen_CO - tt.tt_col); +} + +gen_delchar(n) { - tttputs(gen_DC, gen_CO - tt.tt_col); + if (gen_DCn) + ttpgoto(gen_DCn, 0, n, gen_CO - tt.tt_col); + else + while (--n >= 0) + tttputs(gen_DC, gen_CO - tt.tt_col); } -gen_scroll_down() +gen_scroll_down(n) { gen_move(tt.tt_scroll_bot, 0); - ttxputs(gen_SF); + if (gen_SFn) + ttpgoto(gen_SFn, 0, n, n); + else + while (--n >= 0) + ttxputs(gen_SF); } -gen_scroll_up() +gen_scroll_up(n) { gen_move(tt.tt_scroll_top, 0); - ttxputs(gen_SR); + if (gen_SRn) + ttpgoto(gen_SRn, 0, n, n); + else + while (--n >= 0) + ttxputs(gen_SR); } gen_setscroll(top, bot) @@ -341,11 +374,15 @@ tt_generic() gen_CM = ttxgetstr("cm"); /* may not work */ gen_IM = ttxgetstr("im"); gen_IC = tttgetstr("ic"); + gen_ICn = tttgetstr("IC"); gen_IP = tttgetstr("ip"); gen_EI = ttxgetstr("ei"); gen_DC = tttgetstr("dc"); + gen_DCn = tttgetstr("DC"); gen_AL = tttgetstr("al"); + gen_ALn = tttgetstr("AL"); gen_DL = tttgetstr("dl"); + gen_DLn = tttgetstr("DL"); gen_CE = tttgetstr("ce"); gen_CD = tttgetstr("cd"); gen_CL = ttxgetstr("cl"); @@ -370,7 +407,9 @@ tt_generic() gen_XS = ttxgetstr("XS"); gen_XE = ttxgetstr("XE"); gen_SF = ttxgetstr("sf"); + gen_SFn = ttxgetstr("SF"); gen_SR = ttxgetstr("sr"); + gen_SRn = ttxgetstr("SR"); gen_CS = ttxgetstr("cs"); gen_MI = tgetflag("mi"); gen_MS = tgetflag("ms"); @@ -425,6 +464,10 @@ tt_generic() if (gen_UG > 0 || gen_US && gen_SO && ttstrcmp(gen_US, gen_SO) == 0) gen_US = 0; + if (gen_IM) + tt.tt_setinsert = gen_setinsert; + else if (gen_IC) + tt.tt_inschar = gen_inschar; if (gen_DC) tt.tt_delchar = gen_delchar; if (gen_AL) @@ -453,7 +496,6 @@ tt_generic() tt.tt_availmodes |= WWM_GRP; if (gen_XS) tt.tt_availmodes |= WWM_USR; - tt.tt_hasinsert = gen_IM || gen_IC; tt.tt_wrap = gen_AM; tt.tt_retain = gen_DB; tt.tt_ncol = gen_CO; @@ -464,7 +506,6 @@ tt_generic() tt.tt_putc = gen_putc; tt.tt_move = gen_move; tt.tt_clear = gen_clear; - tt.tt_setinsert = gen_setinsert; tt.tt_setmodes = gen_setmodes; tt.tt_frame = gen_AS && ttstrcmp(gen_AS, &ansi_AS) == 0 ? ansi_frame : gen_frame; diff --git a/usr/src/usr.bin/window/tth19.c b/usr/src/usr.bin/window/tth19.c index ffd87128b8..57bcde6a83 100644 --- a/usr/src/usr.bin/window/tth19.c +++ b/usr/src/usr.bin/window/tth19.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)tth19.c 3.19 (Berkeley) %G%"; +static char sccsid[] = "@(#)tth19.c 3.20 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -50,17 +50,17 @@ extern struct tt_str *gen_VE; int h19_msp10c; -#define pc(c) ttputc('c') -#define esc() pc(\033) +#define pc(c) ttputc(c) +#define esc() pc('\033') #define PAD(ms10) { \ register i; \ for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \ - pc(\0); \ + pc('\0'); \ } #define ICPAD() PAD((NCOL - tt.tt_col) * 1) /* 0.1 ms per char */ #define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */ -#define H19_SETINSERT(m) (esc(), (tt.tt_insert = (m)) ? pc(@) : pc(O)) +#define H19_SETINSERT(m) (esc(), (tt.tt_insert = (m)) ? pc('@') : pc('O')) h19_setinsert(new) { @@ -76,32 +76,36 @@ register new; if (diff & WWM_REV) { esc(); if (new & WWM_REV) - pc(p); + pc('p'); else - pc(q); + pc('q'); } if (diff & WWM_GRP) { esc(); if (new & WWM_GRP) - pc(F); + pc('F'); else - pc(G); + pc('G'); } tt.tt_modes = new; } -h19_insline() +h19_insline(n) { - esc(); - pc(L); - ILPAD(); + while (--n >= 0) { + esc(); + pc('L'); + ILPAD(); + } } -h19_delline() +h19_delline(n) { - esc(); - pc(M); - ILPAD(); + while (--n >= 0) { + esc(); + pc('M'); + ILPAD(); + } } h19_putc(c) @@ -111,7 +115,7 @@ register char c; (*tt.tt_setmodes)(tt.tt_nmodes); if (tt.tt_ninsert != tt.tt_insert) H19_SETINSERT(tt.tt_ninsert); - ttputc(c); + pc(c); if (tt.tt_insert) ICPAD(); if (++tt.tt_col == NCOL) @@ -128,7 +132,7 @@ register n; H19_SETINSERT(tt.tt_ninsert); if (tt.tt_insert) { while (--n >= 0) { - ttputc(*p++); + pc(*p++); ICPAD(); tt.tt_col++; } @@ -147,39 +151,39 @@ register char row, col; if (tt.tt_col == col) return; if (col == 0) { - pc(\r); + pc('\r'); goto out; } if (tt.tt_col == col - 1) { esc(); - pc(C); + pc('C'); goto out; } if (tt.tt_col == col + 1) { - pc(\b); + pc('\b'); goto out; } } if (tt.tt_col == col) { if (tt.tt_row == row + 1) { esc(); - pc(A); + pc('A'); goto out; } if (tt.tt_row == row - 1) { - pc(\n); + pc('\n'); goto out; } } if (col == 0 && row == 0) { esc(); - pc(H); + pc('H'); goto out; } esc(); - pc(Y); - ttputc(' ' + row); - ttputc(' ' + col); + pc('Y'); + pc(' ' + row); + pc(' ' + col); out: tt.tt_col = col; tt.tt_row = row; @@ -190,9 +194,9 @@ h19_init() if (gen_VS) ttxputs(gen_VS); esc(); - pc(w); + pc('w'); esc(); - pc(E); + pc('E'); tt.tt_col = tt.tt_row = 0; tt.tt_ninsert = tt.tt_insert = 0; tt.tt_nmodes = tt.tt_modes = 0; @@ -203,44 +207,49 @@ h19_end() if (gen_VE) ttxputs(gen_VE); esc(); - pc(v); + pc('v'); } h19_clreol() { esc(); - pc(K); + pc('K'); } h19_clreos() { esc(); - pc(J); + pc('J'); } h19_clear() { esc(); - pc(E); + pc('E'); } -h19_delchar() +h19_delchar(n) { - esc(); - pc(N); + while (--n >= 0) { + esc(); + pc('N'); + } } -h19_scroll_down() +h19_scroll_down(n) { h19_move(NROW - 1, 0); - pc(\n); + while (--n >= 0) + pc('\n'); } -h19_scroll_up() +h19_scroll_up(n) { h19_move(0, 0); - esc(); - pc(I); + while (--n >= 0) { + esc(); + pc('I'); + } } tt_h19() @@ -270,7 +279,6 @@ tt_h19() tt.tt_ncol = NCOL; tt.tt_nrow = NROW; - tt.tt_hasinsert = 1; tt.tt_availmodes = WWM_REV|WWM_GRP; tt.tt_frame = h19_frame; return 0; diff --git a/usr/src/usr.bin/window/tth29.c b/usr/src/usr.bin/window/tth29.c index 943174d5e4..5a48fbed37 100644 --- a/usr/src/usr.bin/window/tth29.c +++ b/usr/src/usr.bin/window/tth29.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)tth29.c 3.6 (Berkeley) %G%"; +static char sccsid[] = "@(#)tth29.c 3.7 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -38,8 +38,8 @@ kC|h29|heath-29|z29|zenith-29:\ * */ -#define pc(c) ttputc('c') -#define esc() pc(\033) +#define pc(c) ttputc(c) +#define esc() pc('\033') h29_setmodes(new) register new; @@ -57,14 +57,14 @@ register new; if (new & WWM_USR) modes += 0x10; esc(); - pc(s); - ttputc(modes); + pc('s'); + pc(modes); if (new & WWM_GRP) { if ((tt.tt_modes & WWM_GRP) == 0) - esc(), pc(F); + esc(), pc('F'); } else if (tt.tt_modes & WWM_GRP) - esc(), pc(G); + esc(), pc('G'); tt.tt_modes = new; } diff --git a/usr/src/usr.bin/window/tttermcap.c b/usr/src/usr.bin/window/tttermcap.c index d16a903813..938fdf79e1 100644 --- a/usr/src/usr.bin/window/tttermcap.c +++ b/usr/src/usr.bin/window/tttermcap.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)tttermcap.c 3.9 (Berkeley) %G%"; +static char sccsid[] = "@(#)tttermcap.c 3.10 (Berkeley) %G%"; #endif /* not lint */ #include "tt.h" @@ -79,6 +79,13 @@ tttgoto(s, col, row) ttputc(0); } +ttpgoto(s, col, row, n) + struct tt_str *s; +{ + + tputs(tgoto(s->ts_str, col, row), n, tttputc); +} + ttstrcmp(a, b) register struct tt_str *a, *b; { diff --git a/usr/src/usr.bin/window/ttzapple.c b/usr/src/usr.bin/window/ttzapple.c index 7e498dae41..10d6858d2b 100644 --- a/usr/src/usr.bin/window/ttzapple.c +++ b/usr/src/usr.bin/window/ttzapple.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1983 Regents of the University of California. + * Copyright (c) 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)ttzapple.c 3.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)ttzapple.c 3.2 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -42,14 +42,44 @@ zz|zapple|unorthodox apple:\ #define esc1() pc(ctrl('\\')) #define esc2() pc(ctrl(']')) -#define ZZ_SETINSERT(new) (tt.tt_insert = new) - extern short gen_frame[]; -zz_setinsert(new) -{ - ZZ_SETINSERT(new); -} +/* + * stuff for token compression + */ + +#define N 4 +#define NTOKEN 128 +#define NCTOKEN (NTOKEN * 4) +#define H 11 +#define HSIZE (1 << H) +struct ctoken { + short index; + short hash; + unsigned long time; + unsigned long count; + char string[N]; + struct ctoken *forw; + struct ctoken *back; +}; + +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]) +*/ zz_setmodes(new) { @@ -66,55 +96,50 @@ zz_setmodes(new) tt.tt_modes = new; } -zz_insline() +zz_insline(n) { - esc(); - pc('a'); + if (n == 0) { + esc(); + pc('a'); + } else { + esc1(); + pc(n + ' '); + pc('A'); + } } -zz_delline() +zz_delline(n) { - esc(); - pc('d'); + if (n == 0) { + esc(); + pc('d'); + } else { + esc1(); + pc(n + ' '); + pc('D'); + } } zz_putc(c) char c; { - if (tt.tt_ninsert != tt.tt_insert) - ZZ_SETINSERT(tt.tt_ninsert); if (tt.tt_nmodes != tt.tt_modes) zz_setmodes(tt.tt_nmodes); - if (tt.tt_insert) { - esc(); - pc('i'); - ttputc(c); - } else - ttputc(c); + ttputc(c); if (++tt.tt_col == NCOL) tt.tt_col = 0, tt.tt_row++; } -int zz_histo[127]; - zz_write(p, n) register char *p; register n; { - if (n < 128) - zz_histo[n]++; - else - zz_histo[127]++; - if (tt.tt_ninsert != tt.tt_insert) - ZZ_SETINSERT(tt.tt_ninsert); if (tt.tt_nmodes != tt.tt_modes) zz_setmodes(tt.tt_nmodes); - if (tt.tt_insert) { - esc1(); - pc(n + ' '); - pc('I'); - } - ttwrite(p, n); + if (n < N) + ttwrite(p, n); + else + zc_write(p, n); tt.tt_col += n; if (tt.tt_col == NCOL) tt.tt_col = 0, tt.tt_row++; @@ -188,14 +213,21 @@ out: zz_init() { - ZZ_SETINSERT(0); zz_setmodes(0); zz_setscroll(0, NROW - 1); zz_clear(); + esc1(); + pc(N + ' '); + pc('T'); + zc_init(); } zz_end() { + esc1(); + pc(' '); + pc('T'); + pc(0); } zz_clreol() @@ -217,15 +249,37 @@ zz_clear() tt.tt_col = tt.tt_row = 0; } -zz_delchar() +zz_inschar(n) { - esc(); - pc('c'); + if (n != 1) { + esc1(); + pc(n + ' '); + pc('I'); + } else { + esc(); + pc('i'); + } +} + +zz_delchar(n) +{ + if (n != 1) { + esc1(); + pc(n + ' '); + pc('C'); + } else { + esc(); + pc('c'); + } } -zz_scroll_down() +zz_scroll_down(n) { - if (tt.tt_row == tt.tt_scroll_bot) + if (n != 1) { + esc1(); + pc(n + ' '); + pc('F'); + } else if (tt.tt_row == tt.tt_scroll_bot) pc('\n'); else { esc(); @@ -233,10 +287,16 @@ zz_scroll_down() } } -zz_scroll_up() +zz_scroll_up(n) { - esc(); - pc('r'); + if (n == 1) { + esc(); + pc('r'); + } else { + esc1(); + pc(n + ' '); + pc('R'); + } } zz_setscroll(top, bot) @@ -249,56 +309,150 @@ zz_setscroll(top, bot) tt.tt_scroll_bot = bot; } -#ifdef notdef -struct ctoken { - char ct_index; - short ct_hash - unsigned long ct_time; - unsigned long ct_count; - char ct_string[8]; - struct ctoken ct_forw; - struct ctoken ct_back; - struct ctoken ct_hforw; - struct ctoken ct_hback; -}; - -zz_compress(p, n) - register char *p; +zc_write(s, n) + char *s; register n; { -} - -zc_insert(string, hash) - char *string; - short hash; -{ + register char *p; + register h; + register i; register struct ctoken *tp; - for (tp = zc_hashtable[hash]; - *tp && strncmp(string, tp->ct_string, 8) != 0; - tp = tp->ct_hforw) + p = s; + for (i = N - 2, h = zc_hash(0, *p++); --i >= 0; h = zc_hash(h, *p++)) ; - if (tp == 0) { - if (eval(q2.ct_back) < THRESH) { - tp = q2.ct_back; - bcopy(string, tp->string, 8); - tp->hash = hash; + for (i = 0;;) { + tick++; + h = zc_hash(h, *p++); + if ((tp = htab[h]) == 0) { + tp = q2.back; + if (tp->hash >= 0) + htab[tp->hash] = 0; + zc_copy(p - N, tp->string); + tp->hash = h; tp->count = 0; + htab[h] = tp; + } else if (!zc_equal(tp->string, p - N)) { + if (tp->index == 0 && zc_eval(tp) < 0) { + zc_copy(p - N, tp->string); + tp->count = 0; + } else { + line[i] = 0; + goto cont; + } } + tp->time = tick; + tp->count++; + if (tp->index == 0) + zc_head(tp, &q2); + else + zc_head(tp, &q1); + line[i] = tp; + cont: + if (++i > n - N) + break; + h = zc_unhash(h, p[- N]); } - tp->time = zc_time; - tp->count++; + while (i < n) + line[i++] = 0; + for (i = 0; i < n;) { + register struct ctoken *tp; + + if ((tp = line[i]) == 0) { + pc(s[i]); + i++; + } else if (tp->index > 0) { + zc_head(tp, &q1); + pc(tp->index - 1 | 0x80); + wwzc1++; + wwzcsave += N - 1; + i += N; + } else if (tp->index < 0) { + tp->index = - tp->index; + zc_head(tp, &q1); + pc(ctrl('^')); + pc(tp->index - 1); + ttwrite(tp->string, N); + wwzc0++; + wwzcsave -= 2; + i += N; + } else if (tp->count > 1 && zc_eval(tp) > zc_eval(q1.back)) { + tp->index = abs(q1.back->index); + q1.back->index = 0; + zc_head(q1.back, &q2); + zc_head(tp, &q1); + pc(ctrl('^')); + pc(tp->index - 1); + ttwrite(tp->string, N); + wwzc0++; + wwzcsave -= 2; + i += N; + } else { + pc(s[i]); + i++; + } + } + wwzctotal += n; +} + +zc_head(tp, q) + register struct ctoken *tp, *q; +{ + tp->back->forw = tp->forw; tp->forw->back = tp->back; - if (tp->index == 0) { - if (eval(q1.ct_back) < eval(tp)) { - } + q->forw->back = tp; + tp->forw = q->forw; + q->forw = tp; + tp->back = q; +} + +zc_init() +{ + register struct ctoken *tp; + + for (tp = tokens; tp < tokens + sizeof tokens / sizeof *tokens; tp++) + if (tp->index > 0) + tp->index = - tp->index; +} + +zc_start() +{ + register struct ctoken *tp; + register i; + + tick = 0; + bzero((char *)htab, sizeof htab); + q1.forw = &q1; + q1.back = &q1; + for (i = 0, tp = tokens; i < NTOKEN; i++, tp++) { + tp->index = i + 1; + tp->hash = -1; + tp->count = 0; + tp->time = 0; + q1.forw->back = tp; + tp->forw = q1.forw; + q1.forw = tp; + tp->back = &q1; + } + q2.forw = &q2; + q2.back = &q2; + for (; i < sizeof tokens / sizeof *tokens; i++, tp++) { + tp->index = 0; + tp->hash = -1; + tp->count = 0; + tp->time = 0; + q2.forw->back = tp; + tp->forw = q2.forw; + q2.forw = tp; + tp->back = &q2; } } -#endif tt_zapple() { + zc_start(); + tt.tt_inschar = zz_inschar; tt.tt_delchar = zz_delchar; tt.tt_insline = zz_insline; tt.tt_delline = zz_delline; @@ -308,7 +462,6 @@ tt_zapple() tt.tt_scroll_up = zz_scroll_up; tt.tt_setscroll = zz_setscroll; tt.tt_availmodes = WWM_REV; - tt.tt_hasinsert = 1; tt.tt_wrap = 1; tt.tt_retain = 0; tt.tt_ncol = 80; @@ -319,7 +472,6 @@ tt_zapple() tt.tt_putc = zz_putc; tt.tt_move = zz_move; tt.tt_clear = zz_clear; - tt.tt_setinsert = zz_setinsert; tt.tt_setmodes = zz_setmodes; tt.tt_frame = gen_frame; return 0; diff --git a/usr/src/usr.bin/window/ww.h b/usr/src/usr.bin/window/ww.h index 11825abcd0..eed74f60b0 100644 --- a/usr/src/usr.bin/window/ww.h +++ b/usr/src/usr.bin/window/ww.h @@ -14,7 +14,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#)ww.h 3.52 (Berkeley) %G% + * @(#)ww.h 3.53 (Berkeley) %G% */ #include @@ -207,6 +207,7 @@ int wwerrno; /* error number */ /* statistics */ int wwnflush, wwnwr, wwnwre, wwnwrz, wwnwrc; int wwnwwr, wwnwwra, wwnwwrc; +int wwzc0, wwzc1, wwzcsave, wwzctotal; int wwnupdate, wwnupdline, wwnupdmiss; int wwnupdscan, wwnupdclreol, wwnupdclreos, wwnupdclreosmiss, wwnupdclreosline; int wwnread, wwnreade, wwnreadz, wwnreadc; diff --git a/usr/src/usr.bin/window/wwdelchar.c b/usr/src/usr.bin/window/wwdelchar.c index bc9a570c8a..9ed4f9dd9d 100644 --- a/usr/src/usr.bin/window/wwdelchar.c +++ b/usr/src/usr.bin/window/wwdelchar.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)wwdelchar.c 3.13 (Berkeley) %G%"; +static char sccsid[] = "@(#)wwdelchar.c 3.14 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -94,9 +94,7 @@ register struct ww *w; if (tt.tt_delchar != 0 && nvis > (wwncol - col) / 2) { register union ww_char *p, *q; - (*tt.tt_move)(row, col); - (*tt.tt_delchar)(); - + xxdelchar(row, col); p = &wwos[row][col]; q = p + 1; for (i = wwncol - col; --i > 0;) diff --git a/usr/src/usr.bin/window/wwend.c b/usr/src/usr.bin/window/wwend.c index 307eb237d1..39eb87e911 100644 --- a/usr/src/usr.bin/window/wwend.c +++ b/usr/src/usr.bin/window/wwend.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)wwend.c 3.11 (Berkeley) %G%"; +static char sccsid[] = "@(#)wwend.c 3.12 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -33,7 +33,7 @@ wwend() if (tt.tt_modes) (*tt.tt_setmodes)(0); if (tt.tt_scroll_down) - (*tt.tt_scroll_down)(); + (*tt.tt_scroll_down)(1); (*tt.tt_move)(tt.tt_nrow - 1, 0); (*tt.tt_end)(); ttflush(); diff --git a/usr/src/usr.bin/window/wwinit.c b/usr/src/usr.bin/window/wwinit.c index 6902671224..9edadc8f80 100644 --- a/usr/src/usr.bin/window/wwinit.c +++ b/usr/src/usr.bin/window/wwinit.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)wwinit.c 3.32 (Berkeley) %G%"; +static char sccsid[] = "@(#)wwinit.c 3.33 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -82,6 +82,8 @@ wwinit() wwncol = tt.tt_ncol; wwavailmodes = tt.tt_availmodes; wwwrap = tt.tt_wrap; + if (xxinit() < 0) + return -1; (*tt.tt_init)(); if (wwavailmodes & WWM_REV) @@ -147,7 +149,7 @@ wwinit() wwaddcap1(WWT_USR, &kp); if (tt.tt_insline && tt.tt_delline || tt.tt_setscroll) wwaddcap1(WWT_ALDL, &kp); - if (tt.tt_hasinsert) + if (tt.tt_inschar || tt.tt_setinsert) wwaddcap1(WWT_IMEI, &kp); if (tt.tt_delchar) wwaddcap1(WWT_DC, &kp); diff --git a/usr/src/usr.bin/window/wwinschar.c b/usr/src/usr.bin/window/wwinschar.c index f501ea3d2b..ebb1fac483 100644 --- a/usr/src/usr.bin/window/wwinschar.c +++ b/usr/src/usr.bin/window/wwinschar.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)wwinschar.c 3.16 (Berkeley) %G%"; +static char sccsid[] = "@(#)wwinschar.c 3.17 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -92,19 +92,14 @@ short c; /* * Can/Should we use delete character? */ - if (tt.tt_hasinsert && nvis > (wwncol - col) / 2) { + if ((tt.tt_inschar || tt.tt_setinsert) && nvis > (wwncol - col) / 2) { register union ww_char *p, *q; - tt.tt_ninsert = 1; - tt.tt_nmodes = c >> WWC_MSHIFT & tt.tt_availmodes; - (*tt.tt_move)(row, col); - (*tt.tt_putc)(c & WWC_CMASK); - tt.tt_ninsert = 0; - + xxinschar(row, col, c & wwavailmodes << WWC_MSHIFT); p = &wwos[row][wwncol]; q = p - 1; for (i = wwncol - col; --i > 0;) *--p = *--q; - q->c_w = c; + q->c_w = tt.tt_setinsert ? c : ' '; } } diff --git a/usr/src/usr.bin/window/wwredraw.c b/usr/src/usr.bin/window/wwredraw.c index da8f1e8c35..19bccbe2c0 100644 --- a/usr/src/usr.bin/window/wwredraw.c +++ b/usr/src/usr.bin/window/wwredraw.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)wwredraw.c 3.9 (Berkeley) %G%"; +static char sccsid[] = "@(#)wwredraw.c 3.10 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -27,6 +27,7 @@ wwredraw() register i, j; register union ww_char *os; + xxreset(); (*tt.tt_clear)(); for (i = 0; i < wwnrow; i++) { wwtouched[i] = WWU_TOUCHED; diff --git a/usr/src/usr.bin/window/wwscroll.c b/usr/src/usr.bin/window/wwscroll.c index 276e06d32e..7b7b3a9119 100644 --- a/usr/src/usr.bin/window/wwscroll.c +++ b/usr/src/usr.bin/window/wwscroll.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)wwscroll.c 3.21 (Berkeley) %G%"; +static char sccsid[] = "@(#)wwscroll.c 3.22 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -68,7 +68,6 @@ int leaveit; int nvis; int nvismax; int scrolled = 0; - int (*scroll_func)(); /* * See how many lines on the screen are affected. @@ -95,63 +94,15 @@ int leaveit; /* * If it's a good idea to scroll and the terminal can, then do it. - * We handle retain (da and db) by putting the burden on scrolling up, - * which is the less common operation. It must ensure that - * text is not pushed below the screen, so scrolling down doesn't - * have to worry about it. */ if (nvis < nvismax / 2) goto no_scroll; /* not worth it */ - /* - * Try scrolling region (or scrolling the whole screen) first. - * Can we assume "sr" doesn't push text below the screen - * so we don't have to worry about retain below? - * What about scrolling down with a newline? It probably does - * push text above (with da). Scrolling up would then have - * to take care of that. - * It's easy to be fool proof, but that slows things down. - * The current solution is to disallow tt_scroll_up if da or db is true - * but cs (scrolling region) is not. Again, we sacrifice scrolling - * up in favor of scrolling down. The idea is having scrolling regions - * probably means we can scroll (even the whole screen) with impunity. - * This lets us work efficiently on simple terminals (use newline - * on the bottom to scroll), on any terminal without retain, and - * on vt100 style scrolling regions (I think). - */ - if (scroll_func = dir > 0 ? tt.tt_scroll_down : tt.tt_scroll_up) { - if (tt.tt_scroll_top != row1x || tt.tt_scroll_bot != row2x - 1) - if (tt.tt_setscroll == 0) - scroll_func = 0; - else - (*tt.tt_setscroll)(row1x, row2x - 1); - if (scroll_func) { - (*scroll_func)(); - goto did_scroll; - } - } - /* - * Try insert/delete line. - * Don't worry about retain when scrolling down, - * but do worry when scrolling up, for hp2621. - */ - if (tt.tt_delline == 0 || tt.tt_insline == 0) - goto no_scroll; - if (dir > 0) { - (*tt.tt_move)(row1x, 0); - (*tt.tt_delline)(); - if (row2x < wwnrow) { - (*tt.tt_move)(row2x - 1, 0); - (*tt.tt_insline)(); - } - } else { - if (tt.tt_retain || row2x != wwnrow) { - (*tt.tt_move)(row2x - 1, 0); - (*tt.tt_delline)(); - } - (*tt.tt_move)(row1x, 0); - (*tt.tt_insline)(); - } -did_scroll: + if ((dir > 0 ? tt.tt_scroll_down == 0 : tt.tt_scroll_up == 0) || + (tt.tt_scroll_top != row1x || tt.tt_scroll_bot != row2x - 1) && + tt.tt_setscroll == 0) + if (tt.tt_delline == 0 || tt.tt_insline == 0) + goto no_scroll; + xxscroll(dir, row1x, row2x); scrolled = 1; /* * Fix up the old screen. diff --git a/usr/src/usr.bin/window/wwtty.c b/usr/src/usr.bin/window/wwtty.c index c71789c5df..e7b218e978 100644 --- a/usr/src/usr.bin/window/wwtty.c +++ b/usr/src/usr.bin/window/wwtty.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)wwtty.c 3.12 (Berkeley) %G%"; +static char sccsid[] = "@(#)wwtty.c 3.13 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -51,7 +51,7 @@ bad: wwsettty(d, t, o) register struct ww_tty *t, *o; { - if (ioctl(d, TIOCSETN, (char *)&t->ww_sgttyb) < 0) + if (ioctl(d, TIOCSETP, (char *)&t->ww_sgttyb) < 0) goto bad; if (ioctl(d, TIOCSETC, (char *)&t->ww_tchars) < 0) goto bad; diff --git a/usr/src/usr.bin/window/wwupdate.c b/usr/src/usr.bin/window/wwupdate.c index 4296ab7506..eba3632478 100644 --- a/usr/src/usr.bin/window/wwupdate.c +++ b/usr/src/usr.bin/window/wwupdate.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)wwupdate.c 3.23 (Berkeley) %G%"; +static char sccsid[] = "@(#)wwupdate.c 3.24 (Berkeley) %G%"; #endif /* not lint */ #include "ww.h" @@ -28,10 +28,10 @@ wwupdate1(top, bot) register j; char *touched; struct ww_update *upd; - char didit; char check_clreos = 0; int scan_top, scan_bot; + xxflush(); wwnupdate++; { register char *t1 = wwtouched + top, *t2 = wwtouched + bot; @@ -225,7 +225,7 @@ simple: tt.tt_nmodes = m; if (wwwrap && i == wwnrow - 1 && q - buf + c == wwncol) { - if (tt.tt_hasinsert) { + if (tt.tt_setinsert) { if (q - buf != 1) { (*tt.tt_move)(i, c); (*tt.tt_write)(buf + 1, @@ -243,6 +243,22 @@ simple: (*tt.tt_write)(&ns[-2].c_c, 1); tt.tt_ninsert = 0; } + } else if (tt.tt_inschar) { + if (q - buf != 1) { + (*tt.tt_move)(i, c); + (*tt.tt_write)(buf + 1, + q - buf - 1); + (*tt.tt_move)(i, c); + (*tt.tt_inschar)(1); + (*tt.tt_write)(buf, 1); + } else { + (*tt.tt_move)(i, c - 1); + (*tt.tt_write)(buf, 1); + tt.tt_nmodes = ns[-2].c_m; + (*tt.tt_move)(i, c - 1); + (*tt.tt_inschar)(1); + (*tt.tt_write)(&ns[-2].c_c, 1); + } } else { if (q - buf > 1) { (*tt.tt_move)(i, c); -- 2.20.1