home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / pccurs14.zoo / pccurses.2 / clrtoeol.c < prev    next >
C/C++ Source or Header  |  1990-01-20  |  3KB  |  106 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 (bl@infovox.se)    */
  10. /****************************************************************/
  11. /* 1.4:  Use of short wherever possible. Portability        */
  12. /*     improvements, misspelled name of mvcrltoeol():    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:    880210    */
  15. /* 1.0:     Release:                    870515    */
  16. /****************************************************************/
  17.  
  18. #include <curses.h>
  19. #include <curspriv.h>
  20.  
  21. char _curses_clrtoeol_rcsid[] = "@(#)clrtoeol.c   v.1.4  - 900114";
  22.  
  23. /****************************************************************/
  24. /* Wclrtoeol() fills the half of the cursor line to the right    */
  25. /* of the cursor in window 'win' with blanks.            */
  26. /****************************************************************/
  27.  
  28. int    wclrtoeol(win)
  29.    WINDOW    *win;
  30.   {
  31.   short        *maxx;
  32.   short        *ptr;
  33.   short        *end;
  34.   static short     y;
  35.   static short     x;
  36.   static short     minx;
  37.   static short     blank;
  38.   
  39.   y = win->_cury;
  40.   x = win->_curx;
  41.   blank = ' ' | (win->_attrs & ATR_MSK);
  42.  
  43.   end = &win->_line[y][win->_maxx - 1];
  44.   minx = _NO_CHANGE;
  45.   maxx = &win->_line[y][x];
  46.   for (ptr = maxx; ptr <= end; ptr++)
  47.     {
  48.     if (*ptr != blank)
  49.       {
  50.       maxx = ptr;
  51.       if (minx == _NO_CHANGE)
  52.     minx = (int) (ptr - win->_line[y]);
  53.       *ptr = blank;
  54.       } /* if */
  55.     } /* for */
  56.  
  57.   if (minx != _NO_CHANGE)
  58.     {
  59.     if ((win->_minchng[y] > minx) || (win->_minchng[y] == _NO_CHANGE))
  60.       win->_minchng[y] = minx;
  61.     if (win->_maxchng[y] < (int) (maxx - win->_line[y]))
  62.       win->_maxchng[y] = (int) (maxx - win->_line[y]);
  63.     } /* if */
  64.   return(OK);
  65.   } /* wclrtoeol */
  66.  
  67. /****************************************************************/
  68. /* Clrtoeol() fills the half of the cursor line to the right    */
  69. /* of the cursor in stdscr with blanks.                */
  70. /****************************************************************/
  71.  
  72. int clrtoeol()
  73.   {
  74.   return(wclrtoeol(stdscr));
  75.   } /* clrtoeol */
  76.  
  77. /****************************************************************/
  78. /* Mvclrtoeol() moves the cursor to a new position in stdscr    */
  79. /* and fills the right half of the cursor line with blanks.    */
  80. /****************************************************************/
  81.  
  82. int mvclrtoeol(y,x)
  83.   int y;
  84.   int x;
  85.   {
  86.   if (wmove(stdscr,y,x) == ERR)
  87.     return(ERR);
  88.   return(wclrtoeol(stdscr));
  89.   } /* mvclrtoeol */
  90.  
  91. /****************************************************************/
  92. /* Mvwclrtoeol() moves the cursor to a new position in window    */
  93. /* 'win', and fills the right half of the cursor line with    */
  94. /* blanks.                            */
  95. /****************************************************************/
  96.  
  97. int mvwclrtoeol(win,y,x)
  98.   WINDOW *win;
  99.   int y;
  100.   int x;
  101.   {
  102.   if (wmove(win,y,x) == ERR)
  103.     return(ERR);
  104.   return(wclrtoeol(win));
  105.   } /* mvwclrtoeol */
  106.