home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / SB_READ.C < prev    next >
C/C++ Source or Header  |  1990-07-11  |  6KB  |  164 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software <no-Inc>                   */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          No-Cost<no-tm> Software.                       */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-90, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*              Box Drawing subroutines for BinkleyTerm 2.10                */
  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.  
  53. #include <stdio.h>
  54. #include <ctype.h>
  55. #include <conio.h>
  56.  
  57. #include "sbuf.h"
  58. #include "com.h"
  59. #include "xfer.h"
  60. #include "zmodem.h"
  61. #include "keybd.h"
  62. #include "sched.h"
  63. #include "externs.h"
  64. #include "prototyp.h"
  65.  
  66. extern BUFFER Sbuf;
  67. extern CELLP Scrnbuf;
  68.  
  69. unsigned char sb_ra (win, r, c)
  70. REGIONP win;
  71. int r, c;
  72. {
  73.    return ((unsigned char) (Scrnbuf + (win->r0 + r) * SB_COLS + win->c0 + c)->b.attr);
  74. }
  75.  
  76. unsigned char sb_rc (win, r, c)
  77. REGIONP win;
  78. int r, c;
  79. {
  80.    return ((unsigned char) (Scrnbuf + (win->r0 + r) * SB_COLS + win->c0 + c)->b.ch);
  81. }
  82.  
  83. unsigned int sb_rca (win, r, c)
  84. REGIONP win;
  85. int r, c;
  86. {
  87.    return ((unsigned int) (Scrnbuf + (win->r0 + r) * SB_COLS + win->c0 + c)->cap);
  88. }
  89.  
  90. int sb_input_chars (win, row, col, str, len)
  91. REGIONP win;
  92. int row;
  93. int col;
  94. char *str;
  95. int len;
  96. {
  97.     int i;
  98.     int j;
  99.  
  100.     sb_move (win, row, col);
  101.     for (i = 0; i < len; i++)
  102.         sb_putc (win, '_');
  103.     sb_move (win, row, col);
  104.  
  105.     i = 0;
  106.     while (i < len)
  107.         {
  108.         sb_show ();
  109.         while (!KEYPRESS ())
  110.             time_release ();
  111.         j = FOSSIL_CHAR ();
  112.         if ((j & 0xff) != 0)
  113.             {
  114.             j &= 0xff;
  115.             j = toupper (j);
  116.             if (isprint (j))
  117.                 {
  118.                 sb_putc (win, j & 0xff);
  119.                 *str = (char) (j & 0xff);
  120.                 ++str;
  121.                 ++i;
  122.                 ++col;
  123.                 continue;
  124.                 }
  125.             }
  126.  
  127.         switch (j)
  128.             {
  129.             case ESC:
  130.                 return (1);
  131.  
  132.             case BS:
  133.             case LFAR:
  134.                 if (i > 0)
  135.                     {
  136.                     --col;
  137.                     sb_move (win, row, col);
  138.                     sb_putc (win, '_');
  139.                     sb_move (win, row, col);
  140.                     --str;
  141.                     --i;
  142.                     }
  143.                 break;
  144.  
  145.             case CR:
  146.             case LV:
  147.                 *str = '\0';
  148.                 for (j = i; j < len; j++)
  149.                     sb_putc (win, ' ');
  150.  
  151.                 if (i)
  152.                     return (0);
  153.                 else
  154.                     return (1);
  155.             }
  156.         }
  157.  
  158.     *str = '\0';
  159.     sb_show ();
  160.     return (0);
  161. }
  162.  
  163.  
  164.