Converted to new data structures.
authorElan Amir <elan@ucbvax.Berkeley.EDU>
Tue, 15 Sep 1992 02:00:46 +0000 (18:00 -0800)
committerElan Amir <elan@ucbvax.Berkeley.EDU>
Tue, 15 Sep 1992 02:00:46 +0000 (18:00 -0800)
SCCS-vsn: lib/libcurses/addbytes.c 5.9
SCCS-vsn: lib/libcurses/box.c 5.6
SCCS-vsn: lib/libcurses/clear.c 5.6
SCCS-vsn: lib/libcurses/clrtobot.c 5.7
SCCS-vsn: lib/libcurses/clrtoeol.c 5.6
SCCS-vsn: lib/libcurses/cr_put.c 5.9
SCCS-vsn: lib/libcurses/curses.h 5.13
SCCS-vsn: lib/libcurses/delch.c 5.7
SCCS-vsn: lib/libcurses/deleteln.c 5.8
SCCS-vsn: lib/libcurses/delwin.c 5.7
SCCS-vsn: lib/libcurses/erase.c 5.6
SCCS-vsn: lib/libcurses/getch.c 5.8
SCCS-vsn: lib/libcurses/getstr.c 5.6
SCCS-vsn: lib/libcurses/id_subwins.c 5.7
SCCS-vsn: lib/libcurses/idlok.c 5.6
SCCS-vsn: lib/libcurses/initscr.c 5.8
SCCS-vsn: lib/libcurses/insch.c 5.6
SCCS-vsn: lib/libcurses/insertln.c 5.7
SCCS-vsn: lib/libcurses/move.c 5.7
SCCS-vsn: lib/libcurses/mvwin.c 5.6
SCCS-vsn: lib/libcurses/newwin.c 5.7
SCCS-vsn: lib/libcurses/overlay.c 5.8
SCCS-vsn: lib/libcurses/overwrite.c 5.7
SCCS-vsn: lib/libcurses/refresh.c 5.9
SCCS-vsn: lib/libcurses/scroll.c 5.7
SCCS-vsn: lib/libcurses/setterm.c 5.10
SCCS-vsn: lib/libcurses/standout.c 5.6
SCCS-vsn: lib/libcurses/toucholap.c 5.7
SCCS-vsn: lib/libcurses/touchwin.c 5.6
SCCS-vsn: lib/libcurses/ctrace.c 5.2
SCCS-vsn: lib/libcurses/tty.c 5.3

31 files changed:
usr/src/lib/libcurses/addbytes.c
usr/src/lib/libcurses/box.c
usr/src/lib/libcurses/clear.c
usr/src/lib/libcurses/clrtobot.c
usr/src/lib/libcurses/clrtoeol.c
usr/src/lib/libcurses/cr_put.c
usr/src/lib/libcurses/ctrace.c
usr/src/lib/libcurses/curses.h
usr/src/lib/libcurses/delch.c
usr/src/lib/libcurses/deleteln.c
usr/src/lib/libcurses/delwin.c
usr/src/lib/libcurses/erase.c
usr/src/lib/libcurses/getch.c
usr/src/lib/libcurses/getstr.c
usr/src/lib/libcurses/id_subwins.c
usr/src/lib/libcurses/idlok.c
usr/src/lib/libcurses/initscr.c
usr/src/lib/libcurses/insch.c
usr/src/lib/libcurses/insertln.c
usr/src/lib/libcurses/move.c
usr/src/lib/libcurses/mvwin.c
usr/src/lib/libcurses/newwin.c
usr/src/lib/libcurses/overlay.c
usr/src/lib/libcurses/overwrite.c
usr/src/lib/libcurses/refresh.c
usr/src/lib/libcurses/scroll.c
usr/src/lib/libcurses/setterm.c
usr/src/lib/libcurses/standout.c
usr/src/lib/libcurses/toucholap.c
usr/src/lib/libcurses/touchwin.c
usr/src/lib/libcurses/tty.c

index 104b4bd..43ff644 100644 (file)
@@ -6,14 +6,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)addbytes.c 5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)addbytes.c 5.9 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #include <termios.h>
 
 #endif /* not lint */
 
 #include <curses.h>
 #include <termios.h>
 
-#define        SYNCH_IN        {y = win->_cury; x = win->_curx;}
-#define        SYNCH_OUT       {win->_cury = y; win->_curx = x;}
+#define        SYNCH_IN        {y = win->cury; x = win->curx;}
+#define        SYNCH_OUT       {win->cury = y; win->curx = x;}
 
 /*
  * waddbytes --
 
 /*
  * waddbytes --
@@ -27,6 +27,7 @@ waddbytes(win, bytes, count)
 {
        static char blanks[] = "        ";
        register int c, newx, x, y;
 {
        static char blanks[] = "        ";
        register int c, newx, x, y;
+       LINE *lp;
 
        SYNCH_IN;
 
 
        SYNCH_IN;
 
@@ -46,34 +47,37 @@ waddbytes(win, bytes, count)
                default:
 #ifdef DEBUG
        __TRACE("ADDBYTES: 1: y = %d, x = %d, firstch = %d, lastch = %d\n",
                default:
 #ifdef DEBUG
        __TRACE("ADDBYTES: 1: y = %d, x = %d, firstch = %d, lastch = %d\n",
-           y, x, win->_firstch[y], win->_lastch[y]);
+           y, x, win->lines[y]->firstch, win->lines[y]->lastch);
 #endif
 #endif
-                       if (win->_flags & _STANDOUT)
-                               c |= _STANDOUT;
+                       if (win->flags & __WSTANDOUT)
+                               c |= __STANDOUT;
 #ifdef DEBUG
        __TRACE("ADDBYTES(%0.2o, %d, %d)\n", win, y, x);
 #endif
 #ifdef DEBUG
        __TRACE("ADDBYTES(%0.2o, %d, %d)\n", win, y, x);
 #endif
-                       if (win->_y[y][x] != c) {
-                               newx = x + win->_ch_off;
-                               if (win->_firstch[y] == _NOCHANGE)
-                                       win->_firstch[y] =
-                                           win->_lastch[y] = newx;
-                               else if (newx < win->_firstch[y])
-                                       win->_firstch[y] = newx;
-                               else if (newx > win->_lastch[y])
-                                       win->_lastch[y] = newx;
+                       lp = win->lines[y];
+                       
+                       if (lp->line[x] != c) {
+                               newx = x + win->ch_off;
+                               if (!(lp->flags & __ISDIRTY)) {
+                                       lp->flags |= __ISDIRTY;
+                                       lp->firstch = lp->lastch = newx;
+                               }
+                               else if (newx < lp->firstch)
+                                       lp->firstch = newx;
+                               else if (newx > lp->lastch)
+                                       lp->lastch = newx;
 #ifdef DEBUG
        __TRACE("ADDBYTES: change gives f/l: %d/%d [%d/%d]\n",
 #ifdef DEBUG
        __TRACE("ADDBYTES: change gives f/l: %d/%d [%d/%d]\n",
-           win->_firstch[y], win->_lastch[y],
-           win->_firstch[y] - win->_ch_off,
-           win->_lastch[y] - win->_ch_off);
+           lp->firstch, lp->lastch,
+           lp->firstch - win->ch_off,
+           lp->lastch - win->ch_off);
 #endif
                        }
 #endif
                        }
-                       win->_y[y][x] = c;
-                       if (++x >= win->_maxx) {
+                       lp->line[x] = c;
+                       if (++x >= win->maxx) {
                                x = 0;
                                x = 0;
-newline:                       if (++y >= win->_maxy)
-                                       if (win->_scroll) {
+newline:                       if (++y >= win->maxy) 
+                                       if (win->flags & __SCROLLOK) {
                                                SYNCH_OUT;
                                                scroll(win);
                                                SYNCH_IN;
                                                SYNCH_OUT;
                                                scroll(win);
                                                SYNCH_IN;
@@ -83,7 +87,7 @@ newline:                      if (++y >= win->_maxy)
                        }
 #ifdef DEBUG
        __TRACE("ADDBYTES: 2: y = %d, x = %d, firstch = %d, lastch = %d\n",
                        }
 #ifdef DEBUG
        __TRACE("ADDBYTES: 2: y = %d, x = %d, firstch = %d, lastch = %d\n",
-           y, x, win->_firstch[y], win->_lastch[y]);
+           y, x, win->lines[y]->firstch, win->lines[y]->lastch);
 #endif
                        break;
                case '\n':
 #endif
                        break;
                case '\n':
index f83a9cb..84ba8e7 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)box.c      5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)box.c      5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -24,16 +24,16 @@ box(win, vert, hor)
        register int endy, endx, i;
        register char *fp, *lp;
 
        register int endy, endx, i;
        register char *fp, *lp;
 
-       endx = win->_maxx;
-       endy = win->_maxy - 1;
-       fp = win->_y[0];
-       lp = win->_y[endy];
+       endx = win->maxx;
+       endy = win->maxy - 1;
+       fp = win->topline->line;
+       lp = win->lines[endy]->line;
        for (i = 0; i < endx; i++)
                fp[i] = lp[i] = hor;
        endx--;
        for (i = 0; i <= endy; i++)
        for (i = 0; i < endx; i++)
                fp[i] = lp[i] = hor;
        endx--;
        for (i = 0; i <= endy; i++)
-               win->_y[i][0] = (win->_y[i][endx] = vert);
-       if (!win->_scroll && (win->_flags & _SCROLLWIN))
+               win->lines[i]->line[0] = (win->lines[i]->line[endx] = vert);
+       if (!(win->flags & __SCROLLOK) && (win->flags & __SCROLLWIN))
                fp[0] = fp[endx] = lp[0] = lp[endx] = ' ';
        touchwin(win);
        return (OK);
                fp[0] = fp[endx] = lp[0] = lp[endx] = ' ';
        touchwin(win);
        return (OK);
index eba1a92..ae472e0 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)clear.c    5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)clear.c    5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -20,7 +20,7 @@ wclear(win)
        register WINDOW *win;
 {
        if (werase(win) == OK) {
        register WINDOW *win;
 {
        if (werase(win) == OK) {
-               win->_clear = 1;
+               win->flags |= __CLEAROK;
                return (OK);
        }
        return (ERR);
                return (OK);
        }
        return (ERR);
index fe018c0..f862f19 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)clrtobot.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)clrtobot.c 5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -22,19 +22,20 @@ wclrtobot(win)
        register int minx, startx, y;
        register char *sp, *end, *maxx;
 
        register int minx, startx, y;
        register char *sp, *end, *maxx;
 
-       startx = win->_curx;
-       for (y = win->_cury; y < win->_maxy; y++) {
-               minx = _NOCHANGE;
-               end = &win->_y[y][win->_maxx];
-               for (sp = &win->_y[y][startx]; sp < end; sp++)
+       startx = win->curx;
+       for (y = win->cury; y < win->maxy; y++) {
+               minx = -1;
+               end = &win->lines[y]->line[win->maxx];
+               for (sp = &win->lines[y]->line[startx]; sp < end; sp++)
                        if (*sp != ' ') {
                                maxx = sp;
                        if (*sp != ' ') {
                                maxx = sp;
-                               if (minx == _NOCHANGE)
-                                       minx = sp - win->_y[y];
+                               if (minx == -1)
+                                       minx = sp - win->lines[y]->line;
                                *sp = ' ';
                        }
                                *sp = ' ';
                        }
-               if (minx != _NOCHANGE)
-                       touchline(win, y, minx, maxx - &win->_y[y][0]);
+               if (minx != -1)
+                       touchline(win, y, minx, 
+                           maxx - win->lines[y]->line);
                startx = 0;
        }
        return (OK);
                startx = 0;
        }
        return (OK);
index b76ac92..713207e 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)clrtoeol.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)clrtoeol.c 5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -22,22 +22,23 @@ wclrtoeol(win)
        register int minx, x, y;
        register char *end, *maxx, *sp;
 
        register int minx, x, y;
        register char *end, *maxx, *sp;
 
-       y = win->_cury;
-       x = win->_curx;
-       end = &win->_y[y][win->_maxx];
-       minx = _NOCHANGE;
-       maxx = &win->_y[y][x];
+       y = win->cury;
+       x = win->curx;
+       end = &win->lines[y]->line[win->maxx];
+       minx = -1;
+       maxx = &win->lines[y]->line[x];
        for (sp = maxx; sp < end; sp++)
                if (*sp != ' ') {
                        maxx = sp;
        for (sp = maxx; sp < end; sp++)
                if (*sp != ' ') {
                        maxx = sp;
-                       if (minx == _NOCHANGE)
-                               minx = sp - win->_y[y];
+                       if (minx == -1)
+                               minx = sp - win->lines[y]->line;
                        *sp = ' ';
                }
 #ifdef DEBUG
        __TRACE("CLRTOEOL: minx = %d, maxx = %d, firstch = %d, lastch = %d\n",
                        *sp = ' ';
                }
 #ifdef DEBUG
        __TRACE("CLRTOEOL: minx = %d, maxx = %d, firstch = %d, lastch = %d\n",
-           minx, maxx - win->_y[y], win->_firstch[y], win->_lastch[y]);
+           minx, maxx - win->lines[y]->line, win->lines[y]->firstch, 
+           win->lines[y]->lastch);
 #endif
        /* Update firstch and lastch for the line. */
 #endif
        /* Update firstch and lastch for the line. */
