1 /*	SCCS Id: @(#)wintty.h	3.4	1996/02/18	*/
2 /* Copyright (c) David Cohrs, 1991,1992				  */
3 /* NetHack may be freely redistributed.  See license for details. */
4 
5 #ifndef WINTTY_H
6 #define WINTTY_H
7 
8 #define E extern
9 
10 #ifndef WINDOW_STRUCTS
11 #define WINDOW_STRUCTS
12 
13 /* menu structure */
14 typedef struct tty_mi {
15     struct tty_mi *next;
16     anything identifier;	/* user identifier */
17     long count;			/* user count */
18     long maxcount;		/* maximum user count */
19     char *str;			/* description string (including accelerator) */
20     int attr;			/* string attribute */
21     boolean selected;		/* TRUE if selected by user */
22     char selector;		/* keyboard accelerator */
23     char gselector;		/* group accelerator */
24     glyph_t glyph;		/* glyph display in menu */
25 } tty_menu_item;
26 
27 /* descriptor for tty-based windows */
28 struct WinDesc {
29     int flags;			/* window flags */
30     xchar type;			/* type of window */
31     boolean active;		/* true if window is active */
32     uchar offx, offy;		/* offset from topleft of display */
33     long rows, cols;		/* dimensions */
34     long curx, cury;		/* current cursor position */
35     long maxrow, maxcol;	/* the maximum size used -- for MENU wins */
36 				/* maxcol is also used by WIN_MESSAGE for */
37 				/* tracking the ^P command */
38     short *datlen;		/* allocation size for *data */
39     char **data;		/* window data [row][column] */
40     char *morestr;		/* string to display instead of default */
41     tty_menu_item *mlist;	/* menu information (MENU) */
42     tty_menu_item **plist;	/* menu page pointers (MENU) */
43     long plist_size;		/* size of allocated plist (MENU) */
44     long npages;		/* number of pages in menu (MENU) */
45     long nitems;		/* total number of items (MENU) */
46     short how;			/* menu mode - pick 1 or N (MENU) */
47     char menu_ch;		/* menu char (MENU) */
48 };
49 
50 /* window flags */
51 #define WIN_CANCELLED 1
52 #define WIN_STOP 1		/* for NHW_MESSAGE; stops output */
53 
54 /* descriptor for tty-based displays -- all the per-display data */
55 struct DisplayDesc {
56     uchar rows, cols;		/* width and height of tty display */
57     uchar curx, cury;		/* current cursor position on the screen */
58 #ifdef TEXTCOLOR
59     int color;			/* current color */
60 #endif
61     int attrs;			/* attributes in effect */
62     int toplin;			/* flag for topl stuff */
63     int rawprint;		/* number of raw_printed lines since synch */
64     int inmore;			/* non-zero if more() is active */
65     int inread;			/* non-zero if reading a character */
66     int intr;			/* non-zero if inread was interrupted */
67     winid lastwin;		/* last window used for I/O */
68     char dismiss_more;		/* extra character accepted at --More-- */
69 };
70 
71 #endif /* WINDOW_STRUCTS */
72 
73 #define MAXWIN 20		/* maximum number of windows, cop-out */
74 
75 /* tty dependent window types */
76 #ifdef NHW_BASE
77 #undef NHW_BASE
78 #endif
79 #define NHW_BASE    6
80 
81 extern struct window_procs tty_procs;
82 
83 /* port specific variable declarations */
84 extern winid BASE_WINDOW;
85 
86 extern struct WinDesc *wins[MAXWIN];
87 
88 extern struct DisplayDesc *ttyDisplay;	/* the tty display descriptor */
89 
90 extern char morc;		/* last character typed to xwaitforspace */
91 extern char defmorestr[];	/* default --more-- prompt */
92 
93 /* port specific external function references */
94 
95 /* ### getline.c ### */
96 E void FDECL(xwaitforspace, (const char *));
97 
98 /* ### termcap.c, video.c ### */
99 
100 E void FDECL(tty_startup,(int*, int*));
101 #ifndef NO_TERMS
102 E void NDECL(tty_shutdown);
103 #endif
104 #if defined(apollo)
105 /* Apollos don't widen old-style function definitions properly -- they try to
106  * be smart and use the prototype, or some such strangeness.  So we have to
107  * define UNWIDENDED_PROTOTYPES (in tradstdc.h), which makes CHAR_P below a
108  * char.  But the tputs termcap call was compiled as if xputc's argument
109  * actually would be expanded.	So here, we have to make an exception. */
110 E void FDECL(xputc, (int));
111 #else
112 E void FDECL(xputc, (CHAR_P));
113 #endif
114 E void FDECL(xputs, (const char *));
115 #if defined(SCREEN_VGA) || defined(SCREEN_8514)
116 E void FDECL(xputg, (int, int, unsigned));
117 #endif
118 E void NDECL(cl_end);
119 E void NDECL(clear_screen);
120 E void NDECL(home);
121 E void NDECL(standoutbeg);
122 E void NDECL(standoutend);
123 # if 0
124 E void NDECL(revbeg);
125 E void NDECL(boldbeg);
126 E void NDECL(blinkbeg);
127 E void NDECL(dimbeg);
128 E void NDECL(m_end);
129 # endif
130 E void NDECL(backsp);
131 E void NDECL(graph_on);
132 E void NDECL(graph_off);
133 E void NDECL(cl_eos);
134 
135 /*
136  * termcap.c (or facsimiles in other ports) is the right place for doing
137  * strange and arcane things such as outputting escape sequences to select
138  * a color or whatever.  wintty.c should concern itself with WHERE to put
139  * stuff in a window.
140  */
141 E void FDECL(term_start_attr,(int attr));
142 E void FDECL(term_end_attr,(int attr));
143 E void NDECL(term_start_raw_bold);
144 E void NDECL(term_end_raw_bold);
145 
146 #ifdef TEXTCOLOR
147 E void NDECL(term_end_color);
148 E void FDECL(term_start_color,(int color));
149 E int FDECL(has_color,(int color));
150 #endif /* TEXTCOLOR */
151 
152 #ifdef STATUS_COLORS
153 E boolean FDECL(parse_status_color_options, (char *));
154 #endif /* STATUS_COLOR */
155 
156 /* ### topl.c ### */
157 
158 E void FDECL(addtopl, (const char *));
159 E void NDECL(more);
160 E void FDECL(update_topl, (const char *));
161 E void FDECL(putsyms, (const char*));
162 
163 /* ### wintty.c ### */
164 #ifdef CLIPPING
165 E void NDECL(setclipped);
166 #endif
167 E void FDECL(docorner, (int, int));
168 E void NDECL(end_glyphout);
169 E void FDECL(g_putch, (int));
170 E void NDECL(win_tty_init);
171 
172 /* external declarations */
173 E void FDECL(tty_init_nhwindows, (int *, char **));
174 E void NDECL(tty_player_selection);
175 E void NDECL(tty_askname);
176 E void NDECL(tty_get_nh_event) ;
177 E void FDECL(tty_exit_nhwindows, (const char *));
178 E void FDECL(tty_suspend_nhwindows, (const char *));
179 E void NDECL(tty_resume_nhwindows);
180 E winid FDECL(tty_create_nhwindow, (int));
181 E void FDECL(tty_clear_nhwindow, (winid));
182 E void FDECL(tty_display_nhwindow, (winid, BOOLEAN_P));
183 E void FDECL(tty_dismiss_nhwindow, (winid));
184 E void FDECL(tty_destroy_nhwindow, (winid));
185 E void FDECL(tty_curs, (winid,int,int));
186 E void FDECL(tty_putstr, (winid, int, const char *));
187 #ifdef FILE_AREAS
188 E void FDECL(tty_display_file, (const char *, const char *, BOOLEAN_P));
189 #else
190 E void FDECL(tty_display_file, (const char *, BOOLEAN_P));
191 #endif
192 E void FDECL(tty_start_menu, (winid));
193 E void FDECL(tty_add_menu, (winid,int,int,const ANY_P *,
194 			CHAR_P,CHAR_P,int,const char *, BOOLEAN_P));
195 E void FDECL(tty_end_menu, (winid, const char *));
196 E int FDECL(tty_select_menu, (winid, int, MENU_ITEM_P **));
197 E char FDECL(tty_message_menu, (CHAR_P,int,const char *));
198 E void NDECL(tty_update_inventory);
199 E void NDECL(tty_mark_synch);
200 E void NDECL(tty_wait_synch);
201 #ifdef CLIPPING
202 E void FDECL(tty_cliparound, (int, int));
203 #endif
204 #ifdef POSITIONBAR
205 E void FDECL(tty_update_positionbar, (char *));
206 #endif
207 E void FDECL(tty_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
208 E void FDECL(tty_raw_print, (const char *));
209 E void FDECL(tty_raw_print_bold, (const char *));
210 E int NDECL(tty_nhgetch);
211 E int FDECL(tty_nh_poskey, (int *, int *, int *));
212 E void NDECL(tty_nhbell);
213 E int NDECL(tty_doprev_message);
214 E char FDECL(tty_yn_function, (const char *, const char *, CHAR_P));
215 E void FDECL(tty_getlin, (const char *,char *));
216 E int NDECL(tty_get_ext_cmd);
217 E void FDECL(tty_number_pad, (int));
218 E void NDECL(tty_delay_output);
219 #ifdef CHANGE_COLOR
220 E void FDECL(tty_change_color,(int color,long rgb,int reverse));
221 #ifdef MAC
222 E void FDECL(tty_change_background,(int white_or_black));
223 E short FDECL(set_tty_font_name, (winid, char *));
224 #endif
225 E char * NDECL(tty_get_color_string);
226 #endif
227 
228 /* other defs that really should go away (they're tty specific) */
229 E void NDECL(tty_start_screen);
230 E void NDECL(tty_end_screen);
231 
232 E void FDECL(genl_outrip, (winid,int));
233 
234 #ifdef NO_TERMS
235 # ifdef MAC
236 #  ifdef putchar
237 #   undef putchar
238 #   undef putc
239 #  endif
240 #  define putchar term_putc
241 #  define fflush term_flush
242 #  define puts term_puts
243 E int FDECL(term_putc, (int c));
244 E int FDECL(term_flush, (void *desc));
245 E int FDECL(term_puts, (const char *str));
246 # endif /* MAC */
247 # if defined(MSDOS) || defined(WIN32CON)
248 #  if defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST) || defined(WIN32CON)
249 #   undef putchar
250 #   undef putc
251 #   undef puts
252 #   define putchar(x) xputc(x)	/* these are in video.c, nttty.c */
253 #   define putc(x) xputc(x)
254 #   define puts(x) xputs(x)
255 #  endif/*SCREEN_BIOS || SCREEN_DJGPPFAST || WIN32CON */
256 #  ifdef POSITIONBAR
257 E void FDECL(video_update_positionbar, (char *));
258 #  endif
259 # endif/*MSDOS*/
260 #endif/*NO_TERMS*/
261 
262 #undef E
263 
264 #endif /* WINTTY_H */
265