home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / WNUPDATE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-13  |  2.8 KB  |  100 lines

  1. /**
  2. *
  3. * Name        wnupdate -- Write pending I/O requests to a window.
  4. *
  5. * Synopsis    presult = wnupdate(pwin);
  6. *
  7. *        BWINDOW *presult  Pointer to BWINDOW structure updated,
  8. *                  or NIL if failure.
  9. *        BWINDOW *pwin      Pointer to BWINDOW structure to
  10. *                  update.
  11. *
  12. * Description    This function writes any pending I/O requests to the
  13. *        designated window if there are any waiting.  (Nothing
  14. *        will occur if any portion of the window's data area is
  15. *        covered by another window.)
  16. *
  17. *        This function does not designate the window "not
  18. *        delayed".  Use WNSETOPT to designate a window "delayed"
  19. *        or "not delayed".
  20. *
  21. *        An error occurs if pwin does not point to a valid window
  22. *        structure or if the window is not currently displayed.
  23. *
  24. * Returns    presult       Pointer to newly-hidden BWINDOW
  25. *                  structure, or NIL if failure.
  26. *        *pwin          Several fields altered.
  27. *        b_wnerr       Possible values:
  28. *                  (No change)       Success.
  29. *                  WN_BAD_WIN       *pwin is invalid.
  30. *                  WN_NOT_SHOWN       Not currently shown.
  31. *                  WN_BAD_DEV       Internal error.
  32. *                  WN_ILL_DIM       Internal error.
  33. *                  WN_NULL_PTR       Internal error.
  34. *
  35. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  36. *
  37. * Version    3.02 March 20, 1987
  38. *        Corrected returned value.
  39. *        Added code to move physical cursor.
  40. *
  41. **/
  42.  
  43. #include <bwindow.h>
  44.  
  45. BWINDOW *wnupdate(pwin)
  46. BWINDOW *pwin;
  47. {
  48.     int old_dev,old_page,old_npage;
  49.     int mode,columns,act_page;
  50.     BWINDOW *presult;
  51.  
  52.     if (wnvalwin(pwin) == NIL)          /* Validate window structure    */
  53.     {
  54.     wnerror(WN_BAD_WIN);
  55.     return NIL;
  56.     }
  57.     if (     pwin->options.hidden     /* Quit if invisible          */
  58.     || (!pwin->internals.dirty)   /* or if already up-to-date     */
  59.     ||   pwin->internals.frozen)  /* or if frozen.              */
  60.     return pwin;
  61.  
  62.                       /* Note former device.          */
  63.     old_dev  = scmode(&mode,&columns,&act_page);
  64.  
  65.     old_page = _curpage;          /* Note current page on former  */
  66.                       /* device.              */
  67.  
  68.     if (wnseldev(&pwin->where_shown,&pwin->img.dim,&old_npage))
  69.     {                      /* Validate and select device   */
  70.     wnerror(WN_NOT_SHOWN);          /* and page.              */
  71.     return NIL;
  72.     }
  73.  
  74.     presult = pwin;
  75.     if (wnputimg(&pwin->img,
  76.          &pwin->where_shown) == NIL)
  77.     presult = NIL;
  78.     else
  79.     {
  80.     pwin->internals.dirty = 0;
  81.  
  82.                       /* Move physical cursor.          */
  83.     if (!pwin->internals.cur_frozen)
  84.         sccurset(pwin->where_shown.corner.row
  85.              + b_pcurwin->cur_loc.row,
  86.              pwin->where_shown.corner.col
  87.              + b_pcurwin->cur_loc.col);
  88.     }
  89.  
  90.     scpage(old_npage);              /* Restore current page on new  */
  91.                       /* device.              */
  92.  
  93.     scchgdev(old_dev);              /* Restore old device.          */
  94.  
  95.     scpage(old_page);              /* Restore current page on old  */
  96.                       /* device.              */
  97.  
  98.     return presult;
  99. }
  100.