-       return (touchline(win, y, win->_curx, win->_maxx - 1));
+       return (touchline(win, y, win->curx, win->maxx - 1));
 }
 }
index 866998b..dd909ef 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)cr_put.c   5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)cr_put.c   5.9 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -350,9 +350,9 @@ dontcr:     while (outline < destline) {
                        if (plodflg)    /* Avoid a complex calculation. */
                                plodcnt--;
                        else {
                        if (plodflg)    /* Avoid a complex calculation. */
                                plodcnt--;
                        else {
-                               i = curscr->_y[outline][outcol];
-                               if ((i & _STANDOUT) ==
-                                   (curscr->_flags & _STANDOUT))
+                               i = curscr->lines[outline]->line[outcol];
+                               if ((i & __STANDOUT) ==
+                                   (curscr->flags & __STANDOUT))
                                        putchar(i & 0177);
                                else
                                        goto nondes;
                                        putchar(i & 0177);
                                else
                                        goto nondes;
index 46a7d4e..47ada8f 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)ctrace.c   5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)ctrace.c   5.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #ifdef DEBUG
 #endif /* not lint */
 
 #ifdef DEBUG
index 6392e01..68ac443 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)curses.h    5.12 (Berkeley) %G%
+ *     @(#)curses.h    5.13 (Berkeley) %G%
  */
 
 #ifndef _CURSES_H_
  */
 
 #ifndef _CURSES_H_
@@ -50,34 +50,46 @@ extern char *Def_term;              /* Default terminal type. */
 #define        unctrl(c)               __unctrl[(c) & 0x7f]
 #define        unctrllen(ch)           __unctrllen[(ch) & 0x7f]
 
 #define        unctrl(c)               __unctrl[(c) & 0x7f]
 #define        unctrllen(ch)           __unctrllen[(ch) & 0x7f]
 
-typedef struct _win_st {               /* Window structure. */
-       short           _cury, _curx;   /* Current x, y coordinates. */
-       short           _maxy, _maxx;   /* Maximum values for curx, cury. */
      short           _begy, _begx;   /* Window home. */
+/*
+ * A window is a circular doubly linked list of LINEs who's first line is 
+ * given by the topline pointer in the WINDOW structure.
+ */
 
 
-#define        _ENDLINE        0x001           /* End of screen. */
-#define        _FLUSH          0x002           /* fflush(stdout) after refresh. */
-#define        _FULLLINE       0x004           /* Line width = terminal width. */
-#define        _FULLWIN        0x008           /* Window is a screen. */
-#define        _IDLINE         0x010           /* Insert/delete sequences. */
-#define        _SCROLLWIN      0x020           /* Last char will scroll window. */
+typedef struct __line {
+       struct __line *next, *prev;     /* Next line, previous line. */
+#define        __ISDIRTY       0x01            /* Line is dirty. */
+       u_int flags;
+       u_int hash;                     /* Hash value for the line. */
+       size_t firstch, lastch;         /* First and last changed columns. */
 /* 
  * XXX
  * _STANDOUT is the 8th bit, characters themselves are encoded.
  */
 /* 
  * XXX
  * _STANDOUT is the 8th bit, characters themselves are encoded.
  */
-#define        _STANDOUT       0x080           /* Added characters are standout. */
-       unsigned short  _flags;
+#define        __STANDOUT      0x080           /* Added characters are standout. */
+       char *line;                     /* Pointer to line itself. */
+} LINE;
 
 
-       short           _ch_off;        /* x offset for firstch/lastch. */
-       char            _clear;         /* If clear on next refresh. */
-       char            _leave;         /* If cursor left. */
-       char            _scroll;        /* If scrolling permitted. */
-       char            **_y;           /* Line describing the window. */
+typedef struct __window {              /* Window structure. */
+       struct __window *nextp, *orig;  /* Subwindows list and parent. */
+       size_t begy, begx;              /* Window home. */
+       size_t cury, curx;              /* Current x, y coordinates. */
+       size_t maxy, maxx;              /* Maximum values for curx, cury. */
+       short ch_off;                   /* x offset for firstch/lastch. */
+       LINE **lines;                   /* Array of pointers to the lines */
+       LINE *topline;                  /* Pointer to first line in window */
+       char *wspace;                   /* window space (for cleanup) */
 
 
-#define        _NOCHANGE       -1              /* No change since last refresh. */
-       short           *_firstch;      /* First and last changed in line. */
-       short           *_lastch;
-       struct _win_st  *_nextp, *_orig;/* Subwindows list and parent. */
+#define        __ENDLINE       0x001           /* End of screen. */
+#define        __FLUSH         0x002           /* Fflush(stdout) after refresh. */
+#define        __FULLLINE      0x004           /* Line width = terminal width. */
+#define        __FULLWIN       0x008           /* Window is a screen. */
+#define        __IDLINE        0x010           /* Insert/delete sequences. */
+#define        __SCROLLWIN     0x020           /* Last char will scroll window. */
+#define        __SCROLLOK      0x040           /* Scrolling ok. */
+#define        __CLEAROK       0x080           /* Clear on next refresh. */
+#define __WSTANDOUT    0x100           /* Standout window */
+#define __LEAVEOK      0x200           /* If curser left */    
+       u_int flags;
 } WINDOW;
 
 /* Termcap capabilities. */
 } WINDOW;
 
 /* Termcap capabilities. */
@@ -158,13 +170,16 @@ extern char        __unctrllen[0x80];     /* Control strings length. */
 #define        mvwinsch(win, y, x, c)  (wmove(win, y, x) == ERR ? ERR : winsch(win, c))
 
 /* Random psuedo functions. */
 #define        mvwinsch(win, y, x, c)  (wmove(win, y, x) == ERR ? ERR : winsch(win, c))
 
 /* Random psuedo functions. */
-#define        clearok(win, bf)        (win->_clear = (bf))
-#define        flushok(win, bf)        ((bf) ? (win->_flags |= _FLUSH) : \
-                                   (win->_flags &= ~_FLUSH))
-#define        getyx(win, y, x)        (y) = win->_cury, (x) = win->_curx
-#define        leaveok(win, bf)        (win->_leave = (bf))
-#define        scrollok(win, bf)       (win->_scroll = (bf))
-#define        winch(win)              (win->_y[win->_cury][win->_curx] & 0177)
+#define        clearok(win, bf)  ((bf) ? (win->flags |= __CLEAROK) : \
+                                 (win->flags &= ~__CLEAROK))
+#define        flushok(win, bf)  ((bf) ? (win->flags |= __FLUSH) : \
+                                 (win->flags &= ~__FLUSH))
+#define        scrollok(win, bf) ((bf) ? (win->flags |= __SCROLLOK) : \
+                                 (win->flags &= ~__SCROLLOK))
+#define        leaveok(win, bf)  ((bf) ? (win->flags |= __LEAVEOK) : \
+                                 (win->flags &= ~__LEAVEOK))
+#define        getyx(win, y, x)        (y) = win->cury, (x) = win->curx
+#define        winch(win)              (win->lines[win->cury]->line[win->curx] & 0177)
 
 /* Public function prototypes. */
 void    __cputchar __P((int));
 
 /* Public function prototypes. */
 void    __cputchar __P((int));
