4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / lib / libcurses / insch.c
index 0d8fd3f..743756a 100644 (file)
@@ -1,41 +1,47 @@
 /*
 /*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * Copyright (c) 1981 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)insch.c    5.1 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)insch.c    5.13 (Berkeley) %G%";
+#endif /* not lint */
 
 
-# include      "curses.ext"
+#include <curses.h>
+#include <string.h>
 
 /*
 
 /*
- *     This routine performs an insert-char on the line, leaving
- * (_cury,_curx) unchanged.
- *
+ * winsch --
+ *     Do an insert-char on the line, leaving (cury, curx) unchanged.
  */
  */
-winsch(win, c)
-reg WINDOW     *win;
-char           c; {
+int
+winsch(win, ch)
+       register WINDOW *win;
+       int ch;
+{
 
 
-       reg char        *temp1, *temp2;
-       reg char        *end;
+       register __LDATA *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;
        temp2 = temp1 - 1;
-       while (temp1 > end)
-               *temp1-- = *temp2--;
-       *temp1 = c;
-       touchline(win, win->_cury, win->_curx, win->_maxx - 1);
-       if (win->_cury == LINES - 1 && win->_y[LINES-1][COLS-1] != ' ')
-               if (win->_scroll) {
+       while (temp1 > end) {
+               (void)memcpy(temp1, temp2, sizeof(__LDATA));
+               temp1--, temp2--;
+       }
+       temp1->ch = ch;
+       temp1->attr &= ~__STANDOUT;
+       __touchline(win, win->cury, win->curx, win->maxx - 1, 0);
+       if (win->cury == LINES - 1 && 
+           (win->lines[LINES - 1]->line[COLS - 1].ch != ' ' ||
+           win->lines[LINES -1]->line[COLS - 1].attr != 0))
+               if (win->flags & __SCROLLOK) {
                        wrefresh(win);
                        scroll(win);
                        wrefresh(win);
                        scroll(win);
-                       win->_cury--;
-               }
-               else
-                       return ERR;
-       return OK;
+                       win->cury--;
+               } else
+                       return (ERR);
+       return (OK);
 }
 }