home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boldly Go Collection
/
version40.iso
/
TS
/
17A
/
DRWIN101.ZIP
/
WUTIL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1991-11-06
|
15KB
|
440 lines
#ifndef __WUTIL_H
#define __WUTIL_H
#if defined(M_I86SM)
#define __SMALL__
#endif
#if defined(M_I86CM)
#define __COMPACT__
#endif
#if defined(M_I86MM)
#define __MEDIUM__
#endif
#if defined(M_I86LM)
#define __LARGE__
#endif
#if defined(M_I86HM)
#define __HUGE__
#endif
#ifndef BYTE
#define BYTE unsigned char
#endif
#ifndef WORD
#define WORD unsigned int
#endif
#ifndef COLOR_POINTER
#define COLOR_POINTER (WORD far *)0xB8000000L
#endif
#ifndef MONO_POINTER
#define MONO_POINTER (WORD far *)0xB0000000L
#endif
#if !defined(__COLORS)
#define __COLORS
enum COLORS {
BLACK=0, /*dark colors*/
BLUE,
GREEN,
CYAN,
RED,
MAGENTA,
BROWN,
LIGHTGRAY,
DARKGRAY, /*light colors -- only foreground*/
LIGHTBLUE,
LIGHTGREEN,
LIGHTCYAN,
LIGHTRED,
LIGHTMAGENTA,
YELLOW,
WHITE
};
#endif /*if colors not already defined*/
#ifndef BLINK
#define BLINK 0x80
#endif
#define ATTR(fg,bg) ((fg)+((bg)<<4)) /*auto-shifter for attribute fg,bg*/
#define DEF_CSIZE 0x0607 /*default cursor size*/
#define NO_CURSOR 0xFFFF
typedef enum {
WCHAR=0,
WUCHAR,
WINT,
WUINT,
WLONG,
WULONG,
WFLOAT,
WDOUBLE,
WLDOUBLE,
WSTRING
} WTYPES;
#define WCHAR_FMT "%c"
#define WUCHAR_FMT "%02X"
#define WINT_FMT "%d"
#define WUINT_FMT "%04X"
#define WLONG_FMT "%ld"
#define WULONG_FMT "%08lX"
#define WFLOAT_FMT "%g"
#define WDOUBLE_FMT "%G"
#define WLDOUBLE_FMT "%LG"
#define WSTRING_FMT "%s"
typedef struct { /*field specifier for data entry*/
int r; /*row for field*/
int c; /*starting column for field*/
int w; /*width of field, 0=to end of row*/
WTYPES t; /*type of data*/
void *d; /*pointer to data*/
char *f; /*format for input/output of data*/
} WFIELD;
/****************************************************************************/
/* ASCII control characters... */
/****************************************************************************/
#ifndef __ASCII
#define __ASCII
#define NUL 0x00 /*null character*/
#define SOH 0x01 /*start of header*/
#define STX 0x02 /*start of text*/
#define ETX 0x03 /*end of text*/
#define EOT 0x04 /*end of transmission*/
#define ENQ 0x05 /*enquiry*/
#define ACK 0x06 /*acknowledge*/
#define BEL 0x07 /*bell, beep*/
#define BS 0x08 /*backspace*/
#define HT 0x09 /*horizontal tab*/
#define TAB 0x09 /*horizontal tab, common name*/
#define LF 0x0A /*linefeed*/
#define VT 0x0B /*vertical tab*/
#define FF 0x0C /*formfeed*/
#define CR 0x0D /*carriage return, enter*/
#define SO 0x0E /*shift out*/
#define SI 0x0F /*shift in*/
#define DC0 0x10 /*device control 0*/
#define DLE 0x10 /*data link escape*/
#define DC1 0x11 /*device control 1*/
#define XON 0x11 /*transmit on*/
#define DC2 0x12 /*device control 2*/
#define DC3 0x13 /*device control 3*/
#define XOFF 0x13 /*transmit off*/
#define DC4 0x14 /*device control 4*/
#define NAK 0x15 /*negative acknowledge*/
#define SYN 0x16 /*synchronous idle*/
#define ETB 0x17 /*end transmission block*/
#define CAN 0x18 /*cancel*/
#define EM 0x19 /*end of medium*/
#define SUB 0x1A /*substitute*/
#define ESC 0x1B /*escape*/
#define FS 0x1C /*file separator*/
#define GS 0x1D /*group separator*/
#define RS 0x1E /*record separator*/
#define US 0x1F /*unit separator*/
#define SPC 0x20 /*space, blank*/
#define DEL 0x7F /*delete character*/
#endif /*if ascii not already defined*/
/****************************************************************************/
/* The following special keys are returned by the getkey() function. */
/* The keys are simply the second (scan) code with 256 added. */
/****************************************************************************/
#ifndef __FKEYS
#define __FKEYS
#define A_ESC 0x0101
#define A_1 0x0178
#define A_2 0x0179
#define A_3 0x017A
#define A_4 0x017B
#define A_5 0x017C
#define A_6 0x017D
#define A_7 0x017E
#define A_8 0x017F
#define A_9 0x0180
#define A_0 0x0181
#define A_MINUS 0x0182 /*0x010C?*/
#define A_EQUAL 0x0183 /*0x010D?*/
#define A_BS 0x010E
#define S_TAB 0x010F
#define A_Q 0x0110
#define A_W 0x0111
#define A_E 0x0112
#define A_R 0x0113
#define A_T 0x0114
#define A_Y 0x0115
#define A_U 0x0116
#define A_I 0x0117
#define A_O 0x0118
#define A_P 0x0119
#define A_LTBRKT 0x011A
#define A_RTBRKT 0x011B
#define A_ENTER 0x011C
#define A_A 0x011E
#define A_S 0x011F
#define A_D 0x0120
#define A_F 0x0121
#define A_G 0x0122
#define A_H 0x0123
#define A_J 0x0124
#define A_K 0x0125
#define A_L 0x0126
#define A_SEMICOL 0x0127
#define A_QUOTE 0x0128
#define A_TILDE 0x0129
#define A_BSLASH 0x012B
#define _F11 0x01D9
#define _F12 0x01DA
#define S_F11 0x0187
#define S_F12 0x0188
#define C_F11 0x0189
#define C_F12 0x018A
#define A_F11 0x018B
#define A_F12 0x018C
#define A_Z 0x012C
#define A_X 0x012D
#define A_C 0x012E
#define A_V 0x012F
#define A_B 0x0130
#define A_N 0x0131
#define A_M 0x0132
#define A_COMMA 0x0133
#define A_PERIOD 0x0134
#define A_SLASH 0x0135
#define A_TAB 0x01A5
#define _F1 0x013B
#define _F2 0x013C
#define _F3 0x013D
#define _F4 0x013E
#define _F5 0x013F
#define _F6 0x0140
#define _F7 0x0141
#define _F8 0x0142
#define _F9 0x0143
#define _F10 0x0144
#define _HOME 0x0147
#define _UPAR 0x0148
#define _PGUP 0x0149
#define _LTAR 0x014B
#define _RTAR 0x014D
#define _END 0x014F
#define _DNAR 0x0150
#define _PGDN 0x0151
#define _INS 0x0152
#define _DEL 0x0153
#define S_F1 0x0154
#define S_F2 0x0155
#define S_F3 0x0156
#define S_F4 0x0157
#define S_F5 0x0158
#define S_F6 0x0159
#define S_F7 0x015A
#define S_F8 0x015B
#define S_F9 0x015C
#define S_F10 0x015D
#define C_F1 0x015E
#define C_F2 0x015F
#define C_F3 0x0160
#define C_F4 0x0161
#define C_F5 0x0162
#define C_F6 0x0163
#define C_F7 0x0164
#define C_F8 0x0165
#define C_F9 0x0166
#define C_F10 0x0167
#define A_F1 0x0168
#define A_F2 0x0169
#define A_F3 0x016A
#define A_F4 0x016B
#define A_F5 0x016C
#define A_F6 0x016D
#define A_F7 0x016E
#define A_F8 0x016F
#define A_F9 0x0170
#define A_F10 0x0171
#define C_PRTSC 0x0172
#define C_LTAR 0x0173
#define C_RTAR 0x0174
#define C_END 0x0175
#define C_PGDN 0x0176
#define C_HOME 0x0177
#define C_PGUP 0x0184 /*0x0178?*/
#define C_A 0x01
#define C_B 0x02
#define C_C 0x03
#define C_D 0x04
#define C_E 0x05
#define C_F 0x06
#define C_G 0x07
#define C_H 0x08
#define C_I 0x09
#define C_J 0x0A
#define C_K 0x0B
#define C_L 0x0C
#define C_M 0x0D
#define C_N 0x0E
#define C_O 0x0F
#define C_P 0x10
#define C_Q 0x11
#define C_R 0x12
#define C_S 0x13
#define C_T 0x14
#define C_U 0x15
#define C_V 0x16
#define C_W 0x17
#define C_X 0x18
#define C_Y 0x19
#define C_Z 0x1A
#endif /*if keys not already defined*/
/****************************************************************************/
/* The following are the text graphics characters of the IBM extended */
/* ASCII code. The following letters are used to describe each value: */
/* S=single D=double T=top L=left R=right B=bot H=horiz V=vert M=middle */
/****************************************************************************/
#define _STL 0xDA
#define _SH 0xC4
#define _ST 0xC2
#define _STR 0xBF
#define _SV 0xB3
#define _SL 0xC3
#define _SM 0xC5
#define _SR 0xB4
#define _SBL 0xC0
#define _SB 0xC1
#define _SBR 0xD9
#define _DTL 0xC9
#define _DH 0xCD
#define _DT 0xCB
#define _DTR 0xBB
#define _DV 0xBA
#define _DL 0xCC
#define _DM 0xCE
#define _DR 0xB9
#define _DBL 0xC8
#define _DB 0xCA
#define _DBR 0xBC
#define _DSTL 0xD5
#define _DST 0xD1
#define _DSTR 0xB8
#define _DSL 0xC6
#define _DSM 0xD8
#define _DSR 0xB5
#define _DSBL 0xD4
#define _DSB 0xCF
#define _DSBR 0xBE
#define _SDTL 0xD6
#define _SDT 0xD2
#define _SDTR 0xB7
#define _SDL 0xC7
#define _SDM 0xD7
#define _SDR 0xB6
#define _SDBL 0xD3
#define _SDB 0xD0
#define _SDBR 0xBD
/****************************************************************************/
/* structures and typedefs... */
/****************************************************************************/
typedef struct {
WORD wrap:1; /*wrap at end of line?*/
WORD scroll:1; /*scrolling on?*/
WORD moves:1; /*window movement allowed in wgetch()*/
WORD sizes:1; /*window resizing allowed in wgetch()*/
WORD alive:1; /*display window flag*/
WORD saved:1; /*saved when wsetDOSscr called*/
WORD showcr:1; /*show CR character*/
WORD showlf:1; /*show LF character*/
WORD showbs:1; /*show BS character*/
} wflags;
typedef struct w_struct {
WORD rows; /*rows in window*/
WORD cols; /*columns in window*/
WORD srow; /*starting row for screen display*/
WORD scol; /*starting column for screen*/
WORD row; /*row of cursor in window*/
WORD col; /*column of cursor in window*/
WORD csiz; /*cursor size*/
WORD attr; /*current attribute on screen*/
WORD fchr; /*fill character for clearing*/
WORD bord; /*border type (0,1 or 2 lines)*/
WORD battr; /*border attribute*/
char *prompt; /*set prompt pointer*/
wflags fl; /*various flags for window*/
struct w_struct *wprv; /*previous window in linked list*/
struct w_struct *wnxt; /*next window in linked list*/
WORD wtxt[1]; /*dummy text, made bigger by malloc*/
} WIND;
int winit(void); /*initialize windowing environment*/
void wvscr(void); /*copy virtual to real screen*/
void wupdate(WIND *w); /*updates screen -- rewrites*/
void wpurge(void); /*purges all windows, closes environ*/
void wclose(WIND *w); /*closes a given window*/
WIND *wopen(WORD bord,char *p,WORD sr,WORD sc,WORD rows,WORD cols,WORD attr);
WORD wgetcrow(WIND *w);
WORD wgetccol(WIND *w);
WORD wgetcsiz(WIND *w);
void wsetcpos(WIND *w,WORD row,WORD col);
void wsetcsiz(WIND *w,WORD siz);
void wfcolor(WIND *w,WORD color); /*sets foreground color for window*/
void wbcolor(WIND *w,WORD color); /*sets background color for window*/
WORD wsetattr(WIND* w,WORD attr); /*sets attribute, returns old*/
WORD wgetattr(WIND *w); /*gets entire attribute*/
void wclr(WIND *w); /*clears entire window,resets cursor*/
void wclrbor(WIND *w); /*clears from beginning of row to curs*/
void wclreor(WIND *w); /*clears from cursor to end of row*/
void wclrbow(WIND *w); /*clears from beginning of window*/
void wclreow(WIND *w); /*clears to end of window*/
void wfront(WIND *w); /*brings window to front/top*/
void wback(WIND *w); /*pushes window to back/bottom*/
void whide(WIND *w); /*pushes to back and hides*/
void wsetDOSscr(void); /*bring up base (DOS) window, hide all*/
void wgetDOSscr(void); /*restore after wsetDOSscr*/
void wdelrow(WIND *w); /*deletes current row of window*/
void winsrow(WIND *w); /*inserts row at current row of window*/
void wputc(WIND *w,int c); /*puts a character out to the window*/
void wputs(WIND *w,char *s); /*puts a string to window*/
void wputns(WIND *w,char *s,int n); //writes n chars to window
void wputrcs(WIND *w,WORD r,WORD c,char *s); /*puts to window location*/
void cdecl wprintf(WIND *w,char *fmt,...); //formatted print to window
int wgetc(WIND *w); /*gets a character from a window*/
int wgetce(WIND *w); /*gets char and echoes it to window*/
int wgets(WIND *w,char *s,int n); /*gets a string (max n-1 chars)*/
int wgetsfield(WIND *ww,char *s,int n,int w,WORD a); /*gets s w/edit*/
int wgetfields(WIND *w,WFIELD *f,int nf,WORD a); /*gets info from fields*/
int wfile(WIND *w,char *fn); /*displays a text file*/
int hotlen(char* s,char hotkey); /*length of a string, less hotkeys*/
void wputshot(WIND* w,char *s,WORD hat,char hotkey); /*put out hotkeys str*/
extern char winitd; /*flag for windows initialization*/
extern char wupd; /*flag for updating*/
extern char wcga; /*flag for checking for CGA snow*/
extern WORD *vscr; /*pointer to virtual screen*/
extern WORD far *vidp; /*pointer to video segment*/
extern WIND *wscr; /*original screen, base window*/
extern WIND *wact; /*current active window pointer*/
#endif /* wutil already loaded */