index f5ab846..528b0a1 100644 (file)
@@ -6,14 +6,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)delch.c    5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)delch.c    5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 
 /*
  * wdelch --
 #endif /* not lint */
 
 #include <curses.h>
 
 /*
  * wdelch --
- *     Do an insert-char on the line, leaving (_cury, _curx) unchanged.
+ *     Do an insert-char on the line, leaving (cury, curx) unchanged.
  */
 int
 wdelch(win)
  */
 int
 wdelch(win)
@@ -21,12 +21,12 @@ wdelch(win)
 {
        register char *end, *temp1, *temp2;
 
 {
        register char *end, *temp1, *temp2;
 
-       end = &win->_y[win->_cury][win->_maxx - 1];
-       temp1 = &win->_y[win->_cury][win->_curx];
+       end = &win->lines[win->cury]->line[win->maxx - 1];
+       temp1 = &win->lines[win->cury]->line[win->curx];
        temp2 = temp1 + 1;
        while (temp1 < end)
                *temp1++ = *temp2++;
        *temp1 = ' ';
        temp2 = temp1 + 1;
        while (temp1 < end)
                *temp1++ = *temp2++;
        *temp1 = ' ';
-       touchline(win, win->_cury, win->_curx, win->_maxx - 1);
+       touchline(win, win->cury, win->curx, win->maxx - 1);
        return (OK);
 }
        return (OK);
 }
index d097338..71be47e 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)deleteln.c 5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)deleteln.c 5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -14,33 +14,36 @@ static char sccsid[] = "@(#)deleteln.c      5.7 (Berkeley) %G%";
 
 /*
  * wdeleteln --
 
 /*
  * wdeleteln --
- *     Delete a line from the screen.  It leaves (_cury, _curx) unchanged.
+ *     Delete a line from the screen.  It leaves (cury, curx) unchanged.
  */
 int
 wdeleteln(win)
        register WINDOW *win;
 {
        register int y;
  */
 int
 wdeleteln(win)
        register WINDOW *win;
 {
        register int y;
-       register char *temp;
+       register LINE *temp;
 
 #ifdef DEBUG
        __TRACE("deleteln: (%0.2o)\n", win);
 #endif
 
 #ifdef DEBUG
        __TRACE("deleteln: (%0.2o)\n", win);
 #endif
-       temp = win->_y[win->_cury];
-       for (y = win->_cury; y < win->_maxy - 1; y++) {
-               if (win->_orig == NULL)
-                       win->_y[y] = win->_y[y + 1];
+       temp = win->lines[win->cury];
+       for (y = win->cury; y < win->maxy - 1; y++) {
+               if (win->orig == NULL)
+                       win->lines[y] = win->lines[y + 1];
                else
                else
-                       bcopy(win->_y[y + 1], win->_y[y], win->_maxx);
-               touchline(win, y, 0, win->_maxx - 1);
+                       bcopy(win->lines[y + 1]->line, win->lines[y]->line, 
+                             win->maxx);
+               touchline(win, y, 0, win->maxx - 1);
        }
        }
-       if (win->_orig == NULL)
-               win->_y[y] = temp;
+
+       if (win->orig == NULL)
+               win->lines[y] = temp;
        else
        else
-               temp = win->_y[y];
-       (void)memset(temp, ' ', &temp[win->_maxx] - temp);
-       touchline(win, win->_cury, 0, win->_maxx - 1);
-       if (win->_orig == NULL)
+               temp = win->lines[y];
+
+       (void)memset(temp->line, ' ', &temp->line[win->maxx] - temp->line);
+       touchline(win, y, 0, win->maxx - 1);
+       if (win->orig == NULL)
                __id_subwins(win);
        return (OK);
 }
                __id_subwins(win);
        return (OK);
 }
index 008b956..90562aa 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)delwin.c   5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)delwin.c   5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -22,20 +22,23 @@ delwin(win)
 {
 
        register WINDOW *wp, *np;
 {
 
        register WINDOW *wp, *np;
+       register LINE *lp;
        register int i;
 
        register int i;
 
-       if (win->_orig == NULL) {
+       if (win->orig == NULL) {
                /*
                 * If we are the original window, delete the space for all
                /*
                 * If we are the original window, delete the space for all
-                * the subwindows, and the array of space as well.
+                * the subwindows, and the array of space as well which is
+                * pointed to by win->topline->line.
                 */
                 */
-               for (i = 0; i < win->_maxy && win->_y[i]; i++)
-                       free(win->_y[i]);
-               free(win->_firstch);
-               free(win->_lastch);
-               wp = win->_nextp;
+
+               for (lp = win->topline, i = 0; i < win->maxy; i++) 
+                       free(lp);
+               free(win->wspace);
+               free(win->lines);
+               wp = win->nextp;
                while (wp != win) {
                while (wp != win) {
-                       np = wp->_nextp;
+                       np = wp->nextp;
                        delwin(wp);
                        wp = np;
                }
                        delwin(wp);
                        wp = np;
                }
@@ -46,11 +49,10 @@ delwin(win)
                 * followed by this subwindow, so there are always at least
                 * two windows in the list.
                 */
                 * followed by this subwindow, so there are always at least
                 * two windows in the list.
                 */
-               for (wp = win->_nextp; wp->_nextp != win; wp = wp->_nextp)
+               for (wp = win->nextp; wp->nextp != win; wp = wp->nextp)
                        continue;
                        continue;
-               wp->_nextp = win->_nextp;
+               wp->nextp = win->nextp;
        }
        }
-       free(win->_y);
        free(win);
        return (OK);
 }
        free(win);
        return (OK);
 }
index 95d37c0..3035398 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)erase.c    5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)erase.c    5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -26,20 +26,20 @@ werase(win)
 #ifdef DEBUG
        __TRACE("werase: (%0.2o)\n", win);
 #endif
 #ifdef DEBUG
        __TRACE("werase: (%0.2o)\n", win);
 #endif
-       for (y = 0; y < win->_maxy; y++) {
-               minx = _NOCHANGE;
-               start = win->_y[y];
-               end = &start[win->_maxx];
+       for (y = 0; y < win->maxy; y++) {
+               minx = -1;
+               start = win->lines[y]->line;
+               end = &start[win->maxx];
                for (sp = start; sp < end; sp++)
                        if (*sp != ' ') {
                                maxx = sp;
                for (sp = start; sp < end; sp++)
                        if (*sp != ' ') {
                                maxx = sp;
-                               if (minx == _NOCHANGE)
+                               if (minx == -1)
                                        minx = sp - start;
                                *sp = ' ';
                        }
                                        minx = sp - start;
                                *sp = ' ';
                        }
-               if (minx != _NOCHANGE)
-                       touchline(win, y, minx, maxx - win->_y[y]);
+               if (minx != -1)
+                       touchline(win, y, minx, maxx - win->lines[y]->line);
        }
        }
-       win->_curx = win->_cury = 0;
+       win->curx = win->cury = 0;
        return (OK);
 }
        return (OK);
 }
index 4e0b8ab..b26ddad 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)getch.c    5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)getch.c    5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -21,8 +21,8 @@ wgetch(win)
 {
        register int inp, weset;
 
 {
        register int inp, weset;
 
-       if (!win->_scroll && (win->_flags & _FULLWIN)
-           && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1)
+       if (!(win->flags & __SCROLLOK) && (win->flags & __FULLWIN)
+           && win->curx == win->maxx - 1 && win->cury == win->maxy - 1)
                return (ERR);
 #ifdef DEBUG
        __TRACE("wgetch: __echoit = %d, __rawmode = %d\n",
                return (ERR);
 #ifdef DEBUG
        __TRACE("wgetch: __echoit = %d, __rawmode = %d\n",
@@ -40,7 +40,7 @@ wgetch(win)
 #endif
        if (__echoit) {
                mvwaddch(curscr,
 #endif
        if (__echoit) {
                mvwaddch(curscr,
-                   win->_cury + win->_begy, win->_curx + win->_begx, inp);
+                   win->cury + win->begy, win->curx + win->begx, inp);
                waddch(win, inp);
        }
        if (weset)
                waddch(win, inp);
        }
        if (weset)
index 6a74689..4eed0fb 100644 (file)
@@ -6,14 +6,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)getstr.c   5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)getstr.c   5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 
 /*
  * wgetstr --
 #endif /* not lint */
 
 #include <curses.h>
 
 /*
  * wgetstr --
- *     Get a string starting at (_cury,_curx).
+ *     Get a string starting at (cury, curx).
  */
 int
 wgetstr(win, str)
  */
 int
 wgetstr(win, str)
index 525ed03..dab9ff4 100644 (file)
@@ -6,14 +6,14 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)id_subwins.c       5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)id_subwins.c       5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 
 /*
  * __id_subwins --
 #endif /* not lint */
 
 #include <curses.h>
 
 /*
  * __id_subwins --
- *     Re-sync the pointers to _y for all the subwindows.
+ *     Re-sync the pointers to lines for all the subwindows.
  */
 void
 __id_subwins(orig)
  */
 void
 __id_subwins(orig)
@@ -22,17 +22,18 @@ __id_subwins(orig)
        register WINDOW *win;
        register int oy, realy, y;
 
        register WINDOW *win;
        register int oy, realy, y;
 
