home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CURSES.LZH / WINSCROL.C < prev    next >
C/C++ Source or Header  |  1980-01-01  |  2KB  |  57 lines

  1. /****************************************************************/
  2. /* Scroll() 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_winscrol_rcsid[] = "@(#)winscrol.c v1.3 - 881005";
  20.  
  21. /****************************************************************/
  22. /* Scroll() scrolls the scrolling region of 'win', but only if    */
  23. /* scrolling is allowed and if the cursor is inside the scrol-    */
  24. /* ling region.                            */
  25. /****************************************************************/
  26.  
  27. void    scroll(win)
  28.   WINDOW    *win;
  29.   {
  30.   int         i;
  31.   int        *ptr;
  32.   int        *temp;
  33.   static   int     blank;
  34.  
  35.   blank = ' ' | (win->_attrs & ATR_MSK);
  36.   if  (       (!win->_scroll)            /* check if window scrolls */
  37.     || (win->_cury < win->_regtop)        /* and cursor in region */
  38.         || (win->_cury > win->_regbottom)
  39.       )
  40.     return;
  41.  
  42.   temp = win->_line[win->_regtop];
  43.   for (i = win->_regtop; i < win->_regbottom; i++)
  44.     {
  45.     win->_line[i] = win->_line[i+1];        /* re-arrange line pointers */
  46.     win->_minchng[i] = 0;
  47.     win->_maxchng[i] = win->_maxx - 1;
  48.     }
  49.   for (ptr = temp; ptr - temp < win->_maxx; ptr++)
  50.     *ptr = blank;                /* make a blank line */
  51.   win->_line[win->_regbottom] = temp;
  52.   if (win->_cury > win->_regtop)        /* if not on top line */
  53.     win->_cury--;                /* cursor scrolls too */
  54.   win->_minchng[win->_regbottom] = 0;
  55.   win->_maxchng[win->_regbottom] = win->_maxx - 1;
  56.   } /* scroll */
  57.