home *** CD-ROM | disk | FTP | other *** search
- /*=====[ The TesSeRact(TM) CXL User Interface Development System ]======*
- | Copyright (c) 1987-1991, Innovative Data Concepts, Inc.
- | All Rights Reserved.
- |
- | This Library is part of IDC's TesSeRact Development Tools product
- | line. For information about other IDC products, call 1-215-443-9705.
- *-V--------------------------------------------------------------------*
- | $Header: tcxlinp.h 552.5 31 May 1991 14:21:42 $
- |
- | $Log: tcxlinp.h $
- *-D--------------------------------------------------------------------*
- | <TCXLinp.h> : Public definitions and prototypes for TCXL Input system.
- *-N-----------------------[ Notes and Caveats ]------------------------*
- | 1) If an enhanced (101-key) keyboard is detected at start-up (MS-DOS),
- | the DEFAULT action is to enable the extended keyboard BIOS and to
- | translate all enhanced keycodes to their normal equivalents. The
- | KextOn() and KextOff() macros enable/disable the extended BIOS. The
- | KfixOn() and KfixOff() enable/disable enhanced keycode translation.
- | 2) To change the size of the internal TCXL key-queue, you MUST modify
- | the value of the KEY_MAX define here AND re-compile key/_keyctl.c.
- *======================================================================*/
- #ifndef _TCXLinp_
- # define _TCXLinp_ 1
- # ifndef _TCXLkey_
- # include <TCXLkey.h> /* Keyboard definitions */
- # endif
- #define KEY_MAX 128 /* Size of TCXL key-queue */
-
- /*------------------[ Data objects and access macros ]------------------*/
-
- TYP struct _Kbnd KbndT, *KbndP; /* object, pointer types */
- TYP struct _Kctl KctlT, *KctlP;
-
- struct _Kbnd /*-[ Key-binding stack-object ]-----------*/
- { KbndP bptr; /* 00|00 : KbndPtr : Previous binding */
- union /* */
- { VfvCP fun; /* 02|04 : KbndFun : Bound function */
- KcodP str; /* 02|04 : KbndStr : Bound macro */
- } b; /* key-string */
- KeyT bkey; /* 04|08 : KbndKey : Bound keycode */
- KeyT brtn; /* 06|0C : KbndRtn : Return keycode */
- /* 0xFFFF = macro */
- VposT bpos; /* 08:0E : KbndPos : Mouse Position */
- }; /* 0A|10 ]--------------------------------*/
- #define KbndPtr(b) ((b)->bptr) /* Previous binding */
- #define KbndFun(b) ((b)->b.fun) /* Bound function */
- #define KbndStr(b) ((b)->b.str) /* Bound macro string */
- #define KbndKey(b) ((b)->bkey) /* Bound keycode */
- #define KbndRtn(b) ((b)->brtn) /* Return keycode */
- #define KbndPos(b) ((b)->bpos) /* Mouse Position */
- #define KbndPosW(b) (VposW((b)->bpos)) /* word */
- #define KbndPosR(b) (VposR((b)->bpos)) /* row */
- #define KbndPosC(b) (VposC((b)->bpos)) /* col */
-
- struct _Kctl /*-[ Key-control object ]-----------------*/
- { IntT kbeg; /* 00|00 : KctlBeg : Key-queue head */
- IntT kend; /* 02|02 : KctlEnd : Key-queue tail */
- IntT kcnt; /* 04|04 : KctlCnt : Key-queue count */
- IntT kmax; /* 06|06 : KctlMax : Key-queue size */
- KeyP kbas; /* 08|08 : KctlBas : Key-queue base */
- KbndP kbnd; /* 0A|0C : KctlBnd : Global binding-stack */
- VfvCP kidl; /* 0C|10 : KctlIdl : Idle-loop function */
- KeyT khlp; /* 0E|14 : KctlHlp : Help keycode */
- VfvCP kfun; /* 10|16 : KctlFun : Help function */
- BytT kflg; /* 12|1A : KctlFlg : Control-flag */
- BytT ksrc; /* 13|1B : KctlSrc : Keycode source */
- }; /* 14|1C ]--------------------------------*/
-
- GBL KctlT CDC _KeyCtl; /*- global key-control object ------------*/
- #define KctlBeg (_KeyCtl.kbeg) /* Queue-head */
- #define KctlEnd (_KeyCtl.kend) /* Queue-tail */
- #define KctlCnt (_KeyCtl.kcnt) /* Queue-count */
- #define KctlMax (_KeyCtl.kmax) /* Queue-size */
- #define KctlBas (_KeyCtl.kbas) /* Queue-base */
- #define KctlBnd (_KeyCtl.kbnd) /* Global binding-stack */
- #define KctlIdl (_KeyCtl.kidl) /* Idle function */
- #define KctlHlp (_KeyCtl.khlp) /* Help keycode */
- #define KctlFun (_KeyCtl.kfun) /* Help function */
- #define KctlFlg (_KeyCtl.kflg) /* Control-flag */
- #define KctlExt (0 != (KctlFlg & KEY_EXT)) /* extended */
- #define KctlFix (0 != (KctlFlg & KEY_FIX)) /* translate */
- #define KctlSrc (_KeyCtl.ksrc) /* Keycode-source */
- #define KctlKbd (KctlSrc == KEY_KBD) /* keyboard */
- #define KctlQue (KctlSrc == KEY_QUE) /* key-queue */
- #define KctlMou (KctlSrc == KEY_MOU) /* mouse */
-
- GBL KeyT CDC _KeyQue[]; /*- global key-queue ---------------------*/
-
- /*------------------------[ Function prototypes ]-----------------------*/
-
- #ifdef __cplusplus /* no mangling, please */
- extern "C" {
- #endif
- /*- Input to active window ---------------*/
- ChrT CTYP KwGetCf(ChrP v, ChrT d); /* Get valid key */
- ChrT CTYP KwGetCh(NOARG); /* Get key */
- IntT CTYP KwGetFmt(ChrP s, ChrP f); /* Get TCXL formatted string */
- IntT CTYP KwGetSn(ChrP s, IntT m); /* Get limited string */
- IntT CTYP KwGetSt(ChrP ps); /* Get string */
- ChrT CTYP KwGetYn(ChrT cd); /* Get Y|N answer */
- #ifdef __TURBOC__
- IntT CDC KwScanf(ChrP fs, ...); /* Get scanf() string [TC only] */
- #endif
- /*- Input to default video ---------------*/
- ChrT CTYP KvGetCf(ChrP v, ChrT d); /* Get valid key */
- ChrT CTYP KvGetCh(NOARG); /* Get key */
- IntT CTYP KvGetFmt(ChrP s, ChrP f); /* Get TCXL formatted string */
- IntT CTYP KvGetSn(ChrP s, IntT m); /* Get limited string */
- VOID CTYP KvGetSt(ChrP ps); /* Get string */
- ChrT CTYP KvGetYn(ChrT cd); /* Get Y|N answer */
- #ifdef __TURBOC__
- VOID CDC KvScanf(ChrP fs, ...); /* Get scanf() string [TC only] */
- #endif
- /*- Global asynchronous input ------------*/
- KbndP CTYP KbndChg(KbndP s); /* Swap binding-stacks */
- IntT CTYP KbndClr(KeyT kc); /* Unbind global key */
- VOID CTYP KbndFre(NOARG); /* Free all global key-bindings */
- VOID KbndIdle(VfvCP fi); /* Assign idle-loop function */
- IntT CTYP KbndMac(KeyT kc, /* Bind global key to macro */
- KcodP bs); /* key-string */
- IntT CTYP KbndMou(KeyT kc, /* Bind Mouse event to function */
- VfvCP fn, IntT r, IntT c, IntT l);
- VOID CTYP KbndPut(KbndP kb); /* Enqueue bound macro string */
- IntT CTYP KbndSet(KeyT kc, /* Bind global key to function & */
- VfvCP fb, KeyT rc); /* return key */
- /*- Local (user) asyncronous input -------*/
- KbndP CTYP KusrClr(KeyT kc, /* Unbind local key */
- KbndP kb);
- VOID CTYP KusrFre(KbndP kb); /* Free all local key-bindings */
- KbndP CTYP KusrMac(KeyT kc, /* Bind local key to macro */
- KcodP bs, KbndP kb); /* key-string */
- KbndP CTYP KusrSet(KeyT kc, VfvCP fb, /* Bind local key to function & */
- KeyT rc, KbndP kb); /* return key */
- /*- Input, no echo -----------------------*/
- VOID CTYP KeyClear(NOARG); /* Clear keyboard */
- FlgT CTYP KeyEvent(NOARG); /* Detect key/mouse event */
- KeyT CTYP KeyGetc(NOARG); /* Get key/mouse event */
- KeyT CTYP KeyPeek(NOARG); /* Peek at waiting keycode */
- WrdT CTYP KeyStat(NOARG); /* Get keyboard status */
- KeyT CTYP KeyTime(IntT t); /* Wait for key or time-out */
- KeyT CTYP KeyWait(NOARG); /* Wait for key */
- /*- TCXL key-queue -----------------------*/
- IntT KqueChk(NOARG); /* Test for enqueued keycodes */
- VOID PAS KqueClr(NOARG); /* Clear FIFO queue */
- KeyT PAS KqueGet(NOARG); /* Dequeue head keycode */
- IntT PAS KquePut(KeyT k); /* Put key on tail of queue */
- IntT CTYP KqueStr(ChrP s); /* Put string on tail of queue */
- /*- Enhanced keyboard support (MS-DOS) ---*/
- VOID KextOff(NOARG); /* Extended BIOS support OFF */
- VOID KextOn(NOARG); /* Extended BIOS support ON */
- VOID KfixOff(NOARG); /* Extended key translation OFF */
- VOID KfixOn(NOARG); /* Extended key translation ON */
- /*- Implementation macros ----------------*/
- #define KbndIdle(a) (KctlIdl = a)
- #define KextOff() (KctlFlg &= ~KEY_EXT)
- #define KextOn() if(TcxlKey) KctlFlg |= KEY_EXT
- #define KfixOff() (KctlFlg &= ~KEY_FIX)
- #define KfixOn() if(TcxlKey) KctlFlg |= KEY_FIX
- #define KqueChk() (KctlCnt > 0)
- /*- Internals ----------------------------*/
- KeyT CTYP _MouChk(NOARG); /* gather mouse events */
- KeyT CTYP _MouGet(NOARG); /* return mouse events */
- VOID CTYP _MouClr(NOARG); /* clear internal mouse flags */
- #ifdef __cplusplus
- }
- #endif
- #endif /* _TCXLinp_ : End of TCXLinp.h -------------------------------*/