-       realy = orig->_begy + orig->_cury;
-       for (win = orig->_nextp; win != orig; win = win->_nextp) {
+       realy = orig->begy + orig->cury;
+       for (win = orig->nextp; win != orig; win = win->nextp) {
                /*
                 * If the window ends before our current position, don't need
                 * to do anything.
                 */
                /*
                 * If the window ends before our current position, don't need
                 * to do anything.
                 */
-               if (win->_begy + win->_maxy <= realy)
+               if (win->begy + win->maxy <= realy)
                        continue;
 
                        continue;
 
-               oy = orig->_cury;
-               for (y = realy - win->_begy; y < win->_maxy; y++, oy++)
-                       win->_y[y] = &orig->_y[oy][win->_ch_off];
+               oy = orig->cury;
+               for (y = realy - win->begy; y < win->maxy; y++, oy++)
+                       win->lines[y]->line = 
+                               &orig->lines[oy]->line[win->ch_off];
        }
 }
        }
 }
index e1e4e85..cc3355c 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)idlok.c    5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)idlok.c    5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -22,7 +22,7 @@ idlok(win, bf)
        int bf;
 {
        if (bf)
        int bf;
 {
        if (bf)
-               win->_flags |= _IDLINE;
+               win->flags |= __IDLINE;
        else
        else
-               win->_flags &= ~_IDLINE;
+               win->flags &= ~__IDLINE;
 }
 }
index 6b4291e..7be6aff 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)initscr.c  5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)initscr.c  5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -53,7 +53,7 @@ initscr()
        if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
                return (NULL);
        clearok(curscr, 1);
        if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
                return (NULL);
        clearok(curscr, 1);
-       curscr->_flags &= ~_FULLLINE;
+       curscr->flags &= ~__FULLLINE;
        if (stdscr != NULL) {
 #ifdef DEBUG
                __TRACE("initscr: stdscr = 0%o\n", stdscr);
        if (stdscr != NULL) {
 #ifdef DEBUG
                __TRACE("initscr: stdscr = 0%o\n", stdscr);
@@ -62,3 +62,4 @@ initscr()
        }
        return(stdscr = newwin(LINES, COLS, 0, 0));
 }
        }
        return(stdscr = newwin(LINES, COLS, 0, 0));
 }
+
index 3ae098b..66dcd66 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)insch.c    5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)insch.c    5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -23,18 +23,19 @@ winsch(win, ch)
 
        register char *end, *temp1, *temp2;
 
 
        register char *end, *temp1, *temp2;
 
-       end = &win->_y[win->_cury][win->_curx];
-       temp1 = &win->_y[win->_cury][win->_maxx - 1];
+       end = &win->lines[win->cury]->line[win->curx];
+       temp1 = &win->lines[win->cury]->line[win->maxx - 1];
        temp2 = temp1 - 1;
        while (temp1 > end)
                *temp1-- = *temp2--;
        *temp1 = ch;
        temp2 = temp1 - 1;
        while (temp1 > end)
                *temp1-- = *temp2--;
        *temp1 = ch;
-       touchline(win, win->_cury, win->_curx, win->_maxx - 1);
-       if (win->_cury == LINES - 1 && win->_y[LINES - 1][COLS - 1] != ' ')
-               if (win->_scroll) {
+       touchline(win, win->cury, win->curx, win->maxx - 1);
+       if (win->cury == LINES - 1 && 
+           win->lines[LINES - 1]->line[COLS - 1] != ' ')
+               if (win->flags & __SCROLLOK) {
                        wrefresh(win);
                        scroll(win);
                        wrefresh(win);
                        scroll(win);
-                       win->_cury--;
+                       win->cury--;
                } else
                        return (ERR);
        return (OK);
                } else
                        return (ERR);
        return (OK);
index 18acfbd..6bae576 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)insertln.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)insertln.c 5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -14,7 +14,7 @@ static char sccsid[] = "@(#)insertln.c        5.6 (Berkeley) %G%";
 
 /*
  * winsertln --
 
 /*
  * winsertln --
- *     Do an insert-line on the window, leaving (_cury,_curx) unchanged.
+ *     Do an insert-line on the window, leaving (cury, curx) unchanged.
  */
 int
 winsertln(win)
  */
 int
 winsertln(win)
@@ -22,28 +22,29 @@ winsertln(win)
 {
 
        register int y;
 {
 
        register int y;
-       register char *end, *temp;
+       register char *end;
+       register LINE *temp;
 
 #ifdef DEBUG
        __TRACE("insertln: (%0.2o)\n", win);
 #endif
 
 #ifdef DEBUG
        __TRACE("insertln: (%0.2o)\n", win);
 #endif
-       if (win->_orig == NULL)
-               temp = win->_y[win->_maxy - 1];
-       for (y = win->_maxy - 1; y > win->_cury; --y) {
-               if (win->_orig == NULL)
-                       win->_y[y] = win->_y[y - 1];
+       if (win->orig == NULL)
+               temp = win->lines[win->maxy - 1];
+       for (y = win->maxy - 1; y > win->cury; --y) {
+               if (win->orig == NULL)
+                       win->lines[y] = win->lines[y - 1];
                else
                else
-                       bcopy(win->_y[y - 1], win->_y[y], win->_maxx);
-               touchline(win, y, 0, win->_maxx - 1);
+                       bcopy(win->lines[y - 1]->line, 
+                             win->lines[y]->line, win->maxx);
+               touchline(win, y, 0, win->maxx - 1);
        }
        }
-       if (win->_orig == NULL)
-               win->_y[y] = temp;
+       if (win->orig == NULL)
+               win->lines[y] = temp;
        else
        else
-               temp = win->_y[y];
-       for (end = &temp[win->_maxx]; temp < end;)
-               *temp++ = ' ';
-       touchline(win, y, 0, win->_maxx - 1);
-       if (win->_orig == NULL)
+               temp = win->lines[y];
+       (void)memset(temp->line, ' ', &temp->line[win->maxx] - temp->line);
+       touchline(win, y, 0, win->maxx - 1);
+       if (win->orig == NULL)
                __id_subwins(win);
        return (OK);
 }
                __id_subwins(win);
        return (OK);
 }
index 017547e..a6715ce 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)move.c     5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)move.c     5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -26,9 +26,9 @@ wmove(win, y, x)
 #endif
        if (x < 0 || y < 0)
                return (ERR);
 #endif
        if (x < 0 || y < 0)
                return (ERR);
-       if (x >= win->_maxx || y >= win->_maxy)
+       if (x >= win->maxx || y >= win->maxy)
                return (ERR);
                return (ERR);
-       win->_curx = x;
-       win->_cury = y;
+       win->curx = x;
+       win->cury = y;
        return (OK);
 }
        return (OK);
 }
index da3f1f8..e6a087c 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)mvwin.c    5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)mvwin.c    5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -23,26 +23,26 @@ mvwin(win, by, bx)
        register WINDOW *orig;
        register int dy, dx;
 
        register WINDOW *orig;
        register int dy, dx;
 
-       if (by + win->_maxy > LINES || bx + win->_maxx > COLS)
+       if (by + win->maxy > LINES || bx + win->maxx > COLS)
                return (ERR);
                return (ERR);
-       dy = by - win->_begy;
-       dx = bx - win->_begx;
-       orig = win->_orig;
+       dy = by - win->begy;
+       dx = bx - win->begx;
+       orig = win->orig;
        if (orig == NULL) {
                orig = win;
                do {
        if (orig == NULL) {
                orig = win;
                do {
-                       win->_begy += dy;
-                       win->_begx += dx;
+                       win->begy += dy;
+                       win->begx += dx;
                        __swflags(win);
                        __swflags(win);
-                       win = win->_nextp;
+                       win = win->nextp;
                } while (win != orig);
        } else {
                } while (win != orig);
        } else {
-               if (by < orig->_begy || win->_maxy + dy > orig->_maxy)
+               if (by < orig->begy || win->maxy + dy > orig->maxy)
                        return (ERR);
                        return (ERR);
-               if (bx < orig->_begx || win->_maxx + dx > orig->_maxx)
+               if (bx < orig->begx || win->maxx + dx > orig->maxx)
                        return (ERR);
                        return (ERR);
-               win->_begy = by;
-               win->_begx = bx;
+               win->begy = by;
+               win->begx = bx;
                __swflags(win);
                __set_subwin(orig, win);
        }
                __swflags(win);
                __set_subwin(orig, win);
        }
index 81500d1..c320e7e 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)newwin.c   5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)newwin.c   5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -14,96 +14,74 @@ static char sccsid[] = "@(#)newwin.c        5.6 (Berkeley) %G%";
 
 #undef nl              /* Don't need it here, and it interferes. */
 
 
 #undef nl              /* Don't need it here, and it interferes. */
 
-static WINDOW *makenew __P((int, int, int, int));
+static WINDOW  *makenew __P((int, int, int, int));
+static void     __swflags __P((WINDOW *));
+
+void    __set_subwin __P((WINDOW *, WINDOW *));
 
 /*
  * newwin --
  *     Allocate space for and set up defaults for a new window.
  */
 WINDOW *
 
 /*
  * newwin --
  *     Allocate space for and set up defaults for a new window.
  */
 WINDOW *
