home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / txcl552 / inc / tcxlfmt.h < prev    next >
Encoding:
Text File  |  1991-03-15  |  15.2 KB  |  240 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:   tcxlfmt.h     552.0   17 Mar 1991 18:26:36  $
  9.  |
  10.  | $Log:   tcxlfmt.h    $
  11.  *-D--------------------------------------------------------------------*
  12.  | <TCXLfmt.h> : Definitions and prototypes for TCXL conversion functions
  13.  | and format-string field-input/output subsystem.
  14.  *-N-----------------------[ Notes and Caveats ]------------------------*
  15.  | 1) _FmtCtl is declared in _FmtInit.C
  16.  | 2) National-language support [NLS] is implemented as defined in
  17.  |    <TCXLnls.h>.
  18.  | 3) There are 3 possible usage-states, flagged as shown to the right:
  19.  |    a) FMT_VID : input with echo to default video.                (VID)
  20.  |    b) FMT_WIN : input with echo or output to active window.      (WIN)
  21.  |    c) FMT_ENT : input/output within the data-entry system        (ENT)
  22.  | 4) The format options are toggled on or off by "!..!" format-string
  23.  |    sequences, where valid option characters, depending on usage-state
  24.  |    are:
  25.  |       Option   Char                          VID WIN ENT
  26.  |                '-'  Decrement attribute           X   X
  27.  |                '+'  Increment attribute           X   X
  28.  |                'Aa' Set attribute 'a'             X   X
  29.  |       FMT_LWR  'L'  Convert to lower-case     X   X   X
  30.  |       FMT_MIX  'M'  Convert to mixed-case     X   X   X
  31.  |       FMT_PAS  'P'  Mask password field       X   X   X
  32.  |       FMT_UPR  'U'  Convert to upper-case     X   X   X
  33.  |       FMT_CPY  'C'  Copy strings to output    X   X
  34.  |       FMT_ESC  'E'  Detect [Esc] key          X   X
  35.  |       FMT_RTN  'R'  Detect [Enter] key        X   X
  36.  |    Default initial option-state also depends on usage:
  37.  |    a) FMT_VID - No options enabled.
  38.  |    b) FMT_WIN - [Esc] detection enabled unless suppressed by WctlEsc.
  39.  |    c) FMT_ENT - Both [Enter] and [Esc] detection enabled.
  40.  |    For FMT_ENT usage, additional initial option values are set by the
  41.  |    field feature-mask.
  42.  | 5) Input character validation is specified, one input position at a
  43.  |    time, by one of the following format-string constructs:
  44.  |    a) An inclusion-set, enclosed in '<>', where the input character
  45.  |       must be a member of the set.
  46.  |    b) An exclusion-set, enclosed in '[]', where the input character
  47.  |       must NOT be a member of the set.
  48.  |    c) A format-type character, where the input character must be one
  49.  |       of those specified:
  50.  |          'A'   Alphabetic                 'X'   Alphanumeric
  51.  |          'D'   Date                       'Y'   Yes/No (NLS dependent)
  52.  |          'F'   Valid filename             '#'   Numeric
  53.  |          'H'   Hexadecimal                '%'   Numeric or space
  54.  |          'L'   Lower-case                 '*'   ASCII printable
  55.  |          'M'   Mixed-case                 '?'   Any character
  56.  |          'P'   Password                   '9'   Decimal numeric
  57.  |          'T'   Telephone                  '.'   Decimal point
  58.  |          'U'   Upper-case                 '$'   Decimal currency
  59.  |          'W'   Filename with wildcards
  60.  |       Decimal fields specified by '9', '.' and '$' are formatted and
  61.  |       handled only for FMT_ENT usage at present.
  62.  | 6) Any 'L', 'M' and 'U' conversion specified by either format option
  63.  |    or format-type character is done BEFORE validating an input
  64.  |    character.
  65.  | 7) Format-strings may also include quoted strings (which are copied to
  66.  |    the output if FMT_CPY is in effect), NewLines to format multi-line
  67.  |    fields, and spaces for readability. Any other character is invalid.
  68.  | 8) The cvt???() functions are used to convert between integer or
  69.  |    floating-point values and TCXL format-string fields.
  70.  *======================================================================*/
  71. #ifndef  _TCXLfmt_
  72. #  define   _TCXLfmt_ 1                /* Only once!                    */
  73. #  ifndef   _TCXLdef_
  74. #     include  <TCXLdef.h>             /* Standard definitions          */
  75. #  endif
  76. #  ifndef   _TCXLnls_
  77. #     include  <TCXLnls.h>             /* National-language definitions */
  78. #  endif
  79.                               /*- FmtSet/FmtOpt option bits ------------*/
  80. #define  FMT_LWR  0x01        /* 'L' Convert to lower case              */
  81. #define  FMT_MIX  0x02        /* 'M' Convert to mixed case              */
  82. #define  FMT_UPR  0x04        /* 'U' Convert to upper case              */
  83. #define  FMT_PAS  0x08        /* 'P' Password -- masked display         */
  84. #define  FMT_CPY  0x10        /* 'C' Copy to output              (!ENT) */
  85. #define  FMT_ESC  0x20        /* 'E' [Esc] detect                (!ENT) */
  86. #define  FMT_RTN  0x40        /* 'R' [CR] detect                 (!ENT) */
  87. #define  FMT_EOF  0x80        /* End-of-format                          */
  88. #define  FMT_FIN  0xC0        /* End | 'R' - Done with format           */
  89.                               /*- FmtUse usage-bits --------------------*/
  90. #define  FMT_VID  0x00        /* KvGetFmt(), etc.                 (VID) */
  91. #define  FMT_WIN  0x01        /* KwGetFmt(), etc.                 (WIN) */
  92. #define  FMT_ENT  0x02        /* EntFld(), etc.                   (ENT) */
  93. #define  FMT_USE  0x03        /* Usage mask                             */
  94. #define  FMT_PUT  0x04        /* Output mode                            */
  95. #define  FMT_DEC  0x10        /* Decimal field                    (ENT) */
  96. #define  FMT_CUR  0x20        /* Currency field                   (ENT) */
  97. #define  FMT_INP  0x40        /* Input to field                   (ENT) */
  98. #define  FMT_CHK  0x80        /* Validation pending               (ENT) */
  99. #define  FMT_PND  0xC0        /* Input/validation pending         (ENT) */
  100.                               /*- FmtFlg transient-flag bits -----------*/
  101. #define  FMT_MOD  0x03        /* Display-mode                     (ENT) */
  102. #define  FMT_INI  0x00        /*    Initial                             */
  103. #define  FMT_CHG  0x01        /*    Change                              */
  104. #define  FMT_CND  0x02        /*    Conditional-update                  */
  105. #define  FMT_DSP  0x04        /* Re-display field                 (ENT) */
  106. #define  FMT_DFP  0x08        /* Decimal-field format pending     (ENT) */
  107. #define  FMT_INS  0x20        /* Insert mode ON                         */
  108. #define  FMT_WRP  0xC0        /* Field-wrap                       (ENT) */
  109. #define  FMT_PRV  0x40        /*    End of previous field               */
  110. #define  FMT_NXT  0x80        /*    Start of next field                 */
  111.  
  112. /*------------------[ Data objects and access macros ]------------------*/
  113.  
  114. TYP   struct   _Fmt  FmtT, *FmtP;
  115. struct   _Fmt                 /*-[ Format-control object ]--------------*/
  116. {  ChrP     fsep;             /* 00|00 : FmtSep : Word-separator string */
  117.    KfvCP    fget;             /* 02|04 : FmtGet : Input function        */
  118.    IfcpCP   fval;             /* 04|08 : FmtVal : User "Valid" function */
  119.    ChrP     ffmt;             /* 06|0C : FmtFmt : Format string         */
  120.    ChrP     fptr;             /* 08|10 : FmtPtr : Format pointer        */
  121.    ChrP     fbfr;             /* 0A|14 : FmtBfr : Buffer string         */
  122.    VposT    forg;             /* 0C|18 : FmtOrg : Screen position       */
  123.    VposT    fpos;             /* 0E|1A : FmtPos : Cursor position       */
  124.    IntT     flen;             /* 10|1C : FmtLen : Field length          */
  125.    IntT     fofs;             /* 12|1E : FmtOfs : Current offset        */
  126.    BytT     fext;             /* 14|20 : FmtExt : Input extent          */
  127.    BytT     fdot;             /* 15|21 : FmtDec : Decimal offset        */
  128.    BytT     ferr;             /* 16|22 : FmtErr : Error offset          */
  129.    ChrT     fchr;             /* 17|23 : FmtChr : Field fill-char       */
  130.    ChrT     fmsk;             /* 18|24 : FmtMsk : Password mask char    */
  131.    AtrT     fatr;             /* 19|25 : FmtAtr : Field attribute       */
  132.    BytT     fset;             /* 1A|26 : FmtSet : Initial options       */
  133.    BytT     fopt;             /* 1B|27 : FmtOpt : Option state          */
  134.    BytT     fuse;             /* 1C|28 : FmtUse : Usage state           */
  135.    BytT     fflg;             /* 1D|29 : FmtFlg : Transient flags       */
  136. };                            /* 1E|2A ]--------------------------------*/
  137.  
  138. GBL   FmtT  CDC   _FmtCtl;    /*- Global format-control object ---------*/
  139. #define  FmtSep   (_FmtCtl.fsep)                /* Word-separators      */
  140. #define  FmtGet   (_FmtCtl.fget)                /* Input function       */
  141. #define  FmtVal   (_FmtCtl.fval)                /* "Valid" function     */
  142. #define  FmtFmt   (_FmtCtl.ffmt)                /* Format string        */
  143. #define  FmtPtr   (_FmtCtl.fptr)                /* Format pointer       */
  144. #define  FmtBfr   (_FmtCtl.fbfr)                /* Buffer string        */
  145. #define  FmtOrg   (_FmtCtl.forg)                /* Screen position      */
  146. #define  FmtOrgW  (VposW(FmtOrg))                  /* Word              */
  147. #define  FmtOrgR  (VposR(FmtOrg))                  /* Row               */
  148. #define  FmtOrgC  (VposC(FmtOrg))                  /* Col               */
  149. #define  FmtPos   (_FmtCtl.fpos)                /* Cursor position      */
  150. #define  FmtPosW  (VposW(FmtPos))                  /* Word              */
  151. #define  FmtRow   (VposR(FmtPos))                  /* Row               */
  152. #define  FmtCol   (VposC(FmtPos))                  /* Col               */
  153. #define  FmtLen   (_FmtCtl.flen)                /* Field length         */
  154. #define  FmtOfs   (_FmtCtl.fofs)                /* Current offset       */
  155. #define  FmtExt   (_FmtCtl.fext)                /* Input-extent         */
  156. #define  FmtDot   (_FmtCtl.fdot)                /* Decimal offset       */
  157. #define  FmtErr   (_FmtCtl.ferr)                /* Error offset         */
  158. #define  FmtChr   (_FmtCtl.fchr)                /* Field-fill character */
  159. #define  FmtMsk   (_FmtCtl.fmsk)                /* Password mask char   */
  160. #define  FmtAtr   (_FmtCtl.fatr)                /* Field attribute      */
  161. #define  FmtSet   (_FmtCtl.fset)                /* Initial options      */
  162. #define  FmtOpt   (_FmtCtl.fopt)                /* Option state         */
  163. #define  FmtLwr   (0 != (FmtOpt & FMT_LWR))        /* Lower case        */
  164. #define  FmtMix   (0 != (FmtOpt & FMT_MIX))        /* Mixed case        */
  165. #define  FmtUpr   (0 != (FmtOpt & FMT_UPR))        /* Upper case        */
  166. #define  FmtPas   (0 != (FmtOpt & FMT_PAS))        /* Password mask     */
  167. #define  FmtCpy   (0 != (FmtOpt & FMT_CPY))        /* Copy to output    */
  168. #define  FmtEsc   (0 != (FmtOpt & FMT_ESC))        /* [Esc] detect      */
  169. #define  FmtRtn   (0 != (FmtOpt & FMT_RTN))        /* [Enter] detect    */
  170. #define  FmtEof   (0 != (FmtOpt & FMT_EOF))        /* End-of-format     */
  171. #define  FmtFin   (0 != (FmtOpt & FMT_FIN))        /* Done with format  */
  172. #define  FmtUse   (_FmtCtl.fuse)                /* Usage state          */
  173. #define  FmtVid   (FMT_VID == (FmtUse & FMT_USE))  /* KvGetFmt(), etc   */
  174. #define  FmtWin   (FMT_WIN == (FmtUse & FMT_USE))  /* KwGetFmt(), etc   */
  175. #define  FmtEnt   (FMT_ENT == (FmtUse & FMT_USE))  /* EntDsp()/EntGet() */
  176. #define  FmtPut   (0 != (FmtUse & FMT_PUT))        /* Output mode       */
  177. #define  FmtDec   (0 != (FmtUse & FMT_DEC))        /* Decimal field     */
  178. #define  FmtCur   (0 != (FmtUse & FMT_CUR))        /* Currency field    */
  179. #define  FmtInp   (0 != (FmtUse & FMT_INP))        /* Input             */
  180. #define  FmtChk   (0 != (FmtUse & FMT_CHK))        /* Validation        */
  181. #define  FmtPnd   (FMT_PND == (FmtUse & FMT_PND))  /* Pending           */
  182. #define  FmtFlg   (_FmtCtl.fflg)                /* Transient flags      */
  183. #define  FmtMod   (_FmtCtl.fflg & FMT_MOD)         /* Display mode      */
  184. #define  FmtIni   (FMT_INI == FmtMod)              /*    Initial        */
  185. #define  FmtChg   (FMT_CHG == FmtMod)              /*    Change         */
  186. #define  FmtCnd   (FMT_CND == FmtMod)              /*    Conditional    */
  187. #define  FmtDsp   (0 != (FmtFlg & FMT_DSP))        /* Re-display field  */
  188. #define  FmtDfp   (0 != (FmtFlg & FMT_DFP))        /* Decimal format    */
  189. #define  FmtIns   (0 != (FmtFlg & FMT_INS))        /* Insert mode ON    */
  190. #define  FmtWrp   (0 != (FmtFlg & FMT_WRP))        /* Field-wrap        */
  191. #define  FmtPrv   (0 != (FmtFlg & FMT_PRV))        /*    Previous       */
  192. #define  FmtNxt   (0 != (FmtFlg & FMT_NXT))        /*    Next           */
  193.  
  194. GBL   ChrP  CDC   _FmtSep;    /*- Default word-separator string --------*/
  195.  
  196. /*------------------------[ Function prototypes ]-----------------------*/
  197.  
  198. #ifdef __cplusplus                     /* No mangling, please           */
  199.    extern   "C"   {
  200. #endif
  201.                               /*- Conversion functions -----------------*/
  202. DblT  CTYP  cvtcf(ChrP fp);            /* TCXL field to double          */
  203. IntT  CTYP  cvtci(ChrP fp);            /* TCXL field to integer         */
  204. VOID  CTYP  cvtfc(ChrP fp, DblT dv,    /* Double to TCXL field          */
  205.    IntT fw, IntT nd);
  206. VOID  CTYP  cvtic(ChrP fp, IntT iv,    /* Integer to TCXL field         */
  207.    IntT fs);
  208. ChrT  CTYP  touplow(ChrP s, ChrP p,    /* Character to initial caps     */
  209.    ChrT c);
  210.                               /*- Format-string functions --------------*/
  211. VOID        _FmtAttr(AtrT c);          /* Assign field-attribute        */
  212. FlgT  CTYP  _FmtChar(ChrT c);          /* Validate input character      */
  213. VOID        _FmtFill(ChrT c);          /* Assign field-fill char        */
  214. VOID  CTYP  _FmtFunc(KfvCP f);         /* Assign input function         */
  215. KeyT  CTYP  _FmtGetc(NOARG);           /* Get formatted input char      */
  216. FlgT  CTYP  _FmtGets(ChrP s, ChrP f);  /* Get formatted input string    */
  217. IntT  CTYP  _FmtInit(ChrP f, BytT u);  /* Inititalize and verify format */
  218. VOID        _FmtMask(ChrT c);          /* Assign password-mask char     */
  219. ChrP  CTYP  _FmtOpts(ChrP f);          /* Toggle format-options         */
  220. VOID  CTYP  _FmtPuts(NOARG);           /* Put formatted output string   */
  221. VOID  CTYP  _FmtSeps(ChrP s);          /* Assign word-separation string */
  222. FlgT  CTYP  _FmtVali(NOARG);           /* Validate current field        */
  223.                               /*- Internal field-buffer management -----*/
  224. VOID  CTYP  _FmtClr(IntT o);           /* Clear from <o> to end         */
  225. VOID  CTYP  _FmtCpy(ChrP s);           /* Copy string <s>               */
  226. VOID  CTYP  _FmtCur(NOARG);            /* Currency-field prefix/suffix  */
  227. VOID  CTYP  _FmtDec(NOARG);            /* Format decimal/currency       */
  228. VOID  CTYP  _FmtDel(IntT o, IntT n);   /* Delete <n> chars at <o>       */
  229. VOID  CTYP  _FmtIns(IntT o, IntT n);   /* Insert <n> blanks at <o>      */
  230. IntT  CTYP  _FmtPos(IntT o);           /* Position buffer/format at <o> */
  231. FlgT  CTYP  _FmtSpa(IntT o);           /* Test for clear at <o>         */
  232.                               /*- Implementation macros ----------------*/
  233. #define  _FmtAttr(a) (FmtAtr = (a))
  234. #define  _FmtFill(c) (FmtChr = (c))
  235. #define  _FmtMask(c) (FmtMsk = (c))
  236. #ifdef __cplusplus
  237.    }
  238. #endif
  239. #endif   /*- _TCXLfmt_ : End of TCXLfmt.h ------------------------------*/
  240.