386BSD 0.1 development
[unix-history] / usr / src / lib / libcurses / addch.c
index e823d77..897660a 100644 (file)
@@ -1,96 +1,49 @@
-# include      "curses.ext"
-
 /*
 /*
- *     This routine adds the character to the current position
+ * Copyright (c) 1981 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- * @(#)addch.c 1.7 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
  */
-waddch(win, c)
-reg WINDOW     *win;
-char           c;
-{
-       reg int         x, y;
-       reg WINDOW      *wp;
-       reg int         newx;
 
 
-       x = win->_curx;
-       y = win->_cury;
-# ifdef FULLDEBUG
-       fprintf(outf, "ADDCH('%c') at (%d, %d)\n", c, y, x);
-# endif
-       switch (c) {
-         case '\t':
-               for (newx = x + (8 - (x & 07)); x < newx; x++)
-                       if (waddch(win, ' ') == ERR)
-                               return ERR;
-               return OK;
+#ifndef lint
+static char sccsid[] = "@(#)addch.c    5.5 (Berkeley) 6/1/90";
+#endif /* not lint */
 
 
-         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;
-               set_ch(win, y, x, c);
-               win->_y[y][x++] = c;
-               if (x >= win->_maxx) {
-                       x = 0;
-newline:
-                       if (++y >= win->_maxy)
-                               if (win->_scroll) {
-                                       scroll(win);
-                                       --y;
-                               }
-                               else
-                                       return ERR;
-               }
-# ifdef FULLDEBUG
-               fprintf(outf, "ADDCH: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]);
-# endif
-               break;
-         case '\n':
-               wclrtoeol(win);
-               if (!NONL)
-                       x = 0;
-               goto newline;
-         case '\r':
-               x = 0;
-               break;
-         case '\b':
-               if (--x < 0)
-                       x = 0;
-               break;
-       }
-       win->_curx = x;
-       win->_cury = y;
-       return OK;
-}
+# include      "curses.ext"
 
 /*
 
 /*
- * set_ch:
- *     Set the first and last change flags for this window.
+ *     This routine adds the character to the current position
+ *
  */
  */
-static
-set_ch(win, y, x, ch)
-reg WINDOW     *win;
-int            y, x;
+waddch(win, c)
+WINDOW *win;
+char           c;
 {
 {
-# ifdef        FULLDEBUG
-       fprintf(outf, "SET_CH(%0.2o, %d, %d)\n", win, y, x);
-# endif
-       if (win->_y[y][x] != ch) {
-               x += win->_ch_off;
-               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;
-# ifdef FULLDEBUG
-               fprintf(outf, "SET_CH: 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);
-# endif
-       }
+    return waddbytes(win, &c, 1);
 }
 }