-newwin(num_lines, num_cols, begy, begx)
-       int num_lines, num_cols, begy, begx;
+newwin(nl, nc, by, bx)
+       register int nl, nc, by, bx;
 {
        register WINDOW *win;
 {
        register WINDOW *win;
-       register int by, bx, i, j, nl, nc;
+       register LINE *lp;
+       register int  i, j;
        register char *sp;
 
        register char *sp;
 
-       by = begy;
-       bx = begx;
-       nl = num_lines;
-       nc = num_cols;
-
        if (nl == 0)
                nl = LINES - by;
        if (nc == 0)
                nc = COLS - bx;
        if (nl == 0)
                nl = LINES - by;
        if (nc == 0)
                nc = COLS - bx;
+
        if ((win = makenew(nl, nc, by, bx)) == NULL)
                return (NULL);
        if ((win = makenew(nl, nc, by, bx)) == NULL)
                return (NULL);
-       if ((win->_firstch = malloc(nl * sizeof(win->_firstch[0]))) == NULL) {
-               free(win->_y);
-               free(win);
-               return (NULL);
-       }
-       if ((win->_lastch = malloc(nl * sizeof(win->_lastch[0]))) == NULL) {
-               free(win->_y);
-               free(win->_firstch);
-               free(win);
-               return (NULL);
-       }
-       win->_nextp = win;
-       for (i = 0; i < nl; i++) {
-               win->_firstch[i] = _NOCHANGE;
-               win->_lastch[i] = _NOCHANGE;
-       }
-       for (i = 0; i < nl; i++)
-               if ((win->_y[i] = malloc(nc * sizeof(win->_y[0]))) == NULL) {
-                       for (j = 0; j < i; j++)
-                               free(win->_y[j]);
-                       free(win->_firstch);
-                       free(win->_lastch);
-                       free(win->_y);
-                       free(win);
-                       return (NULL);
-               } else
-                       for (sp = win->_y[i]; sp < win->_y[i] + nc;)
-                               *sp++ = ' ';
-       win->_ch_off = 0;
+
+       win->nextp = win;
+       win->ch_off = 0;
+
 #ifdef DEBUG
 #ifdef DEBUG
-       __TRACE("newwin: win->_ch_off = %d\n", win->_ch_off);
+       __TRACE("newwin: win->ch_off = %d\n", win->ch_off);
 #endif
 #endif
+
+       for (lp = win->topline, i = 0; i < nl; i++, lp = lp->next) {
+               lp->flags = 0;
+               lp->flags &= ~__ISDIRTY;
+               for (sp = lp->line; sp < lp->line + nc; sp++)
+                       *sp = ' ';
+               lp->hash = __hash(lp->line);
+       }
+
        return (win);
 }
 
 WINDOW *
        return (win);
 }
 
 WINDOW *
-subwin(orig, num_lines, num_cols, begy, begx)
+subwin(orig, nl, nc, by, bx)
        register WINDOW *orig;
        register WINDOW *orig;
-       int num_lines, num_cols, begy, begx;
+       register int by, bx, nl, nc;
 {
        register WINDOW *win;
 {
        register WINDOW *win;
-       register int by, bx, nl, nc;
-
-       by = begy;
-       bx = begx;
-       nl = num_lines;
-       nc = num_cols;
 
        /* Make sure window fits inside the original one. */
 #ifdef DEBUG
        __TRACE("subwin: (%0.2o, %d, %d, %d, %d)\n", orig, nl, nc, by, bx);
 #endif
 
        /* Make sure window fits inside the original one. */
 #ifdef DEBUG
        __TRACE("subwin: (%0.2o, %d, %d, %d, %d)\n", orig, nl, nc, by, bx);
 #endif
-       if (by < orig->_begy || bx < orig->_begx
-           || by + nl > orig->_maxy + orig->_begy
-           || bx + nc > orig->_maxx + orig->_begx)
+       if (by < orig->begy || bx < orig->begx
+           || by + nl > orig->maxy + orig->begy
+           || bx + nc > orig->maxx + orig->begx)
                return (NULL);
        if (nl == 0)
                return (NULL);
        if (nl == 0)
-               nl = orig->_maxy + orig->_begy - by;
+               nl = orig->maxy + orig->begy - by;
        if (nc == 0)
        if (nc == 0)
-               nc = orig->_maxx + orig->_begx - bx;
+               nc = orig->maxx + orig->begx - bx;
        if ((win = makenew(nl, nc, by, bx)) == NULL)
                return (NULL);
        if ((win = makenew(nl, nc, by, bx)) == NULL)
                return (NULL);
-       win->_nextp = orig->_nextp;
-       orig->_nextp = win;
-       win->_orig = orig;
+       win->nextp = orig->nextp;
+       orig->nextp = win;
+       win->orig = orig;
        __set_subwin(orig, win);
        return (win);
 }
        __set_subwin(orig, win);
        return (win);
 }
@@ -115,18 +93,30 @@ void
 __set_subwin(orig, win)
        register WINDOW *orig, *win;
 {
 __set_subwin(orig, win)
        register WINDOW *orig, *win;
 {
-       register int i, j, k;
+       register int j, k, ocnt, cnt;
+       register LINE *lp, *olp;
 
 
-       j = win->_begy - orig->_begy;
-       k = win->_begx - orig->_begx;
-       win->_ch_off = k;
+       j = win->begy - orig->begy;
+       k = win->begx - orig->begx;
+       win->ch_off = k;
 #ifdef DEBUG
 #ifdef DEBUG
-       __TRACE("__set_subwin: win->_ch_off = %d\n", win->_ch_off);
+       __TRACE("__set_subwin: win->ch_off = %d\n", win->ch_off);
 #endif
 #endif
-       win->_firstch = &orig->_firstch[j];
-       win->_lastch = &orig->_lastch[j];
-       for (i = 0; i < win->_maxy; i++, j++)
-               win->_y[i] = &orig->_y[j][k];
+
+       lp = win->topline;
+       olp = orig->topline; 
+       ocnt = 0;
+       for (ocnt = 0; ocnt < orig->maxy && cnt < win->maxy; ocnt++) {
+               if (ocnt >= j) {
+                       lp->firstch = olp->firstch;
+                       lp->lastch = olp->lastch;
+                       lp->line = &olp->line[k];
+                       lp = lp->next;
+                       lp->flags = olp->flags;
+                       cnt++;
+               }
+               olp = olp->next;
+       }
 }
 
 /*
 }
 
 /*
@@ -134,16 +124,12 @@ __set_subwin(orig, win)
  *     Set up a window buffer and returns a pointer to it.
  */
 static WINDOW *
  *     Set up a window buffer and returns a pointer to it.
  */
 static WINDOW *
-makenew(num_lines, num_cols, begy, begx)
-       int num_lines, num_cols, begy, begx;
+makenew(nl, nc, by, bx)
+       register int by, bx, nl, nc;
 {
        register WINDOW *win;
 {
        register WINDOW *win;
-       register int by, bx, nl, nc;
-
-       by = begy;
-       bx = begx;
-       nl = num_lines;
-       nc = num_cols;
+       register LINE *cur, *prev;
+       int i;
 
 #ifdef DEBUG
        __TRACE("makenew: (%d, %d, %d, %d)\n", nl, nc, by, bx);
 
 #ifdef DEBUG
        __TRACE("makenew: (%d, %d, %d, %d)\n", nl, nc, by, bx);
@@ -153,49 +139,78 @@ makenew(num_lines, num_cols, begy, begx)
 #ifdef DEBUG
        __TRACE("makenew: nl = %d\n", nl);
 #endif
 #ifdef DEBUG
        __TRACE("makenew: nl = %d\n", nl);
 #endif
-       if ((win->_y = malloc(nl * sizeof(win->_y[0]))) == NULL) {
+
+       /*
+        * Allocate structure of lines in a window.
+         */
+       if ((win->topline = malloc (nl * sizeof (LINE))) == NULL) {
+               free (win);
+               return NULL;
+       }
+
+       /*
+        * Allocate window space in one chunk.
+        */
+       if ((win->wspace = malloc(nc * nl)) == NULL) {
+               free(win->topline);
                free(win);
                free(win);
-               return (NULL);
+               return NULL;
+       }
+       /* 
+        * Link up the lines, set up line pointer array and point line pointers
+        * to the line space.
+         */
+       if ((win->lines = malloc (nl * sizeof (LINE *))) == NULL) {
+               free(win->wspace);
+               free(win->topline);
+               free(win);
+               return NULL;
        }
        }
+       prev = &win->topline[nl - 1];
+       cur = win->topline;
+       for (i = 1; i <= nl; i++, prev = cur, cur = cur->next) {
+               cur->next = &win->topline[i % nl];
+               cur->prev = prev;
+               cur->line = &win->wspace[(i - 1) * nc];
+               win->lines[i - 1] = cur;
+       }
+
 #ifdef DEBUG
        __TRACE("makenew: nc = %d\n", nc);
 #endif
 #ifdef DEBUG
        __TRACE("makenew: nc = %d\n", nc);
 #endif
-       win->_cury = win->_curx = 0;
-       win->_clear = 0;
-       win->_maxy = nl;
-       win->_maxx = nc;
-       win->_begy = by;
-       win->_begx = bx;
-       win->_flags = 0;
-       win->_scroll = win->_leave = 0;
+       win->cury = win->curx = 0;
+       win->maxy = nl;
+       win->maxx = nc;
+
+       win->begy = by;
+       win->begx = bx;
+       win->flags = 0;
        __swflags(win);
 #ifdef DEBUG
        __swflags(win);
 #ifdef DEBUG
-       __TRACE("makenew: win->_clear = %d\n", win->_clear);
-       __TRACE("makenew: win->_leave = %d\n", win->_leave);
-       __TRACE("makenew: win->_scroll = %d\n", win->_scroll);
-       __TRACE("makenew: win->_flags = %0.2o\n", win->_flags);
-       __TRACE("makenew: win->_maxy = %d\n", win->_maxy);
-       __TRACE("makenew: win->_maxx = %d\n", win->_maxx);
-       __TRACE("makenew: win->_begy = %d\n", win->_begy);
-       __TRACE("makenew: win->_begx = %d\n", win->_begx);
+       __TRACE("makenew: win->flags = %0.2o\n", win->flags);
+       __TRACE("makenew: win->maxy = %d\n", win->maxy);
+       __TRACE("makenew: win->maxx = %d\n", win->maxx);
+       __TRACE("makenew: win->begy = %d\n", win->begy);
+       __TRACE("makenew: win->begx = %d\n", win->begx);
 #endif
        return (win);
 }
 
 #endif
        return (win);
 }
 
-void
+static void
 __swflags(win)
        register WINDOW *win;
 {
 __swflags(win)
        register WINDOW *win;
 {
-       win->_flags &= ~(_ENDLINE | _FULLLINE | _FULLWIN | _SCROLLWIN);
-       if (win->_begx + win->_maxx == COLS) {
-               win->_flags |= _ENDLINE;
-               if (win->_begx == 0) {
+       win->flags &= 
+           ~(__ENDLINE | __FULLLINE | __FULLWIN | __SCROLLWIN | __LEAVEOK);
+       if (win->begx + win->maxx == COLS) {
+               win->flags |= __ENDLINE;
+               if (win->begx == 0) {
                        if (AL && DL)
                        if (AL && DL)
-                               win->_flags |= _FULLLINE;
-                       if (win->_maxy == LINES && win->_begy == 0)
-                               win->_flags |= _FULLWIN;
+                               win->flags |= __FULLLINE;
+                       if (win->maxy == LINES && win->begy == 0)
+                               win->flags |= __FULLWIN;
                }
                }
-               if (win->_begy + win->_maxy == LINES)
-                       win->_flags |= _SCROLLWIN;
+               if (win->begy + win->maxy == LINES)
+                       win->flags |= __SCROLLWIN;
        }
 }
        }
 }
index df42357..b94c410 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)overlay.c  5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)overlay.c  5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <ctype.h>
 #endif /* not lint */
 
 #include <ctype.h>
