home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CURSES.LZH / LINEINS.C < prev    next >
C/C++ Source or Header  |  1980-01-01  |  3KB  |  91 lines

  1. /****************************************************************/
  2. /* Winsertln() routine of the PCcurses package            */
  3. /*                                */
  4. /****************************************************************/
  5. /* This version of curses is based on ncurses, a curses version    */
  6. /* originally written by Pavel Curtis at Cornell University.    */
  7. /* I have made substantial changes to make it run on IBM PC's,    */
  8. /* and therefore consider myself free to make it public domain.    */
  9. /*        Bjorn Larsson (...mcvax!enea!infovax!bl)    */
  10. /****************************************************************/
  11. /* 1.0:    Release:                    870515    */
  12. /* 1.1:    Mvinsertln() and friends were misrenamed:    880305    */
  13. /* 1.2:    Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  14. /* 1.3:    MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  15. /****************************************************************/
  16.  
  17. #include <curses.h>
  18. #include <curspriv.h>
  19.  
  20. char _curses_lineins_rcsid[] = "@(#)lineins.c v1.3 - 881005";
  21.  
  22. /****************************************************************/
  23. /* Winsertln() inserts a blank line instead of the cursor line    */
  24. /* in window 'win' and pushes other lines down.            */
  25. /****************************************************************/
  26.  
  27. int    winsertln(win)
  28.   WINDOW    *win;
  29.   {
  30.   int        *temp;
  31.   int        *end;
  32.   short     y;
  33.   static   int     blank;
  34.   
  35.   blank = ' ' | (win->_attrs & ATR_MSK);
  36.   temp = win->_line[win->_regbottom];
  37.   for (y = win->_regbottom;  y > win->_cury;  y--)
  38.     {
  39.     win->_line[y] = win->_line[y-1];
  40.     win->_minchng[y] = 0;
  41.     win->_maxchng[y] = win->_maxx - 1;
  42.     } /* for */
  43.   win->_line[win->_cury] = temp;
  44.   for (end = &temp[win->_maxx -1];  temp <= end;  temp++)
  45.     *temp = blank;
  46.   win->_minchng[win->_cury] = 0;
  47.   win->_maxchng[win->_cury] = win->_maxx - 1;
  48.   return(OK);
  49.   } /* winsertln */
  50.  
  51. /****************************************************************/
  52. /* Insertln() inserts a blank line instead of the cursor line    */
  53. /* in stdscr and pushes other lines down.            */
  54. /****************************************************************/
  55.  
  56. int insertln()
  57.   {
  58.   return(winsertln(stdscr));
  59.   } /* insertln */
  60.  
  61. /****************************************************************/
  62. /* Mvinsertln() moves the stdscr cursor to a new positions, in-    */
  63. /* serts a blank line instead of the cursor line and pushes    */
  64. /* other lines down.                        */
  65. /****************************************************************/
  66.  
  67. int mvinsertln(y,x)
  68.   int y;
  69.   int x;
  70.   {
  71.   if (wmove(stdscr,y,x) == ERR)
  72.     return(ERR);
  73.   return(winsertln(stdscr));
  74.   } /* mvinsertln */
  75.  
  76. /****************************************************************/
  77. /* Mvwinsertln() moves the cursor in window 'win' to a new po-    */
  78. /* si tions, inserts a blank line instead of the cursor line    */
  79. /* and pushes other lines down.                    */
  80. /****************************************************************/
  81.  
  82. int mvwinsertln(win,y,x)
  83.   WINDOW *win;
  84.   int y;
  85.   int x;
  86.   {
  87.   if (wmove(win,y,x) == ERR)
  88.     return(ERR);
  89.   return(winsertln(win));
  90.   } /* mvwinsertln */
  91.