|
|
1.1 root 1: /* UIFC.H */
2:
1.1.1.2 ! root 3: /* Rob Swindell's Text-mode User Interface Library */
! 4:
! 5: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
! 6:
! 7: #include <io.h>
1.1 root 8: #include <dos.h>
9: #include <time.h>
1.1.1.2 ! root 10: #include <fcntl.h>
1.1 root 11: #include <alloc.h>
12: #include <ctype.h>
13: #include <conio.h>
14: #include <stdio.h>
15: #include <string.h>
16: #include <stdarg.h>
17: #include <stdlib.h>
18:
1.1.1.2 ! root 19: /* OS Specific */
! 20: #if defined(__FLAT__)
! 21: #define far
! 22: #endif
! 23:
! 24: #if !defined(__OS2__)
! 25: #include <bios.h>
! 26: #endif
! 27:
! 28:
! 29: /****************************************************************************/
! 30: /* MALLOC/FREE Macros for various compilers and environments */
! 31: /* MALLOC is used for allocations of 64k or less */
! 32: /* FREE is used to free buffers allocated with MALLOC */
! 33: /* LMALLOC is used for allocations of possibly larger than 64k */
! 34: /* LFREE is used to free buffers allocated with LMALLOC */
! 35: /* REALLOC is used to re-size a previously MALLOCed or LMALLOCed buffer */
! 36: /****************************************************************************/
! 37: #if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
! 38: #if defined(__TURBOC__)
! 39: #define REALLOC(x,y) farrealloc(x,y)
! 40: #define LMALLOC(x) farmalloc(x)
! 41: #define MALLOC(x) farmalloc(x)
! 42: #define LFREE(x) farfree(x)
! 43: #define FREE(x) farfree(x)
! 44: #elif defined(__WATCOMC__)
! 45: #define REALLOC realloc
! 46: #define LMALLOC(x) halloc(x,1) /* far heap, but slow */
! 47: #define MALLOC malloc /* far heap, but 64k max */
! 48: #define LFREE hfree
! 49: #define FREE free
! 50: #else /* Other 16-bit Compiler */
! 51: #define REALLOC realloc
! 52: #define LMALLOC malloc
! 53: #define MALLOC malloc
! 54: #define LFREE free
! 55: #define FREE free
! 56: #endif
! 57: #else /* 32-bit Compiler or Small Memory Model */
! 58: #define REALLOC realloc
! 59: #define LMALLOC malloc
! 60: #define MALLOC malloc
! 61: #define LFREE free
! 62: #define FREE free
! 63: #endif
! 64:
! 65: #ifdef __DPMI32__
! 66: #define INT_86(i,j,k) int386(i,j,k)
! 67: #else
! 68: #define INT_86(i,j,k) int86(i,j,k)
! 69: #endif
! 70:
! 71: #ifdef __FLAT__
! 72: #define MAX_OPTS 1000
! 73: #define MSK_ON 0xf0000000
! 74: #define MSK_OFF 0x0fffffff
! 75: #define MSK_INS 0x10000000
! 76: #define MSK_DEL 0x20000000
! 77: #define MSK_GET 0x30000000
! 78: #define MSK_PUT 0x40000000
! 79: #else
! 80: #define MAX_OPTS 500 /* Maximum number of options per menu call */
! 81: #define MSK_ON 0xf000
! 82: #define MSK_OFF 0x0fff
! 83: #define MSK_INS 0x1000
! 84: #define MSK_DEL 0x2000
! 85: #define MSK_GET 0x3000
! 86: #define MSK_PUT 0x4000
! 87: #endif
! 88: #define MAX_OPLN 75 /* Maximum length of each option per menu call */
! 89: #define MAX_BUFS 7 /* Maximum number of screen buffers to save */
1.1 root 90: #define MAX_BFLN 8000 /* Maximum size of screen buffers - 80x50 */
91:
92: #ifndef uint
93: #define uint unsigned int
94: #endif
95:
96: #define UIFC_INMSG (1<<0) /* Currently in Message Routine non-recursive */
1.1.1.2 ! root 97: #define UIFC_MOUSE (1<<1) /* Mouse installed and available */
! 98: #define UIFC_MONO (1<<2) /* Force monochrome mode */
! 99: #define UIFC_COLOR (1<<3) /* Force color mode */
1.1 root 100:
101: #define WIN_ORG (1<<0) /* Original menu - destroy valid screen area */
102: #define WIN_SAV (1<<1) /* Save existing text and replace when finished */
103: #define WIN_ACT (1<<2) /* Menu remains active after a selection */
104: #define WIN_L2R (1<<3) /* Center the window based on 'width' */
105: #define WIN_T2B (1<<4) /* Center the window based on 'height' */
106: #define WIN_INS (1<<5) /* Allows user to user insert key */
107: #define WIN_INSACT (1<<6) /* Remains active after insert key */
108: #define WIN_DEL (1<<7) /* Allows user to use delete key */
109: #define WIN_DELACT (1<<8) /* Remains active after delete key */
110: #define WIN_ESC (1<<9) /* Screen is active when escape is hit */
1.1.1.2 ! root 111: #define WIN_RHT (1<<10) /* Place window against right side of screen */
! 112: #define WIN_BOT (1<<11) /* Place window against botton of screen */
! 113: #define WIN_GET (1<<12) /* Allows F5 to Get a menu item */
! 114: #define WIN_PUT (1<<13) /* Allows F6 to Put a menu item */
! 115: #define WIN_CHE (1<<14) /* Stay active after escape if changes */
! 116: #define WIN_XTR (1<<15) /* Add extra line at end for inserting at end */
1.1 root 117:
118: #define WIN_MID WIN_L2R|WIN_T2B /* Place window in middle of screen */
119:
120: #define SCRN_TOP 3
121: #define SCRN_LEFT 5
122: #define SCRN_RIGHT 76
123:
1.1.1.2 ! root 124: /* Bits in 'mode' for getkey and getstr */
! 125: #define K_UPPER (1L<<0) /* Converts all letters to upper case */
! 126: #define K_UPRLWR (1L<<1) /* Upper/Lower case automatically */
! 127: #define K_NUMBER (1L<<2) /* Allow numbers only */
! 128: #define K_WRAP (1L<<3) /* Allows word wrap */
! 129: #define K_MSG (1L<<4) /* Allows ANSI, ^N ^A ^G */
! 130: #define K_SPIN (1L<<5) /* Spinning cursor (same as SPIN) */
! 131: #define K_LINE (1L<<6) /* Input line (inverse color) */
! 132: #define K_EDIT (1L<<7) /* Edit string passed */
! 133: #define K_CHAT (1L<<8) /* In chat multi-chat */
! 134: #define K_NOCRLF (1L<<9) /* Don't print CRLF after string input */
! 135: #define K_ALPHA (1L<<10) /* Only allow alphabetic characters */
! 136:
! 137: #define HELPBUF_SIZE 4000
! 138:
! 139: #define SETHELP(where) helpline=__LINE__; helpfile=__FILE__
! 140:
! 141: #ifndef TAB
! 142: /* Control characters */
! 143: #define STX 0x02 /* Start of text ^B */
! 144: #define ETX 0x03 /* End of text ^C */
! 145: #define BS 0x08 /* Back space ^H */
! 146: #define TAB 0x09 /* Horizontal tabulation ^I */
! 147: #define LF 0x0a /* Line feed ^J */
! 148: #define FF 0x0c /* Form feed ^L */
! 149: #define CR 0x0d /* Carriage return ^M */
! 150: #define ESC 0x1b /* Escape ^[ */
! 151: #define SP 0x20 /* Space */
1.1 root 152:
1.1.1.2 ! root 153: #endif
1.1 root 154:
1.1.1.2 ! root 155: #define CLREOL 256
1.1 root 156:
1.1.1.2 ! root 157: #ifndef uchar /* Short-hand for unsigned data types */
! 158: #define uchar unsigned char
! 159: #endif
! 160: #ifndef uint
! 161: #define uint unsigned int
! 162: #endif
! 163: #ifndef ulong
! 164: #define ulong unsigned long
! 165: #endif
1.1 root 166:
167:
168: typedef struct {
169: char left,top,right,bot,*buf;
170: } win_t;
171:
1.1.1.2 ! root 172:
1.1 root 173: /* LCLOLL.ASM */
174: int lclini(int);
175: void lclxy(int,int);
176: int lclwx(void);
177: int lclwy(void);
178: int lclatr(int);
179: void lputc(int);
180: long lputs(char far *);
181:
1.1.1.2 ! root 182: #if defined(__OS2__) || !defined(__FLAT__)
! 183: void mswait(int msecs);
! 184: extern mswtyp;
! 185: #endif
1.1 root 186:
187: extern char scrn_len,lclr,hclr,bclr,cclr,blk_scrn[MAX_BFLN],savdepth
1.1.1.2 ! root 188: ,changes,show_free_mem,savnum,uifc_status,*helpfile,*helpbuf
! 189: ,helpdatfile[256]
! 190: ,helpixbfile[256];
1.1 root 191: extern win_t sav[MAX_BUFS];
1.1.1.2 ! root 192: extern uint cursor,helpline;
1.1 root 193:
194: void uifcini(void);
1.1.1.2 ! root 195: int uscrn(char *str);
! 196: int ulist(int mode, char left, int top, char width, int *dflt, int *bar
! 197: ,char *title, char **option);
! 198: int uinput(int imode, char left, char top, char *prompt, char *str
! 199: ,char len ,int kmode);
! 200: int uprintf(char x, char y, char attr, char *fmt,...);
1.1 root 201: void umsg(char *str);
1.1.1.2 ! root 202: void upop(char *str);
! 203: int getstr(char *str, int maxlen, long mode);
1.1 root 204: void timedisplay();
205: void puttextinfo(struct text_info txt);
206: int lprintf(char *fmt,...);
207: char *timestr(time_t *intime);
1.1.1.2 ! root 208: void help(void);
! 209: void truncsp(char *str);
! 210: void uifcbail(void);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.