BSD 4_2 release
[unix-history] / usr / src / usr.lib / libcurses / addch.c
index 6dae0cf..3ae88d6 100644 (file)
@@ -3,13 +3,14 @@
 /*
  *     This routine adds the character to the current position
  *
 /*
  *     This routine adds the character to the current position
  *
- * 3/5/81 (Berkeley) @(#)addch.c       1.3
+ * @(#)addch.c 1.5 (Berkeley) 5/19/83
  */
 waddch(win, c)
 reg WINDOW     *win;
 char           c;
 {
        reg int         x, y;
  */
 waddch(win, c)
 reg WINDOW     *win;
 char           c;
 {
        reg int         x, y;
+       reg WINDOW      *wp;
 
        x = win->_curx;
        y = win->_cury;
 
        x = win->_curx;
        y = win->_cury;
@@ -28,20 +29,16 @@ char                c;
                                return ERR;
                return OK;
          }
                                return ERR;
                return OK;
          }
+
          default:
 # ifdef FULLDEBUG
                fprintf(outf, "ADDCH: 1: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]);
 # endif
                if (win->_flags & _STANDOUT)
                        c |= _STANDOUT;
          default:
 # ifdef FULLDEBUG
                fprintf(outf, "ADDCH: 1: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]);
 # endif
                if (win->_flags & _STANDOUT)
                        c |= _STANDOUT;
-               if (win->_y[y][x] != c) {
-                       if (win->_firstch[y] == _NOCHANGE)
-                               win->_firstch[y] = win->_lastch[y] = x;
-                       else if (x < win->_firstch[y])
-                               win->_firstch[y] = x;
-                       else if (x > win->_lastch[y])
-                               win->_lastch[y] = x;
-               }
+               set_ch(win, y, x, c, NULL);
+               for (wp = win->_nextp; wp != win; wp = wp->_nextp)
+                       set_ch(wp, y, x, c, win);
                win->_y[y][x++] = c;
                if (x >= win->_maxx) {
                        x = 0;
                win->_y[y][x++] = c;
                if (x >= win->_maxx) {
                        x = 0;
@@ -76,3 +73,29 @@ newline:
        win->_cury = y;
        return OK;
 }
        win->_cury = y;
        return OK;
 }
+
+/*
+ * set_ch:
+ *     Set the first and last change flags for this window.
+ */
+static
+set_ch(win, y, x, ch, orig)
+reg WINDOW     *win;
+int            y, x;
+WINDOW         *orig; {
+
+       if (orig != NULL) {
+               y -= win->_begy - orig->_begy;
+               x -= win->_begx - orig->_begx;
+       }
+       if (y < 0 || y >= win->_maxy || x < 0 || x >= win->_maxx)
+               return;
+       if (win->_y[y][x] != ch) {
+               if (win->_firstch[y] == _NOCHANGE)
+                       win->_firstch[y] = win->_lastch[y] = x;
+               else if (x < win->_firstch[y])
+                       win->_firstch[y] = x;
+               else if (x > win->_lastch[y])
+                       win->_lastch[y] = x;
+       }
+}