home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 332_01 / lineins.c < prev    next >
C/C++ Source or Header  |  1990-01-06  |  3KB  |  93 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 (bl@infovox.se)    */
  10. /****************************************************************/
  11. /* 1.4:  Use of short wherever possible. Portability        */
  12. /*     improvements:                    900114    */
  13. /* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  14. /* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  15. /* 1.1:     Mvinsertln() and friends were misrenamed:    880305    */
  16. /* 1.0:     Release:                    870515    */
  17. /****************************************************************/
  18.  
  19. #include <curses.h>
  20. #include <curspriv.h>
  21.  
  22. char _curses_lineins_rcsid[] = "@(#)lineins.c    v.1.4  - 900114";
  23.  
  24. /****************************************************************/
  25. /* Winsertln() inserts a blank line instead of the cursor line    */
  26. /* in window 'win' and pushes other lines down.            */
  27. /****************************************************************/
  28.  
  29. int    winsertln(win)
  30.   WINDOW    *win;
  31.   {
  32.   short        *temp;
  33.   short        *end;
  34.   short     y;
  35.   static short     blank;
  36.   
  37.   blank = ' ' | (win->_attrs & ATR_MSK);
  38.   temp = win->_line[win->_regbottom];
  39.   for (y = win->_regbottom;  y > win->_cury;  y--)
  40.     {
  41.     win->_line[y] = win->_line[y-1];
  42.     win->_minchng[y] = 0;
  43.     win->_maxchng[y] = win->_maxx - 1;
  44.     } /* for */
  45.   win->_line[win->_cury] = temp;
  46.   for (end = &temp[win->_maxx -1];  temp <= end;  temp++)
  47.     *temp = blank;
  48.   win->_minchng[win->_cury] = 0;
  49.   win->_maxchng[win->_cury] = win->_maxx - 1;
  50.   return(OK);
  51.   } /* winsertln */
  52.  
  53. /****************************************************************/
  54. /* Insertln() inserts a blank line instead of the cursor line    */
  55. /* in stdscr and pushes other lines down.            */
  56. /****************************************************************/
  57.  
  58. int insertln()
  59.   {
  60.   return(winsertln(stdscr));
  61.   } /* insertln */
  62.  
  63. /****************************************************************/
  64. /* Mvinsertln() moves the stdscr cursor to a new positions, in-    */
  65. /* serts a blank line instead of the cursor line and pushes    */
  66. /* other lines down.                        */
  67. /****************************************************************/
  68.  
  69. int mvinsertln(y,x)
  70.   int y;
  71.   int x;
  72.   {
  73.   if (wmove(stdscr,y,x) == ERR)
  74.     return(ERR);
  75.   return(winsertln(stdscr));
  76.   } /* mvinsertln */
  77.  
  78. /****************************************************************/
  79. /* Mvwinsertln() moves the cursor in window 'win' to a new po-    */
  80. /* si tions, inserts a blank line instead of the cursor line    */
  81. /* and pushes other lines down.                    */
  82. /****************************************************************/
  83.  
  84. int mvwinsertln(win,y,x)
  85.   WINDOW *win;
  86.   int y;
  87.   int x;
  88.   {
  89.   if (wmove(win,y,x) == ERR)
  90.     return(ERR);
  91.   return(winsertln(win));
  92.   } /* mvwinsertln */
  93.