home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume7 / rvi / part3 / rv_scroll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-09  |  1.6 KB  |  82 lines

  1. #include "rv.h"
  2.  
  3. void
  4. rv_scroll(n)
  5. /*
  6.  * Scroll n lines
  7.  * Must be within window
  8.  * Cursor is set to last line
  9.  */
  10. register INT n;
  11. {
  12.     register struct li_line   *line, *oldline;
  13.     register struct sc_screen *sc;
  14.     register INT    seg,newseg,i;
  15.     register struct wi_window *wi;
  16.  
  17.     sc = &screen;
  18.     wi = &window;
  19.     /*
  20.      * Set cursor to bottom line+1
  21.      */
  22.     newseg = 0;
  23.     for (line = sc->sc_topline; line <= sc->sc_botline; ++line)
  24.         newseg += line->li_segments;
  25.     newseg += sc->sc_abovetop;
  26.     move(newseg,0);
  27.     clrtobot();
  28.     /*
  29.      * Calculate number of segments to scroll in
  30.      */
  31.     seg = 0;
  32.     for (i=n; i > 0 && line <= wi->wi_botline; --i, ++line)
  33.         seg += line->li_segments;
  34.     seg -= LINES-newseg-1;
  35.     move(LINES-1,0);
  36.     rv_fscroll(seg);
  37.     move(newseg-seg,0);
  38.     /*
  39.      * Scroll in new line(s)
  40.      */
  41.     for (line = sc->sc_botline+1; n > 0; --n, ++line) {
  42.         if (line > wi->wi_botline) {
  43.             errflag = 1;
  44.             botprint(TRUE, "rv_scroll - past bottom of window\n\n");
  45.             hitcr_continue();
  46.             return;
  47.         }
  48.         print_line(line->li_text);
  49.         if (CURCOLUMN != 0 || line->li_text[0] == '\0') {
  50.             if (CURLINE == LINES-1) {
  51.                 move(LINES-1, 0);
  52.             } else
  53.                 move(CURLINE+1, 0);
  54.         }
  55.     }
  56.     /*
  57.      * Adjust screen params
  58.      */
  59.     xmit_curline();
  60.     --line;
  61.     sc->sc_lineno += (line - sc->sc_curline);
  62.     sc->sc_botline = line;
  63.     sc->sc_curline = line;
  64.     sc->sc_column = 0;
  65.  
  66.     /*
  67.      * Compute new top line
  68.      */
  69.     for (seg = line->li_segments; seg < LINES;
  70.             seg += line->li_segments) {
  71.         --line;
  72.         if (line < wi->wi_topline)
  73.             break;
  74.     }
  75.     sc->sc_topline = line+1;
  76.     /*
  77.      * Compute # of displayed segs above top line
  78.      */
  79.     if (line >= wi->wi_topline)
  80.         sc->sc_abovetop = LINES-1 - (seg - line->li_segments);
  81. }
  82.