home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / SB_SCRL.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  6KB  |  139 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 scrolling windows 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.  
  58. void sb_scrl (REGIONP win, int n)
  59. {
  60.    register int r, c;
  61.  
  62.    c = win->sc0;
  63.    if (n == 0)
  64.       {
  65.       /* clear the entire region to spaces */
  66.       sb_fillc (win, ' ');
  67.       }
  68.    else if (n > 0)
  69.       {
  70.       /* scroll n rows up */
  71.       for (r = win->sr0; r <= win->sr1 - n; r++)
  72.          {
  73.          (void) memcpy (Scrnbuf + r * SB_COLS + c, Scrnbuf + (r + n) * SB_COLS + c,
  74.                  (unsigned) (win->sc1 - win->sc0 + 1) * 2);
  75.  
  76.          if (win->sc0 < Sbuf.lcol[r])
  77.             {
  78.             Sbuf.lcol[r] = win->sc0;
  79.             }
  80.          if (win->sc1 > Sbuf.rcol[r])
  81.             {
  82.             Sbuf.rcol[r] = win->sc1;
  83.             }
  84.          }
  85.       for (; r <= win->sr1; r++)
  86.          {
  87.          for (c = win->sc0; c <= win->sc1; c++)
  88.             {
  89.             (Scrnbuf + r * SB_COLS + c)->b.ch = ' ';
  90.             }
  91.          if (win->sc0 < Sbuf.lcol[r])
  92.             {
  93.             Sbuf.lcol[r] = win->sc0;
  94.             }
  95.          if (win->sc1 > Sbuf.rcol[r])
  96.             {
  97.             Sbuf.rcol[r] = win->sc1;
  98.             }
  99.          }
  100.       }
  101.    else
  102.       {
  103.       /* scroll n rows down */
  104.       n = -n;
  105.       for (r = win->sr1; r >= win->sr0 + n; r--)
  106.          {
  107.          (void) memcpy (Scrnbuf + r * SB_COLS + c, Scrnbuf + (r - n) * SB_COLS + c,
  108.                  (unsigned) (win->sc1 - win->sc0 + 1) * 2);
  109.          if (win->sc0 < Sbuf.lcol[r])
  110.             {
  111.             Sbuf.lcol[r] = win->sc0;
  112.             }
  113.          if (win->sc1 > Sbuf.rcol[r])
  114.             {
  115.             Sbuf.rcol[r] = win->sc1;
  116.             }
  117.          }
  118.       for (; r >= win->sr0; r--)
  119.          {
  120.          for (c = win->sc0; c <= win->sc1; c++)
  121.             {
  122.             (Scrnbuf + r * SB_COLS + c)->b.ch = ' ';
  123.             }
  124.          if (win->sc0 < Sbuf.lcol[r])
  125.             {
  126.             Sbuf.lcol[r] = win->sc0;
  127.             }
  128.          if (win->sc1 > Sbuf.rcol[r])
  129.             {
  130.             Sbuf.rcol[r] = win->sc1;
  131.             }
  132.          }
  133.       }
  134.  
  135.    Sbuf.flags |= SB_DELTA;
  136.  
  137.    return;
  138. }
  139.