@@ -27,22 +27,23 @@ overlay(win1, win2)
 #ifdef DEBUG
        __TRACE("overlay: (%0.2o, %0.2o);\n", win1, win2);
 #endif
 #ifdef DEBUG
        __TRACE("overlay: (%0.2o, %0.2o);\n", win1, win2);
 #endif
-       starty = max(win1->_begy, win2->_begy);
-       startx = max(win1->_begx, win2->_begx);
-       endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx);
-       endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
+       starty = max(win1->begy, win2->begy);
+       startx = max(win1->begx, win2->begx);
+       endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx);
+       endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx);
 #ifdef DEBUG
        __TRACE("overlay: from (%d,%d) to (%d,%d)\n",
            starty, startx, endy, endx);
 #endif
        if (starty >= endy || startx >= endx)
                return (OK);
 #ifdef DEBUG
        __TRACE("overlay: from (%d,%d) to (%d,%d)\n",
            starty, startx, endy, endx);
 #endif
        if (starty >= endy || startx >= endx)
                return (OK);
-       y1 = starty - win1->_begy;
-       y2 = starty - win2->_begy;
+       y1 = starty - win1->begy;
+       y2 = starty - win2->begy;
        for (y = starty; y < endy; y++, y1++, y2++) {
        for (y = starty; y < endy; y++, y1++, y2++) {
-               end = &win1->_y[y1][endx - win1->_begx];
-               x = startx - win2->_begx;
-               for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) {
+               end = &win1->lines[y1]->line[endx - win1->begx];
+               x = startx - win2->begx;
+               for (sp = &win1->lines[y1]->line[startx - win1->begx]; 
+                    sp < end; sp++) {
                        if (!isspace(*sp))
                                mvwaddch(win2, y2, x, *sp);
                        x++;
                        if (!isspace(*sp))
                                mvwaddch(win2, y2, x, *sp);
                        x++;
index 1426ce3..f10f979 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)overwrite.c        5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)overwrite.c        5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <ctype.h>
 #endif /* not lint */
 
 #include <ctype.h>
@@ -26,10 +26,10 @@ overwrite(win1, win2)
 #ifdef DEBUG
        __TRACE("overwrite: (%0.2o, %0.2o);\n", win1, win2);
 #endif
 #ifdef DEBUG
        __TRACE("overwrite: (%0.2o, %0.2o);\n", win1, win2);
 #endif
-       starty = max(win1->_begy, win2->_begy);
-       startx = max(win1->_begx, win2->_begx);
-       endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx);
-       endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
+       starty = max(win1->begy, win2->begy);
+       startx = max(win1->begx, win2->begx);
+       endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx);
+       endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx);
        if (starty >= endy || startx >= endx)
                return (OK);
 #ifdef DEBUG
        if (starty >= endy || startx >= endx)
                return (OK);
 #ifdef DEBUG
@@ -38,9 +38,10 @@ overwrite(win1, win2)
 #endif
        x = endx - startx;
        for (y = starty; y < endy; y++) {
 #endif
        x = endx - startx;
        for (y = starty; y < endy; y++) {
-               bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx],
-                   &win2->_y[y - win2->_begy][startx - win2->_begx], x);
-               touchline(win2, y, startx - win2->_begx, endx - win2->_begx);
+               bcopy(&win1->lines[y - win1->begy]->line[startx - win1->begx],
+                   &win2->lines[y - win2->begy]->line[startx - win2->begx], 
+                   x);
+               touchline(win2, y, startx - win2->begx, endx - win2->begx);
        }
        return (OK);
 }
        }
        return (OK);
 }
index dda79f0..9491acf 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)refresh.c  5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)refresh.c  5.9 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -41,29 +41,29 @@ wrefresh(win)
 
        /* Initialize loop parameters. */
 
 
        /* Initialize loop parameters. */
 
-       ly = curscr->_cury;
-       lx = curscr->_curx;
+       ly = curscr->cury;
+       lx = curscr->curx;
        wy = 0;
        _win = win;
        curwin = (win == curscr);
 
        wy = 0;
        _win = win;
        curwin = (win == curscr);
 
-       if (win->_clear || curscr->_clear || curwin) {
-               if ((win->_flags & _FULLWIN) || curscr->_clear) {
+       if (win->flags & __CLEAROK || curscr->flags & __CLEAROK || curwin) {
+               if ((win->flags & __FULLWIN) || curscr->flags & __CLEAROK) {
                        tputs(CL, 0, __cputchar);
                        ly = 0;
                        lx = 0;
                        if (!curwin) {
                        tputs(CL, 0, __cputchar);
                        ly = 0;
                        lx = 0;
                        if (!curwin) {
-                               curscr->_clear = 0;
-                               curscr->_cury = 0;
-                               curscr->_curx = 0;
+                               curscr->flags &= ~__CLEAROK;
+                               curscr->cury = 0;
+                               curscr->curx = 0;
                                werase(curscr);
                        }
                        touchwin(win);
                }
                                werase(curscr);
                        }
                        touchwin(win);
                }
-               win->_clear = 0;
+               win->flags &= ~__CLEAROK;
        }
        if (!CA) {
        }
        if (!CA) {
-               if (win->_curx != 0)
+               if (win->curx != 0)
                        putchar('\n');
                if (!curwin)
                        werase(curscr);
                        putchar('\n');
                if (!curwin)
                        werase(curscr);
@@ -72,48 +72,51 @@ wrefresh(win)
        __TRACE("wrefresh: (%0.2o): curwin = %d\n", win, curwin);
        __TRACE("wrefresh: \tfirstch\tlastch\n");
 #endif
        __TRACE("wrefresh: (%0.2o): curwin = %d\n", win, curwin);
        __TRACE("wrefresh: \tfirstch\tlastch\n");
 #endif
-       for (wy = 0; wy < win->_maxy; wy++) {
+       for (wy = 0; wy < win->maxy; wy++) {
 #ifdef DEBUG
                __TRACE("%d\t%d\t%d\n",
 #ifdef DEBUG
                __TRACE("%d\t%d\t%d\n",
-                   wy, win->_firstch[wy], win->_lastch[wy]);
+                   wy, win->lines[wy]->firstch, win->lines[wy]->lastch);
 #endif
 #endif
-               if (win->_firstch[wy] != _NOCHANGE)
+               if (win->lines[wy]->flags & __ISDIRTY)
                        if (makech(win, wy) == ERR)
                                return (ERR);
                        else {
                        if (makech(win, wy) == ERR)
                                return (ERR);
                        else {
-                               if (win->_firstch[wy] >= win->_ch_off)
-                                       win->_firstch[wy] = win->_maxx +
-                                           win->_ch_off;
-                               if (win->_lastch[wy] < win->_maxx +
-                                   win->_ch_off)
-                                       win->_lastch[wy] = win->_ch_off;
-                               if (win->_lastch[wy] < win->_firstch[wy])
-                                       win->_firstch[wy] = _NOCHANGE;
+                               if (win->lines[wy]->firstch >= win->ch_off)
+                                       win->lines[wy]->firstch = win->maxx +
+                                           win->ch_off;
+                               if (win->lines[wy]->lastch < win->maxx +
+                                   win->ch_off)
+                                       win->lines[wy]->lastch = win->ch_off;
+                               if (win->lines[wy]->lastch < 
+                                   win->lines[wy]->firstch)
+                                       win->lines[wy]->flags &= ~__ISDIRTY;
                        }
 #ifdef DEBUG
                        }
 #ifdef DEBUG
-               __TRACE("\t%d\t%d\n", win->_firstch[wy], win->_lastch[wy]);
+               __TRACE("\t%d\t%d\n", win->lines[wy]->firstch, 
+                       win->lines[wy]->lastch);
 #endif
        }
 #endif
        }
-
+       
+       __TRACE("refresh: ly=%d, lx=%d\n", ly, lx);
        if (win == curscr)
        if (win == curscr)
-               domvcur(ly, lx, win->_cury, win->_curx);
+               domvcur(ly, lx, win->cury, win->curx);
        else {
        else {
-               if (win->_leave) {
-                       curscr->_cury = ly;
-                       curscr->_curx = lx;
-                       ly -= win->_begy;
-                       lx -= win->_begx;
-                       if (ly >= 0 && ly < win->_maxy && lx >= 0 &&
-                           lx < win->_maxx) {
-                               win->_cury = ly;
-                               win->_curx = lx;
+               if (win->flags & __LEAVEOK) {
+                       curscr->cury = ly;
+                       curscr->curx = lx;
+                       ly -= win->begy;
+                       lx -= win->begx;
+                       if (ly >= 0 && ly < win->maxy && lx >= 0 &&
+                           lx < win->maxx) {
+                               win->cury = ly;
+                               win->curx = lx;
                        } else
                        } else
-                               win->_cury = win->_curx = 0;
+                               win->cury = win->curx = 0;
                } else {
                } else {
-                       domvcur(ly, lx, win->_cury + win->_begy,
-                           win->_curx + win->_begx);
-                       curscr->_cury = win->_cury + win->_begy;
-                       curscr->_curx = win->_curx + win->_begx;
+                       domvcur(ly, lx, win->cury + win->begy,
+                           win->curx + win->begx);
+                       curscr->cury = win->cury + win->begy;
+                       curscr->curx = win->curx + win->begx;
                }
        }
        retval = OK;
                }
        }
        retval = OK;
@@ -136,29 +139,32 @@ makech(win, wy)
        register short wx, lch, y;
        register char *nsp, *csp, *ce;
 
        register short wx, lch, y;
        register char *nsp, *csp, *ce;
 
-       wx = win->_firstch[wy] - win->_ch_off;
-       if (wx >= win->_maxx)
+       if (!(win->lines[wy]->flags & __ISDIRTY))
+               return (OK);
+       wx = win->lines[wy]->firstch - win->ch_off;
+       if (wx >= win->maxx)
                return (OK);
        else if (wx < 0)
                wx = 0;
                return (OK);
        else if (wx < 0)
                wx = 0;
-       lch = win->_lastch[wy] - win->_ch_off;
+       lch = win->lines[wy]->lastch - win->ch_off;
        if (lch < 0)
                return (OK);
        if (lch < 0)
                return (OK);
-       else if (lch >= win->_maxx)
-               lch = win->_maxx - 1;;
-       y = wy + win->_begy;
+       else if (lch >= win->maxx)
+               lch = win->maxx - 1;
+       y = wy + win->begy;
 
        if (curwin)
                csp = " ";
        else
 
        if (curwin)
                csp = " ";
        else
-               csp = &curscr->_y[wy + win->_begy][wx + win->_begx];
+               csp = &curscr->lines[wy + win->begy]->line[wx + win->begx];
 
 
-       nsp = &win->_y[wy][wx];
+       nsp = &win->lines[wy]->line[wx];
        if (CE && !curwin) {
        if (CE && !curwin) {
-               for (ce = &win->_y[wy][win->_maxx - 1]; *ce == ' '; ce--)
-                       if (ce <= win->_y[wy])
+               for (ce = &win->lines[wy]->line[win->maxx - 1]; 
+                    *ce == ' '; ce--)
+                       if (ce <= win->lines[wy]->line)
                                break;
                                break;
-               nlsp = ce - win->_y[wy];
+               nlsp = ce - win->lines[wy]->line;
        }
        if (!curwin)
                ce = CE;
        }
        if (!curwin)
                ce = CE;
@@ -178,31 +184,32 @@ makech(win, wy)
                        }
                        break;
                }
                        }
                        break;
                }
