home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CURS13_2.ZIP / CLRTOBOT.C < prev    next >
Text File  |  1989-12-08  |  3KB  |  107 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 (...mcvax!enea!infovax!bl)    */
  10. /****************************************************************/
  11. /* 1.0:    Release:                    870515    */
  12. /* 1.1:    Renamed clrbot() to clrtobot(). Reported by        */
  13. /*    Eric Rosco:                    870907    */
  14. /* 1.2:    Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  15. /* 1.3:    MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  16. /****************************************************************/
  17.  
  18. #include <curses.h>
  19. #include <curspriv.h>
  20.  
  21. char _curses_clrtobot_rcsid[] = "@(#)clrtobot.c v1.3 - 881005";
  22.  
  23. /****************************************************************/
  24. /* Wclrtobot() fills the right half of the cursor line of    */
  25. /* window 'win', and all lines below it with blanks.        */
  26. /****************************************************************/
  27.  
  28. int    wclrtobot(win)
  29.   WINDOW    *win;
  30.   {
  31.   int     y;
  32.   int   minx;
  33.   static int     startx;
  34.   static int    *ptr;
  35.   static int    *end;
  36.   static int    *maxx;
  37.   static int     blank;
  38.  
  39.   blank = ' ' | (win->_attrs & ATR_MSK);
  40.   startx = win->_curx;
  41.   for (y = win->_cury; y <= win->_regbottom; y++)
  42.     {
  43.     minx = _NO_CHANGE;
  44.     end = &win->_line[y][win->_maxx - 1];
  45.     for (ptr = &win->_line[y][startx]; ptr <= end; ptr++)
  46.       {
  47.       if (*ptr != blank)
  48.     {
  49.     maxx = ptr;
  50.     if (minx == _NO_CHANGE)
  51.       minx = ptr - win->_line[y];
  52.     *ptr = blank;
  53.     } /* if */
  54.       } /* for */
  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.     startx = 0;
  63.     } /* for */
  64.   return(OK);
  65.   } /* wclrtobot */
  66.  
  67. /****************************************************************/
  68. /* Clrtobot() fills the right half of the cursor line of    */
  69. /* stdscr, and all lines below it with blanks.            */
  70. /****************************************************************/
  71.  
  72. int clrtobot()
  73.   {
  74.   return(wclrtobot(stdscr));
  75.   } /* clrtobot */
  76.  
  77. /****************************************************************/
  78. /* Mvclrtobot() moves the cursor to a new position in stdscr    */
  79. /* and fills the right half of the cursor line, and all lines    */
  80. /* below it with blanks.                    */
  81. /****************************************************************/
  82.  
  83. int mvclrtobot(y,x)
  84.   int y;
  85.   int x;
  86.   {
  87.   if (wmove(stdscr,y,x) == ERR)
  88.     return(ERR);
  89.   return(wclrtobot(stdscr));
  90.   } /* mvclrtobot */
  91.  
  92. /****************************************************************/
  93. /* Mvwclrtobot() moves the cursor to a new position in window    */
  94. /* 'win', and fills the right half of the cursor line, and all    */
  95. /* lines below it with blanks.                    */
  96. /****************************************************************/
  97.  
  98. int mvwclrtobot(win,y,x)
  99.   WINDOW *win;
  100.   int y;
  101.   int x;
  102.   {
  103.   if (wmove(win,y,x) == ERR)
  104.     return(ERR);
  105.   return(wclrtobot(win));
  106.   } /* mvwclrtobot */
  107.