home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CURS13_2.ZIP / CLRTOEOL.C < prev    next >
Text File  |  1989-12-08  |  3KB  |  104 lines

  1. /****************************************************************/
  2. /* Wclrtoeol() 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:    880210    */
  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_clrtoeol_rcsid[] = "@(#)clrtoeol.c v1.3 - 881005";
  20.  
  21. /****************************************************************/
  22. /* Wclrtoeol() fills the half of the cursor line to the right    */
  23. /* of the cursor in window 'win' with blanks.            */
  24. /****************************************************************/
  25.  
  26. int    wclrtoeol(win)
  27.    WINDOW    *win;
  28.   {
  29.   int        *maxx;
  30.   int        *ptr;
  31.   int        *end;
  32.   static int     y;
  33.   static int     x;
  34.   static int     minx;
  35.   static int      blank;
  36.   
  37.   y = win->_cury;
  38.   x = win->_curx;
  39.   blank = ' ' | (win->_attrs & ATR_MSK);
  40.  
  41.   end = &win->_line[y][win->_maxx - 1];
  42.   minx = _NO_CHANGE;
  43.   maxx = &win->_line[y][x];
  44.   for (ptr = maxx; ptr <= end; ptr++)
  45.     {
  46.     if (*ptr != blank)
  47.       {
  48.       maxx = ptr;
  49.       if (minx == _NO_CHANGE)
  50.     minx = ptr - win->_line[y];
  51.       *ptr = blank;
  52.       } /* if */
  53.     } /* for */
  54.  
  55.   if (minx != _NO_CHANGE)
  56.     {
  57.     if (win->_minchng[y] > minx || win->_minchng[y] == _NO_CHANGE)
  58.       win->_minchng[y] = minx;
  59.     if (win->_maxchng[y] < maxx - win->_line[y])
  60.       win->_maxchng[y] = maxx - win->_line[y];
  61.     } /* if */
  62.   return(OK);
  63.   } /* wclrtoeol */
  64.  
  65. /****************************************************************/
  66. /* Clrtoeol() fills the half of the cursor line to the right    */
  67. /* of the cursor in stdscr with blanks.                */
  68. /****************************************************************/
  69.  
  70. int clrtoeol()
  71.   {
  72.   return(wclrtoeol(stdscr));
  73.   } /* clrtoeol */
  74.  
  75. /****************************************************************/
  76. /* Mvclrtoeol() moves the cursor to a new position in stdscr    */
  77. /* and fills the right half of the cursor line with blanks.    */
  78. /****************************************************************/
  79.  
  80. int mvcltoreol(y,x)
  81.   int y;
  82.   int x;
  83.   {
  84.   if (wmove(stdscr,y,x) == ERR)
  85.     return(ERR);
  86.   return(wclrtoeol(stdscr));
  87.   } /* mvclrtoeol */
  88.  
  89. /****************************************************************/
  90. /* Mvwclrtoeol() moves the cursor to a new position in window    */
  91. /* 'win', and fills the right half of the cursor line with    */
  92. /* blanks.                            */
  93. /****************************************************************/
  94.  
  95. int mvwclrtoeol(win,y,x)
  96.   WINDOW *win;
  97.   int y;
  98.   int x;
  99.   {
  100.   if (wmove(win,y,x) == ERR)
  101.     return(ERR);
  102.   return(wclrtoeol(win));
  103.   } /* mvwclrtoeol */
  104.