home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / SB_READ.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  6KB  |  142 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. /*                 Box Drawing subroutines for 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. unsigned char sb_ra (REGIONP win, int r, int c)
  59. {
  60.    return ((unsigned char) (Scrnbuf + (win->r0 + r) * SB_COLS + win->c0 + c)->b.attr);
  61. }
  62.  
  63. unsigned char sb_rc (REGIONP win, int r, int c)
  64. {
  65.    return ((unsigned char) (Scrnbuf + (win->r0 + r) * SB_COLS + win->c0 + c)->b.ch);
  66. }
  67.  
  68. unsigned int sb_rca (REGIONP win, int r, int c)
  69. {
  70.    return ((unsigned int) (Scrnbuf + (win->r0 + r) * SB_COLS + win->c0 + c)->cap);
  71. }
  72.  
  73. int sb_input_chars (REGIONP win, int row, int col, char *str, int len)
  74. {
  75.    int i;
  76.    int j;
  77.  
  78.    sb_move (win, row, col);
  79.    for (i = 0; i < len; i++)
  80.       (void) sb_putc (win, '_');
  81.    sb_move (win, row, col);
  82.  
  83.    i = 0;
  84.    while (i < len)
  85.       {
  86.       sb_show ();
  87.       while (!KEYPRESS ())
  88.          time_release ();
  89.       j = FOSSIL_CHAR ();
  90.       if ((j & 0xff) != 0)
  91.          {
  92.          j &= 0xff;
  93.          j = toupper (j);
  94.          if (isprint (j))
  95.             {
  96.             (void) sb_putc (win, j & 0xff);
  97.             *str = (char) (j & 0xff);
  98.             ++str;
  99.             ++i;
  100.             ++col;
  101.             continue;
  102.             }
  103.          }
  104.  
  105.       switch (j)
  106.          {
  107.          case ESC:
  108.             return (1);
  109.  
  110.          case BS:
  111.          case LFAR:
  112.             if (i > 0)
  113.                {
  114.                --col;
  115.                sb_move (win, row, col);
  116.                (void) sb_putc (win, '_');
  117.                sb_move (win, row, col);
  118.                --str;
  119.                --i;
  120.                }
  121.             break;
  122.  
  123.          case CR:
  124.          case LV:
  125.             *str = '\0';
  126.             for (j = i; j < len; j++)
  127.                (void) sb_putc (win, ' ');
  128.  
  129.             if (i)
  130.                return (0);
  131.             else
  132.                return (1);
  133.          }
  134.       }
  135.  
  136.    *str = '\0';
  137.    sb_show ();
  138.    return (0);
  139. }
  140.  
  141.  
  142.