home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / cursesp.zip / LINEDEL.C < prev    next >
C/C++ Source or Header  |  1991-12-02  |  4KB  |  95 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.0: Release:                                        870515  */
  12. /* 1.2: max limits off by 1. Fixed thanks to S. Creps:  881002  */
  13. /* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes:            881005  */
  14. /****************************************************************/
  15.  
  16. #include <curses.h>
  17. #include <curspriv.h>
  18.  
  19. char _curses_linedel_rcsid[] = "@(#)linedel.c v1.3 - 881005";
  20.  
  21. /****************************************************************/
  22. /* Wdeleteln() deletes the line at the window cursor, and the   */
  23. /* lines below it are shifted up, inserting a blank line at     */
  24. /* the bottom of the window.                                    */
  25. /****************************************************************/
  26.  
  27. int     wdeleteln(win)
  28.   WINDOW        *win;
  29.   {
  30.   int           *end;
  31.   int           *temp;
  32.   short  y;
  33.   static   int   blank;
  34.   
  35.   blank = ' ' | (win->_attrs & ATR_MSK);
  36.  
  37.   temp = win->_line[win->_cury];
  38.   for (y = win->_cury; y < win->_regbottom; y++)
  39.     {
  40.     win->_line[y] = win->_line[y+1];
  41.     win->_minchng[y] = 0;
  42.     win->_maxchng[y] = win->_maxx - 1;
  43.     }
  44.   win->_minchng[y] = 0;
  45.   win->_maxchng[y] = win->_maxx - 1;
  46.   win->_line[win->_regbottom] = temp;
  47.   for (end = &(temp[win->_maxx -1]); temp <= end;)
  48.     *temp++ = blank;
  49.   return(OK);
  50.   } /* wdeleteln */
  51.  
  52. /****************************************************************/
  53. /* Deleteln() deletes the line at the stdscr cursor, and the    */
  54. /* lines below it are shifted up, inserting a blank line at     */
  55. /* the bottom of stdscr.                                        */
  56. /****************************************************************/
  57.  
  58. int deleteln()
  59.   {
  60.   return(wdeleteln(stdscr));
  61.   } /* deleteln */
  62.  
  63. /****************************************************************/
  64. /* Mvdeleteln() moves the cursor to a new position in stdscr,   */
  65. /* then deletes the line at the window cursor, and the lines    */
  66. /* below it are shifted up, inserting a blank line at the bot-  */
  67. /* tom of stdscr.                                               */
  68. /****************************************************************/
  69.  
  70. int mvdeleteln(y,x)
  71.   int y;
  72.   int x;
  73.   {
  74.   if (wmove(stdscr,y,x) == ERR)
  75.     return(ERR);
  76.   return(wdeleteln(stdscr));
  77.   } /* mvdeleteln */
  78.  
  79. /****************************************************************/
  80. /* Mvwdeleteln() moves the cursor to a new position in a win-   */
  81. /* dow, then deletes the line at the window cursor, and the     */
  82. /* lines below it are shifted up, inserting a blank line at     */
  83. /* the bottom of the window.                                    */
  84. /****************************************************************/
  85.  
  86. int mvwdeleteln(win,y,x)
  87.   WINDOW *win;
  88.   int y;
  89.   int x;
  90.   {
  91.   if (wmove(win,y,x) == ERR)
  92.     return(ERR);
  93.   return(wdeleteln(win));
  94.   } /* mvwdeleteln */
  95.