From f2a77fe16de0a7d0f625e5e77e5af81683f572ae Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Thu, 15 Sep 1983 17:10:51 -0800 Subject: [PATCH] Now uses screen address for all buffers. SCCS-vsn: usr.bin/window/wwinit.c 3.10 SCCS-vsn: usr.bin/window/wwmisc.c 3.3 SCCS-vsn: usr.bin/window/wwopen.c 3.12 SCCS-vsn: usr.bin/window/ww.h 3.14 SCCS-vsn: usr.bin/window/cmd.c 3.12 SCCS-vsn: usr.bin/window/wwwrite.c 3.11 SCCS-vsn: usr.bin/window/wwclose.c 3.5 SCCS-vsn: usr.bin/window/wwframe.c 3.10 SCCS-vsn: usr.bin/window/wwlabel.c 3.7 SCCS-vsn: usr.bin/window/cmd5.c 3.6 SCCS-vsn: usr.bin/window/:ww 1.4 SCCS-vsn: usr.bin/window/wwadd.c 3.5 SCCS-vsn: usr.bin/window/wwdelete.c 3.5 SCCS-vsn: usr.bin/window/wwalloc.c 3.5 SCCS-vsn: usr.bin/window/wwinsline.c 3.5 SCCS-vsn: usr.bin/window/wwdelline.c 3.5 SCCS-vsn: usr.bin/window/wwclreol.c 3.9 SCCS-vsn: usr.bin/window/wwdata.c 3.5 SCCS-vsn: usr.bin/window/wwdump.c 3.5 SCCS-vsn: usr.bin/window/wwinschar.c 3.8 SCCS-vsn: usr.bin/window/wwunframe.c 3.8 SCCS-vsn: usr.bin/window/wwclreos.c 3.3 SCCS-vsn: usr.bin/window/wwdelchar.c 3.6 SCCS-vsn: usr.bin/window/wwscroll.c 3.10 SCCS-vsn: usr.bin/window/wwredrawwin.c 3.5 SCCS-vsn: usr.bin/window/wwcursor.c 3.3 SCCS-vsn: usr.bin/window/wwmove.c 3.2 --- usr/src/usr.bin/window/:ww | 8 +- usr/src/usr.bin/window/cmd.c | 4 +- usr/src/usr.bin/window/cmd5.c | 29 +++---- usr/src/usr.bin/window/ww.h | 17 ++-- usr/src/usr.bin/window/wwadd.c | 17 ++-- usr/src/usr.bin/window/wwalloc.c | 14 ++-- usr/src/usr.bin/window/wwclose.c | 12 +-- usr/src/usr.bin/window/wwclreol.c | 46 ++++------- usr/src/usr.bin/window/wwclreos.c | 10 +-- usr/src/usr.bin/window/wwcursor.c | 15 ++-- usr/src/usr.bin/window/wwdata.c | 2 +- usr/src/usr.bin/window/wwdelchar.c | 40 ++++----- usr/src/usr.bin/window/wwdelete.c | 12 ++- usr/src/usr.bin/window/wwdelline.c | 23 +++--- usr/src/usr.bin/window/wwdump.c | 16 ++-- usr/src/usr.bin/window/wwframe.c | 46 +++++------ usr/src/usr.bin/window/wwinit.c | 8 +- usr/src/usr.bin/window/wwinschar.c | 40 ++++----- usr/src/usr.bin/window/wwinsline.c | 27 +++--- usr/src/usr.bin/window/wwlabel.c | 16 ++-- usr/src/usr.bin/window/wwmisc.c | 13 +-- usr/src/usr.bin/window/wwmove.c | 40 +++++++-- usr/src/usr.bin/window/wwopen.c | 57 ++++++++----- usr/src/usr.bin/window/wwredrawwin.c | 19 ++--- usr/src/usr.bin/window/wwscroll.c | 81 +++++++++--------- usr/src/usr.bin/window/wwunframe.c | 11 +-- usr/src/usr.bin/window/wwwrite.c | 118 ++++++++++++++------------- 27 files changed, 380 insertions(+), 361 deletions(-) diff --git a/usr/src/usr.bin/window/:ww b/usr/src/usr.bin/window/:ww index 64a726d9d5..34d1ec9352 100644 --- a/usr/src/usr.bin/window/:ww +++ b/usr/src/usr.bin/window/:ww @@ -1,10 +1,12 @@ ./"forw"16t"back"16t"state"8t"wstate"8t"modes"nppbbb +/"xxx"8t"index"8t"order"nbbb++ -+/"w.nr"16t"w.nc"nDDn ++/"w.nr"16t"w.nc"nDD +/"w.t"16t"w.b"16t"w.l"16t"w.r"nDDDD -+/"i.nr"16t"i.nc"nDDn ++/"b.nr"16t"b.nc"nDD ++/"b.t"16t"b.b"16t"b.l"16t"b.r"nDDDD ++/"i.nr"16t"i.nc"nDD +/"i.t"16t"i.b"16t"i.l"16t"i.r"nDDDD -+/"nline"16t"scroll"16t"cur.r"16t"cur.c"nDDDD ++/"cur.r"16t"cur.c"nDD +/"win"16t"buf"16t"cov"16t"fmap"16tnpppp +/"nvis"np +/"pty"16t"tty"16t"pid"16t"ttyname"nDDD11C diff --git a/usr/src/usr.bin/window/cmd.c b/usr/src/usr.bin/window/cmd.c index e1c41cc7e0..51d46afcee 100644 --- a/usr/src/usr.bin/window/cmd.c +++ b/usr/src/usr.bin/window/cmd.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)cmd.c 3.11 83/09/02"; +static char *sccsid = "@(#)cmd.c 3.12 83/09/15"; #endif #include "defs.h" @@ -207,7 +207,7 @@ getwin() if (!terse) (void) wwputs("Which window? ", cmdwin); - wwsetcursor(wwcurrow(cmdwin), wwcurcol(cmdwin)); + wwcurtowin(cmdwin); while ((c = bgetc()) < 0) bread(); if (debug && c == 'c') diff --git a/usr/src/usr.bin/window/cmd5.c b/usr/src/usr.bin/window/cmd5.c index 022cb69458..fa3310aac2 100644 --- a/usr/src/usr.bin/window/cmd5.c +++ b/usr/src/usr.bin/window/cmd5.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)cmd5.c 3.5 83/09/14"; +static char *sccsid = "@(#)cmd5.c 3.6 83/09/15"; #endif #include "defs.h" @@ -59,25 +59,22 @@ getminmax(x, n, a, b, curx, minx, maxx) register x, n, a, b; int *curx, *minx, *maxx; { - if (x < a) { + if (x < 0) *curx = x + n - 1; - *minx = 1 - n; - *maxx = a; - } else if (x == a) { + else *curx = x; + + if (x <= a) *minx = 1 - n; - *maxx = b - n; - } else if (x < b - n) { - *curx = x; - *minx = a; - *maxx = b - n; - } else if (x == b - n) { - *curx = x; + else if (x <= b - n) *minx = a; - *maxx = b - 1; - } else { - *curx = x; + else *minx = b - n; + + if (x >= b - n) *maxx = b - 1; - } + else if (x >= a) + *maxx = b - n; + else + *maxx = a; } diff --git a/usr/src/usr.bin/window/ww.h b/usr/src/usr.bin/window/ww.h index a722bf5d15..ca777a05fe 100644 --- a/usr/src/usr.bin/window/ww.h +++ b/usr/src/usr.bin/window/ww.h @@ -1,5 +1,5 @@ /* - * @(#)ww.h 3.13 83/09/14 + * @(#)ww.h 3.14 83/09/15 */ #include @@ -32,16 +32,20 @@ struct ww { char ww_hasframe :1; /* frame it */ char ww_index; /* the index, for wwindex[] */ char ww_order; /* the overlapping order */ - struct ww_dim ww_w; /* window dimemsions */ + + /* sizes and positions */ + struct ww_dim ww_w; /* window size and pos */ + struct ww_dim ww_b; /* buffer size and pos */ struct ww_dim ww_i; /* the part inside the screen */ - int ww_nline; /* size of the buffer */ - int ww_scroll; /* where the window is relative to the buffer */ struct ww_pos ww_cur; /* the cursor position, relative to ww_w */ + + /* arrays */ char **ww_win; /* the window */ union ww_char **ww_buf; /* the buffer */ char **ww_cov; /* the covered-by array */ char **ww_fmap; /* map for frame and box windows */ short *ww_nvis; /* how many ww_buf chars are visible per row */ + int ww_pty; /* file descriptor of pty */ int ww_tty; /* . . . tty */ int ww_pid; /* pid of process, if WWS_HASPROC true */ @@ -146,12 +150,11 @@ int wwnwrite, wwnwritec; int wwnupdate, wwntouched, wwnmiss; /* quicky macros */ -#define wwcurrow(w) ((w)->ww_cur.r + (w)->ww_w.t) -#define wwcurcol(w) ((w)->ww_cur.c + (w)->ww_w.l) #define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c)) -#define wwcurtowin(w) wwsetcursor(wwcurrow(w), wwcurcol(w)) +#define wwcurtowin(w) wwsetcursor((w)->ww_cur.r, (w)->ww_cur.c) #define wwbell() putchar(CTRL(g)) #define wwunbox(w) wwunframe(w) +#define wwclreol(w,r,c) wwclreol1((w), (r), (c), 0) /* the window virtual terminal */ #define WWT_TERM "TERM=window" diff --git a/usr/src/usr.bin/window/wwadd.c b/usr/src/usr.bin/window/wwadd.c index f564983f11..2ae74820ef 100644 --- a/usr/src/usr.bin/window/wwadd.c +++ b/usr/src/usr.bin/window/wwadd.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwadd.c 3.4 83/09/14"; +static char *sccsid = "@(#)wwadd.c 3.5 83/09/15"; #endif #include "ww.h" @@ -35,16 +35,13 @@ register struct ww *w1, *w2; char *touched = &wwtouched[i]; for (; i < w1->ww_i.b; i++, touched++) { - int j = w1->ww_i.nc; - register char *win = &w1->ww_win[i - w1->ww_w.t] - [w1->ww_i.l - w1->ww_w.l]; - register char *smap = &wwsmap[i][w1->ww_i.l]; - register union ww_char *ns = &wwns[i][w1->ww_i.l]; - register union ww_char *buf - = &w1->ww_buf[w1->ww_scroll + i - w1->ww_w.t] - [w1->ww_i.l - w1->ww_w.l]; + int j = w1->ww_i.l; + register char *win = &w1->ww_win[i][j]; + register char *smap = &wwsmap[i][j]; + register union ww_char *ns = &wwns[i][j]; + register union ww_char *buf = &w1->ww_buf[i][j]; - while (--j >= 0) { + for (; j < w1->ww_i.r; j++) { if ((*win & (WWM_GLS|WWM_COV)) == 0) { *touched = 1; *smap++ = w1->ww_index; diff --git a/usr/src/usr.bin/window/wwalloc.c b/usr/src/usr.bin/window/wwalloc.c index f51ffc7fb3..791e4e50da 100644 --- a/usr/src/usr.bin/window/wwalloc.c +++ b/usr/src/usr.bin/window/wwalloc.c @@ -1,12 +1,11 @@ #ifndef lint -static char *sccsid = "@(#)wwalloc.c 3.4 83/08/26"; +static char *sccsid = "@(#)wwalloc.c 3.5 83/09/15"; #endif #include "ww.h" char ** -wwalloc(nrow, ncol, size) -int nrow, ncol, size; +wwalloc(row, col, nrow, ncol, size) { register char *p, **pp; register int i; @@ -19,17 +18,18 @@ int nrow, ncol, size; return 0; } p = (char *)&pp[nrow]; + col *= size; size /= sizeof (char); /* paranoid */ size *= ncol; for (i = 0; i < nrow; i++) { - pp[i] = p; + pp[i] = p - col; p += size; } - return pp; + return pp - row; } -wwfree(p) +wwfree(p, row) register char **p; { - free((char *)p); + free((char *)(p + row)); } diff --git a/usr/src/usr.bin/window/wwclose.c b/usr/src/usr.bin/window/wwclose.c index 25cc3aee7b..45d92edc48 100644 --- a/usr/src/usr.bin/window/wwclose.c +++ b/usr/src/usr.bin/window/wwclose.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwclose.c 3.4 83/08/26"; +static char *sccsid = "@(#)wwclose.c 3.5 83/09/15"; #endif #include "ww.h" @@ -15,11 +15,11 @@ register struct ww *w; (void) close(w->ww_tty); (void) close(w->ww_pty); } - wwfree((char **)w->ww_win); - wwfree((char **)w->ww_cov); - wwfree((char **)w->ww_buf); + wwfree((char **)w->ww_win, w->ww_w.t); + wwfree((char **)w->ww_cov, w->ww_w.t); + wwfree((char **)w->ww_buf, w->ww_w.t); if (w->ww_fmap != 0) - wwfree((char **)w->ww_fmap); - free((char *)w->ww_nvis); + wwfree((char **)w->ww_fmap, w->ww_w.t); + free((char *)(w->ww_nvis + w->ww_w.t)); free((char *)w); } diff --git a/usr/src/usr.bin/window/wwclreol.c b/usr/src/usr.bin/window/wwclreol.c index 5052d663e6..9c2b401705 100644 --- a/usr/src/usr.bin/window/wwclreol.c +++ b/usr/src/usr.bin/window/wwclreol.c @@ -1,30 +1,21 @@ #ifndef lint -static char *sccsid = "@(#)wwclreol.c 3.8 83/09/14"; +static char *sccsid = "@(#)wwclreol.c 3.9 83/09/15"; #endif #include "ww.h" #include "tt.h" -wwclreol(w, line, col) -struct ww *w; -{ - wwclreol1(w, line, col, 0); -} - /* * Clear w to the end of line. * If cleared is true, then the screen line has already been cleared * previously. */ -wwclreol1(w, line, col, cleared) +wwclreol1(w, row, col, cleared) register struct ww *w; -int line, col; +int row, col; char cleared; { register i; - int row = line - w->ww_scroll; - int srow = w->ww_w.t + row; - int scol = w->ww_w.l + col; int nblank, ncleared; /* @@ -33,21 +24,20 @@ char cleared; { register union ww_char *buf; - buf = &w->ww_buf[line][col]; - for (i = w->ww_w.nc - col; --i >= 0;) + buf = &w->ww_buf[row][col]; + for (i = w->ww_b.r - col; --i >= 0;) buf++->c_w = ' '; } /* * If can't see it, just return. */ - if (srow < w->ww_i.t || srow >= w->ww_i.b - || w->ww_i.r <= 0 || w->ww_i.r <= scol) + if (row < w->ww_i.t || row >= w->ww_i.b + || w->ww_i.r <= 0 || w->ww_i.r <= col) return; - if (scol < w->ww_i.l) - scol = w->ww_i.l; - col = scol - w->ww_w.l; + if (col < w->ww_i.l) + col = w->ww_i.l; /* * Now find out how much is actually cleared, and fix wwns. @@ -57,13 +47,13 @@ char cleared; register char *smap, *win; register char *touched; - smap = &wwsmap[srow][scol]; - s = &wwns[srow][scol]; - touched = &wwtouched[srow]; + smap = &wwsmap[row][col]; + s = &wwns[row][col]; + touched = &wwtouched[row]; win = &w->ww_win[row][col]; ncleared = nblank = 0; - for (i = w->ww_i.r - scol; --i >= 0;) { + for (i = w->ww_i.r - col; --i >= 0;) { if (*smap++ != w->ww_index) { if (s++->c_w == ' ') nblank++; @@ -85,15 +75,15 @@ char cleared; * Can/Should we use clear eol? */ if (!cleared && tt.tt_clreol != 0 - && ncleared > wwncol - scol - nblank - && nblank > (wwncol - scol) / 2) { + && ncleared > wwncol - col - nblank + && nblank > (wwncol - col) / 2) { register union ww_char *s; /* clear to the end */ - (*tt.tt_move)(srow, scol); + (*tt.tt_move)(row, col); (*tt.tt_clreol)(); - s = &wwos[srow][scol]; - for (i = wwncol - scol; --i >= 0;) + s = &wwos[row][col]; + for (i = wwncol - col; --i >= 0;) s++->c_w = ' '; } } diff --git a/usr/src/usr.bin/window/wwclreos.c b/usr/src/usr.bin/window/wwclreos.c index f2391473d1..3e6c604ae3 100644 --- a/usr/src/usr.bin/window/wwclreos.c +++ b/usr/src/usr.bin/window/wwclreos.c @@ -1,15 +1,15 @@ #ifndef lint -static char *sccsid = "@(#)wwclreos.c 3.2 83/08/11"; +static char *sccsid = "@(#)wwclreos.c 3.3 83/09/15"; #endif #include "ww.h" -wwclreos(w, line, col) +wwclreos(w, row, col) register struct ww *w; { register i; - wwclreol(w, line, col); - for (i = line + 1; i < w->ww_nline; i++) - wwclreol(w, i, 0); + wwclreol(w, row, col); + for (i = row + 1; i < w->ww_b.b; i++) + wwclreol(w, i, w->ww_b.l); } diff --git a/usr/src/usr.bin/window/wwcursor.c b/usr/src/usr.bin/window/wwcursor.c index 86e15450ea..07460bd8f7 100644 --- a/usr/src/usr.bin/window/wwcursor.c +++ b/usr/src/usr.bin/window/wwcursor.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwcursor.c 3.2 83/09/14"; +static char *sccsid = "@(#)wwcursor.c 3.3 83/09/15"; #endif #include "ww.h" @@ -8,7 +8,6 @@ wwcursor(w, on) register struct ww *w; { register char *win; - register r, c; if (on) { if (w->ww_hascursor) @@ -26,14 +25,12 @@ register struct ww *w; else if (*win == wwcursormodes) w->ww_nvis[w->ww_cur.r]++; *win ^= wwcursormodes; - r = wwcurrow(w); - c = wwcurcol(w); - if (r < w->ww_i.t || r >= w->ww_i.b - || c < w->ww_i.l || c >= w->ww_i.r) + if (w->ww_cur.r < w->ww_i.t || w->ww_cur.r >= w->ww_i.b + || w->ww_cur.c < w->ww_i.l || w->ww_cur.c >= w->ww_i.r) return; - if (wwsmap[r][c] == w->ww_index) { - wwns[r][c].c_m ^= wwcursormodes; - wwtouched[r] = 1; + if (wwsmap[w->ww_cur.r][w->ww_cur.c] == w->ww_index) { + wwns[w->ww_cur.r][w->ww_cur.c].c_m ^= wwcursormodes; + wwtouched[w->ww_cur.r] = 1; } } } diff --git a/usr/src/usr.bin/window/wwdata.c b/usr/src/usr.bin/window/wwdata.c index 84125caed3..4e1d32b2e9 100644 --- a/usr/src/usr.bin/window/wwdata.c +++ b/usr/src/usr.bin/window/wwdata.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwdata.c 3.4 83/08/17"; +static char *sccsid = "@(#)wwdata.c 3.5 83/09/15"; #endif #include "ww.h" diff --git a/usr/src/usr.bin/window/wwdelchar.c b/usr/src/usr.bin/window/wwdelchar.c index 2a28c74ae5..7ac82b6727 100644 --- a/usr/src/usr.bin/window/wwdelchar.c +++ b/usr/src/usr.bin/window/wwdelchar.c @@ -1,17 +1,14 @@ #ifndef lint -static char *sccsid = "@(#)wwdelchar.c 3.5 83/09/14"; +static char *sccsid = "@(#)wwdelchar.c 3.6 83/09/15"; #endif #include "ww.h" #include "tt.h" -wwdelchar(w, line, col) +wwdelchar(w, row, col) register struct ww *w; { register i; - int row = line - w->ww_scroll; - int srow = row + w->ww_w.t; - int scol = col + w->ww_w.l; int nvis; /* @@ -20,9 +17,9 @@ register struct ww *w; { register union ww_char *p, *q; - p = &w->ww_buf[line][col]; + p = &w->ww_buf[row][col]; q = p + 1; - for (i = w->ww_w.nc - col - 1; --i >= 0;) + for (i = w->ww_b.r - col; --i > 0;) *p++ = *q++; p->c_w = ' '; } @@ -30,13 +27,12 @@ register struct ww *w; /* * If can't see it, just return. */ - if (srow < w->ww_i.t || srow >= w->ww_i.b - || w->ww_i.r <= 0 || w->ww_i.r <= scol) + if (row < w->ww_i.t || row >= w->ww_i.b + || w->ww_i.r <= 0 || w->ww_i.r <= col) return; - if (scol < w->ww_i.l) - scol = w->ww_i.l; - col = scol - w->ww_w.l; + if (col < w->ww_i.l) + col = w->ww_i.l; /* * Now find out how much is actually changed, and fix wwns. @@ -49,15 +45,15 @@ register struct ww *w; char *touched; nvis = 0; - smap = &wwsmap[srow][scol]; - for (i = w->ww_i.r - scol; i > 0 && *smap++ != w->ww_index; i--) - col++, scol++; + smap = &wwsmap[row][col]; + for (i = w->ww_i.r - col; i > 0 && *smap++ != w->ww_index; i--) + col++; if (i <= 0) return; - buf = &w->ww_buf[line][col]; + buf = &w->ww_buf[row][col]; win = &w->ww_win[row][col]; - ns = &wwns[srow][scol]; - touched = &wwtouched[srow]; + ns = &wwns[row][col]; + touched = &wwtouched[row]; for (; --i >= 0;) { if (*win) { if ((*win & (WWM_COV|WWM_GLS)) != 0) { @@ -80,15 +76,15 @@ register struct ww *w; /* * Can/Should we use delete character? */ - if (tt.tt_delchar != 0 && nvis > (wwncol - scol) / 2) { + if (tt.tt_delchar != 0 && nvis > (wwncol - col) / 2) { register union ww_char *p, *q; - (*tt.tt_move)(srow, scol); + (*tt.tt_move)(row, col); (*tt.tt_delchar)(); - p = &wwos[srow][scol]; + p = &wwos[row][col]; q = p + 1; - for (i = wwncol - scol; --i > 0;) + for (i = wwncol - col; --i > 0;) *p++ = *q++; p->c_w = ' '; } diff --git a/usr/src/usr.bin/window/wwdelete.c b/usr/src/usr.bin/window/wwdelete.c index a1d6500a31..02c4c3662e 100644 --- a/usr/src/usr.bin/window/wwdelete.c +++ b/usr/src/usr.bin/window/wwdelete.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwdelete.c 3.4 83/09/14"; +static char *sccsid = "@(#)wwdelete.c 3.5 83/09/15"; #endif #include "ww.h" @@ -46,16 +46,14 @@ register struct ww *w; register i; for (i = w->ww_i.t; i < w->ww_i.b; i++) { - register j; - register char *win = &w->ww_win[i - w->ww_w.t] - [w->ww_i.l - w->ww_w.l]; - register char *cov = &w->ww_cov[i - w->ww_w.t] - [w->ww_i.l - w->ww_w.l]; + register j = w->ww_i.l; + register char *win = &w->ww_win[i][j]; + register char *cov = &w->ww_cov[i][j]; for (j = w->ww_i.nc; --j >= 0;) { if (*win != 0) { if ((*win++ &= ~WWM_COV) == 0) - w->ww_nvis[i - w->ww_w.t]++; + w->ww_nvis[i]++; } else win++; *cov++ = WWX_NOBODY; diff --git a/usr/src/usr.bin/window/wwdelline.c b/usr/src/usr.bin/window/wwdelline.c index fc57420ad4..659d0c5ca9 100644 --- a/usr/src/usr.bin/window/wwdelline.c +++ b/usr/src/usr.bin/window/wwdelline.c @@ -1,12 +1,12 @@ #ifndef lint -static char *sccsid = "@(#)wwdelline.c 3.4 83/09/14"; +static char *sccsid = "@(#)wwdelline.c 3.5 83/09/15"; #endif #include "ww.h" -wwdelline(w, line) +wwdelline(w, row) register struct ww *w; -int line; +int row; { register i; register union ww_char **cpp, **cqq; @@ -18,10 +18,11 @@ int line; /* * Scroll first. */ - if ((row1 = line - w->ww_scroll) < w->ww_i.t - w->ww_w.t) - row1 = w->ww_i.t - w->ww_w.t; - if ((row2 = w->ww_nline - w->ww_scroll) > w->ww_i.b - w->ww_w.t) { - row2 = w->ww_i.b - w->ww_w.t; + if ((row1 = row) < w->ww_i.t) { + row1 = w->ww_i.t; + } + if ((row2 = w->ww_b.b) > w->ww_i.b) { + row2 = w->ww_i.b; visible = 0; } else visible = 1; @@ -31,10 +32,10 @@ int line; * Fix the buffer. * But leave clearing the last line for wwclreol(). */ - cpp = &w->ww_buf[line]; + cpp = &w->ww_buf[row]; cqq = cpp + 1; cp = *cpp; - for (i = w->ww_nline - line; --i > 0;) + for (i = w->ww_b.b - row; --i > 0;) *cpp++ = *cqq++; *cpp = cp; @@ -42,8 +43,8 @@ int line; * Now clear the last line. */ if (visible) - wwclreol1(w, w->ww_nline - 1, 0, deleted); + wwclreol1(w, w->ww_b.b - 1, w->ww_b.l, deleted); else - for (i = w->ww_w.nc; --i >= 0;) + for (i = w->ww_b.nc; --i >= 0;) cp++->c_w = ' '; } diff --git a/usr/src/usr.bin/window/wwdump.c b/usr/src/usr.bin/window/wwdump.c index 8e871bc846..27c77ef066 100644 --- a/usr/src/usr.bin/window/wwdump.c +++ b/usr/src/usr.bin/window/wwdump.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwdump.c 3.4 83/08/19"; +static char *sccsid = "@(#)wwdump.c 3.5 83/09/15"; #endif #include "ww.h" @@ -14,9 +14,9 @@ register struct ww *w; (*tt.tt_setmodes)(0); (*tt.tt_clear)(); - for (i = 0; i < w->ww_w.nr; i++) { - (*tt.tt_move)(w->ww_w.t + i, w->ww_w.l); - for (j = 0; j < w->ww_w.nc; j++) + for (i = w->ww_i.t; i < w->ww_i.b; i++) { + (*tt.tt_move)(i, w->ww_i.l); + for (j = w->ww_i.l; j < w->ww_i.r; j++) (*tt.tt_putc)(cmap[w->ww_cov[i][j]]); } } @@ -28,9 +28,9 @@ register struct ww *w; (*tt.tt_setmodes)(0); (*tt.tt_clear)(); - for (i = 0; i < w->ww_w.nr; i++) { - (*tt.tt_move)(w->ww_w.t + i, w->ww_w.l); - for (j = 0; j < w->ww_w.nc; j++) + for (i = w->ww_i.t; i < w->ww_i.b; i++) { + (*tt.tt_move)(i, w->ww_i.l); + for (j = w->ww_i.l; j < w->ww_i.r; j++) (*tt.tt_putc)(w->ww_win[i][j] & WWM_COV ? 'C' : ' '); } } @@ -43,7 +43,7 @@ register struct ww *w; (*tt.tt_setmodes)(0); (*tt.tt_clear)(); for (i = 0; i < w->ww_w.nr; i++) { - (*tt.tt_move)(w->ww_w.t + i, w->ww_w.l); + (*tt.tt_move)(i, w->ww_w.l); (*tt.tt_putc)(w->ww_nvis[i] / 100 % 10 + '0'); (*tt.tt_putc)(w->ww_nvis[i] / 10 % 10 + '0'); (*tt.tt_putc)(w->ww_nvis[i] % 10 + '0'); diff --git a/usr/src/usr.bin/window/wwframe.c b/usr/src/usr.bin/window/wwframe.c index 833ae242d8..3c3c71dba9 100644 --- a/usr/src/usr.bin/window/wwframe.c +++ b/usr/src/usr.bin/window/wwframe.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwframe.c 3.9 83/09/14"; +static char *sccsid = "@(#)wwframe.c 3.10 83/09/15"; #endif #include "ww.h" @@ -158,35 +158,29 @@ struct ww *wframe; } } -wwframec(f, rr, cc, code) +wwframec(f, r, c, code) register struct ww *f; -register rr, cc; +register r, c; char code; { - register r, c; char oldcode; - if (rr < f->ww_i.t || rr >= f->ww_i.b - || cc < f->ww_i.l || cc >= f->ww_i.r) + if (r < f->ww_i.t || r >= f->ww_i.b || c < f->ww_i.l || c >= f->ww_i.r) return; { register struct ww *w; - w = wwindex[wwsmap[rr][cc]]; + w = wwindex[wwsmap[r][c]]; if (w->ww_order > f->ww_order) { if (w != &wwnobody) { - r = rr - w->ww_w.t; - c = cc - w->ww_w.l; if ((w->ww_win[r][c] |= WWM_COV) == WWM_COV) w->ww_nvis[r]--; w->ww_cov[r][c] = f->ww_index; } - wwsmap[rr][cc] = f->ww_index; + wwsmap[r][c] = f->ww_index; } } - r = rr - f->ww_w.t; - c = cc - f->ww_w.l; if (f->ww_fmap != 0) { register char *fmap; @@ -199,22 +193,20 @@ char code; } else oldcode = 0; { - { - register char *win = &f->ww_win[r][c]; + register char *win = &f->ww_win[r][c]; - if (*win == WWM_GLS) - f->ww_nvis[r]++; - *win &= ~WWM_GLS; - } - if (oldcode != code && (code & WWF_LABEL) == 0) { - register short frame; - - frame = tt.tt_frame[code & WWF_MASK] & WWC_CMASK; - f->ww_buf[f->ww_scroll + r][c].c_w = frame; - if (wwsmap[rr][cc] == f->ww_index) { - wwtouched[rr] = 1; - wwns[rr][cc].c_w = frame; - } + if (*win == WWM_GLS) + f->ww_nvis[r]++; + *win &= ~WWM_GLS; + } + if (oldcode != code && (code & WWF_LABEL) == 0) { + register short frame; + + frame = tt.tt_frame[code & WWF_MASK] & WWC_CMASK; + f->ww_buf[r][c].c_w = frame; + if (wwsmap[r][c] == f->ww_index) { + wwtouched[r] = 1; + wwns[r][c].c_w = frame; } } } diff --git a/usr/src/usr.bin/window/wwinit.c b/usr/src/usr.bin/window/wwinit.c index 410bbe96fa..f6e738130c 100644 --- a/usr/src/usr.bin/window/wwinit.c +++ b/usr/src/usr.bin/window/wwinit.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwinit.c 3.9 83/08/26"; +static char *sccsid = "@(#)wwinit.c 3.10 83/09/15"; #endif #include "ww.h" @@ -54,21 +54,21 @@ wwinit() else if (wwavailmodes & WWM_UL) wwcursormodes = WWM_UL; - if ((wwsmap = wwalloc(wwnrow, wwncol, sizeof (char))) == 0) + if ((wwsmap = wwalloc(0, 0, wwnrow, wwncol, sizeof (char))) == 0) goto bad; for (i = 0; i < wwnrow; i++) for (j = 0; j < wwncol; j++) wwsmap[i][j] = WWX_NOBODY; wwos = (union ww_char **) - wwalloc(wwnrow, wwncol, sizeof (union ww_char)); + wwalloc(0, 0, wwnrow, wwncol, sizeof (union ww_char)); if (wwos == 0) goto bad; for (i = 0; i < wwnrow; i++) for (j = 0; j < wwncol; j++) wwos[i][j].c_w = ' '; wwns = (union ww_char **) - wwalloc(wwnrow, wwncol, sizeof (union ww_char)); + wwalloc(0, 0, wwnrow, wwncol, sizeof (union ww_char)); if (wwns == 0) goto bad; for (i = 0; i < wwnrow; i++) diff --git a/usr/src/usr.bin/window/wwinschar.c b/usr/src/usr.bin/window/wwinschar.c index 3f81496e67..ddf22cbd47 100644 --- a/usr/src/usr.bin/window/wwinschar.c +++ b/usr/src/usr.bin/window/wwinschar.c @@ -1,18 +1,15 @@ #ifndef lint -static char *sccsid = "@(#)wwinschar.c 3.7 83/09/14"; +static char *sccsid = "@(#)wwinschar.c 3.8 83/09/15"; #endif #include "ww.h" #include "tt.h" -wwinschar(w, line, col, c) +wwinschar(w, row, col, c) register struct ww *w; short c; { register i; - int row = line - w->ww_scroll; - int srow = row + w->ww_w.t; - int scol = col + w->ww_w.l; int nvis; /* @@ -21,9 +18,9 @@ short c; { register union ww_char *p, *q; - p = &w->ww_buf[line][w->ww_w.nc]; + p = &w->ww_buf[row][w->ww_b.r]; q = p - 1; - for (i = w->ww_w.nc - col - 1; --i >= 0;) + for (i = w->ww_b.r - col; --i > 0;) *--p = *--q; q->c_w = c; } @@ -31,13 +28,12 @@ short c; /* * If can't see it, just return. */ - if (srow < w->ww_i.t || srow >= w->ww_i.b - || w->ww_i.r <= 0 || w->ww_i.r <= scol) + if (row < w->ww_i.t || row >= w->ww_i.b + || w->ww_i.r <= 0 || w->ww_i.r <= col) return; - if (scol < w->ww_i.l) - scol = w->ww_i.l; - col = scol - w->ww_w.l; + if (col < w->ww_i.l) + col = w->ww_i.l; /* * Now find out how much is actually changed, and fix wwns. @@ -50,15 +46,15 @@ short c; char *touched; nvis = 0; - smap = &wwsmap[srow][scol]; - for (i = w->ww_i.r - scol; i > 0 && *smap++ != w->ww_index; i--) - col++, scol++; + smap = &wwsmap[row][col]; + for (i = w->ww_i.r - col; i > 0 && *smap++ != w->ww_index; i--) + col++; if (i <= 0) return; - buf = &w->ww_buf[line][col]; + buf = &w->ww_buf[row][col]; win = &w->ww_win[row][col]; - ns = &wwns[srow][scol]; - touched = &wwtouched[srow]; + ns = &wwns[row][col]; + touched = &wwtouched[row]; c = buf->c_w ^ *win << WWC_MSHIFT; for (; --i >= 0;) { if (*win) { @@ -82,18 +78,18 @@ short c; /* * Can/Should we use delete character? */ - if (tt.tt_setinsert != 0 && nvis > (wwncol - scol) / 2) { + if (tt.tt_setinsert != 0 && nvis > (wwncol - col) / 2) { register union ww_char *p, *q; (*tt.tt_setinsert)(1); - (*tt.tt_move)(srow, scol); + (*tt.tt_move)(row, col); (*tt.tt_setmodes)(c >> WWC_MSHIFT); (*tt.tt_putc)(c & WWC_CMASK); (*tt.tt_setinsert)(0); - p = &wwos[srow][wwncol]; + p = &wwos[row][wwncol]; q = p - 1; - for (i = wwncol - scol; --i > 0;) + for (i = wwncol - col; --i > 0;) *--p = *--q; q->c_w = c; } diff --git a/usr/src/usr.bin/window/wwinsline.c b/usr/src/usr.bin/window/wwinsline.c index 79fc6bb299..5eb7c85b7c 100644 --- a/usr/src/usr.bin/window/wwinsline.c +++ b/usr/src/usr.bin/window/wwinsline.c @@ -1,40 +1,41 @@ #ifndef lint -static char *sccsid = "@(#)wwinsline.c 3.4 83/09/14"; +static char *sccsid = "@(#)wwinsline.c 3.5 83/09/15"; #endif #include "ww.h" -wwinsline(w, line) +wwinsline(w, row) register struct ww *w; -int line; +int row; { register i; register union ww_char **cpp, **cqq; register union ww_char *cp; - int row11, row2; + int row1, row2; char deleted; int visible; /* * Scroll first. */ - if ((row11 = line - w->ww_scroll) < w->ww_i.t - w->ww_w.t) { - row11 = 0; + if ((row1 = row) < w->ww_i.t) { + row1 = w->ww_i.t; visible = 0; } else visible = 1; - if ((row2 = w->ww_nline - w->ww_scroll) > w->ww_i.b - w->ww_w.t) - row2 = w->ww_i.b - w->ww_w.t; - deleted = wwscroll1(w, row11, row2, -1, visible); + if ((row2 = w->ww_b.b) > w->ww_i.b) { + row2 = w->ww_i.b; + } + deleted = wwscroll1(w, row1, row2, -1, visible); /* * Fix the buffer. * But leave clearing the last line for wwclreol(). */ - cpp = &w->ww_buf[w->ww_nline]; + cpp = &w->ww_buf[w->ww_b.b]; cqq = cpp - 1; cp = *cqq; - for (i = w->ww_nline - line - 1; --i >= 0;) + for (i = w->ww_b.b - row; --i > 0;) *--cpp = *--cqq; *cqq = cp; @@ -42,8 +43,8 @@ int line; * Now clear the last line. */ if (visible) - wwclreol1(w, line, 0, deleted); + wwclreol1(w, row, w->ww_b.l, deleted); else - for (i = w->ww_w.nc; --i >= 0;) + for (i = w->ww_b.nc; --i >= 0;) cp++->c_w = ' '; } diff --git a/usr/src/usr.bin/window/wwlabel.c b/usr/src/usr.bin/window/wwlabel.c index edbf234e73..7dbef97dd3 100644 --- a/usr/src/usr.bin/window/wwlabel.c +++ b/usr/src/usr.bin/window/wwlabel.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwlabel.c 3.6 83/08/26"; +static char *sccsid = "@(#)wwlabel.c 3.7 83/09/15"; #endif #include "ww.h" @@ -26,22 +26,18 @@ char *l; if (f->ww_fmap == 0) return; - i = w->ww_w.t - 1 - f->ww_w.t; - if (i < 0) + i = w->ww_w.t - 1; + if (i < f->ww_i.t || i >= f->ww_i.b) return; - j = w->ww_w.l + where - f->ww_w.l; - if (j < 0) - j = 0; + j = w->ww_i.l + where; win = &f->ww_win[i][j]; - buf = &f->ww_buf[f->ww_scroll + i][j]; + buf = &f->ww_buf[i][j]; fmap = &f->ww_fmap[i][j]; - i += f->ww_w.t; - j += f->ww_w.l; ns = &wwns[i][j]; touched = &wwtouched[i]; - j = MIN(w->ww_w.r, f->ww_w.r) - j; + j = MIN(w->ww_i.r, f->ww_i.r) - j; for (; j > 0 && *l;) for (p = unctrl(*l++); j > 0 && *p; j--) { /* can't label if not already framed */ diff --git a/usr/src/usr.bin/window/wwmisc.c b/usr/src/usr.bin/window/wwmisc.c index 5c1e04900d..aee47d969a 100644 --- a/usr/src/usr.bin/window/wwmisc.c +++ b/usr/src/usr.bin/window/wwmisc.c @@ -1,11 +1,11 @@ #ifndef lint -static char *sccsid = "@(#)wwmisc.c 3.2 83/09/02"; +static char *sccsid = "@(#)wwmisc.c 3.3 83/09/15"; #endif #include "ww.h" /* - * Sufficient but necessary test for total visibility. + * Sufficient but not necessary test for total visibility. */ wwvisible(w) register struct ww *w; @@ -13,11 +13,14 @@ register struct ww *w; register i; register nvis = 0; - for (i = 0; i < w->ww_w.nr; i++) + for (i = w->ww_i.t; i < w->ww_i.b; i++) nvis += w->ww_nvis[i]; - if (w->ww_hascursor && wwsmap[wwcurrow(w)][wwcurcol(w)] == w->ww_index) + if (w->ww_hascursor + && w->ww_cur.r >= w->ww_i.b && w->ww_cur.r < w->ww_i.t + && w->ww_cur.c >= w->ww_i.l && w->ww_cur.c < w->ww_i.r + && wwsmap[w->ww_cur.r][w->ww_cur.c] == w->ww_index) nvis++; - return nvis == w->ww_w.nr * w->ww_w.nc; + return nvis == w->ww_i.nr * w->ww_i.nc; } char * diff --git a/usr/src/usr.bin/window/wwmove.c b/usr/src/usr.bin/window/wwmove.c index 3a961b709a..17fdc1cc15 100644 --- a/usr/src/usr.bin/window/wwmove.c +++ b/usr/src/usr.bin/window/wwmove.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwmove.c 3.1 83/09/14"; +static char *sccsid = "@(#)wwmove.c 3.2 83/09/15"; #endif #include "ww.h" @@ -10,13 +10,24 @@ static char *sccsid = "@(#)wwmove.c 3.1 83/09/14"; wwmove(w, row, col) register struct ww *w; { + register dr, dc; + register i; + if (w->ww_forw != 0 || w->ww_back != 0) return; /* sanity */ - w->ww_w.t = row; - w->ww_w.b = w->ww_w.t + w->ww_w.nr; - w->ww_w.l = col; - w->ww_w.r = w->ww_w.l + w->ww_w.nc; + dr = row - w->ww_w.t; + dc = col - w->ww_w.l; + + w->ww_w.t += dr; + w->ww_w.b += dr; + w->ww_w.l += dc; + w->ww_w.r += dc; + + w->ww_b.t += dr; + w->ww_b.b += dr; + w->ww_b.l += dc; + w->ww_b.r += dc; w->ww_i.t = MAX(w->ww_w.t, 0); w->ww_i.b = MIN(w->ww_w.b, wwnrow); @@ -24,4 +35,23 @@ register struct ww *w; w->ww_i.l = MAX(w->ww_w.l, 0); w->ww_i.r = MIN(w->ww_w.r, wwncol); w->ww_i.nc = w->ww_i.r - w->ww_i.l; + + w->ww_cur.r += dr; + w->ww_cur.c += dc; + + w->ww_win -= dr; + for (i = w->ww_w.t; i < w->ww_w.b; i++) + w->ww_win[i] -= dc; + w->ww_cov -= dr; + for (i = w->ww_w.t; i < w->ww_w.b; i++) + w->ww_cov[i] -= dc; + if (w->ww_fmap != 0) { + w->ww_fmap -= dr; + for (i = w->ww_w.t; i < w->ww_w.b; i++) + w->ww_fmap[i] -= dc; + } + w->ww_nvis -= dr; + w->ww_buf -= dr; + for (i = w->ww_b.t; i < w->ww_b.b; i++) + w->ww_buf[i] -= dc; } diff --git a/usr/src/usr.bin/window/wwopen.c b/usr/src/usr.bin/window/wwopen.c index 39abe3b335..09d4574b53 100644 --- a/usr/src/usr.bin/window/wwopen.c +++ b/usr/src/usr.bin/window/wwopen.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwopen.c 3.11 83/09/14"; +static char *sccsid = "@(#)wwopen.c 3.12 83/09/15"; #endif #include "ww.h" @@ -26,12 +26,23 @@ wwopen(flags, nrow, ncol, row, col, nline) } w->ww_index = i; + if (nline < nrow) + nline = nrow; + w->ww_w.t = row; w->ww_w.b = row + nrow; w->ww_w.l = col; w->ww_w.r = col + ncol; w->ww_w.nr = nrow; w->ww_w.nc = ncol; + + w->ww_b.t = row; + w->ww_b.b = row + nline; + w->ww_b.l = col; + w->ww_b.r = col + ncol; + w->ww_b.nr = nline; + w->ww_b.nc = ncol; + w->ww_i.t = MAX(w->ww_w.t, 0); w->ww_i.b = MIN(w->ww_w.b, wwnrow); w->ww_i.l = MAX(w->ww_w.l, 0); @@ -39,7 +50,8 @@ wwopen(flags, nrow, ncol, row, col, nline) w->ww_i.nr = w->ww_i.b - w->ww_i.t; w->ww_i.nc = w->ww_i.r - w->ww_i.l; - w->ww_nline = MAX(nline, w->ww_w.nr); + w->ww_cur.r = w->ww_w.t; + w->ww_cur.c = w->ww_w.l; if (flags & WWO_PTY) { if (wwgetpty(w) < 0) @@ -49,7 +61,8 @@ wwopen(flags, nrow, ncol, row, col, nline) goto bad; } - w->ww_win = wwalloc(w->ww_w.nr, w->ww_w.nc, sizeof (char)); + w->ww_win = wwalloc(w->ww_w.t, w->ww_w.l, + w->ww_w.nr, w->ww_w.nc, sizeof (char)); if (w->ww_win == 0) goto bad; m = 0; @@ -57,32 +70,35 @@ wwopen(flags, nrow, ncol, row, col, nline) m |= WWM_GLS; if (flags & WWO_REVERSE) m |= WWM_REV; - for (i = 0; i < w->ww_w.nr; i++) - for (j = 0; j < w->ww_w.nc; j++) + for (i = w->ww_w.t; i < w->ww_w.b; i++) + for (j = w->ww_w.l; j < w->ww_w.r; j++) w->ww_win[i][j] = m; - w->ww_cov = wwalloc(w->ww_w.nr, w->ww_w.nc, sizeof (char)); + w->ww_cov = wwalloc(w->ww_w.t, w->ww_w.l, + w->ww_w.nr, w->ww_w.nc, sizeof (char)); if (w->ww_cov == 0) goto bad; - for (i = 0; i < w->ww_w.nr; i++) - for (j = 0; j < w->ww_w.nc; j++) + for (i = w->ww_w.t; i < w->ww_w.b; i++) + for (j = w->ww_w.l; j < w->ww_w.r; j++) w->ww_cov[i][j] = WWX_NOBODY; if (flags & WWO_FRAME) { - w->ww_fmap = wwalloc(w->ww_w.nr, w->ww_w.nc, sizeof (char)); + w->ww_fmap = wwalloc(w->ww_w.t, w->ww_w.l, + w->ww_w.nr, w->ww_w.nc, sizeof (char)); if (w->ww_fmap == 0) wwerrno = WWE_NOMEM; - for (i = 0; i < wwnrow; i++) - for (j = 0; j < wwncol; j++) + for (i = w->ww_w.t; i < w->ww_w.b; i++) + for (j = w->ww_w.l; j < w->ww_w.r; j++) w->ww_fmap[i][j] = 0; } w->ww_buf = (union ww_char **) - wwalloc(w->ww_nline, w->ww_w.nc, sizeof (union ww_char)); + wwalloc(w->ww_b.t, w->ww_b.l, + w->ww_b.nr, w->ww_b.nc, sizeof (union ww_char)); if (w->ww_buf == 0) goto bad; - for (i = 0; i < w->ww_nline; i++) - for (j = 0; j < w->ww_w.nc; j++) + for (i = w->ww_b.t; i < w->ww_b.b; i++) + for (j = w->ww_b.l; j < w->ww_b.r; j++) w->ww_buf[i][j].c_w = ' '; w->ww_nvis = (short *)malloc((unsigned) w->ww_w.nr * sizeof (short)); @@ -90,8 +106,9 @@ wwopen(flags, nrow, ncol, row, col, nline) wwerrno = WWE_NOMEM; goto bad; } + w->ww_nvis -= w->ww_w.t; nvis = m ? 0 : w->ww_w.nc; - for (i = 0; i < w->ww_w.nr; i++) + for (i = w->ww_w.t; i < w->ww_w.b; i++) w->ww_nvis[i] = nvis; w->ww_state = WWS_INITIAL; @@ -99,15 +116,15 @@ wwopen(flags, nrow, ncol, row, col, nline) bad: if (w != 0) { if (w->ww_win != 0) - wwfree(w->ww_win); + wwfree(w->ww_win, w->ww_w.t); if (w->ww_cov != 0) - wwfree(w->ww_cov); + wwfree(w->ww_cov, w->ww_w.t); if (w->ww_fmap != 0) - wwfree(w->ww_fmap); + wwfree(w->ww_fmap, w->ww_w.t); if (w->ww_buf != 0) - wwfree((char **)w->ww_buf); + wwfree((char **)w->ww_buf, w->ww_b.t); if (w->ww_nvis != 0) - free((char *)w->ww_nvis); + free((char *)(w->ww_nvis + w->ww_w.t)); if (w->ww_haspty) { (void) close(w->ww_tty); (void) close(w->ww_pty); diff --git a/usr/src/usr.bin/window/wwredrawwin.c b/usr/src/usr.bin/window/wwredrawwin.c index 2d684ab9a3..4e8045f7c3 100644 --- a/usr/src/usr.bin/window/wwredrawwin.c +++ b/usr/src/usr.bin/window/wwredrawwin.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwredrawwin.c 3.4 83/09/14"; +static char *sccsid = "@(#)wwredrawwin.c 3.5 83/09/15"; #endif #include "ww.h" @@ -7,13 +7,12 @@ static char *sccsid = "@(#)wwredrawwin.c 3.4 83/09/14"; wwredrawwin(w) register struct ww *w; { - wwredrawwin1(w, w->ww_i.t - w->ww_w.t, w->ww_i.b - w->ww_w.t, - w->ww_scroll); + wwredrawwin1(w, w->ww_i.t, w->ww_i.b, 0); } -wwredrawwin1(w, row1, row2, scroll) +wwredrawwin1(w, row1, row2, offset) register struct ww *w; -int row1, row2, scroll; +int row1, row2, offset; { int i; register j; @@ -23,12 +22,12 @@ int row1, row2, scroll; register union ww_char *ns; char *touched; - touched = &wwtouched[row1 + w->ww_w.t]; + touched = &wwtouched[row1]; for (i = row1; i < row2; i++, touched++) { - ns = &wwns[i + w->ww_w.t][w->ww_i.l]; - smap = &wwsmap[i + w->ww_w.t][w->ww_i.l]; - buf = &w->ww_buf[scroll + i][w->ww_i.l - w->ww_w.l]; - win = &w->ww_win[i][w->ww_i.l - w->ww_w.l]; + ns = &wwns[i][w->ww_i.l]; + smap = &wwsmap[i][w->ww_i.l]; + buf = &w->ww_buf[i + offset][w->ww_i.l]; + win = &w->ww_win[i][w->ww_i.l]; for (j = w->ww_i.nc; --j >= 0;) if (*smap++ != w->ww_index) win++, ns++, buf++; diff --git a/usr/src/usr.bin/window/wwscroll.c b/usr/src/usr.bin/window/wwscroll.c index e2f4f828f5..9e6936c118 100644 --- a/usr/src/usr.bin/window/wwscroll.c +++ b/usr/src/usr.bin/window/wwscroll.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwscroll.c 3.9 83/09/14"; +static char *sccsid = "@(#)wwscroll.c 3.10 83/09/15"; #endif #include "ww.h" @@ -7,28 +7,31 @@ static char *sccsid = "@(#)wwscroll.c 3.9 83/09/14"; wwscroll(w, n) register struct ww *w; -register n; +int n; { - int dir; - register scroll; + register dir; + register top; if (n == 0) return; dir = n < 0 ? -1 : 1; - scroll = w->ww_scroll + n; - if (scroll < 0) - scroll = 0; - else if (scroll > w->ww_nline - w->ww_w.nr) - scroll = w->ww_nline - w->ww_w.nr; - n = abs(scroll - w->ww_scroll); + top = w->ww_b.t - n; + if (top > w->ww_w.t) + top = w->ww_w.t; + else if (top + w->ww_b.nr < w->ww_w.b) + top = w->ww_w.b - w->ww_b.nr; + n = abs(top - w->ww_b.t); if (n < w->ww_i.nr) { while (--n >= 0) { - (void) wwscroll1(w, w->ww_i.t - w->ww_w.t, - w->ww_i.b - w->ww_w.t, dir, 0); - w->ww_scroll += dir; + (void) wwscroll1(w, w->ww_i.t, w->ww_i.b, dir, 0); + w->ww_buf += dir; + w->ww_b.t -= dir; + w->ww_b.b -= dir; } } else { - w->ww_scroll = scroll; + w->ww_buf -= top - w->ww_b.t; + w->ww_b.t = top; + w->ww_b.b = top + w->ww_b.nr; wwredrawwin(w); } } @@ -85,42 +88,40 @@ int leaveit; * But do worry when scrolling up. For hp2621. */ if (dir > 0) { - (*tt.tt_move)(row1x + w->ww_w.t, 0); + (*tt.tt_move)(row1x, 0); (*tt.tt_delline)(); - if (row2x + w->ww_w.t < wwnrow) { - (*tt.tt_move)(row2x + w->ww_w.t - 1, 0); + if (row2x < wwnrow) { + (*tt.tt_move)(row2x - 1, 0); (*tt.tt_insline)(); } /* * Fix up the old screen. */ - cpp = &wwos[row1x + w->ww_w.t]; + cpp = &wwos[row1x]; cqq = cpp + 1; tmp = *cpp; for (i = row2x - row1x; --i > 0;) *cpp++ = *cqq++; *cpp = tmp; - for (i = wwncol; --i >= 0;) - tmp++->c_w = ' '; } else { - if (tt.tt_retain || row2x + w->ww_w.t != wwnrow) { - (*tt.tt_move)(row2x + w->ww_w.t - 1, 0); + if (tt.tt_retain || row2x != wwnrow) { + (*tt.tt_move)(row2x - 1, 0); (*tt.tt_delline)(); } - (*tt.tt_move)(row1x + w->ww_w.t, 0); + (*tt.tt_move)(row1x, 0); (*tt.tt_insline)(); /* * Fix up the old screen. */ - cpp = &wwos[row2x + w->ww_w.t]; + cpp = &wwos[row2x]; cqq = cpp - 1; tmp = *cqq; for (i = row2x - row1x; --i > 0;) *--cpp = *--cqq; *cqq = tmp; - for (i = wwncol; --i >= 0;) - tmp++->c_w = ' '; } + for (i = wwncol; --i >= 0;) + tmp++->c_w = ' '; deleted++; } @@ -136,7 +137,7 @@ int leaveit; register union ww_char *tmp; register union ww_char **cpp, **cqq; - cpp = &wwns[row1x + w->ww_w.t]; + cpp = &wwns[row1x]; cqq = cpp + 1; tmp = *cpp; for (i = row2x - row1x; --i > 0;) @@ -146,7 +147,7 @@ int leaveit; if (deleted) { register char *p, *q; - p = &wwtouched[row1x + w->ww_w.t]; + p = &wwtouched[row1x]; q = p + 1; for (i = row2x - row1x; --i > 0;) *p++ = *q++; @@ -154,19 +155,18 @@ int leaveit; } else { register char *p; - p = &wwtouched[row1x + w->ww_w.t]; + p = &wwtouched[row1x]; for (i = row2x - row1x; --i >= 0;) *p++ = 1; } - wwredrawwin1(w, row1, row1x, w->ww_scroll + dir); - wwredrawwin1(w, row2x - 1, row2 - leaveit, - w->ww_scroll + dir); + wwredrawwin1(w, row1, row1x, dir); + wwredrawwin1(w, row2x - 1, row2 - leaveit, dir); } else { { register union ww_char *tmp; register union ww_char **cpp, **cqq; - cpp = &wwns[row2x + w->ww_w.t]; + cpp = &wwns[row2x]; cqq = cpp - 1; tmp = *cqq; for (i = row2x - row1x; --i > 0;) @@ -176,7 +176,7 @@ int leaveit; if (deleted) { register char *p, *q; - p = &wwtouched[row2x + w->ww_w.t]; + p = &wwtouched[row2x]; q = p - 1; for (i = row2x - row1x; --i > 0;) *--p = *--q; @@ -184,22 +184,19 @@ int leaveit; } else { register char *p; - p = &wwtouched[row1x + w->ww_w.t]; + p = &wwtouched[row1x]; for (i = row2x - row1x; --i >= 0;) *p++ = 1; } - wwredrawwin1(w, row1 + leaveit, row1x - 1, - w->ww_scroll + dir); - wwredrawwin1(w, row2x, row2, w->ww_scroll + dir); + wwredrawwin1(w, row1 + leaveit, row1x + 1, dir); + wwredrawwin1(w, row2x, row2, dir); } } else { out: if (dir > 0) - wwredrawwin1(w, row1, row2 - leaveit, - w->ww_scroll + dir); + wwredrawwin1(w, row1, row2 - leaveit, dir); else - wwredrawwin1(w, row1 + leaveit, row2, - w->ww_scroll + dir); + wwredrawwin1(w, row1 + leaveit, row2, dir); } return deleted; } diff --git a/usr/src/usr.bin/window/wwunframe.c b/usr/src/usr.bin/window/wwunframe.c index 5de0d34c45..2b8bf2051b 100644 --- a/usr/src/usr.bin/window/wwunframe.c +++ b/usr/src/usr.bin/window/wwunframe.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwunframe.c 3.7 83/08/19"; +static char *sccsid = "@(#)wwunframe.c 3.8 83/09/15"; #endif #include "ww.h" @@ -12,11 +12,12 @@ register struct ww *w; register char *fmap; register struct ww *wp; - for (i = w->ww_w.t; i < w->ww_w.b; i++) { - win = w->ww_win[i - w->ww_w.t]; + for (i = w->ww_i.t; i < w->ww_i.b; i++) { + j = w->ww_i.l; + win = &w->ww_win[i][j]; if (w->ww_fmap) - fmap = w->ww_fmap[i]; - for (j = w->ww_w.l; j < w->ww_w.r; j++) { + fmap = &w->ww_fmap[i][j]; + for (; j < w->ww_i.r; j++) { if (*win & WWM_GLS) { win++; fmap++; diff --git a/usr/src/usr.bin/window/wwwrite.c b/usr/src/usr.bin/window/wwwrite.c index a6e8baee55..26b86a75ab 100644 --- a/usr/src/usr.bin/window/wwwrite.c +++ b/usr/src/usr.bin/window/wwwrite.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwwrite.c 3.10 83/09/14"; +static char *sccsid = "@(#)wwwrite.c 3.11 83/09/15"; #endif #include "ww.h" @@ -18,47 +18,49 @@ int n; while (n > 0) { if (w->ww_wstate == 0 && !ISCTRL(*p)) { register i; - int crow, ccol; register union ww_char *bp; union ww_char *bq; + int col; if (w->ww_insert) { n--; - wwinschar(w, w->ww_scroll + w->ww_cur.r, - w->ww_cur.c, + wwinschar(w, w->ww_cur.r, w->ww_cur.c, *p++ | w->ww_modes << WWC_MSHIFT); goto right; } - bp = bq = &w->ww_buf[w->ww_scroll+w->ww_cur.r] - [w->ww_cur.c]; - if ((i = w->ww_w.nc - w->ww_cur.c) > n) + bp = bq = &w->ww_buf[w->ww_cur.r][w->ww_cur.c]; + if ((i = w->ww_b.r - w->ww_cur.c) > n) i = n; while (--i >= 0 && !ISCTRL(*p)) bp++->c_w = *p++ | w->ww_modes << WWC_MSHIFT; + i = bp - bq; n -= i; + col = w->ww_cur.c; + w->ww_cur.c += i; bp = bq; - - crow = wwcurrow(w); - ccol = wwcurcol(w); - if (ccol < w->ww_i.l) { - bp += w->ww_i.l - ccol; - ccol = w->ww_i.l; + if (col < w->ww_i.l) { + /* use col as a temporary */ + col = w->ww_i.l - col; + bp += col; + i -= col; + col = w->ww_i.l; } - w->ww_cur.c += i; - if (crow >= w->ww_i.t && crow < w->ww_i.b) { + if (i > w->ww_i.r - col) + i = w->ww_i.r - col; + + if (w->ww_cur.r >= w->ww_i.t && w->ww_cur.r < w->ww_i.b) + { register union ww_char *ns; register char *smap; register char *win; char *touched; - win = &w->ww_win[w->ww_cur.r][ccol - w->ww_w.l]; - smap = &wwsmap[crow][ccol]; - ns = &wwns[crow][ccol]; - touched = &wwtouched[crow]; - if (i > w->ww_i.r - ccol) - i = w->ww_i.r - ccol; + win = &w->ww_win[w->ww_cur.r][col]; + smap = &wwsmap[w->ww_cur.r][col]; + ns = &wwns[w->ww_cur.r][col]; + touched = &wwtouched[w->ww_cur.r]; while (--i >= 0) if (*smap++ == w->ww_index) { *touched = 1; @@ -70,8 +72,8 @@ int n; win++; } } - if (w->ww_cur.c >= w->ww_w.nc) { - w->ww_cur.c = 0; + if (w->ww_cur.c >= w->ww_w.r) { + w->ww_cur.c = w->ww_w.l; goto lf; } continue; @@ -82,33 +84,32 @@ int n; switch (*p++) { case '\n': if (w->ww_mapnl) - w->ww_cur.c = 0; + w->ww_cur.c = w->ww_w.l; lf: - if (++w->ww_cur.r >= w->ww_w.nr) { - w->ww_cur.r = w->ww_w.nr - 1; - if (w->ww_scroll + w->ww_w.nr - < w->ww_nline) + if (++w->ww_cur.r >= w->ww_w.b) { + w->ww_cur.r = w->ww_w.b - 1; + if (w->ww_w.b < w->ww_b.b) wwscroll(w, 1); else - wwdelline(w, 0); + wwdelline(w, w->ww_b.t); } break; case '\t': - w->ww_cur.c |= 7; - right: - if (++w->ww_cur.c >= w->ww_w.nc) { - w->ww_cur.c = 0; + w->ww_cur.c += + 8 - (w->ww_cur.c - w->ww_w.l & 7); + if (w->ww_cur.c >= w->ww_w.r) { + w->ww_cur.c = w->ww_w.l; goto lf; } break; case '\b': - if (--w->ww_cur.c < 0) { - w->ww_cur.c = w->ww_w.nc - 1; + if (--w->ww_cur.c < w->ww_w.l) { + w->ww_cur.c = w->ww_w.r - 1; goto up; } break; case '\r': - w->ww_cur.c = 0; + w->ww_cur.c = w->ww_w.l; break; case CTRL(g): wwbell(); @@ -126,43 +127,48 @@ int n; break; case 'A': up: - if (--w->ww_cur.r < 0) { - w->ww_cur.r = 0; - if (w->ww_scroll > 0) + if (--w->ww_cur.r < w->ww_w.t) { + w->ww_cur.r = w->ww_w.t; + if (w->ww_w.t > w->ww_b.t) wwscroll(w, -1); else - wwinsline(w, 0); + wwinsline(w, w->ww_b.t); } break; case 'B': goto lf; case 'C': - goto right; + right: + if (++w->ww_cur.c >= w->ww_w.r) { + w->ww_cur.c = w->ww_w.l; + goto lf; + } + break; case 'E': - w->ww_scroll = 0; - w->ww_cur.c = w->ww_cur.r = 0; - wwclreos(w, 0, 0); + w->ww_b.t = w->ww_w.t; + w->ww_b.b = w->ww_b.t + w->ww_b.nr; + w->ww_cur.r = w->ww_w.t; + w->ww_cur.c = w->ww_w.l; + wwclreos(w, w->ww_w.t, w->ww_w.l); break; case 'H': - w->ww_cur.c = w->ww_cur.r = 0; + w->ww_cur.r = w->ww_w.t; + w->ww_cur.c = w->ww_w.l; break; case 'J': - wwclreos(w, w->ww_scroll + w->ww_cur.r, - w->ww_cur.c); + wwclreos(w, w->ww_cur.r, w->ww_cur.c); break; case 'K': - wwclreol(w, w->ww_scroll + w->ww_cur.r, - w->ww_cur.c); + wwclreol(w, w->ww_cur.r, w->ww_cur.c); break; case 'L': - wwinsline(w, w->ww_scroll + w->ww_cur.r); + wwinsline(w, w->ww_cur.r); break; case 'M': - wwdelline(w, w->ww_scroll + w->ww_cur.r); + wwdelline(w, w->ww_cur.r); break; case 'N': - wwdelchar(w, w->ww_scroll + w->ww_cur.r, - w->ww_cur.c); + wwdelchar(w, w->ww_cur.r, w->ww_cur.c); break; case 'O': w->ww_insert = 0; @@ -185,11 +191,11 @@ int n; } break; case 2: - w->ww_cur.r = (*p++ - ' ') % w->ww_w.nr; - w->ww_wstate++; + w->ww_cur.r = w->ww_w.t + (*p++ - ' ') % w->ww_w.nr; + w->ww_wstate = 3; break; case 3: - w->ww_cur.c = (*p++ - ' ') % w->ww_w.nc; + w->ww_cur.c = w->ww_w.l + (*p++ - ' ') % w->ww_w.nc; w->ww_wstate = 0; break; } -- 2.20.1