home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 328_02 / wscroll.c < prev    next >
C/C++ Source or Header  |  1991-03-17  |  2KB  |  83 lines

  1. /*! wscroll
  2.  *
  3.  * move text up one line in current window
  4.  *
  5.  *
  6.  */
  7.  
  8. #include "wscreen.h"
  9. #include "wsys.h"
  10.  
  11. void wscroll(void)
  12.     {
  13.  
  14.  
  15.     unsigned char far *target_line;
  16.     unsigned char far *source_line;
  17.  
  18.     int nrow, ncol, col;
  19.  
  20.  
  21.     char    clr_attr;
  22.  
  23.     #ifndef TEXTONLY
  24.         /* graphics mode declarations
  25.          */
  26.         int right, bottom;
  27.     #endif    /* ! TEXTONLY */
  28.  
  29.  
  30.     clr_attr = wgetattr();
  31.  
  32.  
  33.  
  34.     if (wmode == 'T')
  35.         {
  36.         /* point to top line, then work done one line at at time
  37.          */
  38.         target_line = wpage_ram + 2*80*(w0->wintop) +2*(w0->winleft);
  39.  
  40.         /* number of rows to scroll is 1 less than current row
  41.          * but we start counting from zero.
  42.          */
  43.         nrow = w0->winy;
  44.         ncol = 2*(w0-> winxmax +1);
  45.  
  46.         while (nrow--)
  47.             {
  48.             source_line = target_line + 2*80;
  49.             for (col =0; col < ncol; ++col)
  50.                 {
  51.                 *(target_line +col) = *(source_line +col);
  52.                 }
  53.             target_line =source_line;
  54.             }
  55.         /* write a new blank line */
  56.         for (col = 0; col < ncol ;  col += 2)
  57.             {
  58.             *(source_line + col +1) = clr_attr;
  59.             *(source_line + col   ) = ' ';
  60.             }
  61.         }
  62. #ifndef TEXTONLY
  63.     /* graphics mode scrolling
  64.      */
  65.     else     {
  66.         right  = w0->winleft +w0->winxmax;
  67.         bottom = w0->wintop +w0->winy;
  68.         wgscrollv    ( w0->winleft, w0->wintop +1, right, bottom,
  69.                 -wpychar );
  70.  
  71.         wclearabs     ( w0->winleft, bottom, right, bottom  );
  72.  
  73.         }
  74.  
  75. #endif    /* ifndef TEXTONLY - end graphics mode scrolling */
  76.  
  77.     /*position to start of line */
  78.     wgoto(0,-1);
  79.  
  80.     return;         /* end of wscroll */
  81.     }
  82.  
  83.