-               domvcur(ly, lx, y, wx + win->_begx);
+               domvcur(ly, lx, y, wx + win->begx);
 #ifdef DEBUG
                __TRACE("makech: 1: wx = %d, lx = %d, newy = %d, newx = %d\n", 
 #ifdef DEBUG
                __TRACE("makech: 1: wx = %d, lx = %d, newy = %d, newx = %d\n", 
-                   wx, lx, y, wx + win->_begx);
+                   wx, lx, y, wx + win->begx);
 #endif
                ly = y;
 #endif
                ly = y;
-               lx = wx + win->_begx;
+               lx = wx + win->begx;
                while (*nsp != *csp && wx <= lch) {
                        if (ce != NULL && wx >= nlsp && *nsp == ' ') {
                                /* Check for clear to end-of-line. */
                while (*nsp != *csp && wx <= lch) {
                        if (ce != NULL && wx >= nlsp && *nsp == ' ') {
                                /* Check for clear to end-of-line. */
-                               ce = &curscr->_y[ly][COLS - 1];
+                               ce = &curscr->lines[ly]->line[COLS - 1];
                                while (*ce == ' ')
                                        if (ce-- <= csp)
                                                break;
                                while (*ce == ' ')
                                        if (ce-- <= csp)
                                                break;
-                               clsp = ce - curscr->_y[ly] - win->_begx;
+                               clsp = ce - curscr->lines[ly]->line - 
+                                      win->begx;
 #ifdef DEBUG
                        __TRACE("makech: clsp = %d, nlsp = %d\n", clsp, nlsp);
 #endif
                                if (clsp - nlsp >= strlen(CE) &&
 #ifdef DEBUG
                        __TRACE("makech: clsp = %d, nlsp = %d\n", clsp, nlsp);
 #endif
                                if (clsp - nlsp >= strlen(CE) &&
-                                   clsp < win->_maxx) {
+                                   clsp < win->maxx) {
 #ifdef DEBUG
                                        __TRACE("makech: using CE\n");
 #endif
                                        tputs(CE, 0, __cputchar);
 #ifdef DEBUG
                                        __TRACE("makech: using CE\n");
 #endif
                                        tputs(CE, 0, __cputchar);
-                                       lx = wx + win->_begx;
+                                       lx = wx + win->begx;
                                        while (wx++ <= clsp)
                                                *csp++ = ' ';
                                        return (OK);
                                        while (wx++ <= clsp)
                                                *csp++ = ' ';
                                        return (OK);
@@ -211,39 +218,39 @@ makech(win, wy)
                        }
 
                        /* Enter/exit standout mode as appropriate. */
                        }
 
                        /* Enter/exit standout mode as appropriate. */
-                       if (SO && (*nsp & _STANDOUT) !=
-                           (curscr->_flags & _STANDOUT)) {
-                               if (*nsp & _STANDOUT) {
+                       if (SO && (*nsp & __STANDOUT) !=
+                           (curscr->flags & __STANDOUT)) {
+                               if (*nsp & __STANDOUT) {
                                        tputs(SO, 0, __cputchar);
                                        tputs(SO, 0, __cputchar);
-                                       curscr->_flags |= _STANDOUT;
+                                       curscr->flags |= __WSTANDOUT;
                                } else {
                                        tputs(SE, 0, __cputchar);
                                } else {
                                        tputs(SE, 0, __cputchar);
-                                       curscr->_flags &= ~_STANDOUT;
+                                       curscr->flags &= ~__WSTANDOUT;
                                }
                        }
 
                        wx++;
                                }
                        }
 
                        wx++;
-                       if (wx >= win->_maxx && wy == win->_maxy - 1)
-                               if (win->_scroll) {
-                                       if (curscr->_flags & _STANDOUT
-                                           && win->_flags & _ENDLINE)
+                       if (wx >= win->maxx && wy == win->maxy - 1)
+                               if (win->flags & __SCROLLOK) {
+                                       if (curscr->flags & __WSTANDOUT
+                                           && win->flags & __ENDLINE)
                                                if (!MS) {
                                                        tputs(SE, 0,
                                                            __cputchar);
                                                if (!MS) {
                                                        tputs(SE, 0,
                                                            __cputchar);
-                                                       curscr->_flags &=
-                                                           ~_STANDOUT;
+                                                       curscr->flags &=
+                                                           ~__WSTANDOUT;
                                                }
                                        if (!curwin)
                                                putchar((*csp = *nsp) & 0177);
                                        else
                                                putchar(*nsp & 0177);
                                                }
                                        if (!curwin)
                                                putchar((*csp = *nsp) & 0177);
                                        else
                                                putchar(*nsp & 0177);
-                                       if (win->_flags & _FULLWIN && !curwin)
+                                       if (win->flags & __FULLWIN && !curwin)
                                                scroll(curscr);
                                                scroll(curscr);
-                                       ly = win->_begy + win->_cury;
-                                       lx = win->_begx + win->_curx;
+                                       ly = win->begy + wy;
+                                       lx = win->begx + wx;
                                        return (OK);
                                } else
                                        return (OK);
                                } else
-                                       if (win->_flags & _SCROLLWIN) {
+                                       if (win->flags & __SCROLLWIN) {
                                                lx = --wx;
                                                return (ERR);
                                        }
                                                lx = --wx;
                                                return (ERR);
                                        }
@@ -254,7 +261,7 @@ makech(win, wy)
 #ifdef DEBUG
                        __TRACE("makech: putchar(%c)\n", *nsp & 0177);
 #endif
 #ifdef DEBUG
                        __TRACE("makech: putchar(%c)\n", *nsp & 0177);
 #endif
-                       if (UC && (*nsp & _STANDOUT)) {
+                       if (UC && (*nsp & __STANDOUT)) {
                                putchar('\b');
                                tputs(UC, 0, __cputchar);
                        }
                                putchar('\b');
                                tputs(UC, 0, __cputchar);
                        }
@@ -263,9 +270,9 @@ makech(win, wy)
 #ifdef DEBUG
                __TRACE("makech: 2: wx = %d, lx = %d\n", wx, lx);
 #endif
 #ifdef DEBUG
                __TRACE("makech: 2: wx = %d, lx = %d\n", wx, lx);
 #endif
-               if (lx == wx + win->_begx)      /* If no change. */
+               if (lx == wx + win->begx)       /* If no change. */
                        break;
                        break;
-               lx = wx + win->_begx;
+               lx = wx + win->begx;
                if (lx >= COLS && AM) {
                        lx = 0;
                        ly++;
                if (lx >= COLS && AM) {
                        lx = 0;
                        ly++;
@@ -293,9 +300,9 @@ static void
 domvcur(oy, ox, ny, nx)
        int oy, ox, ny, nx;
 {
 domvcur(oy, ox, ny, nx)
        int oy, ox, ny, nx;
 {
-       if (curscr->_flags & _STANDOUT && !MS) {
+       if (curscr->flags & __WSTANDOUT && !MS) {
                tputs(SE, 0, __cputchar);
                tputs(SE, 0, __cputchar);
-               curscr->_flags &= ~_STANDOUT;
+               curscr->flags &= ~__WSTANDOUT;
        }
        mvcur(oy, ox, ny, nx);
 }
        }
        mvcur(oy, ox, ny, nx);
 }
index 390d0df..210eb15 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)scroll.c   5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)scroll.c   5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -26,7 +26,7 @@ scroll(win)
        __TRACE("scroll: (%0.2o)\n", win);
 #endif
 
        __TRACE("scroll: (%0.2o)\n", win);
 #endif
 
-       if (!win->_scroll)
+       if (!(win->flags & __SCROLLOK))
                return (ERR);
 
        getyx(win, oy, ox);
                return (ERR);
 
        getyx(win, oy, ox);
@@ -37,7 +37,7 @@ scroll(win)
        if (win == curscr) {
                putchar('\n');
                if (origtermio.c_oflag & ONLCR)
        if (win == curscr) {
                putchar('\n');
                if (origtermio.c_oflag & ONLCR)
-                       win->_curx = 0;
+                       win->curx = 0;
 #ifdef DEBUG
                __TRACE("scroll: win == curscr\n");
 #endif
 #ifdef DEBUG
                __TRACE("scroll: win == curscr\n");
 #endif
index 947cf0a..6fd5495 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)setterm.c  5.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)setterm.c  5.10 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/ioctl.h>
 #endif /* not lint */
 
 #include <sys/ioctl.h>
@@ -134,23 +134,30 @@ zap()
 {
        register char *namp, ***sp;
        register char **fp;
 {
        register char *namp, ***sp;
        register char **fp;
+       char tmp[3];
 #ifdef DEBUG
        register char   *cp;
 #endif
 #ifdef DEBUG
        register char   *cp;
 #endif
+       tmp[2] = '\0';
 
        namp = "ambsdadbeohchzinmimsncnsosulxbxnxtxsxx";
        fp = sflags;
        do {
 
        namp = "ambsdadbeohchzinmimsncnsosulxbxnxtxsxx";
        fp = sflags;
        do {
-               *(*fp++) = tgetflag(namp);
+               *tmp = *namp;
+               *(tmp + 1) = *(namp + 1);
+               *(*fp++) = tgetflag(tmp);
 #ifdef DEBUG
                __TRACE("2.2s = %s\n", namp, *fp[-1] ? "TRUE" : "FALSE");
 #endif
                namp += 2;
 #ifdef DEBUG
                __TRACE("2.2s = %s\n", namp, *fp[-1] ? "TRUE" : "FALSE");
 #endif
                namp += 2;
+               
        } while (*namp);
        namp = "albcbtcdceclcmcrcsdcdldmdoedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmandnlpcrcscsesfsosrtatetiucueupusvbvsveALDLUPDOLERI";
        sp = sstrs;
        do {
        } while (*namp);
        namp = "albcbtcdceclcmcrcsdcdldmdoedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmandnlpcrcscsesfsosrtatetiucueupusvbvsveALDLUPDOLERI";
        sp = sstrs;
        do {
-               *(*sp++) = tgetstr(namp, &aoftspace);
+               *tmp = *namp;
+               *(tmp + 1) = *(namp + 1);
+               *(*sp++) = tgetstr(tmp, &aoftspace);
 #ifdef DEBUG
                __TRACE("2.2s = %s", namp, *sp[-1] == NULL ? "NULL\n" : "\"");
                if (*sp[-1] != NULL) {
 #ifdef DEBUG
                __TRACE("2.2s = %s", namp, *sp[-1] == NULL ? "NULL\n" : "\"");
                if (*sp[-1] != NULL) {
index cced83b..eec660e 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)standout.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)standout.c 5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -22,7 +22,7 @@ wstandout(win)
        if (!SO && !UC)
                return (0);
 
        if (!SO && !UC)
                return (0);
 
-       win->_flags |= _STANDOUT;
+       win->flags |= __WSTANDOUT;
        return (SO ? SO : UC);
 }
 
        return (SO ? SO : UC);
 }
 
@@ -37,6 +37,6 @@ wstandend(win)
        if (!SO && !UC)
                return (0);
 
        if (!SO && !UC)
                return (0);
 
-       win->_flags &= ~_STANDOUT;
+       win->flags &= ~__WSTANDOUT;
        return (SE ? SE : UC);
 }
        return (SE ? SE : UC);
 }
index 5a1a20d..a677dcb 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)toucholap.c        5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)toucholap.c        5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -24,26 +24,26 @@ touchoverlap(win1, win2)
 #ifdef DEBUG
        __TRACE("touchoverlap: (%0.2o, %0.2o);\n", win1, win2);
 #endif
 #ifdef DEBUG
        __TRACE("touchoverlap: (%0.2o, %0.2o);\n", win1, win2);
 #endif
-       starty = max(win1->_begy, win2->_begy);
-       startx = max(win1->_begx, win2->_begx);
-       endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx);
-       endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
+       starty = max(win1->begy, win2->begy);
+       startx = max(win1->begx, win2->begx);
+       endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx);
+       endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx);
 #ifdef DEBUG
        __TRACE("touchoverlap: from (%d,%d) to (%d,%d)\n",
            starty, startx, endy, endx);
        __TRACE("touchoverlap: win1 (%d,%d) to (%d,%d)\n",
 #ifdef DEBUG
        __TRACE("touchoverlap: from (%d,%d) to (%d,%d)\n",
            starty, startx, endy, endx);
        __TRACE("touchoverlap: win1 (%d,%d) to (%d,%d)\n",
-           win1->_begy, win1->_begx, win1->_begy + win1->_maxy,
-           win1->_begx + win1->_maxx);
+           win1->begy, win1->begx, win1->begy + win1->maxy,
+           win1->begx + win1->maxx);
        __TRACE("touchoverlap: win2 (%d,%d) to (%d,%d)\n",
        __TRACE("touchoverlap: win2 (%d,%d) to (%d,%d)\n",
-           win2->_begy, win2->_begx, win2->_begy + win2->_maxy,
-           win2->_begx + win2->_maxx);
+           win2->begy, win2->begx, win2->begy + win2->maxy,
+           win2->begx + win2->maxx);
 #endif
        if (starty >= endy || startx >= endx)
                return (OK);
 #endif
        if (starty >= endy || startx >= endx)
                return (OK);
