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

  1. #include "rv.h"
  2.  
  3. void
  4. redraw_screen(firstline)
  5. /*
  6.  * Regenerate the screen from firstline downwards to curses
  7.  *
  8.  * If firstline is NULL, the entire screen is redrawn.
  9.  */
  10. struct    li_line    *firstline;
  11. {
  12.     register struct   li_line    *line;
  13.     register struct     sc_screen    *sc;
  14.     register struct     wi_window    *wi;
  15.     INT     saveline, savecol, seg;
  16.  
  17.     sc = &screen;
  18.     wi = &window;
  19.     if (firstline == (struct li_line *)0)
  20.         firstline = sc->sc_topline;
  21.     /*
  22.      * Save cursor location
  23.      */
  24.     saveline = CURLINE;
  25.     savecol = CURCOLUMN;
  26.     /*
  27.      * Skip void line segments above topline
  28.      */
  29.     if (firstline == sc->sc_topline) {
  30.         sc->sc_abovetop = 0; /* Reset topline to real screen top */
  31.         seg = 0;
  32.     } else
  33.         seg = sc->sc_abovetop;
  34.     /*
  35.      * Skip lines above firstline
  36.      */
  37.     for (line=sc->sc_topline; line < firstline; ++line)
  38.         seg += line->li_segments;
  39.     /*
  40.      * Clear screen from firstline downward
  41.      */
  42.     move(seg,0);
  43.     clrtobot();
  44.     move(seg,0);  /* Because clrtobot homes the cursor in 4bsd */
  45.  
  46.     /*
  47.      * Redraw remaining lines
  48.      */
  49.     if (line <= wi->wi_botline)
  50.         seg += line->li_segments;
  51.     if (seg >= LINES && sc->sc_curline == line) {
  52.         /*
  53.          * Scroll
  54.          */
  55.         sc->sc_botline = line-1;
  56.         rv_scroll(1);
  57.         redraw_screen(line+1);
  58.         move(saveline, savecol);
  59.         return;
  60.     }
  61.         
  62.     while (seg < LINES) {
  63.         if (line <= wi->wi_botline) {
  64.             print_line(line->li_text);
  65.             if (CURCOLUMN != 0 || line->li_text[0] == '\0')
  66.                 move(CURLINE+1, 0);
  67.             ++line;
  68.         }
  69.         if (line > wi->wi_botline) { /* If past bottom of window */
  70.             if ((line - sc->sc_curline) + sc->sc_lineno >
  71.                     file.fi_numlines) /* If past eof */
  72.                 break;
  73.             /*
  74.              * Fetch window & redraw everything
  75.              */
  76.              if (set_debug > 1)
  77.                  fprintf(stderr, "Forced to redraw\n");
  78.                  fetch_window(sc->sc_lineno - NUM_WINDOW_LINES/4 -
  79.                  LINES/2+1, TRUE);
  80.                  return;
  81.         }
  82.         seg += line->li_segments;
  83.     }
  84.     sc->sc_botline = line-1;
  85.  
  86.     /*
  87.      * Append '~' or '@' lines to screen
  88.      */
  89.     if ((seg = CURLINE) < LINES-1) 
  90.         if (file.fi_numlines > sc->sc_lineno +
  91.                 (sc->sc_botline - sc->sc_curline))
  92.             /*
  93.              * Undisplayed lines
  94.              */
  95.             while (seg < LINES-1)
  96.                 mvaddch(seg++, 0, '@');
  97.         else
  98.             /*
  99.              * End of file
  100.              */
  101.             while (seg < LINES-1)
  102.                 mvaddch(seg++, 0, '~');
  103.     /*
  104.      * Restore cursor
  105.      */
  106.     move(saveline, savecol);
  107. }
  108.