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: tcxlfmt.h 552.0 17 Mar 1991 18:26:36 $
- |
- | $Log: tcxlfmt.h $
- *-D--------------------------------------------------------------------*
- | <TCXLfmt.h> : Definitions and prototypes for TCXL conversion functions
- | and format-string field-input/output subsystem.
- *-N-----------------------[ Notes and Caveats ]------------------------*
- | 1) _FmtCtl is declared in _FmtInit.C
- | 2) National-language support [NLS] is implemented as defined in
- | <TCXLnls.h>.
- | 3) There are 3 possible usage-states, flagged as shown to the right:
- | a) FMT_VID : input with echo to default video. (VID)
- | b) FMT_WIN : input with echo or output to active window. (WIN)
- | c) FMT_ENT : input/output within the data-entry system (ENT)
- | 4) The format options are toggled on or off by "!..!" format-string
- | sequences, where valid option characters, depending on usage-state
- | are:
- | Option Char VID WIN ENT
- | '-' Decrement attribute X X
- | '+' Increment attribute X X
- | 'Aa' Set attribute 'a' X X
- | FMT_LWR 'L' Convert to lower-case X X X
- | FMT_MIX 'M' Convert to mixed-case X X X
- | FMT_PAS 'P' Mask password field X X X
- | FMT_UPR 'U' Convert to upper-case X X X
- | FMT_CPY 'C' Copy strings to output X X
- | FMT_ESC 'E' Detect [Esc] key X X
- | FMT_RTN 'R' Detect [Enter] key X X
- | Default initial option-state also depends on usage:
- | a) FMT_VID - No options enabled.
- | b) FMT_WIN - [Esc] detection enabled unless suppressed by WctlEsc.
- | c) FMT_ENT - Both [Enter] and [Esc] detection enabled.
- | For FMT_ENT usage, additional initial option values are set by the
- | field feature-mask.
- | 5) Input character validation is specified, one input position at a
- | time, by one of the following format-string constructs:
- | a) An inclusion-set, enclosed in '<>', where the input character
- | must be a member of the set.
- | b) An exclusion-set, enclosed in '[]', where the input character
- | must NOT be a member of the set.
- | c) A format-type character, where the input character must be one
- | of those specified:
- | 'A' Alphabetic 'X' Alphanumeric
- | 'D' Date 'Y' Yes/No (NLS dependent)
- | 'F' Valid filename '#' Numeric
- | 'H' Hexadecimal '%' Numeric or space
- | 'L' Lower-case '*' ASCII printable
- | 'M' Mixed-case '?' Any character
- | 'P' Password '9' Decimal numeric
- | 'T' Telephone '.' Decimal point
- | 'U' Upper-case '$' Decimal currency
- | 'W' Filename with wildcards
- | Decimal fields specified by '9', '.' and '$' are formatted and
- | handled only for FMT_ENT usage at present.
- | 6) Any 'L', 'M' and 'U' conversion specified by either format option
- | or format-type character is done BEFORE validating an input
- | character.
- | 7) Format-strings may also include quoted strings (which are copied to
- | the output if FMT_CPY is in effect), NewLines to format multi-line
- | fields, and spaces for readability. Any other character is invalid.
- | 8) The cvt???() functions are used to convert between integer or
- | floating-point values and TCXL format-string fields.
- *======================================================================*/
- #ifndef _TCXLfmt_
- # define _TCXLfmt_ 1 /* Only once! */
- # ifndef _TCXLdef_
- # include <TCXLdef.h> /* Standard definitions */
- # endif
- # ifndef _TCXLnls_
- # include <TCXLnls.h> /* National-language definitions */
- # endif
- /*- FmtSet/FmtOpt option bits ------------*/
- #define FMT_LWR 0x01 /* 'L' Convert to lower case */
- #define FMT_MIX 0x02 /* 'M' Convert to mixed case */
- #define FMT_UPR 0x04 /* 'U' Convert to upper case */
- #define FMT_PAS 0x08 /* 'P' Password -- masked display */
- #define FMT_CPY 0x10 /* 'C' Copy to output (!ENT) */
- #define FMT_ESC 0x20 /* 'E' [Esc] detect (!ENT) */
- #define FMT_RTN 0x40 /* 'R' [CR] detect (!ENT) */
- #define FMT_EOF 0x80 /* End-of-format */
- #define FMT_FIN 0xC0 /* End | 'R' - Done with format */
- /*- FmtUse usage-bits --------------------*/
- #define FMT_VID 0x00 /* KvGetFmt(), etc. (VID) */
- #define FMT_WIN 0x01 /* KwGetFmt(), etc. (WIN) */
- #define FMT_ENT 0x02 /* EntFld(), etc. (ENT) */
- #define FMT_USE 0x03 /* Usage mask */
- #define FMT_PUT 0x04 /* Output mode */
- #define FMT_DEC 0x10 /* Decimal field (ENT) */
- #define FMT_CUR 0x20 /* Currency field (ENT) */
- #define FMT_INP 0x40 /* Input to field (ENT) */
- #define FMT_CHK 0x80 /* Validation pending (ENT) */
- #define FMT_PND 0xC0 /* Input/validation pending (ENT) */
- /*- FmtFlg transient-flag bits -----------*/
- #define FMT_MOD 0x03 /* Display-mode (ENT) */
- #define FMT_INI 0x00 /* Initial */
- #define FMT_CHG 0x01 /* Change */
- #define FMT_CND 0x02 /* Conditional-update */
- #define FMT_DSP 0x04 /* Re-display field (ENT) */
- #define FMT_DFP 0x08 /* Decimal-field format pending (ENT) */
- #define FMT_INS 0x20 /* Insert mode ON */
- #define FMT_WRP 0xC0 /* Field-wrap (ENT) */
- #define FMT_PRV 0x40 /* End of previous field */
- #define FMT_NXT 0x80 /* Start of next field */
-
- /*------------------[ Data objects and access macros ]------------------*/
-
- TYP struct _Fmt FmtT, *FmtP;
- struct _Fmt /*-[ Format-control object ]--------------*/
- { ChrP fsep; /* 00|00 : FmtSep : Word-separator string */
- KfvCP fget; /* 02|04 : FmtGet : Input function */
- IfcpCP fval; /* 04|08 : FmtVal : User "Valid" function */
- ChrP ffmt; /* 06|0C : FmtFmt : Format string */
- ChrP fptr; /* 08|10 : FmtPtr : Format pointer */
- ChrP fbfr; /* 0A|14 : FmtBfr : Buffer string */
- VposT forg; /* 0C|18 : FmtOrg : Screen position */
- VposT fpos; /* 0E|1A : FmtPos : Cursor position */
- IntT flen; /* 10|1C : FmtLen : Field length */
- IntT fofs; /* 12|1E : FmtOfs : Current offset */
- BytT fext; /* 14|20 : FmtExt : Input extent */
- BytT fdot; /* 15|21 : FmtDec : Decimal offset */
- BytT ferr; /* 16|22 : FmtErr : Error offset */
- ChrT fchr; /* 17|23 : FmtChr : Field fill-char */
- ChrT fmsk; /* 18|24 : FmtMsk : Password mask char */
- AtrT fatr; /* 19|25 : FmtAtr : Field attribute */
- BytT fset; /* 1A|26 : FmtSet : Initial options */
- BytT fopt; /* 1B|27 : FmtOpt : Option state */
- BytT fuse; /* 1C|28 : FmtUse : Usage state */
- BytT fflg; /* 1D|29 : FmtFlg : Transient flags */
- }; /* 1E|2A ]--------------------------------*/
-
- GBL FmtT CDC _FmtCtl; /*- Global format-control object ---------*/
- #define FmtSep (_FmtCtl.fsep) /* Word-separators */
- #define FmtGet (_FmtCtl.fget) /* Input function */
- #define FmtVal (_FmtCtl.fval) /* "Valid" function */
- #define FmtFmt (_FmtCtl.ffmt) /* Format string */
- #define FmtPtr (_FmtCtl.fptr) /* Format pointer */
- #define FmtBfr (_FmtCtl.fbfr) /* Buffer string */
- #define FmtOrg (_FmtCtl.forg) /* Screen position */
- #define FmtOrgW (VposW(FmtOrg)) /* Word */
- #define FmtOrgR (VposR(FmtOrg)) /* Row */
- #define FmtOrgC (VposC(FmtOrg)) /* Col */
- #define FmtPos (_FmtCtl.fpos) /* Cursor position */
- #define FmtPosW (VposW(FmtPos)) /* Word */
- #define FmtRow (VposR(FmtPos)) /* Row */
- #define FmtCol (VposC(FmtPos)) /* Col */
- #define FmtLen (_FmtCtl.flen) /* Field length */
- #define FmtOfs (_FmtCtl.fofs) /* Current offset */
- #define FmtExt (_FmtCtl.fext) /* Input-extent */
- #define FmtDot (_FmtCtl.fdot) /* Decimal offset */
- #define FmtErr (_FmtCtl.ferr) /* Error offset */
- #define FmtChr (_FmtCtl.fchr) /* Field-fill character */
- #define FmtMsk (_FmtCtl.fmsk) /* Password mask char */
- #define FmtAtr (_FmtCtl.fatr) /* Field attribute */
- #define FmtSet (_FmtCtl.fset) /* Initial options */
- #define FmtOpt (_FmtCtl.fopt) /* Option state */
- #define FmtLwr (0 != (FmtOpt & FMT_LWR)) /* Lower case */
- #define FmtMix (0 != (FmtOpt & FMT_MIX)) /* Mixed case */
- #define FmtUpr (0 != (FmtOpt & FMT_UPR)) /* Upper case */
- #define FmtPas (0 != (FmtOpt & FMT_PAS)) /* Password mask */
- #define FmtCpy (0 != (FmtOpt & FMT_CPY)) /* Copy to output */
- #define FmtEsc (0 != (FmtOpt & FMT_ESC)) /* [Esc] detect */
- #define FmtRtn (0 != (FmtOpt & FMT_RTN)) /* [Enter] detect */
- #define FmtEof (0 != (FmtOpt & FMT_EOF)) /* End-of-format */
- #define FmtFin (0 != (FmtOpt & FMT_FIN)) /* Done with format */
- #define FmtUse (_FmtCtl.fuse) /* Usage state */
- #define FmtVid (FMT_VID == (FmtUse & FMT_USE)) /* KvGetFmt(), etc */
- #define FmtWin (FMT_WIN == (FmtUse & FMT_USE)) /* KwGetFmt(), etc */
- #define FmtEnt (FMT_ENT == (FmtUse & FMT_USE)) /* EntDsp()/EntGet() */
- #define FmtPut (0 != (FmtUse & FMT_PUT)) /* Output mode */
- #define FmtDec (0 != (FmtUse & FMT_DEC)) /* Decimal field */
- #define FmtCur (0 != (FmtUse & FMT_CUR)) /* Currency field */
- #define FmtInp (0 != (FmtUse & FMT_INP)) /* Input */
- #define FmtChk (0 != (FmtUse & FMT_CHK)) /* Validation */
- #define FmtPnd (FMT_PND == (FmtUse & FMT_PND)) /* Pending */
- #define FmtFlg (_FmtCtl.fflg) /* Transient flags */
- #define FmtMod (_FmtCtl.fflg & FMT_MOD) /* Display mode */
- #define FmtIni (FMT_INI == FmtMod) /* Initial */
- #define FmtChg (FMT_CHG == FmtMod) /* Change */
- #define FmtCnd (FMT_CND == FmtMod) /* Conditional */
- #define FmtDsp (0 != (FmtFlg & FMT_DSP)) /* Re-display field */
- #define FmtDfp (0 != (FmtFlg & FMT_DFP)) /* Decimal format */
- #define FmtIns (0 != (FmtFlg & FMT_INS)) /* Insert mode ON */
- #define FmtWrp (0 != (FmtFlg & FMT_WRP)) /* Field-wrap */
- #define FmtPrv (0 != (FmtFlg & FMT_PRV)) /* Previous */
- #define FmtNxt (0 != (FmtFlg & FMT_NXT)) /* Next */
-
- GBL ChrP CDC _FmtSep; /*- Default word-separator string --------*/
-
- /*------------------------[ Function prototypes ]-----------------------*/
-
- #ifdef __cplusplus /* No mangling, please */
- extern "C" {
- #endif
- /*- Conversion functions -----------------*/
- DblT CTYP cvtcf(ChrP fp); /* TCXL field to double */
- IntT CTYP cvtci(ChrP fp); /* TCXL field to integer */
- VOID CTYP cvtfc(ChrP fp, DblT dv, /* Double to TCXL field */
- IntT fw, IntT nd);
- VOID CTYP cvtic(ChrP fp, IntT iv, /* Integer to TCXL field */
- IntT fs);
- ChrT CTYP touplow(ChrP s, ChrP p, /* Character to initial caps */
- ChrT c);
- /*- Format-string functions --------------*/
- VOID _FmtAttr(AtrT c); /* Assign field-attribute */
- FlgT CTYP _FmtChar(ChrT c); /* Validate input character */
- VOID _FmtFill(ChrT c); /* Assign field-fill char */
- VOID CTYP _FmtFunc(KfvCP f); /* Assign input function */
- KeyT CTYP _FmtGetc(NOARG); /* Get formatted input char */
- FlgT CTYP _FmtGets(ChrP s, ChrP f); /* Get formatted input string */
- IntT CTYP _FmtInit(ChrP f, BytT u); /* Inititalize and verify format */
- VOID _FmtMask(ChrT c); /* Assign password-mask char */
- ChrP CTYP _FmtOpts(ChrP f); /* Toggle format-options */
- VOID CTYP _FmtPuts(NOARG); /* Put formatted output string */
- VOID CTYP _FmtSeps(ChrP s); /* Assign word-separation string */
- FlgT CTYP _FmtVali(NOARG); /* Validate current field */
- /*- Internal field-buffer management -----*/
- VOID CTYP _FmtClr(IntT o); /* Clear from <o> to end */
- VOID CTYP _FmtCpy(ChrP s); /* Copy string <s> */
- VOID CTYP _FmtCur(NOARG); /* Currency-field prefix/suffix */
- VOID CTYP _FmtDec(NOARG); /* Format decimal/currency */
- VOID CTYP _FmtDel(IntT o, IntT n); /* Delete <n> chars at <o> */
- VOID CTYP _FmtIns(IntT o, IntT n); /* Insert <n> blanks at <o> */
- IntT CTYP _FmtPos(IntT o); /* Position buffer/format at <o> */
- FlgT CTYP _FmtSpa(IntT o); /* Test for clear at <o> */
- /*- Implementation macros ----------------*/
- #define _FmtAttr(a) (FmtAtr = (a))
- #define _FmtFill(c) (FmtChr = (c))
- #define _FmtMask(c) (FmtMsk = (c))
- #ifdef __cplusplus
- }
- #endif
- #endif /*- _TCXLfmt_ : End of TCXLfmt.h ------------------------------*/