home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / SB_SHOW.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  7KB  |  185 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*              Routines for updating the screen within BinkleyTerm         */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*    For complete  details  of the licensing restrictions, please refer    */
  17. /*    to the License  agreement,  which  is published in its entirety in    */
  18. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  19. /*                                                                          */
  20. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  21. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  22. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  23. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  24. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  25. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  26. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  27. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  28. /*                                                                          */
  29. /*                                                                          */
  30. /* You can contact Bit Bucket Software Co. at any one of the following      */
  31. /* addresses:                                                               */
  32. /*                                                                          */
  33. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  34. /* P.O. Box 460398                AlterNet 7:491/0                          */
  35. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  36. /*                                Internet f491.n343.z1.fidonet.org         */
  37. /*                                                                          */
  38. /* Please feel free to contact us at any time to share your comments about  */
  39. /* our software and/or licensing policies.                                  */
  40. /*                                                                          */
  41. /*                                                                          */
  42. /*   This module is derived from code developed by Augie Hansen in his      */
  43. /*   book "Proficient C" published by Microsoft Press.  Mr. Hansen was      */
  44. /*   kind enough to give us verbal permission to use his routines, and      */
  45. /*   Bob, Vince and Alan (and all our full screen users) are grateful.      */
  46. /*   If you decide to use this code in some package you are doing, give     */
  47. /*   some thought to going out and buying the book. He deserves that.       */
  48. /*                                                                          */
  49. /*--------------------------------------------------------------------------*/
  50.  
  51. /* Include this file before any other includes or defines! */
  52.  
  53. #include "includes.h"
  54.  
  55. extern BUFFER Sbuf;
  56. extern CELLP Scrnbuf;
  57. extern int cursor_col;
  58. extern int cursor_row;
  59.  
  60. #ifdef MILQ
  61. static BlankedWnd = NULLHWND;
  62. #endif
  63.  
  64. void sb_show ()
  65. {
  66.    register unsigned int r;
  67.    unsigned int src_os;
  68.    char far *q;
  69.  
  70.    if (screen_blank && do_screen_blank)
  71.       {
  72. #ifdef MILQ
  73.       if ( !BlankedWnd ) {
  74.         BlankedWnd = GetFocus();
  75.         }
  76.       WinSetAttr( _HwndDesktop, 0, 0 );
  77.       CloseWindow( MilqueMailerWnd );
  78.       SetFocus( MilqueMailerWnd );
  79.       SetWindowPos( MilqueMailerWnd,
  80.                     NULLHWND,
  81.                     random( GetSystemMetrics(SM_CXSCREEN) - 15 ),
  82.                     random( GetSystemMetrics(SM_CYSCREEN) - 4 ),
  83.                     0, 0,
  84.                     SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW );
  85.       WinDrawAllWindows();
  86. #else
  87.       for (r = 0; r < SB_ROWS; r++)
  88.          {
  89.          q = blanks;
  90.          (void) VioWrtCellStr ((PCH) q, (USHORT) (SB_COLS * 2), (USHORT) r, (USHORT) 0, (HVIO) 0L);
  91.          }
  92. #endif
  93.       sb_dirty ();
  94.       return;
  95.       }
  96.  
  97. #ifdef MILQ
  98.    if ( IsIconic( MilqueMailerWnd ) ) {
  99.      OpenIcon( MilqueMailerWnd );
  100.      BringWindowToTop( MilqueMailerMnu );
  101.      BringWindowToTop( callwin->hWnd );
  102.      BringWindowToTop( filewin->hWnd );
  103.      BringWindowToTop( historywin->hWnd );
  104.      BringWindowToTop( holdwin->hWnd );
  105.      BringWindowToTop( settingswin->hWnd );
  106.      if ( BlankedWnd ) {
  107.        SetFocus( BlankedWnd );
  108.        BlankedWnd = NULLHWND;
  109.        }
  110.      CallDlgPrc( callwin->hWnd, WM_PAINT, 0, 0L );
  111.      }
  112. #endif
  113.    /* Anything to do? */
  114.    if (!(Sbuf.flags & SB_DELTA))
  115.       {
  116.       return;
  117.       }
  118.  
  119.    src_os = 0;
  120.    for (r = 0; r < SB_ROWS; r++)
  121.       {
  122.       /* Copy only changed portions of lines */
  123.       if (((unsigned)Sbuf.lcol[r] < SB_COLS) && (Sbuf.rcol[r] > 0))
  124.          {
  125. #ifndef MILQ
  126.          q = (char far *) (Scrnbuf + src_os + Sbuf.lcol[r]);
  127.          (void) VioWrtCellStr ((PCH) q, (USHORT) ((Sbuf.rcol[r] - Sbuf.lcol[r] + 1) * 2), (USHORT) r, (USHORT) Sbuf.lcol[r], (HVIO) 0L);
  128. #endif   
  129.          Sbuf.lcol[r] = SB_COLS;
  130.          Sbuf.rcol[r] = 0;
  131.          }
  132.       src_os += (unsigned) SB_COLS;
  133.       }
  134.  
  135.    /* the display now matches the buffer -- clear flag bit */
  136.    Sbuf.flags &= ~SB_DELTA;
  137.  
  138.    /* Put sanity check on cursor_row and cursor_col here */
  139.    if (cursor_row < 0 || cursor_row > (int)(SB_ROWS - 1))
  140.       cursor_row = SB_ROWS - 1;
  141.    if (cursor_col < 0 || cursor_col > (int)(SB_COLS - 1))
  142.       cursor_col = SB_COLS - 1;
  143.  
  144. #ifndef MILQ
  145.    gotoxy (cursor_col, cursor_row);
  146. #endif
  147.    return;
  148. }
  149.  
  150. /*
  151.  * Just cleans up the structure to say it is reality - I can use this when
  152.  * I write directly to the screen for single char writes.
  153.  */
  154.  
  155. void sb_clean ()
  156. {
  157.    int r;
  158.  
  159.    for (r = 0; r < (int) SB_ROWS; r++)
  160.       {
  161.       Sbuf.lcol[r] = SB_COLS;
  162.       Sbuf.rcol[r] = 0;
  163.       }
  164.  
  165.    Sbuf.flags &= ~SB_DELTA;
  166. }
  167.  
  168. /*
  169.  * Make the entire buffer "dirty" so it will be updated.
  170.  */
  171.  
  172. void sb_dirty ()
  173. {
  174.    int r;
  175.  
  176.    for (r = 0; r < (int) SB_ROWS; r++)
  177.       {
  178.       Sbuf.lcol[r] = 0;
  179.       Sbuf.rcol[r] = SB_COLS_M_1;
  180.       }
  181.  
  182.    Sbuf.flags |= SB_DELTA;
  183. }
  184.  
  185.