home *** CD-ROM | disk | FTP | other *** search
- /*=====[ The TesSeRact(TM) CXL User Interface Development System ]======*
- | Copyright (c) 1987-1990, Innovative Data Concepts. All Rights Reserved
- |
- | This Library is part of IDC's TesSeRact Development Tools product
- | line. For information about other IDC products, call 1-215-884-3373.
- *----------------------------------------------------------------------*
- |
- | TCXL Demonstration Program
- |
- | Syntax: TCXLDEMO [-switches]
- |
- | -c = CGA snow elimination
- | -b = BIOS screen writing
- | -m = force monochrome text attributes
- |
- | Compiler command lines:
- |
- | MSC 5.1/6.0 : cl /Ot /AS /Gs tcxldemo.c tcxlmss.lib
- | QC 2.0/2.5 : qcl /Ot /AS /Gs tcxldemo.c tcxlmss.lib
- | TC 2.0/TC++ 1.0 : tcc -ms -d -N- -k- -O -Z tcxldemo.c tcxltcs.lib
- | ZTC 2.1 : ztc -ms -o -b tcxldemo.c tcxlzts.lib
- |
- *----------------------------------------------------------------------*
- | PGS : $Id: tcxldemo.c 5.51 90/10/01 00:00:00 MLM Release Locker: MLM $
- | $Log: tcxldemo.c $
- | Revision 5.51 90/10/01 00:00:00 MLM
- | TCXL 5.51
- |
- *======================================================================*/
- #include <ctype.h>
- #include <dos.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <TCXLdos.h>
- #if(_TCXL_cc_ == 1) /* Turbo C */
- # include <alloc.h>
- #endif
- #if(_TCXL_cc_ == 3) /* MicroSoft C */
- # include <malloc.h>
- # define farmalloc(s) _fmalloc(s)
- # define farfree(p) _ffree(p)
- #endif
- #include <TCXLkey.h>
- #include <TCXLmou.h>
- #include <TCXLstr.h>
- #include <TCXLsel.h>
- #include <TCXLmnu.h>
- #include <TCXLent.h>
- #include <TCXLhlp.h>
- #include <TCXLmem.h>
- #include <_TCXLvid.h>
- #include <TCXLcvt.h>
- #include <TCXLfar.h>
- #include <TCXLprn.h>
- #include <TCXLcod.h>
-
- TYP union Vcel FAR *VcelFP; /* user type */
-
- /*---------------------[ Local Function prototypes ]--------------------*/
-
- VOID CTYP ConfirmQuit(NOARG); /* setup and control */
- VOID CTYP ErrorExit(IntT errnum);
- VOID CTYP Initialize(NOARG);
- VOID CTYP ParseCmdLine(IntT argc, ChrP argv[]);
- VOID CTYP OpenBkgrnd(NOARG);
- VOID CTYP MainMenu(NOARG);
- VOID CTYP MoveBarDn(NOARG);
- VOID CTYP NormalExit(NOARG);
-
- VOID CTYP AddShadow(NOARG); /* general utility */
- VOID CTYP DemoWait(NOARG);
- VcelFP CTYP FarVsave(IntT Atr);
- VOID CTYP FarVrestore(VcelFP FarPtr);
- VOID CTYP HorzLine(IntT wrow, IntT wcol, IntT count, IntT attr);
- VOID CTYP PressAKey(IntT wrow);
- VOID CTYP PressAKey1(IntT wrow, IntT wait);
- VOID CTYP VertLine(IntT wrow, IntT wcol, IntT count, IntT attr);
-
- VOID CTYP MenuDemo(NOARG); /* Menu System demo */
- VOID CTYP ChangeSize(NOARG);
- IntT CTYP CheckDate(ChrP buf);
- VOID CTYP Directory(NOARG);
- VOID CTYP DispSureMsg(NOARG);
- VOID CTYP DisplayTitle(IntT tpos);
- VOID CTYP DoNothing(NOARG);
- VOID CTYP Execute(NOARG);
- VOID CTYP DrawEditor(IntT Lmar, IntT Rmar);
- VOID CTYP OsShell(NOARG);
- VOID CTYP OsShell1(ChrP Cmd);
- VOID CTYP ParseDate(ChrP buf, IntP month, IntP day, IntP year);
- VOID CTYP PopupDemo(NOARG);
- VOID CTYP PreHelp(NOARG);
- VOID CTYP PreMenu1(NOARG);
- VOID CTYP PrePick1(NOARG);
- VOID CTYP QuitWindow(NOARG);
- VOID CTYP RMargin(NOARG);
- VOID CTYP SetupMenu(NOARG);
- VOID CTYP ToggleBlock(NOARG);
- VOID CTYP ToggleYN(NOARG);
- VOID CTYP UpdateClock(NOARG);
- IntT CTYP ValidMarg(ChrP Input);
- IntT CTYP ValidModes(NOARG);
-
- VOID CTYP EntryDemo(NOARG); /* Entry System demo */
- VOID CTYP DisplayDate(NOARG);
- WrdT CTYP GetKey(IntP done);
- VOID CTYP PickCompiler(NOARG);
- VOID CTYP PrintOrder(NOARG);
-
- VOID CTYP SelectDemo(NOARG); /* Selection System demo */
- VOID CTYP YouSelected(ChrP str);
-
- VOID CTYP WinDemo(NOARG); /* Window System demo */
- VOID CTYP ActivDemo(NOARG);
- VOID CTYP AttrDemo(NOARG);
- VOID CTYP BordDemo(NOARG);
- VOID CTYP ChgWindAttr(IntT battr, IntT wattr);
- VOID CTYP CloseWinDemo(NOARG);
- VOID CTYP CopyDemo(NOARG);
- VOID CTYP DragWindow(IntT nsrow, IntT nscol);
- VOID CTYP HideDemo(NOARG);
- VOID CTYP MoveDemo(NOARG);
- VOID CTYP MoveWindow(IntT nsrow, IntT nscol);
- VOID CTYP ResizeDemo(NOARG);
- VOID CTYP ScrollDemo(NOARG);
- VOID CTYP SizeWindow(IntT nerow, IntT necol);
- VOID CTYP TLineDemo(NOARG);
- VOID CTYP TitleDemo(NOARG);
-
- VOID CTYP InputDemo(NOARG); /* Input System demo */
- VOID CTYP RestoreCursor(NOARG);
-
- VOID CTYP StringDemo(NOARG); /* Strings System demo */
- VOID CTYP Dstrmatch(NOARG);
- VOID CTYP Dstrtrim(NOARG);
- VOID CTYP Dstrchg(NOARG);
- VOID CTYP Dstrchksum(NOARG);
- VOID CTYP Dstrdel(NOARG);
- VOID CTYP Dstrinc(NOARG);
- VOID CTYP Dstrsrep(NOARG);
- VOID CTYP Dstrmid (NOARG);
- VOID CTYP Dstrljust(NOARG);
- VOID CTYP Dstrblank(NOARG);
-
- VOID CTYP TcxlInfo(NOARG); /* TCXL info display */
-
- /*-----------------------[ help category numbers ]----------------------*/
-
- #define H_NONE 0
- #define H_GLOBAL 1
- #define H_WINDOWING 2
- #define H_MENUING 3
- #define H_LISTPICK 4
- #define H_STRPICK 5
- #define H_FILEPICK 6
- #define H_DATAENTRY 7
- #define H_EDITKEYS 8
- #define H_DATE 9
- #define H_FIRSTNAME 10
- #define H_INITIAL 11
- #define H_LASTNAME 12
- #define H_CITY 13
- #define H_STATE 14
- #define H_ZIPCODE 15
- #define H_COMPILER 16
- #define H_AMOUNT 17
- #define H_NUMERIC 18
- #define H_PULLDOWN 19
- #define H_FILE 20
- #define H_EDITING 21
- #define H_LOAD 22
- #define H_SAVE 23
- #define H_RENAME 24
- #define H_NEW 25
- #define H_DIRECTORY 26
- #define H_EXECUTE 27
- #define H_OSSHELL 28
- #define H_QUIT 29
- #define H_SCROLL 30
- #define H_CHGATTR 31
- #define H_CHGBORD 32
- #define H_WINTITLE 33
- #define H_RESIZE 34
- #define H_TEXTLINE 35
- #define H_WINMOVE 36
- #define H_WINHIDE 37
- #define H_ACTIVATE 38
- #define H_WINCOPY 39
- #define H_PICKATTR 40
- #define H_INPUT 41
- #define H_STRINGS 42
- #define H_DEFAULTS 43
- #define H_RUN 44
- #define H_OPTIONS 45
-
- /*------------------[ miscellaneous global variables ]------------------*/
-
- VcelFP savescrn; /* ptr to saved DOS screen */
- VposT rc; /* starting cursor position */
- WndT w[10]; /* window array for window demo */
- IntT LeftRow, LeftCol, RightRow, RightCol; /* main menu coords */
- IntT DemoFast; /* window delay flag */
- ChrP UvVal[21]; /* used in menu demo */
- IntT UvMd[21]; /* " " " " */
-
- /*------------------[ fields used in data entry demo ]------------------*/
-
- ChrT date[7], firstname[16], initial[2], lastname[26], address[41],
- city[21], state[3], zipcode[10], phone[11], compiler[16],
- amtenc[8], comments[71], ssan[10], company[41];
-
- /*-----------------------------[ constants ]----------------------------*/
-
- ChrP error_text[] = /* global error message table */
- {
- NULL, /* errnum = 0, no error */
- NULL, /* errnum = 1, windowing error */
- "Usage : TCXLDEMO [-switches]\n\n"
- "\t-c = CGA snow elimination\n"
- "\t-b = BIOS screen writing\n"
- "\t-m = force monochrome text attributes",
- "Out of memory!",
- "Far Heap Exhausted!"
- };
-
- ChrP months[] = /* months table -- used in selection demo */
- {
- "January", "February", "March", "April", "May", "June", "July",
- "August", "September", "October", "November", "December", NULL
- };
-
- ChrP prn_ports[] = /* printer ports table -- used in selection demo*/
- {
- "PRN", "LPT1", "LPT2", "COM1", "COM2", NULL
- };
-
- ChrP compilers[] = /* compiler table -- used in entry demo */
- {
- "Microsoft C", "Quick C", "Turbo C/C++", "Zortech C/C++"
- };
- /* used in strings demo */
- ChrP BefAft = " Before: <%s>\n After: <%s>\n";
-
- TYP struct _info
- {
- IntT row; /* row to display on */
- IntT Atr; /* display attribute */
- ChrP Str; /* string to display */
- } INFO;
-
- #define INFO_CNT 14
-
- INFO TcxlI[INFO_CNT] = /* text displayed in Information screen */
- {
- { 1, WHITE|_RED,
- "The TesSeRact(TM) CXL User Interface Development System" },
- { 2, WHITE|_RED,
- "Copyright (c) 1987-1990, Innovative Data Concepts" },
- { 3, WHITE|_RED,
- "All Rights Reserved" },
- { 5, BLACK|_RED,
- "TCXL is a Full-Featured C Development System that supports" },
- { 6, BLACK|_RED,
- "Microsoft C, QuickC, Turbo C/C++, and Zortech C/C++. There" },
- { 7, BLACK|_RED,
- "are over 410 functions available for use." },
- { 9, WHITE|_RED, "Innovative Data Concepts" },
- { 10, WHITE|_RED, "1657 The Fairways, Suite 101" },
- { 11, WHITE|_RED, "Jenkintown, PA 19046 USA" },
- { 12, WHITE|_RED, "1-215-884-3353 (Support)" },
- { 13, WHITE|_RED, "1-800-926-4551 (Sales)" },
- { 14, WHITE|_RED, "1-215-886-4225 (FAX)" },
- { 15, WHITE|_RED, "CompuServe 76702,1361" },
- { 16, WHITE|_RED, "MCIMAIL 315-5415" },
- };
-
- TYP struct _EntDem
- {
- IntT Prow; /* row for prompt */
- IntT Pcol; /* column for prompt */
- IntT Frow; /* EntFld() row */
- IntT Fcol; /* " col */
- IntT Fflg; /* " flag */
- IntT Ftag; /* " field tag */
- IntT Htag; /* " help tag */
- KeyT Fkey; /* FldKey() hot key */
- IfcpCP Val; /* EntFld() validation func */
- VfvCP FunBef; /* FldFun() before func */
- VfvCP FunAft; /* " after func */
- ChrP Field; /* EntFld() field buffer */
- ChrP FmtStr; /* " format string */
- ChrP Prompt; /* prompt text */
- } ENTDEM;
-
- #define DEMO_CNT 13
-
- ENTDEM DmFld[DEMO_CNT] = /* field data for entry demo */
- {
- { 1, 3, 1, 16, FLD_NUL, 1, H_DATE, Key_A_D, CheckDate, NULL,
- DisplayDate, date, "<01>#'/'<0123>#'/'##", "Date" },
- { 3, 3, 3, 16, FLD_NUL, 2, H_FIRSTNAME, Key_A_F, NULL, NULL, NULL,
- firstname, "MMMMMMMMMMMMMMM", "First Name" },
- { 3, 37, 3, 47, FLD_NUL, 3, H_INITIAL, Key_A_I, NULL, NULL, NULL,
- initial, "U'.'", "Initial" },
- { 5, 3, 5, 16, FLD_NUL, 4, H_LASTNAME, Key_A_L, NULL, NULL, NULL,
- lastname, "MMMMMMMMMMMMMMMMMMMMMMMMM", "Last Name" },
- { 7, 3, 7, 16, FLD_MIX, 5, H_NONE, Key_A_O, NULL, NULL, NULL,
- company, "****************************************", "Company" },
- { 9, 3, 9, 16, FLD_MIX, 6, H_NONE, Key_A_A, NULL, NULL, NULL,
- address, "****************************************", "Address" },
- { 11, 3, 11, 16, FLD_NUL, 7, H_CITY, Key_A_C, NULL, NULL, NULL,
- city, "MMMMMMMMMMMMMMMMMMMM", "City" },
- { 11, 41, 11, 50, FLD_NUL, 8, H_STATE, Key_A_S, NULL, NULL, NULL,
- state, "UU", "State" },
- { 13, 3, 13, 16, FLD_NUL, 9, H_ZIPCODE, Key_A_Z, NULL, NULL, NULL,
- zipcode, "#####'-'%%%%", "Zip Code" },
- { 13, 31, 13, 40, FLD_NWR, 10, H_NONE, Key_A_P, NULL, NULL, NULL,
- phone, "'('###') '###'-'####", "Phone" },
- { 15, 3, 15, 16, FLD_MIX, 11, H_COMPILER, Key_A_O, NULL, PickCompiler,
- NULL, compiler, "***************", "Compiler" },
- { 15, 37, 15, 46, FLD_CUR, 12, H_AMOUNT, Key_A_M, NULL, NULL, NULL,
- amtenc, "$$$$.$$", "Amount" },
- { 17, 3, 17, 16, FLD_NUL, 13, H_NONE, Key_A_N, NULL, NULL, NULL,
- comments, "***********************************\n"
- "***********************************", "Comments" },
- };
-
- ChrP sDstrmatch[] = /* sample source text for strings demo */
- {
- "VOID CTYP Dstrmatch(NOARG)\n",
- "{\n",
- " ChrP strings[] = { \"Hello\", \"There\", \"Computer\", \"World\", "
- "NULL };\n",
- " ChrP str1 = \"xhelpx\";\n",
- " IntT i = 0;\n",
- "\n",
- " while(strings[i] != NULL)\n",
- " {\n",
- " Wputf(\" <%s> vs. <%s> = <%d>\\n\", \n",
- " str1, strings[i], strmatch(str1, strings[i]));\n",
- " i++;\n",
- " }\n",
- "\n",
- " Wputf(\" <%s> best matches <%s>\\n\", str1, strbmatch(str1, string"
- "s));\n",
- "}\n",
- NULL,
- };
-
- ChrP sDstrtrim[] =
- {
- "VOID CTYP Dstrtrim(NOARG)\n",
- "{\n",
- " ChrP str1 = \" Hello, world \";\n",
- " ChrT str2[25];\n",
- "\n",
- " strcpy(str2, str1);\n",
- " strltrim(str2);\n",
- " Wputf(BefAft, str1, str2);\n",
- "\n",
- " strcpy(str2, str1);\n",
- " strrtrim(str2); /* identical to strtrim() */\n",
- " Wputf(BefAft, str1, str2);\n",
- "\n",
- " strcpy(str2, str1);\n",
- " strbtrim(str2);\n",
- " Wputf(BefAft, str1, str2);\n",
- "\n",
- "}\n",
- NULL,
- };
-
- ChrP sDstrchg[] =
- {
- "VOID CTYP Dstrchg(NOARG)\n",
- "{ ChrP str1 = \"HelLo, worLd\";\n",
- " ChrP str2 = \"Hello, world\";\n",
- " ChrP str3 = \"xxxhElLoyyyHElLOzzz\";\n",
- " ChrP str4 = \"xxxhElloyyyhellozzz\";\n",
- " ChrT str5[30];\n",
- "\n",
- " strcpy(str5, str1);\n",
- " strchg(str5, 'l', 'z');\n",
- " Wputf(BefAft, str1, str5);\n",
- "\n",
- " strcpy(str5, str2);\n",
- " strichg(str5, 'l', 'z');\n",
- " Wputf(BefAft, str2, str5);\n",
- "\n",
- " strcpy(str5, str3);\n",
- " strischg(str5, \"HeLlO\", \"goodbye\");\n",
- " Wputf(BefAft, str3, str5);\n",
- "\n",
- " strcpy(str5, str4);\n",
- " strschg(str5,\"hello\",\"goodbye\");\n",
- " Wputf(BefAft, str4, str5);\n",
- "}\n",
- NULL,
- };
-
- ChrP sDstrchksum[] =
- {
- "VOID CTYP Dstrchksum(NOARG)\n",
- "{\n",
- " ChrP str1 = \"Hello, world\";\n",
- "\n",
- " Wputf(\"Checksum is %lu, I-Checksum is %lu\\n\",\n",
- " strchksum(str1), strichksum(str1));\n",
- "}\n",
- NULL,
- };
-
- ChrP sDstrdel[] =
- {
- "VOID CTYP Dstrdel(NOARG)\n",
- "{\n",
- " ChrP str1 = \"XyZHello, xYzworldXyZxYz\";\n",
- " ChrT str2[35];\n",
- " \n",
- " strcpy(str2, str1);\n",
- " strdel(\"xYz\", str2);\n",
- " Wputf(BefAft, str1, str2);\n",
- " strcpy(str2, str1);\n",
- " strdela(\"xYz\", str2);\n",
- " Wputf(BefAft, str1, str2);\n",
- " strcpy(str2, str1);\n",
- " stridel(\"xYz\", str2);\n",
- " Wputf(BefAft, str1, str2);\n",
- " strcpy(str2, str1);\n",
- " stridela(\"xYz\", str2);\n",
- " Wputf(BefAft, str1, str2);\n",
- " strcpy(str1, str2);\n",
- " strins(\"xYz\", str2, 4);\n",
- " Wputf(BefAft, str1, str2);\n",
- "}\n",
- NULL,
- };
-
- ChrP sDstrinc[] =
- {
- "VOID CTYP Dstrinc(NOARG)\n",
- "{\n",
- " ChrP str1 = \"Hello1HELLO2HeLlO3hElLo\";\n",
- " ChrP str2 = \"hello\";\n",
- "\n",
- " Wputf(\"str2 is %sincluded in str1\\n\",\n",
- " ( (strinc(str2,str1) == NULL) ? \n",
- " \"not \" : \"\"));\n",
- "\n",
- " Wputf(\"str2 is %sincluded in str1\\n\",\n",
- " ( (striinc(str2,str1) == NULL) ? \n",
- " \"not \" : \"\"));\n",
- "\n",
- " Wputf(\"There are %d occurrences of '%c' in str1\\n\",\n",
- " strocc(str1, 'l'), 'l');\n",
- " Wputf(\"There are %d occurrences of '%c' in str1\\n\",\n",
- " striocc(str1, 'l'), 'l');\n",
- "\n",
- " Wputf(\"str2 occurs in str1 %d times\\n\",\n",
- " strsocc(str2, str1));\n",
- " Wputf(\"str2 occurs in str1 %d times\\n\",\n",
- " strisocc(str2, str1));\n",
- "}\n",
- NULL,
- };
-
- ChrP sDstrsrep[] =
- {
- "VOID CTYP Dstrsrep(NOARG)\n",
- "{\n",
- " ChrP str1 = \"This is a big string\";\n",
- " ChrT str2[25];\n",
- "\n",
- " strcpy(str2, str1);\n",
- " strsrep(str2, \"str\", \"th\");\n",
- " Wputf(BefAft, str1, str2);\n",
- "\n",
- " strcpy(str2, str1);\n",
- " strisrep(str2, \"str\", \"th\");\n",
- " Wputf(BefAft, str1, str2);\n",
- "\n",
- "}\n",
- NULL,
- };
-
- ChrP sDstrmid[] =
- {
- "VOID CTYP Dstrmid(NOARG)\n",
- "{\n",
- " ChrP p;\n",
- " ChrP str = \"Hello, world\";\n",
- "\n",
- " Wputf(\" %s\\n\", p = strmid(str, 5, 5));\n",
- " free(p);\n",
- "\n",
- " Wputf(\" %s\\n\", p = strleft(str, 5));\n",
- " free(p);\n",
- "\n",
- " Wputf(\" %s\\n\", p = strright(str, 5));\n",
- " free(p);\n",
- " \n",
- "}\n",
- NULL,
- };
-
- ChrP sDstrljust[] =
- {
- "VOID CTYP Dstrljust(NOARG)\n",
- "{ ChrP str1 = \" Hello, world \";\n",
- " ChrP str2 = \"Hello, world\";\n",
- " ChrT str3[25];\n",
- " strcpy(str3, str1);\n",
- " strljust(str3);\n",
- " Wputf(BefAft, str1, str3);\n",
- " strcpy(str3, str1);\n",
- " strrjust(str3);\n",
- " Wputf(BefAft, str1, str3);\n",
- " strcpy(str3, str2);\n",
- " strrol(str3, 3);\n",
- " Wputf(BefAft, str2, str3);\n",
- " strcpy(str3, str2);\n",
- " strror(str3, 3);\n",
- " Wputf(BefAft, str2, str3);\n",
- " strcpy(str3, str2);\n",
- " strshl(str3, 3);\n",
- " Wputf(BefAft, str2, str3);\n",
- " strcpy(str3, str2);\n",
- " strshr(str3, 3);\n",
- " Wputf(BefAft, str2, str3);\n",
- "}\n",
- NULL,
- };
-
- ChrP sDstrblank[] =
- {
- "VOID CTYP Dstrblank(NOARG)\n",
- "{ ChrP str1 = \" Hello \";\n",
- " ChrP str2 = \" \\n \\t \\r \";\n",
- " ChrP str3 = \"Hello, world\";\n",
- " ChrP str4 = \"hElLo, wOrLd\";\n",
- " ChrT str5[20];\n",
- " Wputf(\" str1 is %sblank\\n\", strblank(str1) ? \"\" : \"not \");\n",
- " Wputf(\" str2 is %sblank\\n\", strblank(str2) ? \"\" : \"not \");\n",
- " Wputf(\" Before: <%s>\\n\", str3);\n",
- " strcode(str3, \"34&*#Mdq\");\n",
- " Wputf(\" Encrypted: <%s>\\n\", str3);\n",
- " strcode(str3, \"34&*#Mdq\");\n",
- " Wputf(\" Decrypted: <%s>\\n\", str3);\n",
- " strcpy(str5, str3);\n",
- " Wputf(\" Before: <%s>\\n\", str5);\n",
- " strsetsz(str5, 20);\n",
- " Wputf(\" Len=20: <%s>\\n\", str5);\n",
- " strsetsz(str5, 5);\n",
- " Wputf(\" Len=5: <%s>\\n\", str5);\n",
- " strcpy(str5, str4);\n",
- " struplow(str5);\n",
- " Wputf(BefAft, str4, str5);\n",
- "}\n",
- NULL,
- };
-
- ChrP Dstrings[] = /* more text for strings demo */
- { "Hello", "There", "Computer", "World", NULL };
-
-
- ChrP Sdemo1[] = /* strings demo menu titles */
- {
- "Trimming", "Changing", "Checksum", "Delete/Insert",
- "Inclusion", "Replacement", "Substrings", "Justification",
- "Matching", "Miscellaneous", "Exit", NULL
- };
-
- TYP struct _StrDmo
- {
- ChrP *Dsp; /* sample source text array */
- VfvCP Fun; /* demo function */
- IntT Wrws; /* coords for result window */
- IntT Wcls; /* " " " " */
- } STRDMO;
-
- STRDMO Sdemo[] = /* string demo control */
- {
- { sDstrtrim, Dstrtrim, 9, 35 },
- { sDstrchg, Dstrchg, 11, 36 },
- { sDstrchksum, Dstrchksum, 5, 19 },
- { sDstrdel, Dstrdel, 13, 37 },
- { sDstrinc, Dstrinc, 11, 32 },
- { sDstrsrep, Dstrsrep, 7, 33 },
- { sDstrmid, Dstrmid, 7, 15 },
- { sDstrljust, Dstrljust, 15, 35 },
- { sDstrmatch, Dstrmatch, 8, 32 },
- { sDstrblank, Dstrblank, 13, 34 },
- };
-
- ChrP LinArr[] = /* screen lines table -- used by menu demo */
- {
- "25 Lines", "43 Lines", "50 Lines", NULL
- };
-
- ChrP UvArr[] = /* Ultravision screen modes table -- used by menu demo */
- {
- "80x25", "80x43 EGA, 80x50 VGA",
- "80x34 EGA, 80x36 VGA", "80x60 EGA, 80x63 VGA",
- "94x25", "94x43 EGA, 94x50 VGA",
- "94x36", "94x63",
- "108x25", "108x43 EGA, 108x50 VGA",
- "108x34 EGA, 108x36 VGA", "108x60 EGA, 108x63 VGA",
- "120x25", "120x43 EGA, 120x50 VGA",
- "120x36", "120x63", "132x25", "132x44, 132x50 SuperVGA",
- "132x36", "132x60", NULL
- };
-
-
- IntT UvMode[] = /* Ultravision mode numbers */
- {
- 0x11, 0x12, 0x13, 0x14, 0x19, 0x1A, 0x1B, 0x1C,
- 0x21, 0x22, 0x23, 0x24, 0x31, 0x32, 0x39, 0x3A,
- 0x33, 0x34, 0x3B, 0x3C, 0
- };
-
- /* used by menu demo */
- LCL ChrT Rmargin[] = "Right margin 72";
- LCL ChrT Lmargin[] = "Left margin 0";
-
- TYP struct _DoItm
- {
- IntT wr; /* MnuItm() row */
- IntT wc; /* " column */
- ChrP ps; /* " prompt */
- IntT sc; /* " selection character */
- TagT id; /* " id tag */
- IntT fm; /* " feature mask */
- VfvCP sf; /* " selection function */
- WrdT hk; /* " hot key */
- TagT he; /* " help key */
- } DOITM;
-
- DOITM FileMnu[] = /* menu demo -- "File" pulldown menu */
- {
- { 0, 0, "Load", 'L', 20, 0, DoNothing, 0, H_LOAD },
- { 1, 0, "Save", 'S', 21, 0, DoNothing, 0, H_SAVE },
- { 2, 0, "Rename", 'R', 22, 0, DoNothing, 0, H_RENAME },
- { 3, 0, "New", 'N', 23, 0, DoNothing, 0, H_NEW },
- { 4, 0, "Directory F5", 'D', 24, 0, Directory, Key_F5, H_DIRECTORY },
- { 5, 0, "Execute F6", 'E', 25, 0, Execute, Key_F6, H_EXECUTE },
- { 6, 0, "OS Shell F7", 'O', 26, ITM_BEF, OsShell, Key_F7, H_OSSHELL },
- { 7, 0, "Quit", 'Q', 27, ITM_ALL, NULL, 0, H_QUIT },
- };
-
- DOITM EditMnu[] = /* menu demo -- "Edit" pulldown menu */
- {
- { 0, 0, "Cut", 'C', 29, 0, DoNothing, 0, H_NONE },
- { 1, 0, "Paste", 'P', 30, ITM_NSL, DoNothing, 0, H_NONE },
- { 2, 0, "cOpy", 'O', 31, ITM_NSL, DoNothing, 0, H_NONE },
- { 3, 0, "block Begin", 'B', 32, 0, ToggleBlock, 0, H_NONE },
- { 4, 0, "block End", 'E', 33, ITM_NSL, ToggleBlock, 0, H_NONE },
- { 5, 0, "Insert line", 'I', 34, 0, DoNothing, 0, H_NONE },
- { 6, 0, "Delete line", 'D', 35, 0, DoNothing, 0, H_NONE },
- };
-
- DOITM DefMnu[] = /* menu demo -- "Defaults" pulldown menu */
- {
- { 0, 0, Lmargin, 'L', 37, ITM_ALL, RMargin, 0, H_NONE },
- { 1, 0, Rmargin, 'R', 38, ITM_ALL, RMargin, 0, H_NONE },
- { 2, 0, "Tab width 4", 'T', 39, 0, DoNothing, 0, H_NONE },
- { 4, 0, "tab eXpansion yes", 'X', 40, 0, ToggleYN, 0, H_NONE },
- { 5, 0, "Insert mode yes", 'I', 41, 0, ToggleYN, 0, H_NONE },
- { 6, 0, "iNdent mode yes", 'N', 42, 0, ToggleYN, 0, H_NONE },
- { 7, 0, "Word wrap mode no", 'W', 43, 0, ToggleYN, 0, H_NONE },
- { 9, 0, "Save defaults", 'S', 44, 0, DoNothing, 0, H_NONE },
- };
-
- DOITM OptMnu[] = /* menu demo -- "Options" pulldown menu */
- {
- { 0, 0, "screen siZe", 'Z', 47, ITM_ALL, ChangeSize, 0, H_NONE},
- { 1, 0, "Backup files yes", 'B', 48, 0, ToggleYN, 0, H_NONE },
- { 2, 0, "bOxed display no", 'O', 49, 0, ToggleYN, 0, H_NONE },
- { 3, 0, "Load options", 'L', 50, 0, DoNothing, 0, H_NONE },
- { 4, 0, "Save options", 'S', 51, 0, DoNothing, 0, H_NONE },
- };
-
- DOITM MainMnu[] = /* Main Menu Selection Itemns */
- {
- { 0, 0, "Menu System", 'M', 1, 0, MenuDemo, 0, H_MENUING },
- { 1, 0, "Entry System", 'E', 2, 0, EntryDemo, 0, H_DATAENTRY },
- { 2, 0, "Selection System", 'S', 3, 0, SelectDemo, 0, H_LISTPICK },
- { 3, 0, "Window System", 'W', 4, 0, WinDemo, 0, H_WINDOWING },
- { 4, 0, "Input System", 'I', 5, 0, InputDemo, 0, H_INPUT },
- { 5, 0, "Strings System", 't', 6, 0, StringDemo, 0, H_STRINGS },
- { 6, 0, "Information", 'n', 7, 0, TcxlInfo, 0, H_NONE },
- { 7, 0, "Exit demo", 'x', 8, 0, NULL, 0, H_NONE },
- };
-
- IntT Siz1[] = /* used in window demo */
- { 19, 19, 24, 24, 24, 19 };
- IntT Siz2[] =
- { 60, 75, 75, 60, 45, 45 };
- IntT Siz3[] =
- { 0, 10, 6, 1, 11, 2 };
- IntT Siz4[] =
- { 0, 4, 19, 13, 35, 39 };
-
- ChrP Wdm = /* used in window demo */
- "Now that you've had a chance to see the various features "
- "of the TCXL Window System, we'd like to give you a chance "
- "to see the SAME demonstation again . . . this "
- "time, without the built-in delays. Press any key to "
- "start this one running. Watch out!";
-
- ChrP Edemo[] = { /* used in Editor demo */
- "This is a sample editor interface to demonstrate how TCXL's menuing ",
- "functions can be used to create a pull-down menu system. Use the ",
- "arrow keys to move the selection bar around and use the [Esc] key to ",
- "back up to the previous menu. Pressing [F1] will bring up ",
- "context-sensitive help. Select [Q]uit from any menu to exit the ",
- "Menu Demonstration. Be sure to try some of the menu options in ",
- "the pull-down menus. In particular, you might try to change ",
- "the left and right margins under the <D>efault option, or to ",
- "adjust the screen size if you have an EGA/VGA, or use Ultravision.",
- NULL
- };
-
- /*------------------------[ Program entry point ]-----------------------*/
-
- IntT CDC main(IntT argc, ChrP argv[])
- {
- Initialize();
- ParseCmdLine(argc, argv);
- OpenBkgrnd();
- MainMenu();
- NormalExit();
- return(0);
- }
-
- /*----------------------------------------------------------------------*/
- /* Initializes TCXL's video, mouse, keyboard, and help systems. */
-
- VOID CTYP Initialize(NOARG)
- {
- TcxlInit();
- KextOff(); /* no extended key BIOS */
- VcurGet(rc);
- savescrn = FarVsave(LGREY|_BLACK);
- if(MouInit)
- MShome();
- /* attach [Alt-X] to the ConfirmQuit() function */
- KbndSet(Key_A_X, ConfirmQuit, 0);
-
- /* initialize help system, help key = [F1] */
- HlpDef("TCXLDEMO.HLP", Key_F1, YELLOW|_RED, LRED|_RED, WHITE|_RED,
- RED|_LGREY, PreHelp);
-
- }
-
- /*----------------------------------------------------------------------*/
- /* Parses the command line for valid invocation switches. If any valid */
- /* switches are found, the appropriate video variable will be set. If */
- /* any invalid parameters are found, a syntax message is displayed. */
-
- VOID CTYP ParseCmdLine(IntT ac, ChrP av[])
- {
- REG IntT i, j;
- ChrP p;
-
- for(i = 1; i < ac; i++)
- {
- p = av[i];
- if(*p == '-' || *p == '/')
- {
- for(j = 1; *(p + j); j++)
- {
- switch(tolower(*(p + j)))
- {
- case 'c':
- VidParm(VP_CGA);
- break;
-
- case 'b':
- VidParm(VP_BIO);
- break;
-
- case 'm':
- VidParm(VP_MON);
- break;
-
- default:
- ErrorExit(2);
- }
- }
- }
- else
- ErrorExit(2);
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Draws main background window, program title window and system */
- /* information window in preparation for main menu. */
-
- VOID CTYP OpenBkgrnd(NOARG)
- {
- ChrT str[90];
-
- if(!Wopen(0, 0, VidDep - 2, VidWid - 1, 5, 0, LGREEN|_GREEN))
- ErrorExit(1);
-
- if(!WpopUp(CNT_HOR, VidDep - 8, 0, VidDep - 3, 60, 0, LGREY|_RED,
- LGREY|_RED))
- ErrorExit(1);
-
- AddShadow();
- sprintf(str, "DPMI Status: %s VCPI Status: %s\n",
- (MemDPMI ? "INSTALLED" : "NOT INSTALLED"),
- (MemVCPI ? "INSTALLED" : "NOT INSTALLED"));
- WputCen(str);
-
- sprintf(str, "Total EMS: %dK Free EMS: %dK\n",
- MemEtot * 16, MemEfre * 16);
- WputCen(str);
-
- sprintf(str, "Free XMS: %dK HMA is %s\n", MemXtot,
- (MemHfre ? "AVAILABLE" : "IN USE"));
- WputCen(str);
-
- sprintf(str, "Ultravision is %s Screen Size is %dx%d",
- (TcxlUv ? "INSTALLED" : "NOT INSTALLED"), VidWid, VidDep);
- WputCen(str);
-
- WsetFil('\260');
- Wopen(VidDep - 1, 0, VidDep - 1, VidWid - 1, 5, 0, LGREY|_RED);
- Wprts(0, 1, LGREY|_RED, "[F1]=Help");
- WprtCen(0, LGREY|_RED, "Select demonstration to view.");
- Wprtrj(0, VidWid - 2, LGREY|_RED, "[Alt-X]=Quit");
- WsetFil(' ');
- if(!WpopUp(CNT_HOR, 0, 12, 4, 67, 0, LRED|_MAGENTA, LRED|_MAGENTA))
- ErrorExit(1);
-
- AddShadow();
- WprtCen(0, WHITE|_MAGENTA,
- "Welcome to the TCXL Demonstration Program!");
- WprtCen(2, LCYAN|_MAGENTA,
- "Copyright (c) 1987-1990, Innovative Data Concepts");
- }
-
- /*----------------------------------------------------------------------*/
- /* Set up and run the main menu, from which all else happens. But first,*/
- /* push global help category onto help stack, so when [F1] is pressed */
- /* while selection bar is on an item without help, the global help */
- /* category will be used. */
-
- VOID CTYP MainMenu(NOARG)
- {
- IntT i;
-
- LeftRow = ((VidDep - 1) / 2) - 6; /* set up display coordinates */
- RightRow = LeftRow + 9;
- LeftCol = ((VidWid - 1) / 2) - 9;
- RightCol = LeftCol + 19;
-
- HlpPush(H_GLOBAL); /* push global help catagory */
-
- MnuBeg(LeftRow, LeftCol, RightRow, /* define the main menu */
- RightCol, 0, LBLUE|_BLUE, LBLUE|_BLUE, PreMenu1);
-
- for(i = 0; i < 8; i++)
- MnuItm(MainMnu[i].wr, MainMnu[i].wc, MainMnu[i].ps,
- MainMnu[i].sc, MainMnu[i].id, MainMnu[i].fm, MainMnu[i].sf,
- MainMnu[i].hk, MainMnu[i].he);
-
- MnuEnd(1, MNU_VER, 19, 1, LCYAN|_BLUE, WHITE|_BLUE, 0, BLUE|_LGREY);
-
- if(MnuShow() == -1) /* process the menu */
- if(TcxlErr > W_ESCPRESS)
- ErrorExit(1);
-
- HlpDrop(); /* pop help category off stack */
- }
-
- /*----------------------------------------------------------------------*/
- /* The menu demo, a simulated editor interface. */
-
- VOID CTYP MenuDemo(NOARG)
- {
- IntT s, st, i;
- IntT Lines;
- VcelFP VidArea;
-
- KbndIdle(UpdateClock); /* start clock display */
- HlpPush(H_PULLDOWN); /* push help category */
-
- if(VuvAct) /* draw editor display */
- Lines = _VuvGet();
- else
- Lines = VidDep;
- cvtic(&Rmargin[16], VidWid - 8, 3);
- VidArea = FarVsave(LGREY|_BLACK);
- st = VcurHid(-1);
- redraw:
- if(atoi(&Rmargin[16]) > VidWid - 3)
- cvtic(&Rmargin[16], VidWid - 8, 3);
- DrawEditor(atoi(&Lmargin[16]), atoi(&Rmargin[16]));
-
- MnuBeg(1, 1, 1, VidWid - 2, 5, /* start the menu */
- CYAN, CYAN|_BLUE, NULL);
-
- MnuItm(0, 2, "File", 'F', 19, /* define first item, */
- ITM_PUL, NULL, 0, H_FILE); /* a pulldown menu */
- MnuBeg(2, 1, 11, 17, 0, LGREY|_BLUE, _BLUE, NULL);
- for(i = 0; i < 8; i++)
- MnuItm(FileMnu[i].wr, FileMnu[i].wc, FileMnu[i].ps,
- FileMnu[i].sc, FileMnu[i].id, FileMnu[i].fm, FileMnu[i].sf,
- FileMnu[i].hk, FileMnu[i].he);
- ItmFun(QuitWindow, QuitWindow);
- MnuEnd(20, MNU_PUL|MNU_SAV, 15, 1, YELLOW|_BLUE, LCYAN|_BLUE, 0,
- YELLOW|_MAGENTA);
-
- MnuItm(0, 15, "Editing", 'E', 28, /* second item, also a pulldown */
- ITM_PUL, NULL, 0, H_EDITING);
- MnuBeg(2, 14, 10, 28, 0, LGREY|_BLUE, _BLUE, NULL);
- for(i = 0; i < 7; i++)
- MnuItm(EditMnu[i].wr, EditMnu[i].wc, EditMnu[i].ps,
- EditMnu[i].sc, EditMnu[i].id, EditMnu[i].fm, EditMnu[i].sf,
- EditMnu[i].hk, EditMnu[i].he);
- MnuEnd(29, MNU_PUL|MNU_SAV, 13, 1, YELLOW|_BLUE, LCYAN|_BLUE,
- CYAN|_BLUE, YELLOW|_MAGENTA);
-
- MnuItm(0, 31, "Defaults", 'D', 36, /* third item, also a pulldown */
- ITM_PUL, NULL, 0, H_DEFAULTS);
- MnuBeg(2, 30, 13, 52, 0, LGREY|_BLUE, _BLUE, SetupMenu);
- for(i = 0; i < 8; i++)
- MnuItm(DefMnu[i].wr, DefMnu[i].wc, DefMnu[i].ps, DefMnu[i].sc,
- DefMnu[i].id, DefMnu[i].fm, DefMnu[i].sf, DefMnu[i].hk,
- DefMnu[i].he);
- MnuEnd(37, MNU_PUL|MNU_SAV, 21, 1, YELLOW|_BLUE, LCYAN|_BLUE, 0,
- YELLOW|_MAGENTA);
-
- MnuItm(0, 47, "Run", 'R', 45, 0, /* fourth item, a popup menu */
- PopupDemo, 0, H_RUN);
-
- MnuItm(0, 59, "Options", 'O', 46, /* fifth item, another pulldown */
- ITM_PUL, NULL, 0, H_OPTIONS);
- MnuBeg(2, 56, 8, 77, 0, LGREY|_BLUE, _BLUE, NULL);
- for(i = 0; i < 5; i++)
- MnuItm(OptMnu[i].wr, OptMnu[i].wc, OptMnu[i].ps, OptMnu[i].sc,
- OptMnu[i].id, OptMnu[i].fm, OptMnu[i].sf, OptMnu[i].hk,
- OptMnu[i].he);
- MnuEnd(47, MNU_PUL|MNU_SAV, 20, 1, YELLOW|_BLUE, LCYAN|_BLUE, 0,
- YELLOW|_MAGENTA);
-
- MnuItm(0, 73, "Quit", 'Q', 52, /* fifth item, a pulldown with */
- ITM_PUL, NULL, 0, H_NONE); /* an automatic popup window */
- ItmFun(QuitWindow, QuitWindow);
- MnuBeg(2, 60, 7, 78, 0, LGREY|_BLUE, _BLUE, DispSureMsg);
- MnuItm(2, 0, "No", 'N', 53, ITM_AFT, NULL, 0, H_NONE);
- MnuItm(3, 0, "Yes", 'Y', 54, ITM_ALL, NULL, 0, H_NONE);
- MnuEnd(53, MNU_PUL, 17, 7, YELLOW|_BLUE, LCYAN|_BLUE, WHITE|_BLUE,
- YELLOW|_MAGENTA);
-
- MnuEnd(19, MNU_HOR, 0, 0, /* define the end of the menu */
- YELLOW|_BLUE, LCYAN|_BLUE, 0, YELLOW|_MAGENTA);
-
- s = MnuShow(); /* process the menu */
- if(s == -1 && TcxlErr > W_ESCPRESS)
- ErrorExit(1);
-
- Wclose();
- Wclose();
- if((s == 37) || (s == 38) || (s == 47) || (s >= 100))
- goto redraw;
- if(VuvAct)
- {
- if(Lines != _VuvGet())
- _VuvSet(Lines);
- }
- else
- {
- if(Lines != VidDep)
- VsetLin(Lines);
- }
- VcurHid(st);
- FarVrestore(VidArea);
- KbndIdle(NULL);
- HlpDrop();
- MoveBarDn();
- }
-
- /*----------------------------------------------------------------------*/
- /* Entry demo. A form consisting of a group of entry fields is defined.*/
-
- VOID CTYP EntryDemo(NOARG)
- {
- REG IntT c, m = 0, p = 0, i;
- KeyT k;
- VcelFP s;
-
- s = FarVsave(LGREY|_BLUE);
-
- if(!WpopUp(CNT_CNT, 2, 8, 23, 70, 1, LCYAN|_BLUE, LCYAN|_BLUE))
- ErrorExit(1);
-
- AddShadow();
- Wtitle("[ TCXL Order Form ]", TTL_LFT, LCYAN|_BLUE);
- Wmessage("[ $50 Plus $3 S&H ]", BRD_TOP, 42, LCYAN|_BLUE);
- Wmessage(" [F10]=Finished ", BRD_BOT, 5, LCYAN|_BLUE);
- Wmessage(" [F9]=Today ", BRD_BOT, 25, LCYAN|_BLUE);
- Wmessage(" [Esc]=Abort ", BRD_BOT, 45, LCYAN|_BLUE);
- HlpPush(H_EDITKEYS);
- do
- {
- EntDef(BLUE|_LGREY, WHITE|_LGREY);
- for(i = 0; i < DEMO_CNT; i++)
- {
- Wprts(DmFld[i].Prow, DmFld[i].Pcol, WHITE|_BLUE,
- DmFld[i].Prompt);
- EntFld(DmFld[i].Frow, DmFld[i].Fcol, DmFld[i].Field,
- DmFld[i].FmtStr, DmFld[i].Fflg, DmFld[i].Ftag, m,
- DmFld[i].Val, DmFld[i].Htag);
- FldFun(DmFld[i].FunBef, DmFld[i].FunAft);
- FldKey(DmFld[i].Fkey);
- }
- EntKey(GetKey, &k); /* alternate kbd get function */
-
- if(EntShow()) /* Mark end of form and process it. If */
- break; /* [Esc] was pressed, then don't bother */
- /* with the confirmation message. */
- if(!WpopUp(CNT_CNT, 9, 20, 13, 64, 0, WHITE|_CYAN, WHITE|_CYAN))
- ErrorExit(1);
-
-
-
- if(k != Key_F10) /* Test to see if [F10] was pressed. If */
- { /* so, don't display confirmation message.*/
- AddShadow();
- Wputc('\n'); /* Display confirmation message */
- WputCen("Is this information correct? \033A\076Y\b");
- KeyClear();
- c = KwGetYn('Y');
- }
- else
- c = 'Y';
- if(c == 'Y')
- {
- Wclear();
- Wputc('\n');
- WputCen("Would you like your order printed? \033A\076Y\b");
- KeyClear();
- p = KwGetYn('Y');
- }
- Wclose();
- if(p == 'Y')
- PrintOrder();
- m = 1; /* Change fld mode to "update" */
- } while(c != 'Y');
- HlpDrop();
- Wclose();
- FarVrestore(s);
- VcurHid(0);
- MoveBarDn();
- }
-
- /*----------------------------------------------------------------------*/
- /* Selection demo. Demonstrates the string picker, the file picker, */
- /* and the in-place string selector functions. */
-
- VOID CTYP SelectDemo(NOARG)
- {
- REG VcelFP s;
-
- s = FarVsave(LGREY|_BLUE);
- MSpush(MOU_FULL);
-
- if(!WpopUp(CNT_CNT, 5, 11, 17, 68, 3, LMAGENTA|_RED, LRED|_MAGENTA))
- ErrorExit(1);
-
- AddShadow();
- Wputf("\033R\001\033C\003Select a month =>\033R\001\033C\003");
- HlpSet(H_STRPICK);
- YouSelected(months[SelStr(LeftRow, 32, LeftRow + 5, -1, 0,
- LGREEN|_RED, LCYAN|_RED, RED|_LGREY, months, 0, PrePick1)]);
-
- Wputf("\033R\003\033C\003Now, select a file.\033R\003\033C\003");
- HlpSet(H_FILEPICK);
- YouSelected(SelFile(LeftRow, LeftCol - 18, LeftRow + 10,
- LeftCol + 39, 0, LCYAN|_RED, LGREY|_RED, RED|_LGREY, 1, "*.*",
- AddShadow));
-
- Wputf("\033R\005\033C\003Select a printer port:\033R\005\033C\003");
- VcurHid(1);
- YouSelected(prn_ports[SelTxt(5, 27, LMAGENTA|_MAGENTA, prn_ports, 0)]);
- VcurHid(0);
-
- HlpSet(H_PICKATTR);
- Wputf("\033R\007\033C\003Select a text attribute:\033R\007\033C\003");
- VcurHid(1);
- YouSelected(VatrTxt(SelAttr(LeftRow - 6, LeftCol - 21, 0, 0,
- TRUE, AddShadow)));
- VcurHid(0);
- Wclose();
- MSpop();
- FarVrestore(s);
- MoveBarDn();
- }
-
- /*----------------------------------------------------------------------*/
- /* Window Demo. */
-
- VOID CTYP WinDemo(NOARG)
- {
- VcelFP s;
-
- s = FarVsave(LGREY|_BLUE);
- MSpush(MOU_FULL);
- for(DemoFast = 0; DemoFast < 2; DemoFast++)
- {
- ScrollDemo();
- AttrDemo();
- BordDemo();
- TitleDemo();
- ResizeDemo();
- TLineDemo();
- MoveDemo();
- HideDemo();
- ActivDemo();
- CopyDemo();
- CloseWinDemo();
- if(!DemoFast)
- {
- WpopUp(CNT_CNT, 0, 0, 9, 35, 0, WHITE|_CYAN, YELLOW|_RED);
- Wputsw(Wdm);
- KeyWait();
- }
- else
- {
- WpopUp(CNT_CNT, 0, 0, 2, 25, 0, WHITE|_CYAN, YELLOW|_RED);
- WputCen("Fast enough for you?");
- KeyTime(54);
- }
- Wclose();
- }
- DemoFast = 0;
- MSpop();
- FarVrestore(s);
- KeyClear();
- MoveBarDn();
- }
-
- /*----------------------------------------------------------------------*/
- /* Input demo. */
-
- VOID CTYP InputDemo(NOARG)
- {
- VcelFP s;
- IntT st;
-
- s = FarVsave(LGREY|_BLUE);
- st = VcurHid(-1);
- if(!WpopUp(CNT_CNT, 5, 21, 15, 58, 3, LGREEN|_MAGENTA,
- LGREEN|_MAGENTA))
- ErrorExit(1);
-
- Wtitle("[ Single-Line Input ]", TTL_CNT, LGREEN|_MAGENTA);
- HlpSet(H_DATAENTRY);
- AddShadow();
- RestoreCursor();
- if(KwGetFmt(phone, "'\n\n Phone Number? "
- "'!R--!'('!+!###!-!') '!+!###!-!'-'!+!####"))
- ConfirmQuit();
- RestoreCursor();
-
- if(KwGetFmt(ssan, "'\n\n Soc Sec Number? "
- "'!R-!<01234567>##!-!'-'!+!##!-!'-'!+!####"))
- ConfirmQuit();
- RestoreCursor();
-
- if(KwGetFmt(date, "\"\n\n Today's Date? "
- "\"!R-!<01>#!-!'/'!+!<0123>#!-!'/'!+!'19'##"))
- ConfirmQuit();
- Wclose();
- VcurHid(st);
- FarVrestore(s);
- KeyClear();
- MoveBarDn();
- }
-
- /*----------------------------------------------------------------------*/
- /* Strings demo. */
-
- VOID CTYP StringDemo(NOARG)
- {
- VcelFP s;
- IntT st, Sel = 0, i;
-
- s = FarVsave(LGREY|_BLACK);
- MSpush(MOU_FULL);
- st = VcurHid(-1);
- LeftRow = ((VidDep - 1) / 2) - 6;
- RightRow = LeftRow + 12;
- LeftCol = ((VidWid - 1) / 2) - 9;
- RightCol = LeftCol + 16;
-
- for(;;)
- {
- Sel = SelStr(LeftRow, LeftCol, RightRow, RightCol, 1, LCYAN|_BLUE,
- LCYAN|_BLUE, YELLOW|_LGREY, Sdemo1, Sel, NULL);
- if((Sel >= 10) || (Sel < 0))
- break;
- if(!WpopUp(CNT_CNT, 0, 0, 24, VidWid - 1, 1, LCYAN|_BLUE,
- LCYAN|_BLUE))
- ErrorExit(1);
-
- Wtitle(Sdemo1[Sel], TTL_CNT, LCYAN|_BLUE);
- Wmessage(" [Press a Key to Continue ] ", BRD_BOT,
- ((VidWid - 1) / 2) - 15, LCYAN|_BLUE);
- i = 0;
- while(Sdemo[Sel].Dsp[i] != NULL)
- Wputs(Sdemo[Sel].Dsp[i++]);
- if(!Wopen(((VidDep - 25) / 2) + 1, VidWid - 1 - Sdemo[Sel].Wcls - 1,
- ((VidDep - 25) / 2) + 1 + Sdemo[Sel].Wrws, VidWid - 2, 0,
- WHITE|_RED, WHITE|_BLUE))
- ErrorExit(1);
- (*Sdemo[Sel].Fun)();
- PressAKey1(Sdemo[Sel].Wrws - 2, -1);
- Wclose();
- Wclose();
- Sel++;
- }
- VcurHid(st);
- MSpop();
- FarVrestore(s);
- KeyClear();
- MoveBarDn();
- }
-
- /*----------------------------------------------------------------------*/
- /* Display info on TCXL and IDC */
-
- VOID CTYP TcxlInfo(NOARG)
- {
- IntT i;
-
- if(!WpopUp(CNT_CNT, 3, 6, 21, 72, 0, WHITE|_RED, LMAGENTA|_RED))
- ErrorExit(1);
-
- AddShadow();
-
- for(i = 0; i < INFO_CNT; i++)
- WprtCen(TcxlI[i].row, TcxlI[i].Atr, TcxlI[i].Str);
- KeyTime(200);
- Wclose();
- MoveBarDn();
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP ActivDemo(NOARG)
- {
- REG IntT i;
-
- if(0 == (w[5] = Wopen(9, 44, 22, 78, 1, LCYAN|_CYAN, WHITE|_CYAN)))
- ErrorExit(1);
- HlpSet(H_ACTIVATE);
- Wputs("\n TCXL's Wactiv() is used to"
- "\n activate a window, making"
- "\n it available for windowing"
- "\n operations.");
- PressAKey(6);
-
- for(i = 0; i < 6; i++)
- {
- Wactiv(w[i]); /* activate windows 0 thru 5 in order, */
- DemoWait(); /* back to front */
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP AttrDemo(NOARG)
- {
- if(0 == (w[1] = Wopen(9, 35, 22, 65, 0, YELLOW|_BLUE, LCYAN|_BLUE)))
- ErrorExit(1);
-
- HlpSet(H_CHGATTR);
- Wputs("\n The WchgAtr() function"
- "\n allows you to change the"
- "\n attribute of the active"
- "\n window.");
- PressAKey(6);
- ChgWindAttr(LMAGENTA|_BLUE, WHITE|_GREEN);
- ChgWindAttr(GREEN|_LGREY, LMAGENTA|_RED);
- ChgWindAttr(YELLOW|_BROWN, LCYAN|_BLUE);
- ChgWindAttr(YELLOW|_MAGENTA, YELLOW|_MAGENTA);
- ChgWindAttr(LCYAN|_MAGENTA, WHITE|_MAGENTA);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP BordDemo(NOARG)
- {
- REG IntT i;
-
- HlpSet(H_CHGBORD);
- WsetTxt(LGREEN|_MAGENTA);
- Wputs("\n\n The Wborder() function is"
- "\n used to change the style"
- "\n of the window's border.");
- PressAKey(10);
- for(i = 5; i >= 0; i--)
- {
- Wborder(i);
- DemoWait();
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP ChgWindAttr(IntT battr, IntT wattr)
- {
- WchgAtr(battr, wattr);
- DemoWait();
- }
-
- /*----------------------------------------------------------------------*/
- /* The end of the window demo. */
-
- VOID CTYP CloseWinDemo(NOARG)
- {
- REG IntT i;
-
- for(i = 0; i < 8; i++)
- {
- Wclose();
- DemoWait();
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Validates the Date field in the data entry window. */
-
- IntT CTYP CheckDate(ChrP b)
- {
- IntT y, m, d;
-
- if(!strblank(b))
- {
- ParseDate(b, &m, &d, &y);
-
- if(m < 1 || m > 12) /* validate numeric values */
- {
- Wperror("Invalid month");
- return(1);
- }
- if(d < 1 || d > 31)
- {
- Wperror("Invalid day");
- return(3);
- }
- }
- return(0);
- }
-
- /*----------------------------------------------------------------------*/
- /* Pops open a window and confirms that the user really wants to quit */
- /* the demo. If so, it terminates the demo program. */
-
- VOID CTYP ConfirmQuit(NOARG)
- {
- KbndP kblist;
-
- MShide();
- kblist = KbndChg(NULL); /* hide any existing hot keys */
- if(!Wopen(9, 26, 13, 55, 0, WHITE|_BROWN, WHITE|_BROWN))
- ErrorExit(1);
-
- AddShadow();
- Wputs("\n Quit demo, are you sure? \033A\156Y\b");
- KeyClear();
- VcurHid(1);
- if(KwGetYn('Y') == 'Y')
- NormalExit();
- Wclose();
- VcurHid(0);
- KbndChg(kblist); /* restore any hidden hot keys */
- MSshow();
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP CopyDemo(NOARG)
- {
- HlpSet(H_WINCOPY);
- WsetTxt(LCYAN|_CYAN);
- Wputs("\n\n The Wcopy() function is used"
- "\n to copy the active window.");
- PressAKey(9);
- if(!Wcopy(1, 1))
- ErrorExit(1);
- DemoWait();
- if(!Wcopy(3, 40))
- ErrorExit(1);
- DemoWait();
- }
-
- /*----------------------------------------------------------------------*/
- /* Controls delay in demo. */
-
- VOID CTYP DemoWait(NOARG)
- {
- if(DemoFast)
- return;
- else
- _Delay(5);
- }
-
- /*----------------------------------------------------------------------*/
- /* Save the screen image on the far heap. */
-
- VcelFP CTYP FarVsave(IntT Atr)
- {
- VcelFP FarPtr;
- VcelP NearPtr;
- #if (TCXL_cc_ == 2) /* Zortech */
- DwdT sz;
- #else
- WrdT sz;
- #endif
-
- if(NULL == (NearPtr = Vsave()))
- ErrorExit(3);
- sz = (VidDep * VidWid * SIZ(VcelT)) + 1;
- if(NULL == (FarPtr = (VcelFP) farmalloc(sz)))
- ErrorExit(4);
- _PutFar((BytFP) FarPtr, (BytP) NearPtr, sz);
- free(NearPtr);
- Vclear(Atr);
- return(FarPtr);
- }
-
- /*----------------------------------------------------------------------*/
- /* Restore saved screen image from the far heap. */
-
- VOID CTYP FarVrestore(VcelFP FarPtr)
- {
- VcelP NearPtr;
- WrdT sz;
-
- sz = (VidDep * VidWid * SIZ(VcelT)) + 1;
- if(NULL == (NearPtr = (VcelP) malloc(sz)))
- ErrorExit(3);
- _GetFar((BytP) NearPtr, (BytFP) FarPtr, sz);
- farfree(FarPtr);
- Vrestore(NearPtr);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of entry demo. Shows a method of printing entry form data. */
-
- VOID CTYP PrintOrder(NOARG)
- {
- IntT p;
- IntT m, d, y;
-
- if(!WpopUp(CNT_CNT, 9, 20, 13, 64, 0, WHITE|_CYAN, WHITE|_CYAN))
- ErrorExit(1);
-
- WputCen("Is your printer attached\n");
- WputCen("to LPT1 and Ready? \033A\076Y\b");
-
- strtrim(firstname);
- strtrim(initial);
- strtrim(lastname);
- strtrim(address);
- strtrim(company);
- strtrim(city);
- strtrim(state);
- strtrim(zipcode);
- strtrim(comments);
- strltrim(amtenc);
-
- KeyClear();
- p = KwGetYn('Y');
- if(p != 'N')
- {
- ParseDate(date, &m, &d, &y);
-
- Wclear();
- WputCen("Printing TCXL Order Form . . .\n\n");
-
- Wputs("\033C\002Printing Line 1");
- _Delay(5);
- lprintf("TCXL Order Form "
- " %s %d, %d\n\n\n", months[m - 1], d, y);
- Wputs("\033C\002Printing Line 2");
- _Delay(5);
- if(initial[0] == 0)
- lprintf("%s %s\n\n", firstname, lastname);
- else
- lprintf("%s %s. %s\n\n", firstname, initial, lastname);
-
- Wputs("\033C\002Printing Line 3");
- _Delay(5);
- lprints(company);
- lprints("\n\n");
- Wputs("\033C\002Printing Line 4");
- _Delay(5);
- lprints(address);
- lprints("\n\n");
- Wputs("\033C\002Printing Line 5");
- _Delay(5);
- lprintf("%s, %s %s %3.3s-%3.3s-%4.4s\n\n", city, state,
- zipcode, &phone[0], &phone[3], &phone[6]);
- Wputs("\033C\002Printing Line 6");
- _Delay(5);
- lprintf("Compiler: %s Order Total $ %s\n\n", compiler,
- amtenc);
- Wputs("\033C\002Printing Line 7");
- _Delay(5);
- lprints(comments);
- lprints("\n\n");
- Wputs("\033C\002Printing Line 8");
- _Delay(5);
- lprints("Payment Method: Check Enclosed \n\n");
- Wputs("\033C\002Printing Line 9");
- _Delay(5);
- lprints(" (circle one) MasterCard Visa\n\n");
- Wputs("\033C\002Printing Line 10");
- _Delay(5);
- lprints(" "
- "Card Number: ______________________________\n\n");
- Wputs("\033C\002Printing Line 11");
- _Delay(5);
- lprints(" "
- "Expiration Date ___________________________\n\n\n");
- Wputs("\033C\002Printing Line 12");
- _Delay(5);
- lprints(" "
- "Signature _________________________________\n");
- lprintc('\x0c');
- }
- Wclose();
- }
-
- /*----------------------------------------------------------------------*/
- /* Displays a quick 'n' dirty directory of current path -- uses new */
- /* TCXL stuff that is compiler independent! */
-
- VOID CTYP Directory(NOARG)
- {
- LCL IntT bf = 0;
- ChrT fs[41], f1[13], f2[13];
- IntT i, f, l, n;
- FfbT fb;
-
- if(bf) /* AVOID RECURSION! */
- return;
-
- else
- bf = 1;
-
- strcpy(fs, "*.*");
- VcurHid(1);
- if(!Wopen(4, 14, 20, 59, 0, YELLOW|_BLUE, YELLOW|_BLUE))
- ErrorExit(1);
-
- Wtitle("[ Directory ]", TTL_CNT, YELLOW|_BLUE);
- if(!Wopen(6, 6, 8, 49, 0, LCYAN|_RED, LCYAN|_RED))
- ErrorExit(1);
-
- Wtitle("[ Filespec ]", TTL_CNT, LCYAN|_RED);
- EntDef(BLUE|_LGREY, BLUE|_LGREY);
- EntFld(0, 1, fs, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FLD_UPR,
- 13, 2, NULL, H_EDITKEYS);
- i = EntShow();
- Wclose();
- if(!i)
- {
- Wclear();
- WsetTxt(LCYAN|_BLUE);
- l = n = 0;
- f = _FndFst(fs, &fb, 0);
- for(;;)
- {
- if(f)
- break;
- n++;
- strcpy(f1, FfbNam(fb));
- if(!f)
- f = _FndNxt(&fb);
- strcpy(f2, FfbNam(fb));
- if(f)
- f2[0] = EOS;
- else
- {
- n++;
- f = _FndNxt(&fb);
- }
- if(f)
- FfbNam(fb)[0] = EOS;
- else
- n++;
- Wputf(" %-15s%-15s%s\n", f1, f2, FfbNam(fb));
- l++;
- if(l >= 14)
- {
- WsetTxt(LGREEN|_BLUE);
- Wputf(" Press a key to continue....");
- WsetTxt(LCYAN|_BLUE);
- i = (ChrT) KeyTime(36);
- Wputf("\r");
- if(i == ESC)
- break;
- l = 0;
- }
- if(!f)
- f = _FndNxt(&fb);
- }
- WsetTxt(LGREEN|_BLUE);
- Wputf(" Files found: %d Press a key....", n);
- KeyTime(36);
- }
- VcurHid(0);
- Wclose();
- bf = 0; /* not busy */
- }
-
- /*----------------------------------------------------------------------*/
- /* Displays the literal equivalent of the MMDDYY date that the user */
- /* entered into the Date field. It is called immediately after the */
- /* user leaves the Date field. */
-
- VOID CTYP DisplayDate(NOARG)
- {
- FdfP f;
- IntT m, d, y;
-
- if(NULL == (f = FldLoc(1))) /* find address of Date field */
- ErrorExit(1);
-
- VcurHid(0); /* set cursor and clear to */
- Wgotoxy(1, 37); /* end of window's line */
- WclrEol();
- if(!strblank(FdfBfr(f))) /* parse string date into */
- { /*numeric values */
- ParseDate(FdfBfr(f), &m, &d, &y);
- Wputf("%s %d, %d", months[m - 1], d, y);
- }
- VcurHid(1);
- }
-
- /*----------------------------------------------------------------------*/
- /* Called by the pull-down demo for a prompt. */
-
- VOID CTYP DispSureMsg(NOARG)
- {
- Wprts(0, 2, WHITE|_BLUE, "Are you sure?");
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP DisplayTitle(IntT tpos)
- {
- Wtitle("[ My Title ]", tpos, LCYAN|_GREEN);
- DemoWait();
- }
-
- /*----------------------------------------------------------------------*/
- /* Dummy function for several menu items in the pull-down demo */
-
- VOID CTYP DoNothing(NOARG)
- {
- }
-
- /*----------------------------------------------------------------------*/
- /* Abnormal termination. If it is passed an error code of 1, then it */
- /* is a windowing system error. Otherwise the error message is looked */
- /* up in the error message table. */
-
- VOID CTYP ErrorExit(IntT e)
- {
- if(e)
- {
- if(e == 1)
- Werror();
- else
- printf("\n%s\n", error_text[e]);
- exit(e);
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Used by the pull-down demo to execute a DOS command. */
-
- VOID CTYP Execute(NOARG)
- {
- LCL IntT bf = 0;
- ChrT cd[61];
-
- if(bf) /* AVOID RECURSION! */
- return;
- else
- bf = 1;
- if(!Wopen(8, 7, 10, 70, 0, LGREY|_RED, LGREY|_RED))
- ErrorExit(1);
- Wtitle("[ Execute DOS Command ]", TTL_CNT, LGREY|_RED);
- EntDef(BLUE|_LGREY, BLUE|_LGREY);
- EntFld(0, 1, cd,
- "************************************************************",
- FLD_NUL, 14, 0, NULL, H_EDITKEYS);
- if(!EntShow())
- OsShell1(cd);
- VcurHid(0);
- Wclose();
- bf = 0;
- }
-
- /*----------------------------------------------------------------------*/
- /* Alternate get key function for the data entry demo. In this example,*/
- /* I do a normal keyboard get, but if the key is [F10], I want to exit */
- /* the form. The purpose of this is to show how to extend EntShow(). */
- /* If F9 is pressed, we fill in today's date to the keyboard buffer */
-
- WrdT CTYP GetKey(IntP d)
- {
- KeyT x;
- ChrP b;
-
- x = KeyGetc();
- if(x == Key_F9)
- {
- b = SysDate(2);
- KqueStr(&b[1]);
- x = b[0];
- }
- else
- *d = (x == Key_F10);
- return(x);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP HideDemo(NOARG)
- {
- REG IntT i;
-
- HlpSet(H_WINHIDE);
- WsetTxt(YELLOW|_CYAN);
- Wputs("\n\n The Whide() and Wunhide()"
- "\n functions are used to hide"
- "\n and unhide windows.");
- PressAKey(13);
- for(i = 0; i < 5; i++)
- {
- if(Whide()) /* hide all windows, front to */
- ErrorExit(1); /* back */
- DemoWait();
- }
- for(i = 0; i < 5; i++)
- {
- if(Wunhide(0)) /* unhide most recently hidden */
- ErrorExit(1); /* first */
- DemoWait();
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP HorzLine(IntT r, IntT c, IntT n, IntT a)
- {
- WdrwHor(r, c, n, 3, a);
- DemoWait();
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrmatch(NOARG)
- {
- ChrP str1 = "xhelpx";
- IntT i = 0;
-
- while(Dstrings[i] != NULL)
- {
- Wputf(" <%s> vs. <%s> = <%d>\n",
- str1, Dstrings[i], strmatch(str1, Dstrings[i]));
- i++;
- }
-
- Wputf(" <%s> best matches <%s>\n", str1, strbmatch(str1, Dstrings));
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrtrim(NOARG)
- {
- ChrP str1 = " Hello, world ";
- ChrT str2[25];
-
- strcpy(str2, str1);
- strltrim(str2);
- Wputf(BefAft, str1, str2);
-
- strcpy(str2, str1);
- strrtrim(str2); /* identical to strtrim() */
- Wputf(BefAft, str1, str2);
-
- strcpy(str2, str1);
- strbtrim(str2);
- Wputf(BefAft, str1, str2);
-
- }
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrchg(NOARG)
- {
- ChrP str1 = "HelLo, worLd";
- ChrP str2 = "Hello, world";
- ChrP str3 = "xxxhElLoyyyHElLOzzz";
- ChrP str4 = "xxxhElloyyyhellozzz";
- ChrT str5[30];
-
- strcpy(str5, str1);
- strchg(str5, 'l', 'z');
- Wputf(BefAft, str1, str5);
-
- strcpy(str5, str2);
- strichg(str5, 'l', 'z');
- Wputf(BefAft, str2, str5);
-
- strcpy(str5, str3);
- strischg(str5, "HeLlO", "goodbye");
- Wputf(BefAft, str3, str5);
-
- strcpy(str5, str4);
- strschg(str5, "hello", "goodbye");
- Wputf(BefAft, str4, str5);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrchksum(NOARG)
- {
- ChrP str1 = "Hello, world";
-
- Wputf("Checksum is %lu, I-Checksum is %lu\n",
- strchksum(str1), strichksum(str1));
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrdel(NOARG)
- {
- ChrP str1 = "XyZHello, xYzworldXyZxYz";
- ChrT str2[35];
-
- strcpy(str2, str1);
- strdel("xYz", str2);
- Wputf(BefAft, str1, str2);
-
- strcpy(str2, str1);
- strdela("xYz", str2);
- Wputf(BefAft, str1, str2);
-
- strcpy(str2, str1);
- stridel("xYz", str2);
- Wputf(BefAft, str1, str2);
-
- strcpy(str2, str1);
- stridela("xYz", str2);
- Wputf(BefAft, str1, str2);
-
- strcpy(str1, str2);
- strins("xYz", str2, 4);
- Wputf(BefAft, str1, str2);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrinc(NOARG)
- {
- ChrP str1 = "Hello1HELLO2HeLlO3hElLo";
- ChrP str2 = "hello";
-
- Wputf("str2 is %sincluded in str1\n",
- ((strinc(str2, str1) == NULL) ? "not " : ""));
-
- Wputf("str2 is %sincluded in str1\n",
- ((striinc(str2, str1) == NULL) ? "not " : ""));
-
- Wputf("There are %d occurrences of '%c' in str1\n",
- strocc(str1, 'l'), 'l');
-
- Wputf("There are %d occurrences of '%c' in str1\n",
- striocc(str1, 'l'), 'l');
-
- Wputf("str2 occurs in str1 %d times\n",
- strsocc(str2, str1));
- Wputf("str2 occurs in str1 %d times\n",
- strisocc(str2, str1));
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrsrep(NOARG)
- {
- ChrP str1 = "This is a big string";
- ChrT str2[25];
-
- strcpy(str2, str1);
- strsrep(str2, "str", "th");
- Wputf(BefAft, str1, str2);
-
- strcpy(str2, str1);
- strisrep(str2, "str", "th");
- Wputf(BefAft, str1, str2);
-
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrmid(NOARG)
- {
- ChrP p;
- ChrP str = "Hello, world";
-
- Wputf(" %s\n", p = strmid(str, 5, 5));
- free(p);
-
- Wputf(" %s\n", p = strleft(str, 5));
- free(p);
-
- Wputf(" %s\n", p = strright(str, 5));
- free(p);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrljust(NOARG)
- {
- ChrP str1 = " Hello, world ";
- ChrP str2 = "Hello, world";
- ChrT str3[25];
-
- strcpy(str3, str1);
- strljust(str3);
- Wputf(BefAft, str1, str3);
-
- strcpy(str3, str1);
- strrjust(str3);
- Wputf(BefAft, str1, str3);
-
- strcpy(str3, str2);
- strrol(str3, 3);
- Wputf(BefAft, str2, str3);
-
- strcpy(str3, str2);
- strror(str3, 3);
- Wputf(BefAft, str2, str3);
-
- strcpy(str3, str2);
- strshl(str3, 3);
- Wputf(BefAft, str2, str3);
-
- strcpy(str3, str2);
- strshr(str3, 3);
- Wputf(BefAft, str2, str3);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the strings demo. */
-
- VOID CTYP Dstrblank(NOARG)
- {
- ChrP str1 = " Hello ";
- ChrP str2 = " \n \t \r ";
- ChrP str3 = "Hello, world";
- ChrP str4 = "hElLo, wOrLd";
- ChrT str5[25];
-
- Wputf(" str1 is %sblank\n", strblank(str1) ? "" : "not ");
- Wputf(" str2 is %sblank\n", strblank(str2) ? "" : "not ");
-
- Wputf(" Before: <%s>\n", str3);
- strcode(str3, "34&*#Mdq");
- Wputf(" Encrypted: <%s>\n", str3);
- strcode(str3, "34&*#Mdq");
- Wputf(" Decrypted: <%s>\n", str3);
-
- strcpy(str5, str3);
- Wputf(" Before: <%s>\n", str5);
- strsetsz(str5, 20);
- Wputf(" Len=20: <%s>\n", str5);
- strsetsz(str5, 5);
- Wputf(" Len=5: <%s>\n", str5);
-
- strcpy(str5, str4);
- struplow(str5);
- Wputf(BefAft, str4, str5);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of menu demo -- build arrays of valid Ultravision modes */
-
- IntT CTYP ValidModes(NOARG)
- {
- int i, n, q, r;
-
- q = _VuvGet();
- n = 0;
-
- for(i = 0; UvMode[i] != 0; i++)
- {
- if(_VuvVal(UvMode[i]) == 0)
- {
- UvVal[n] = UvArr[i];
- UvMd[n++] = UvMode[i];
- if(q == UvMode[i])
- r = n - 1;
- }
- }
- UvVal[n] = NULL;
- return(r);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of menu demo -- change screen size */
-
- VOID CTYP ChangeSize(NOARG)
- {
- int s, t, st, w;
-
- st = VcurHid(-1);
- w = VidWid;
- if(VuvAct)
- {
- t = ValidModes();
- s = SelStr(4, 45, 12, 74, 0, LGREY|_BLUE, YELLOW|_BLUE,
- YELLOW|_MAGENTA, UvVal, t, NULL);
- if(s >= 0)
- _VuvSet(UvMd[s]);
- }
- else
- {
- if(VidWid != 80)
- Wperror("Invalid Screen Width to Demonstrate");
- else
- {
- if(VisaEga() != -1)
- {
- s = SelStr(4, 57, 8, 71, 0, LGREY|_BLUE, YELLOW|_BLUE,
- YELLOW|_MAGENTA, LinArr,
- ((VidDep == 43) ? 1 : ((VidDep == 50) ? 2 : 0)), NULL);
- switch(s)
- {
- case 0:
- VsetLin(25);
- break;
- case 1:
- VsetLin(43);
- break;
- case 2:
- VsetLin(50);
- break;
- }
- }
- }
- }
- if(w != VidWid)
- cvtic(&Rmargin[16], VidWid - 8, 3);
- VcurHid(st);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of menu demo -- draw a fake editor screen */
-
- VOID CTYP DrawEditor(IntT Lmar, IntT Rmar)
- {
- IntT i = 0, j;
-
- if(!Wopen(0, 0, VidDep - 1, VidWid - 1, 0, CYAN, CYAN))
- ErrorExit(1);
-
- WdrwHor(1, 0, VidWid - 2, 0, CYAN);
- if(!Wopen(3, Lmar + 1, VidDep - 2, Rmar + 1, BOX_SPA, CYAN, CYAN))
- ErrorExit(1);
-
- Wgotoxy(0, 0);
- WsetTxt(YELLOW);
-
- while(Edemo[i] != NULL)
- Wputsw(Edemo[i++]);
-
- if(MouInit)
- Wputsw(" Since you have a mouse, you can use it to move around "
- "and select options!");
-
- j = WdfPosR(WctlAct);
-
- for(i = 0; i < 6; i++)
- WprtCen(TcxlI[i].row + j, TcxlI[i].Atr, TcxlI[i].Str);
-
- }
-
- /*----------------------------------------------------------------------*/
- /* Used to move the selection bar of the Main Menu down to the next menu*/
- /* item. It does this by fetching the address of the current menu, then*/
- /* setting the current tagid to the tagid of the next menu item. If I */
- /* had not numbered the menu items' tagids sequentially, this would not */
- /* work. */
-
- VOID CTYP MoveBarDn(NOARG)
- {
- ItmNxt(IdfTag(ItmCur()) + 1);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP MoveDemo(NOARG)
- {
- IntT i;
-
- if(0 == (w[4] = Wopen(4, 2, 20, 35, 2, YELLOW|_CYAN, YELLOW|_CYAN)))
- ErrorExit(1);
-
- HlpSet(H_WINMOVE);
- Wputs("\n To move the active window,"
- "\n the Wmove() function is"
- "\n used.");
- PressAKey(5);
-
- for(i = 0; i < 6; i++)
- MoveWindow(Siz3[i], Siz4[i]);
-
- Wputs("\n\n Or if you prefer flashier,"
- "\n window movement, try"
- "\n Wslide() instead.");
- PressAKey(9);
-
- for(i = 0; i < 6; i++)
- DragWindow(Siz3[i], Siz4[i]);
- }
-
- /*----------------------------------------------------------------------*/
- /* part of the window demo */
-
- VOID CTYP AddShadow(NOARG)
- {
- Wshadow(LGREY|_BLACK);
- }
-
- /*----------------------------------------------------------------------*/
- /* part of the window demo */
-
- VOID CTYP MoveWindow(IntT r, IntT c)
- {
- if(Wmove(r, c))
- ErrorExit(1);
-
- DemoWait();
- }
-
- /*----------------------------------------------------------------------*/
- /* part of the window demo */
-
- VOID CTYP DragWindow(IntT r, IntT c)
- {
- if(Wslide(r, c))
- ErrorExit(1);
- DemoWait();
- }
-
- /*----------------------------------------------------------------------*/
- /* Normal termination. The original screen and cursor coordinates are */
- /* restored before exiting to DOS with ERRORLEVEL 0. */
-
- VOID CTYP NormalExit(NOARG)
- {
- FarVrestore(savescrn);
- MSpop();
- VcurPut(rc);
- VcurHid(1);
- exit(0);
- }
-
- /*----------------------------------------------------------------------*/
- /* Used by the pull-down demo. It is the [O]S Shell function under the */
- /* [F]ile menu */
-
- VOID CTYP OsShell(NOARG)
- {
- OsShell1("");
- }
-
- /*----------------------------------------------------------------------*/
- /* Does the work for OsShell() */
-
- VOID CTYP OsShell1(ChrP Cmd)
- {
- VcelFP s;
- ChrT c;
-
- c = *Cmd;
- VcurHid(1);
- MShide();
- s = FarVsave(LGREY|_BLACK);
- if(c == EOS)
- printf("Type EXIT to return....\n");
- system(Cmd);
- if(c != EOS)
- { printf("Press a key to return....\n");
- KeyWait();
- }
- FarVrestore(s);
- VcurHid(0);
- MSshow();
- }
-
- /*----------------------------------------------------------------------*/
- /* Parses a MMDDYY date string into separate numeric values. */
-
- VOID CTYP ParseDate(ChrP b, IntP m, IntP d, IntP y)
- {
- ChrT t[7];
-
- strcpy(t, b);
- *y = 1900 + atoi(t + 4);
- *(t + 4) = EOS;
- *d = atoi(t + 2);
- *(t + 2) = EOS;
- *m = atoi(t);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of entry demo -- string picking using a menu */
-
- VOID CTYP PickCompiler(NOARG)
- {
- REG IntT s, i;
-
- HlpCur();
-
- MnuBeg(9, 22, 14, 38, 0, BLUE|_MAGENTA, BLUE|_MAGENTA, PreMenu1);
- for(i = 0; i < 4; i++)
- MnuItm(i, 0, compilers[i], *compilers[i], i + 1, 0, NULL, 0, 0);
- MnuEnd(1, MNU_VER, 15, 1, BLUE|_MAGENTA, LCYAN|_MAGENTA, 0,
- BLUE|_LGREY);
-
- if((s = MnuShow()) == -1)
- ErrorExit(1);
- KquePut(Key_Home);
- if(s)
- {
- KqueStr(compilers[--s]);
- KquePut(Key_C_U);
- }
- /* put either [Tab] or [Shift-Tab] into TCXL's keyboard */
- /* buffer depending on direction entered field from */
- KquePut(FdfUp(FldCur()) ? Key_S_Tab : Key_Tab);
- HlpPop();
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of menu demo -- sample popup menu */
-
- VOID CTYP PopupDemo(NOARG)
- {
- HlpPush(H_PULLDOWN);
- MnuBeg(7, 15, 10, 65, 0, LRED, LCYAN|_BLUE, NULL);
- MnuItm(0, 0, "Add", 'A', 55, 0, NULL, 0, H_NONE);
- ItmTxt(1, 0, LGREEN|_BLUE, "Create a new record");
- MnuItm(0, 8, "Delete", 'D', 56, 0, NULL, 0, H_NONE);
- ItmTxt(1, 0, LGREEN|_BLUE, "Delete an existing record");
- MnuItm(0, 19, "Print", 'P', 57, 0, NULL, 0, H_NONE);
- ItmTxt(1, 0, LGREEN|_BLUE, "Print hardcopy of existing record");
- MnuItm(0, 28, "Show", 'S', 58, 0, NULL, 0, H_NONE);
- ItmTxt(1, 0, LGREEN|_BLUE, "Display an existing record on screen");
- MnuItm(0, 36, "Update", 'U', 59, 0, NULL, 0, H_NONE);
- ItmTxt(1, 0, LGREEN|_BLUE, "Modify an existing record");
- MnuItm(0, 45, "Quit", 'Q', 60, 0, NULL, 0, H_NONE);
- ItmTxt(1, 0, LGREEN|_BLUE, "Quit and return to pull-down menu");
- MnuEnd(55, MNU_HOR, 0, 0, LMAGENTA|_BLUE, WHITE|_BLUE, 0,
- YELLOW|_LGREY);
- MnuShow();
- HlpDrop();
- }
-
- /*----------------------------------------------------------------------*/
- /* Called after the user presses help and the help window appears. First*/
- /* adds a shadow to the help window, then defines Alt-X to be the key to*/
- /* quit the demo. */
-
- VOID CTYP PreHelp(NOARG)
- {
- AddShadow();
- KbndSet(Key_A_X, ConfirmQuit, 0);
- }
-
- /*----------------------------------------------------------------------*/
- /* Called during the setup of the main menu by MnuShow() right after */
- /* the main menu's window is opened. */
-
- VOID CTYP PreMenu1(NOARG)
- {
- VcurHid(0);
- AddShadow();
- }
-
- /*----------------------------------------------------------------------*/
- /* Called during the List Picking demo by SelStr() right after the */
- /* string picker's window is opened. */
-
- VOID CTYP PrePick1(NOARG)
- {
- Wmessage("* *", BRD_BOT, 4, LGREEN|_RED);
- AddShadow();
- }
-
- /*----------------------------------------------------------------------*/
- /* Pauses for a keypress. */
-
- VOID CTYP PressAKey1(IntT r, IntT w)
- {
- REG IntT a;
-
- if(DemoFast)
- return;
-
- a = (_BLINK|YELLOW)|((WdfDat(WctlAct) >> 4) << 4);
- WprtCen(r, a, "Press a key");
- VcurHid(0);
- if(w == -1)
- KeyWait();
- else
- {
- if((ChrT) KeyTime(w) == ESC)
- ConfirmQuit();
- }
- WprtCen(r, a, " ");
- }
-
- /*----------------------------------------------------------------------*/
- /* Displays a pause message, then pauses for a keypress. */
-
- VOID CTYP PressAKey(IntT r)
- {
- PressAKey1(r, 36);
- }
-
- /*----------------------------------------------------------------------*/
- /* Called by the pull-down menu demo anytime the selection bar moves on */
- /* or off the [Q]uit menu items. */
-
- VOID CTYP QuitWindow(NOARG)
- {
- LCL WndT h = 0;
-
- if(h)
- {
- Wactiv(h);
- Wclose();
- h = 0;
- }
- else
- {
- h = Wopen(14, 41, 17, 70, 0, YELLOW|_RED, WHITE|_RED);
- Wputs(" Quit takes you back to the\n demo program's main menu.");
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Validates the [R]ight margin setting from RMargin() */
-
- IntT CTYP ValidMarg(ChrP Input)
- {
- if((atoi(Input) > (VidWid - 3)) || (atoi(Input) < 0))
- {
- Wperror("Invalid Margin!");
- return(1);
- }
- if(IdfTag(ItmCur()) == 37)
- {
- if(atoi(Input) >= atoi(&Rmargin[16]))
- {
- Wperror("Left Margin Too Large!");
- return(1);
- }
- }
- else
- {
- if(atoi(&Lmargin[16]) >= atoi(Input))
- {
- Wperror("Right Margin Too Small!");
- return(1);
- }
- }
- return(0);
- }
-
- /*----------------------------------------------------------------------*/
- /* Gets a new [R]ight margin setting under the [D]efault pull-down menu.*/
-
- VOID CTYP RMargin(NOARG)
- {
- EntDef(WHITE|_CYAN, WHITE|_CYAN);
- EntFld(IdfSpoR(ItmCur()), 17, (IdfStr(ItmCur())) + 16,
- "%%#", FLD_NUM, 15, 1, ValidMarg, 0);
- EntShow();
- VcurHid(0);
- ItmDsp((IdfTag(ItmCur())));
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP ResizeDemo(NOARG)
- {
- IntT i;
-
- HlpSet(H_RESIZE);
- WsetTxt(BLUE|_GREEN);
- Wputs("\n\n\n The Wsize() function"
- "\n allows you to resize"
- "\n the active window.");
- PressAKey(10);
-
- for(i = 0; i < 6; i++)
- SizeWindow(Siz1[i], Siz2[i]);
- }
-
- /*----------------------------------------------------------------------*/
- /* Used by input demo */
-
- VOID CTYP RestoreCursor(NOARG)
- {
- WsetTxt(WHITE|_MAGENTA);
- VcurHid(1);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP ScrollDemo(NOARG)
- {
- REG IntT i, j;
-
- if(0 == (w[0] = Wopen(1, 1, 11, 41, 2, LMAGENTA|_RED, LCYAN|_RED)))
- ErrorExit(1);
- HlpSet(H_SCROLL);
- Wputf("\n TCXL's window TTY output functions"
- "\n such as Wputs() and Wprintf() allow"
- "\n scrolling and ANSI-like Escape code"
- "\n sequences from inside of windows.");
- PressAKey(6);
- Wgotoxy(8, 0);
- for(i = 0; i < 10; i++)
- {
- for(j = DGREY; j <= WHITE; j++)
- {
- Wputf("\033F%cTCXL ", j);
- if(!DemoFast)
- _Delay(1);
- }
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Sets up the [D]efaults menu for the pull-down demo. */
-
- VOID CTYP SetupMenu(NOARG)
- {
- WdrwHor(3, 0, 21, 0, LGREY|_BLUE);
- WdrwHor(8, 0, 21, 0, LGREY|_BLUE);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP SizeWindow(IntT r, IntT c)
- {
- Wsize(r, c);
- DemoWait();
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP TLineDemo(NOARG)
- {
- if(0 == (w[3] = Wopen(10, 3, 23, 41, 3, YELLOW|_BLUE, LMAGENTA|_BLUE)))
- ErrorExit(1);
-
- HlpSet(H_TEXTLINE);
- Wputs("\n The WdrwHor() & WdrwVer() functions"
- "\n are used for drawing \"smart\" text"
- "\n lines which will even make their "
- "\n own corners and intersections! ");
- PressAKey(6);
-
- HorzLine( 6, 6, 24, LCYAN|_BLUE);
- VertLine( 6, 6, 4, LCYAN|_BLUE);
- HorzLine(10, 6, 24, LCYAN|_BLUE);
- VertLine( 6, 30, 5, LRED|_BLUE);
- VertLine( 6, 18, 5, LRED|_BLUE);
- HorzLine( 7, 6, 25, LRED|_BLUE);
- HorzLine( 9, 6, 25, LGREEN|_BLUE);
- VertLine( 6, 11, 5, LGREEN|_BLUE);
- VertLine( 6, 23, 5, LGREEN|_BLUE);
- HorzLine( 8, 6, 25, LMAGENTA|_BLUE);
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP TitleDemo(NOARG)
- {
- if(0 == (w[2] = Wopen(5, 20, 19, 45, 3, LCYAN|_GREEN, WHITE|_GREEN)))
- ErrorExit(1);
-
- HlpSet(H_WINTITLE);
- Wputs("\n The Wtitle() function"
- "\n allows you to give a"
- "\n window a title.");
- PressAKey(5);
-
- DisplayTitle(TTL_LFT);
- DisplayTitle(TTL_RGT);
- DisplayTitle(TTL_CNT);
- }
-
- /*----------------------------------------------------------------------*/
- /* Toggles "block marking" on and off in the sample editor of the */
- /* pulldown menu demo */
-
- VOID CTYP ToggleBlock(NOARG)
- {
- LCL IntT b = OFF;
-
- if(b)
- {
- b = OFF;
- ItmEna(32);
- ItmDis(33);
- ItmNxt(32);
- }
- else
- {
- b = ON;
- ItmDis(32);
- ItmEna(33);
- ItmNxt(33);
- }
- if(Wopen(11, 30, 15, 49, 0, LGREY|_MAGENTA, WHITE|_MAGENTA))
- {
- Wputf("\n Block is now o%s", b ? "n" : "ff");
- _Delay(10);
- Wclose();
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Toggles the yes/no status of some pull-down menu items. This is to */
- /* show you can modify the menu item's string and redisplay it. This is */
- /* done by getting the address of the current menu item's struct, then */
- /* modifying the string pointed to by the str element. The redisp flag */
- /* is set so that when you return to the menu, the screen will be */
- /* automatically updated. */
-
- VOID CTYP ToggleYN(NOARG)
- {
- IdfP i;
- ChrP s, y;
- LCL ChrT yes[] = "yes", no[] = " no";
- i = ItmCur();
- s = ItmGet(IdfTag(i));
- y = s + strlen(s) - 3;
- strcpy(y, strcmp(y, yes) ? yes : no);
- ItmDsp(IdfTag(i));
- }
-
- /*----------------------------------------------------------------------*/
- /* Updates the on-screen clock in the pull-down demo. */
- /* Only updates the clock once per second. */
-
- VOID CTYP UpdateClock(NOARG)
- {
- LCL DwdT t;
-
- if(t < (_Timer()))
- {
- Vprints(0, 70, LGREEN, SysTime(1));
- t = _Timer() + 18;
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* Part of the window demo. */
-
- VOID CTYP VertLine(IntT r, IntT c, IntT n, IntT a)
- {
- WdrwVer(r, c, n, 3, a);
- DemoWait();
- }
-
- /*----------------------------------------------------------------------*/
- /* Used by the List Picking demo to display a selected string, or */
- /* display an error message if an error occurred. It also prompts for a*/
- /* keypress 2 lines below the string/error message. */
-
- VOID CTYP YouSelected(ChrP str)
- {
- VposT rc;
-
- if(TcxlErr)
- Wputf("\033EL%s", WerrMsg());
- else
- Wputf("\033ELYou selected: \033F\005%s\033F\004", str);
- HlpSet(H_LISTPICK);
- WcurGet(rc);
- PressAKey(VposR(rc) + 2);
- }
-
- /*- end of TcxlDemo.c --------------------------------------------------*/