home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / txcl552 / inc / tcxlinp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-22  |  10.4 KB  |  168 lines

  1. /*=====[ The TesSeRact(TM) CXL User Interface Development System ]======*
  2.  | Copyright (c) 1987-1991, Innovative Data Concepts, Inc.
  3.  | All Rights Reserved.
  4.  |
  5.  | This Library is part of IDC's TesSeRact Development Tools product
  6.  | line. For information about other IDC products, call 1-215-443-9705.
  7.  *-V--------------------------------------------------------------------*
  8.  | $Header:   tcxlinp.h     552.5   31 May 1991 14:21:42  $
  9.  |
  10.  | $Log:   tcxlinp.h    $
  11.  *-D--------------------------------------------------------------------*
  12.  | <TCXLinp.h> : Public definitions and prototypes for TCXL Input system.
  13.  *-N-----------------------[ Notes and Caveats ]------------------------*
  14.  | 1) If an enhanced (101-key) keyboard is detected at start-up (MS-DOS),
  15.  |    the DEFAULT action is to enable the extended keyboard BIOS and to
  16.  |    translate all enhanced keycodes to their normal equivalents. The
  17.  |    KextOn() and KextOff() macros enable/disable the extended BIOS. The
  18.  |    KfixOn() and KfixOff() enable/disable enhanced keycode translation.
  19.  | 2) To change the size of the internal TCXL key-queue, you MUST modify 
  20.  |    the value of the KEY_MAX define here AND re-compile key/_keyctl.c.
  21.  *======================================================================*/
  22. #ifndef  _TCXLinp_
  23. #  define   _TCXLinp_ 1
  24. #  ifndef   _TCXLkey_
  25. #     include  <TCXLkey.h>             /* Keyboard definitions          */
  26. #  endif
  27. #define  KEY_MAX  128                  /* Size of TCXL key-queue        */
  28.  
  29. /*------------------[ Data objects and access macros ]------------------*/
  30.  
  31. TYP   struct   _Kbnd KbndT, *KbndP;    /* object, pointer types         */
  32. TYP   struct   _Kctl KctlT, *KctlP;
  33.  
  34. struct   _Kbnd                /*-[ Key-binding stack-object ]-----------*/
  35. {  KbndP    bptr;             /* 00|00 : KbndPtr : Previous binding     */
  36.    union                      /*                                        */
  37.    {  VfvCP fun;              /* 02|04 : KbndFun : Bound function       */
  38.       KcodP str;              /* 02|04 : KbndStr : Bound macro          */
  39.    }  b;                      /*                   key-string           */
  40.    KeyT     bkey;             /* 04|08 : KbndKey : Bound keycode        */
  41.    KeyT     brtn;             /* 06|0C : KbndRtn : Return keycode       */
  42.                               /*                   0xFFFF = macro       */
  43.    VposT    bpos;             /* 08:0E : KbndPos : Mouse Position       */
  44. };                            /* 0A|10 ]--------------------------------*/
  45. #define  KbndPtr(b)  ((b)->bptr)                /* Previous binding     */
  46. #define  KbndFun(b)  ((b)->b.fun)               /* Bound function       */
  47. #define  KbndStr(b)  ((b)->b.str)               /* Bound macro string   */
  48. #define  KbndKey(b)  ((b)->bkey)                /* Bound keycode        */
  49. #define  KbndRtn(b)  ((b)->brtn)                /* Return keycode       */
  50. #define  KbndPos(b)  ((b)->bpos)                /* Mouse Position       */
  51. #define  KbndPosW(b) (VposW((b)->bpos))             /* word             */
  52. #define  KbndPosR(b) (VposR((b)->bpos))             /* row              */
  53. #define  KbndPosC(b) (VposC((b)->bpos))             /* col              */
  54.  
  55. struct   _Kctl                /*-[ Key-control object ]-----------------*/
  56. {  IntT     kbeg;             /* 00|00 : KctlBeg : Key-queue head       */
  57.    IntT     kend;             /* 02|02 : KctlEnd : Key-queue tail       */
  58.    IntT     kcnt;             /* 04|04 : KctlCnt : Key-queue count      */
  59.    IntT     kmax;             /* 06|06 : KctlMax : Key-queue size       */
  60.    KeyP     kbas;             /* 08|08 : KctlBas : Key-queue base       */
  61.    KbndP    kbnd;             /* 0A|0C : KctlBnd : Global binding-stack */
  62.    VfvCP    kidl;             /* 0C|10 : KctlIdl : Idle-loop function   */
  63.    KeyT     khlp;             /* 0E|14 : KctlHlp : Help keycode         */
  64.    VfvCP    kfun;             /* 10|16 : KctlFun : Help function        */
  65.    BytT     kflg;             /* 12|1A : KctlFlg : Control-flag         */
  66.    BytT     ksrc;             /* 13|1B : KctlSrc : Keycode source       */
  67. };                            /* 14|1C ]--------------------------------*/
  68.  
  69. GBL   KctlT CDC _KeyCtl;      /*- global key-control object ------------*/
  70. #define  KctlBeg  (_KeyCtl.kbeg)                /* Queue-head           */
  71. #define  KctlEnd  (_KeyCtl.kend)                /* Queue-tail           */
  72. #define  KctlCnt  (_KeyCtl.kcnt)                /* Queue-count          */
  73. #define  KctlMax  (_KeyCtl.kmax)                /* Queue-size           */
  74. #define  KctlBas  (_KeyCtl.kbas)                /* Queue-base           */
  75. #define  KctlBnd  (_KeyCtl.kbnd)                /* Global binding-stack */
  76. #define  KctlIdl  (_KeyCtl.kidl)                /* Idle function        */
  77. #define  KctlHlp  (_KeyCtl.khlp)                /* Help keycode         */
  78. #define  KctlFun  (_KeyCtl.kfun)                /* Help function        */
  79. #define  KctlFlg  (_KeyCtl.kflg)                /* Control-flag         */
  80. #define  KctlExt  (0 != (KctlFlg & KEY_EXT))       /* extended          */
  81. #define  KctlFix  (0 != (KctlFlg & KEY_FIX))       /* translate         */
  82. #define  KctlSrc  (_KeyCtl.ksrc)                /* Keycode-source       */
  83. #define  KctlKbd  (KctlSrc == KEY_KBD)             /* keyboard          */
  84. #define  KctlQue  (KctlSrc == KEY_QUE)             /* key-queue         */
  85. #define  KctlMou  (KctlSrc == KEY_MOU)             /* mouse             */
  86.  
  87. GBL   KeyT  CDC _KeyQue[];    /*- global key-queue ---------------------*/
  88.  
  89. /*------------------------[ Function prototypes ]-----------------------*/
  90.  
  91. #ifdef __cplusplus                     /* no mangling, please           */
  92.    extern   "C"   {
  93. #endif
  94.                               /*- Input to active window ---------------*/
  95. ChrT  CTYP  KwGetCf(ChrP v, ChrT d);   /* Get valid key                 */
  96. ChrT  CTYP  KwGetCh(NOARG);            /* Get key                       */
  97. IntT  CTYP  KwGetFmt(ChrP s, ChrP f);  /* Get TCXL formatted string     */
  98. IntT  CTYP  KwGetSn(ChrP s, IntT m);   /* Get limited string            */
  99. IntT  CTYP  KwGetSt(ChrP ps);          /* Get string                    */
  100. ChrT  CTYP  KwGetYn(ChrT cd);          /* Get Y|N answer                */
  101. #ifdef   __TURBOC__
  102. IntT  CDC   KwScanf(ChrP fs, ...);     /* Get scanf() string [TC only]  */
  103. #endif
  104.                               /*- Input to default video ---------------*/
  105. ChrT  CTYP  KvGetCf(ChrP v, ChrT d);   /* Get valid key                 */
  106. ChrT  CTYP  KvGetCh(NOARG);            /* Get key                       */
  107. IntT  CTYP  KvGetFmt(ChrP s, ChrP f);  /* Get TCXL formatted string     */
  108. IntT  CTYP  KvGetSn(ChrP s, IntT m);   /* Get limited string            */
  109. VOID  CTYP  KvGetSt(ChrP ps);          /* Get string                    */
  110. ChrT  CTYP  KvGetYn(ChrT cd);          /* Get Y|N answer                */
  111. #ifdef   __TURBOC__
  112. VOID  CDC   KvScanf(ChrP fs, ...);     /* Get scanf() string [TC only]  */
  113. #endif
  114.                               /*- Global asynchronous input ------------*/
  115. KbndP CTYP  KbndChg(KbndP s);          /* Swap binding-stacks           */
  116. IntT  CTYP  KbndClr(KeyT kc);          /* Unbind global key             */
  117. VOID  CTYP  KbndFre(NOARG);            /* Free all global key-bindings  */
  118. VOID        KbndIdle(VfvCP fi);        /* Assign idle-loop function     */
  119. IntT  CTYP  KbndMac(KeyT kc,           /* Bind global key to macro      */
  120.    KcodP bs);                          /*    key-string                 */
  121. IntT  CTYP  KbndMou(KeyT kc,           /* Bind Mouse event to function  */
  122.    VfvCP fn, IntT r, IntT c, IntT l);
  123. VOID  CTYP  KbndPut(KbndP kb);         /* Enqueue bound macro string    */
  124. IntT  CTYP  KbndSet(KeyT kc,           /* Bind global key to function & */
  125.    VfvCP fb, KeyT rc);                 /*    return key                 */
  126.                               /*- Local (user) asyncronous input -------*/
  127. KbndP CTYP  KusrClr(KeyT kc,           /* Unbind local key              */
  128.    KbndP kb);
  129. VOID  CTYP  KusrFre(KbndP kb);         /* Free all local key-bindings   */
  130. KbndP CTYP  KusrMac(KeyT kc,           /* Bind local key to macro       */
  131.    KcodP bs, KbndP kb);                /*    key-string                 */
  132. KbndP CTYP  KusrSet(KeyT kc, VfvCP fb, /* Bind local key to function &  */
  133.    KeyT rc, KbndP kb);                 /*    return key                 */
  134.                               /*- Input, no echo -----------------------*/
  135. VOID  CTYP  KeyClear(NOARG);           /* Clear keyboard                */
  136. FlgT  CTYP  KeyEvent(NOARG);           /* Detect key/mouse event        */
  137. KeyT  CTYP  KeyGetc(NOARG);            /* Get key/mouse event           */
  138. KeyT  CTYP  KeyPeek(NOARG);            /* Peek at waiting keycode       */
  139. WrdT  CTYP  KeyStat(NOARG);            /* Get keyboard status           */
  140. KeyT  CTYP  KeyTime(IntT t);           /* Wait for key or time-out      */
  141. KeyT  CTYP  KeyWait(NOARG);            /* Wait for key                  */
  142.                               /*- TCXL key-queue -----------------------*/
  143. IntT        KqueChk(NOARG);            /* Test for enqueued keycodes    */
  144. VOID  PAS   KqueClr(NOARG);            /* Clear FIFO queue              */
  145. KeyT  PAS   KqueGet(NOARG);            /* Dequeue head keycode          */
  146. IntT  PAS   KquePut(KeyT k);           /* Put key on tail of queue      */
  147. IntT  CTYP  KqueStr(ChrP s);           /* Put string on tail of queue   */
  148.                               /*- Enhanced keyboard support (MS-DOS) ---*/
  149. VOID        KextOff(NOARG);            /* Extended BIOS support OFF     */
  150. VOID        KextOn(NOARG);             /* Extended BIOS support ON      */
  151. VOID        KfixOff(NOARG);            /* Extended key translation OFF  */
  152. VOID        KfixOn(NOARG);             /* Extended key translation ON   */
  153.                               /*- Implementation macros ----------------*/
  154. #define  KbndIdle(a) (KctlIdl = a)
  155. #define  KextOff()   (KctlFlg &= ~KEY_EXT)
  156. #define  KextOn()    if(TcxlKey) KctlFlg |= KEY_EXT
  157. #define  KfixOff()   (KctlFlg &= ~KEY_FIX)
  158. #define  KfixOn()    if(TcxlKey) KctlFlg |= KEY_FIX
  159. #define  KqueChk()   (KctlCnt > 0)
  160.                               /*- Internals ----------------------------*/
  161. KeyT  CTYP  _MouChk(NOARG);            /* gather mouse events           */
  162. KeyT  CTYP  _MouGet(NOARG);            /* return mouse events           */
  163. VOID  CTYP  _MouClr(NOARG);            /* clear internal mouse flags    */
  164. #ifdef __cplusplus
  165.    }
  166. #endif
  167. #endif   /* _TCXLinp_ : End of TCXLinp.h -------------------------------*/
  168.