home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / pccurs14.zoo / pccurses.2 / refresh.c < prev    next >
C/C++ Source or Header  |  1990-01-20  |  4KB  |  110 lines

  1. /****************************************************************/
  2. /* Wrefresh() and wnoutrefresh() routines of the PCcurses    */
  3. /* package                            */
  4. /*                                */
  5. /****************************************************************/
  6. /* This version of curses is based on ncurses, a curses version    */
  7. /* originally written by Pavel Curtis at Cornell University.    */
  8. /* I have made substantial changes to make it run on IBM PC's,    */
  9. /* and therefore consider myself free to make it public domain.    */
  10. /*                Bjorn Larsson (bl@infovox.se)    */
  11. /****************************************************************/
  12. /* 1.4:  Use of short wherever possible. Refresh() slig-    */
  13. /*     htly faster. Portability improvements:        900114    */
  14. /* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  15. /* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  16. /* 1.0:     Release:                    870515    */
  17. /****************************************************************/
  18.  
  19. #include <curses.h>
  20. #include <curspriv.h>
  21.  
  22. char _curses_refresh_rcsid[] = "@(#)refresh.c    v.1.4  - 900114";
  23.  
  24. /****************************************************************/
  25. /* Wrefresh() updates window win's area of the physical screen.    */
  26. /****************************************************************/
  27.  
  28. void wrefresh(win)
  29.   WINDOW    *win;
  30.   {
  31.   if (win == curscr)
  32.     curscr->_clear = TRUE;
  33.   else
  34.     wnoutrefresh(win);
  35.   doupdate();
  36.   } /* wrefresh */
  37.  
  38. /****************************************************************/
  39. /* Wnoutrefresh() updates the image of the desired screen,    */
  40. /* without doing physical update (copies window win's image to    */
  41. /* the _cursvar.tmpwin window, which is hidden from the user).    */
  42. /****************************************************************/
  43.  
  44. void wnoutrefresh(win)
  45.   register WINDOW    *win;
  46.   {
  47.   register short  *dst;            /* start destination in temp window */
  48.   register short  *end;            /* end destination in temp window */
  49.   register short  *src;            /* source in user window */
  50.   register short   first;        /* first changed char on line */
  51.   register short   last;        /* last changed char on line */
  52.   static   WINDOW *nscr;
  53.   static   short   begy;        /* window's place on screen */
  54.   static   short   begx;
  55.   static   short   i;
  56.   static   short   j;
  57.  
  58.   nscr = _cursvar.tmpwin;
  59.   begy = win->_begy;
  60.   begx = win->_begx;
  61.  
  62.   for (i=0, j=begy; i < win->_maxy; i++, j++)
  63.     {
  64.     if (win->_minchng[i] != _NO_CHANGE)
  65.       {
  66.       first = win->_minchng[i];
  67.       last  = win->_maxchng[i];
  68.       dst   = &(nscr->_line[j][begx + first]);
  69.       end   = &(nscr->_line[j][begx + last]);
  70.       src   = &(win->_line[i][first]);
  71.  
  72.       while (dst <= end)         /* copy user line to temp window */
  73.     *dst++ = *src++;
  74.  
  75.       first += begx;            /* nscr's min/max change positions */
  76.       last  += begx;
  77.  
  78.       if ((nscr->_minchng[j] == _NO_CHANGE)||(nscr->_minchng[j] > first))
  79.     nscr->_minchng[j] = first;
  80.       if (last > nscr->_maxchng[j])
  81.     nscr->_maxchng[j] = last;
  82.       
  83.       win->_minchng[i] = _NO_CHANGE;    /* updated now */
  84.       } /* if */
  85.     win->_maxchng[i] = _NO_CHANGE;    /* updated now */
  86.     } /* for */
  87.  
  88.   if (win->_clear)
  89.     {
  90.     win->_clear = FALSE;
  91.     nscr->_clear = TRUE;
  92.     } /* if */
  93.  
  94.   if (!win->_leave)
  95.     {
  96.     nscr->_cury = win->_cury + begy;
  97.     nscr->_curx = win->_curx + begx;
  98.     } /* if */
  99.   } /* wnoutrefresh */
  100.  
  101. /****************************************************************/
  102. /* Refresh() updates stdscr's area of the physical screen.    */
  103. /****************************************************************/
  104.  
  105. void refresh()
  106.   {
  107.   wnoutrefresh(stdscr);
  108.   doupdate();
  109.   } /* refresh */
  110.