Pull in some of the lpt_port_test fixes from lpt.c.
[unix-history] / lib / libcurses / insertln.c
index 09b8b43..9a9e321 100644 (file)
@@ -1,6 +1,6 @@
 /*
 /*
- * Copyright (c) 1981 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1981, 1993
+ *     The 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
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)insertln.c 5.4 (Berkeley) 6/1/90";
-#endif /* not lint */
+static char sccsid[] = "@(#)insertln.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
 
 
-# include      "curses.ext"
+#include <curses.h>
+#include <string.h>
 
 /*
 
 /*
- *     This routine performs an insert-line on the window, leaving
- * (_cury,_curx) unchanged.
- *
+ * winsertln --
+ *     Do an insert-line on the window, leaving (cury, curx) unchanged.
  */
  */
+int
 winsertln(win)
 winsertln(win)
-reg WINDOW     *win; {
+       register WINDOW *win;
+{
 
 
-       reg chtype      *temp;
-       reg int         y;
-       reg chtype      *end;
-       reg int         x;
+       register int y, i;
+       register __LINE *temp;
 
 
-#ifdef DEBUG
-       fprintf(outf, "INSERTLN(%0.2o)\n", win);
+#ifdef DEBUG
+       __CTRACE("insertln: (%0.2o)\n", win);
 #endif
 #endif
-       if (win->_orig == NULL)
-               temp = win->_y[win->_maxy - 1];
-       for (y = win->_maxy - 1; y > win->_cury; --y) {
-               if (win->_orig == NULL)
-                       win->_y[y] = win->_y[y - 1];
+       if (win->orig == NULL)
+               temp = win->lines[win->maxy - 1];
+       for (y = win->maxy - 1; y > (int) win->cury; --y) {
+               win->lines[y]->flags &= ~__ISPASTEOL;
+               win->lines[y - 1]->flags &= ~__ISPASTEOL;
+               if (win->orig == NULL)
+                       win->lines[y] = win->lines[y - 1];
                else
                else
-                       bcopy(win->_y[y - 1], win->_y[y], win->_maxx * sizeof(chtype));
-               touchline(win, y, 0, win->_maxx - 1);
+                       (void)memcpy(win->lines[y]->line, 
+                           win->lines[y - 1]->line, 
+                           win->maxx * __LDATASIZE);
+               __touchline(win, y, 0, win->maxx - 1, 0);
        }
        }
-       if (win->_orig == NULL)
-               win->_y[y] = temp;
+       if (win->orig == NULL)
+               win->lines[y] = temp;
        else
        else
-               temp = win->_y[y];
-       for (end = &temp[win->_maxx]; temp < end; )
-               *temp++ = ' ';
-       touchline(win, y, 0, win->_maxx - 1);
-       if (win->_orig == NULL)
-               _id_subwins(win);
+               temp = win->lines[y];
+       for(i = 0; i < win->maxx; i++) {
+               temp->line[i].ch = ' ';
+               temp->line[i].attr = 0;
+       }
+       __touchline(win, y, 0, win->maxx - 1, 0);
+       if (win->orig == NULL)
+               __id_subwins(win);
+       return (OK);
 }
 }