home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 332_01 / linedel.c < prev    next >
C/C++ Source or Header  |  1990-01-06  |  3KB  |  97 lines

  1. /****************************************************************/
  2. /* Wdeleteln() 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.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.0:     Release:                    870515    */
  16. /****************************************************************/
  17.  
  18. #include <curses.h>
  19. #include <curspriv.h>
  20.  
  21. char _curses_linedel_rcsid[] = "@(#)linedel.c    v.1.4  - 900114";
  22.  
  23. /****************************************************************/
  24. /* Wdeleteln() deletes the line at the window cursor, and the    */
  25. /* lines below it are shifted up, inserting a blank line at    */
  26. /* the bottom of the window.                    */
  27. /****************************************************************/
  28.  
  29. int    wdeleteln(win)
  30.   WINDOW    *win;
  31.   {
  32.   short        *end;
  33.   short        *temp;
  34.   short     y;
  35.   static short     blank;
  36.   
  37.   blank = ' ' | (win->_attrs & ATR_MSK);
  38.  
  39.   temp = win->_line[win->_cury];
  40.   for (y = win->_cury; y < win->_regbottom; y++)
  41.     {
  42.     win->_line[y] = win->_line[y+1];
  43.     win->_minchng[y] = 0;
  44.     win->_maxchng[y] = win->_maxx - 1;
  45.     }
  46.   win->_minchng[y] = 0;
  47.   win->_maxchng[y] = win->_maxx - 1;
  48.   win->_line[win->_regbottom] = temp;
  49.   for (end = &(temp[win->_maxx -1]); temp <= end;)
  50.     *temp++ = blank;
  51.   return(OK);
  52.   } /* wdeleteln */
  53.  
  54. /****************************************************************/
  55. /* Deleteln() deletes the line at the stdscr cursor, and the    */
  56. /* lines below it are shifted up, inserting a blank line at    */
  57. /* the bottom of stdscr.                    */
  58. /****************************************************************/
  59.  
  60. int deleteln()
  61.   {
  62.   return(wdeleteln(stdscr));
  63.   } /* deleteln */
  64.  
  65. /****************************************************************/
  66. /* Mvdeleteln() moves the cursor to a new position in stdscr,    */
  67. /* then deletes the line at the window cursor, and the lines    */
  68. /* below it are shifted up, inserting a blank line at the bot-    */
  69. /* tom of stdscr.                        */
  70. /****************************************************************/
  71.  
  72. int mvdeleteln(y,x)
  73.   int y;
  74.   int x;
  75.   {
  76.   if (wmove(stdscr,y,x) == ERR)
  77.     return(ERR);
  78.   return(wdeleteln(stdscr));
  79.   } /* mvdeleteln */
  80.  
  81. /****************************************************************/
  82. /* Mvwdeleteln() moves the cursor to a new position in a win-    */
  83. /* dow, then deletes the line at the window cursor, and the    */
  84. /* lines below it are shifted up, inserting a blank line at    */
  85. /* the bottom of the window.                    */
  86. /****************************************************************/
  87.  
  88. int mvwdeleteln(win,y,x)
  89.   WINDOW *win;
  90.   int y;
  91.   int x;
  92.   {
  93.   if (wmove(win,y,x) == ERR)
  94.     return(ERR);
  95.   return(wdeleteln(win));
  96.   } /* mvwdeleteln */
  97.