move entry/exit debugging to 21.1
[unix-history] / usr / src / lib / libcurses / addch.c
index 2b769ac..f4b7bb6 100644 (file)
@@ -1,81 +1,40 @@
-# include      "curses.ext"
+/*
+ * Copyright (c) 1981, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)addch.c    8.2 (Berkeley) %G%";
+#endif /* not lint */
+
+#include "curses.h"
 
 /*
 
 /*
- *     This routine adds the character to the current position
+ * waddch --
+ *     Add the character to the current position in the given window.
  *
  *
- * %G% (Berkeley) @(#)addch.c  1.1
  */
  */
-waddch(win, c)
-reg WINDOW     *win;
-char           c;
+int
+waddch(win, ch)
+       WINDOW *win;
+       int ch;
 {
 {
-       reg int         x, y;
+       __LDATA buf;
+
+       buf.ch = ch;
+       buf.attr = 0;
+       return (__waddch(win, &buf));
+}
 
 
-       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;
+int
+__waddch(win, dp)
+       WINDOW *win;
+       __LDATA *dp;
+{
+       char buf[2];
 
 
-               --x;
-               for (newx = x + (8 - (x & 07)) + 1; 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;
+       buf[0] = dp->ch;
+       return (__waddbytes(win, buf, 1, dp->attr & __STANDOUT));
 }
 }