home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / cursesp.zip / REFRESH.C < prev    next >
C/C++ Source or Header  |  1991-12-02  |  4KB  |  105 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 (...mcvax!enea!infovax!bl)        */
  11. /****************************************************************/
  12. /* 1.0: Release:                                        870515  */
  13. /* 1.2: Max limits off by 1. Fixed thanks to S. Creps:  881002  */
  14. /* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes:            881005  */
  15. /****************************************************************/
  16.  
  17. #include <curses.h>
  18. #include <curspriv.h>
  19.  
  20. char _curses_refresh_rcsid[] = "@(#)refresh.c v1.3 - 881005";
  21.  
  22. /****************************************************************/
  23. /* Wrefresh() updates window win's area of the physical screen. */
  24. /****************************************************************/
  25.  
  26. void wrefresh(win)
  27.   WINDOW        *win;
  28.   {
  29.   if (win == curscr)
  30.     curscr->_clear = TRUE;
  31.   else
  32.     wnoutrefresh(win);
  33.   doupdate();
  34.   } /* wrefresh */
  35.  
  36. /****************************************************************/
  37. /* Wnoutrefresh() updates the image of the desired screen,      */
  38. /* without doing physical update (copies window win's image to  */
  39. /* the _cursvar.tmpwin window, which is hidden from the user).  */
  40. /****************************************************************/
  41.  
  42. void wnoutrefresh(win)
  43.   register WINDOW       *win;
  44.   {
  45.   register int    *dst;                 /* start destination in temp window */
  46.   register int    *end;                 /* end destination in temp window */
  47.   register int    *src;                 /* source in user window */
  48.   register int     first;               /* first changed char on line */
  49.   register int     last;                /* last changed char on line */
  50.   WINDOW *nscr;
  51.   int     begy, begx;                   /* window's place on screen */
  52.   int     i, j;
  53.  
  54.   nscr = _cursvar.tmpwin;
  55.   begy = win->_begy;
  56.   begx = win->_begx;
  57.  
  58.   for (i=0, j=begy; i < win->_maxy; i++, j++)
  59.     {
  60.     if (win->_minchng[i] != _NO_CHANGE)
  61.       {
  62.       first = win->_minchng[i];
  63.       last  = win->_maxchng[i];
  64.       dst   = &(nscr->_line[j][begx + first]);
  65.       end   = &(nscr->_line[j][begx + last]);
  66.       src   = &(win->_line[i][first]);
  67.  
  68.       while (dst <= end)                /* copy user line to temp window */
  69.         *dst++ = *src++;
  70.  
  71.       first += begx;                    /* nscr's min/max change positions */
  72.       last  += begx;
  73.  
  74.       if ((nscr->_minchng[j] == _NO_CHANGE)||(nscr->_minchng[j] > first))
  75.         nscr->_minchng[j] = first;
  76.       if (last > nscr->_maxchng[j])
  77.         nscr->_maxchng[j] = last;
  78.       
  79.       win->_minchng[i] = _NO_CHANGE;    /* updated now */
  80.       } /* if */
  81. //    win->_maxchng[i] = _NO_CHANGE;
  82.     } /* for */
  83.  
  84.   if (win->_clear)
  85.     {
  86.     win->_clear = FALSE;
  87.     nscr->_clear = TRUE;
  88.     } /* if */
  89.  
  90.   if (!win->_leave)
  91.     {
  92.     nscr->_cury = win->_cury + begy;
  93.     nscr->_curx = win->_curx + begx;
  94.     } /* if */
  95.   } /* wnoutrefresh */
  96.  
  97. /****************************************************************/
  98. /* Refresh() updates stdscr's area of the physical screen.      */
  99. /****************************************************************/
  100.  
  101. void refresh()
  102.   {
  103.   wrefresh(stdscr);
  104.   } /* refresh */
  105.