home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / SB_SCRL.C < prev    next >
C/C++ Source or Header  |  1990-05-14  |  7KB  |  173 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-90, 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.240.    */
  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:132/491, 1:141/491  */
  34. /* P.O. Box 460398                AlterNet 7:491/0                          */
  35. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  36. /*                                Internet f491.n132.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.  
  52. #include <stdio.h>
  53. #include <string.h>
  54.  
  55. #ifdef __TURBOC__
  56. #include <mem.h>
  57. #else
  58. #include <memory.h>
  59. #endif
  60.  
  61. #include "sbuf.h"
  62. #include "com.h"
  63. #include "xfer.h"
  64. #include "zmodem.h"
  65. #include "keybd.h"
  66. #include "sched.h"
  67. #include "externs.h"
  68. #include "prototyp.h"
  69.  
  70. extern BUFFER Sbuf;
  71. extern CELLP Scrnbuf;
  72.  
  73. void sb_scrl (win, n)
  74. REGIONP win;
  75. int n;
  76. {
  77.    register int r, c;
  78.  
  79.    c = win->sc0;
  80.    if (n == 0)
  81.       {
  82.       /* clear the entire region to spaces */
  83.       sb_fillc (win, ' ');
  84.       }
  85.    else if (n > 0)
  86.       {
  87.       /* scroll n rows up */
  88.       for (r = win->sr0; r <= win->sr1 - n; r++)
  89.          {
  90.          (void) memcpy (Scrnbuf + r * SB_COLS + c, Scrnbuf + (r + n) * SB_COLS + c,
  91.                  (unsigned) (win->sc1 - win->sc0 + 1) * 2);
  92.          if (win->sc0 < Sbuf.lcol[r])
  93.             {
  94.             Sbuf.lcol[r] = win->sc0;
  95.             }
  96.          if (win->sc1 > Sbuf.rcol[r])
  97.             {
  98.             Sbuf.rcol[r] = win->sc1;
  99.             }
  100.          }
  101.       for (; r <= win->sr1; r++)
  102.          {
  103.          for (c = win->sc0; c <= win->sc1; c++)
  104.             {
  105.             (Scrnbuf + r * SB_COLS + c)->b.ch = ' ';
  106.             }
  107.          if (win->sc0 < Sbuf.lcol[r])
  108.             {
  109.             Sbuf.lcol[r] = win->sc0;
  110.             }
  111.          if (win->sc1 > Sbuf.rcol[r])
  112.             {
  113.             Sbuf.rcol[r] = win->sc1;
  114.             }
  115.          }
  116.       }
  117.    else
  118.       {
  119.       /* scroll n rows down */
  120.       n = -n;
  121.       for (r = win->sr1; r >= win->sr0 + n; r--)
  122.          {
  123.          (void) memcpy (Scrnbuf + r * SB_COLS + c, Scrnbuf + (r - n) * SB_COLS + c,
  124.                  (unsigned) (win->sc1 - win->sc0 + 1) * 2);
  125.          if (win->sc0 < Sbuf.lcol[r])
  126.             {
  127.             Sbuf.lcol[r] = win->sc0;
  128.             }
  129.          if (win->sc1 > Sbuf.rcol[r])
  130.             {
  131.             Sbuf.rcol[r] = win->sc1;
  132.             }
  133.          }
  134.       for (; r >= win->sr0; r--)
  135.          {
  136.          for (c = win->sc0; c <= win->sc1; c++)
  137.             {
  138.             (Scrnbuf + r * SB_COLS + c)->b.ch = ' ';
  139.             }
  140.          if (win->sc0 < Sbuf.lcol[r])
  141.             {
  142.             Sbuf.lcol[r] = win->sc0;
  143.             }
  144.          if (win->sc1 > Sbuf.rcol[r])
  145.             {
  146.             Sbuf.rcol[r] = win->sc1;
  147.             }
  148.          }
  149.       }
  150.  
  151.    Sbuf.flags |= SB_DELTA;
  152.  
  153.    return;
  154. }
  155.  
  156. int sb_set_scrl (win, top, left, bottom, right)
  157. REGIONP win;
  158. int top, left;
  159. int bottom, right;
  160. {
  161.    if ((top < 0) || (left < 0) ||
  162.        (bottom > win->r1 - win->r0) ||
  163.        (right > win->c1 - win->c0))
  164.       return (SB_ERR);
  165.  
  166.    win->sr0 = win->r0 + top;
  167.    win->sc0 = win->c0 + left;
  168.    win->sr1 = win->r0 + bottom - 1;
  169.    win->sc1 = win->c0 + right - 1;
  170.  
  171.    return (SB_OK);
  172. }
  173.