home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 332_02 / winscrol.c < prev    next >
C/C++ Source or Header  |  1990-01-06  |  2KB  |  59 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 (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.0:     Release:                    870515    */
  16. /****************************************************************/
  17.  
  18. #include <curses.h>
  19. #include <curspriv.h>
  20.  
  21. char _curses_winscrol_rcsid[] = "@(#)winscrol.c   v.1.4  - 900114";
  22.  
  23. /****************************************************************/
  24. /* Scroll() scrolls the scrolling region of 'win', but only if    */
  25. /* scrolling is allowed and if the cursor is inside the scrol-    */
  26. /* ling region.                            */
  27. /****************************************************************/
  28.  
  29. void    scroll(win)
  30.   WINDOW    *win;
  31.   {
  32.   short         i;
  33.   short        *ptr;
  34.   short        *temp;
  35.   static short     blank;
  36.  
  37.   blank = ' ' | (win->_attrs & ATR_MSK);
  38.   if  (       (!win->_scroll)            /* check if window scrolls */
  39.     || (win->_cury < win->_regtop)        /* and cursor in region */
  40.         || (win->_cury > win->_regbottom)
  41.       )
  42.     return;
  43.  
  44.   temp = win->_line[win->_regtop];
  45.   for (i = win->_regtop; i < win->_regbottom; i++)
  46.     {
  47.     win->_line[i] = win->_line[i+1];        /* re-arrange line pointers */
  48.     win->_minchng[i] = 0;
  49.     win->_maxchng[i] = win->_maxx - 1;
  50.     }
  51.   for (ptr = temp; ptr - temp < win->_maxx; ptr++)
  52.     *ptr = blank;                /* make a blank line */
  53.   win->_line[win->_regbottom] = temp;
  54.   if (win->_cury > win->_regtop)        /* if not on top line */
  55.     win->_cury--;                /* cursor scrolls too */
  56.   win->_minchng[win->_regbottom] = 0;
  57.   win->_maxchng[win->_regbottom] = win->_maxx - 1;
  58.   } /* scroll */
  59.