-       starty -= win2->_begy;
-       startx -= win2->_begx;
-       endy -= win2->_begy;
-       endx -= win2->_begx;
+       starty -= win2->begy;
+       startx -= win2->begx;
+       endy -= win2->begy;
+       endx -= win2->begx;
        for (--endx, y = starty; y < endy; y++)
                touchline(win2, y, startx, endx);
        return (OK);
        for (--endx, y = starty; y < endy; y++)
                touchline(win2, y, startx, endx);
        return (OK);
index 032d165..ddf4f5d 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)touchwin.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)touchwin.c 5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <curses.h>
 #endif /* not lint */
 
 #include <curses.h>
@@ -24,9 +24,9 @@ touchwin(win)
 #ifdef DEBUG
        __TRACE("touchwin: (%0.2o)\n", win);
 #endif
 #ifdef DEBUG
        __TRACE("touchwin: (%0.2o)\n", win);
 #endif
-       maxy = win->_maxy;
+       maxy = win->maxy;
        for (y = 0; y < maxy; y++)
        for (y = 0; y < maxy; y++)
-               touchline(win, y, 0, win->_maxx - 1);
+               touchline(win, y, 0, win->maxx - 1);
        return (OK);
 }
 
        return (OK);
 }
 
@@ -42,22 +42,23 @@ touchline(win, y, sx, ex)
 #ifdef DEBUG
        __TRACE("touchline: (%0.2o, %d, %d, %d)\n", win, y, sx, ex);
        __TRACE("touchline: first = %d, last = %d\n",
 #ifdef DEBUG
        __TRACE("touchline: (%0.2o, %d, %d, %d)\n", win, y, sx, ex);
        __TRACE("touchline: first = %d, last = %d\n",
-           win->_firstch[y], win->_lastch[y]);
+           win->lines[y]->firstch, win->lines[y]->lastch);
 #endif
 #endif
-       sx += win->_ch_off;
-       ex += win->_ch_off;
-       if (win->_firstch[y] == _NOCHANGE) {
-               win->_firstch[y] = sx;
-               win->_lastch[y] = ex;
+       sx += win->ch_off;
+       ex += win->ch_off;
+       if (!(win->lines[y]->flags & __ISDIRTY)) {
+               win->lines[y]->flags |= __ISDIRTY;
+               win->lines[y]->firstch = sx;
+               win->lines[y]->lastch = ex;
        } else {
        } else {
-               if (win->_firstch[y] > sx)
-                       win->_firstch[y] = sx;
-               if (win->_lastch[y] < ex)
-                       win->_lastch[y] = ex;
+               if (win->lines[y]->firstch > sx)
+                       win->lines[y]->firstch = sx;
+               if (win->lines[y]->lastch < ex)
+                       win->lines[y]->lastch = ex;
        }
 #ifdef DEBUG
        __TRACE("touchline: first = %d, last = %d\n",
        }
 #ifdef DEBUG
        __TRACE("touchline: first = %d, last = %d\n",
-           win->_firstch[y], win->_lastch[y]);
+           win->lines[y]->firstch, win->lines[y]->lastch);
 #endif
        return (OK);
 }
 #endif
        return (OK);
 }
index 7207093..bb56547 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)tty.c      5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)tty.c      5.3 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -143,9 +143,9 @@ int
 endwin()
 {
        if (curscr) {
 endwin()
 {
        if (curscr) {
-               if (curscr->_flags & _STANDOUT) {
+               if (curscr->flags & __WSTANDOUT) {
                        tputs(SE, 0, __cputchar);
                        tputs(SE, 0, __cputchar);
-                       curscr->_flags &= ~_STANDOUT;
+                       curscr->flags &= ~__WSTANDOUT;
                }
                __endwin = 1;
        }
                }
                __endwin = 1;
        }