home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / USCX / BSRC_230.ZIP / SB_SCRL.C < prev    next >
C/C++ Source or Header  |  1989-09-05  |  7KB  |  172 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 1989, 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.230.    */
  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:132/101, 1:132/491, 1:141/491  */
  34. /* 427-3 Amherst Street           AlterNet 7:491/0                          */
  35. /* CS2032, Suite 232              BBS-Net  86:2030/1                        */
  36. /* Nashua, NH 03061               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 <string.h>
  53.  
  54. #ifdef __TURBOC__
  55. #include <mem.h>
  56. #else
  57. #include <memory.h>
  58. #endif
  59.  
  60. #include "sbuf.h"
  61. #include "com.h"
  62. #include "xfer.h"
  63. #include "zmodem.h"
  64. #include "keybd.h"
  65. #include "sched.h"
  66. #include "externs.h"
  67. #include "prototyp.h"
  68.  
  69. extern BUFFER Sbuf;
  70. extern CELLP Scrnbuf;
  71.  
  72. int sb_scrl (win, n)
  73. REGIONP win;
  74. int n;
  75. {
  76.    register int r, c;
  77.  
  78.    c = win->sc0;
  79.    if (n == 0)
  80.       {
  81.       /* clear the entire region to spaces */
  82.       sb_fillc (win, ' ');
  83.       }
  84.    else if (n > 0)
  85.       {
  86.       /* scroll n rows up */
  87.       for (r = win->sr0; r <= win->sr1 - n; r++)
  88.          {
  89.          memcpy (Scrnbuf + r * SB_COLS + c, Scrnbuf + (r + n) * SB_COLS + c,
  90.                  (win->sc1 - win->sc0 + 1) * 2);
  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.       for (; r <= win->sr1; r++)
  101.          {
  102.          for (c = win->sc0; c <= win->sc1; c++)
  103.             {
  104.             (Scrnbuf + r * SB_COLS + c)->b.ch = ' ';
  105.             }
  106.          if (win->sc0 < Sbuf.lcol[r])
  107.             {
  108.             Sbuf.lcol[r] = win->sc0;
  109.             }
  110.          if (win->sc1 > Sbuf.rcol[r])
  111.             {
  112.             Sbuf.rcol[r] = win->sc1;
  113.             }
  114.          }
  115.       }
  116.    else
  117.       {
  118.       /* scroll n rows down */
  119.       n = -n;
  120.       for (r = win->sr1; r >= win->sr0 + n; r--)
  121.          {
  122.          memcpy (Scrnbuf + r * SB_COLS + c, Scrnbuf + (r - n) * SB_COLS + c,
  123.                  (win->sc1 - win->sc0 + 1) * 2);
  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.       for (; r >= win->sr0; r--)
  134.          {
  135.          for (c = win->sc0; c <= win->sc1; c++)
  136.             {
  137.             (Scrnbuf + r * SB_COLS + c)->b.ch = ' ';
  138.             }
  139.          if (win->sc0 < Sbuf.lcol[r])
  140.             {
  141.             Sbuf.lcol[r] = win->sc0;
  142.             }
  143.          if (win->sc1 > Sbuf.rcol[r])
  144.             {
  145.             Sbuf.rcol[r] = win->sc1;
  146.             }
  147.          }
  148.       }
  149.  
  150.    Sbuf.flags |= SB_DELTA;
  151.  
  152.    return (SB_OK);
  153. }
  154.  
  155. int sb_set_scrl (win, top, left, bottom, right)
  156. REGIONP win;
  157. int top, left;
  158. int bottom, right;
  159. {
  160.    if ((top < 0) || (left < 0) ||
  161.        (bottom > win->r1 - win->r0) ||
  162.        (right > win->c1 - win->c0))
  163.       return (SB_ERR);
  164.  
  165.    win->sr0 = win->r0 + top;
  166.    win->sc0 = win->c0 + left;
  167.    win->sr1 = win->r0 + bottom - 1;
  168.    win->sc1 = win->c0 + right - 1;
  169.  
  170.    return (SB_OK);
  171. }
  172.