home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CURSES.LZH / REFRESH.C < prev    next >
C/C++ Source or Header  |  1980-01-01  |  4KB  |  107 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.   static   WINDOW *nscr;
  51.   static   int       begy;        /* window's place on screen */
  52.   static   int       begx;
  53.   static   int       i;
  54.   static   int       j;
  55.  
  56.   nscr = _cursvar.tmpwin;
  57.   begy = win->_begy;
  58.   begx = win->_begx;
  59.  
  60.   for (i=0, j=begy; i < win->_maxy; i++, j++)
  61.     {
  62.     if (win->_minchng[i] != _NO_CHANGE)
  63.       {
  64.       first = win->_minchng[i];
  65.       last  = win->_maxchng[i];
  66.       dst   = &(nscr->_line[j][begx + first]);
  67.       end   = &(nscr->_line[j][begx + last]);
  68.       src   = &(win->_line[i][first]);
  69.  
  70.       while (dst <= end)         /* copy user line to temp window */
  71.     *dst++ = *src++;
  72.  
  73.       first += begx;            /* nscr's min/max change positions */
  74.       last  += begx;
  75.  
  76.       if ((nscr->_minchng[j] == _NO_CHANGE)||(nscr->_minchng[j] > first))
  77.     nscr->_minchng[j] = first;
  78.       if (last > nscr->_maxchng[j])
  79.     nscr->_maxchng[j] = last;
  80.       
  81.       win->_minchng[i] = _NO_CHANGE;    /* updated now */
  82.       } /* if */
  83.     win->_maxchng[i] = _NO_CHANGE;    /* updated now */
  84.     } /* for */
  85.  
  86.   if (win->_clear)
  87.     {
  88.     win->_clear = FALSE;
  89.     nscr->_clear = TRUE;
  90.     } /* if */
  91.  
  92.   if (!win->_leave)
  93.     {
  94.     nscr->_cury = win->_cury + begy;
  95.     nscr->_curx = win->_curx + begx;
  96.     } /* if */
  97.   } /* wnoutrefresh */
  98.  
  99. /****************************************************************/
  100. /* Refresh() updates stdscr's area of the physical screen.    */
  101. /****************************************************************/
  102.  
  103. void refresh()
  104.   {
  105.   wrefresh(stdscr);
  106.   } /* refresh */
  107.