make tags for header file too
[unix-history] / usr / src / lib / libcurses / addch.c
index 8650d39..29e5623 100644 (file)
@@ -1,80 +1,33 @@
+/*
+ * Copyright (c) 1981 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)addch.c    5.4 (Berkeley) %G%";
+#endif /* not lint */
+
 # include      "curses.ext"
 
 /*
  *     This routine adds the character to the current position
  *
 # include      "curses.ext"
 
 /*
  *     This routine adds the character to the current position
  *
- * %G% (Berkeley) @(#)addch.c  1.2
  */
 waddch(win, c)
  */
 waddch(win, c)
-reg WINDOW     *win;
+WINDOW *win;
 char           c;
 {
 char           c;
 {
-       reg int         x, y;
-
-       x = win->_curx;
-       y = win->_cury;
-# ifdef FULLDEBUG
-       fprintf(outf, "ADDCH('%c') at (%d, %d)\n", c, y, x);
-# endif
-       if (y >= win->_maxy || x >= win->_maxx || y < 0 || x < 0)
-               return ERR;
-       switch (c) {
-         case '\t':
-         {
-               reg int         newx;
-
-               for (newx = x + (8 - (x & 07)); x < newx; x++)
-                       if (waddch(win, ' ') == ERR)
-                               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;
-               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;
-               }
-               win->_y[y][x++] = c;
-               if (x >= win->_maxx) {
-newline:
-                       x = 0;
-nonewline:
-                       if (++y + 1 == win->_maxy)
-                               if (win->_scroll) {
-                                       wrefresh(win);
-                                       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)
-                       goto nonewline;
-               else
-                       goto newline;
-         case '\r':
-               x = 0;
-               break;
-         case '\b':
-               if (--x < 0)
-                       x = 0;
-               break;
-       }
-       win->_curx = x;
-       win->_cury = y;
-       return OK;
+    return waddbytes(win, &c, 1);
 }
 }