home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / pccurs14.zoo / pccurses.2 / clrtobot.c < prev    next >
C/C++ Source or Header  |  1990-01-20  |  3KB  |  109 lines

  1. /****************************************************************/
  2. /* Wclrtobot() 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:     Renamed clrbot() to clrtobot(). Reported by        */
  16. /*     Eric Roscos:                    870907    */
  17. /* 1.0:     Release:                    870515    */
  18. /****************************************************************/
  19.  
  20. #include <curses.h>
  21. #include <curspriv.h>
  22.  
  23. char _curses_clrtobot_rcsid[] = "@(#)clrtobot.c   v.1.4  - 900114";
  24.  
  25. /****************************************************************/
  26. /* Wclrtobot() fills the right half of the cursor line of    */
  27. /* window 'win', and all lines below it with blanks.        */
  28. /****************************************************************/
  29.  
  30. int    wclrtobot(win)
  31.   WINDOW    *win;
  32.   {
  33.   short     y;
  34.   short   minx;
  35.   static short    startx;
  36.   static short    *ptr;
  37.   static short  *end;
  38.   static short  *maxx;
  39.   static short   blank;
  40.  
  41.   blank = ' ' | (win->_attrs & ATR_MSK);
  42.   startx = win->_curx;
  43.   for (y = win->_cury; y <= win->_regbottom; y++)
  44.     {
  45.     minx = _NO_CHANGE;
  46.     end = &win->_line[y][win->_maxx - 1];
  47.     for (ptr = &win->_line[y][startx]; ptr <= end; ptr++)
  48.       {
  49.       if (*ptr != blank)
  50.     {
  51.     maxx = ptr;
  52.     if (minx == _NO_CHANGE)
  53.       minx = (int) (ptr - win->_line[y]);
  54.     *ptr = blank;
  55.     } /* if */
  56.       } /* for */
  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.     startx = 0;
  65.     } /* for */
  66.   return(OK);
  67.   } /* wclrtobot */
  68.  
  69. /****************************************************************/
  70. /* Clrtobot() fills the right half of the cursor line of    */
  71. /* stdscr, and all lines below it with blanks.            */
  72. /****************************************************************/
  73.  
  74. int clrtobot()
  75.   {
  76.   return(wclrtobot(stdscr));
  77.   } /* clrtobot */
  78.  
  79. /****************************************************************/
  80. /* Mvclrtobot() moves the cursor to a new position in stdscr    */
  81. /* and fills the right half of the cursor line, and all lines    */
  82. /* below it with blanks.                    */
  83. /****************************************************************/
  84.  
  85. int mvclrtobot(y,x)
  86.   int y;
  87.   int x;
  88.   {
  89.   if (wmove(stdscr,y,x) == ERR)
  90.     return(ERR);
  91.   return(wclrtobot(stdscr));
  92.   } /* mvclrtobot */
  93.  
  94. /****************************************************************/
  95. /* Mvwclrtobot() moves the cursor to a new position in window    */
  96. /* 'win', and fills the right half of the cursor line, and all    */
  97. /* lines below it with blanks.                    */
  98. /****************************************************************/
  99.  
  100. int mvwclrtobot(win,y,x)
  101.   WINDOW *win;
  102.   int y;
  103.   int x;
  104.   {
  105.   if (wmove(win,y,x) == ERR)
  106.     return(ERR);
  107.   return(wclrtobot(win));
  108.   } /* mvwclrtobot */
  109.