1 /* NetHack 3.6 winprocs.h $NHDT-Date: 1567213890 2019/08/31 01:11:30 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.50 $ */
2 /* Copyright (c) David Cohrs, 1992 */
3 /* NetHack may be freely redistributed. See license for details. */
10 /* NB: this MUST match chain_procs below */
12 const char *name; /* Names should start with [a-z]. Names must
13 * not start with '-'. Names starting with
14 * '+' are reserved for processors. */
15 unsigned long wincap; /* window port capability options supported */
16 unsigned long wincap2; /* additional window port capability options */
17 boolean has_color[CLR_MAX];
18 void FDECL((*win_init_nhwindows), (int *, char **));
19 void NDECL((*win_player_selection));
20 void NDECL((*win_askname));
21 void NDECL((*win_get_nh_event));
22 void FDECL((*win_exit_nhwindows), (const char *));
23 void FDECL((*win_suspend_nhwindows), (const char *));
24 void NDECL((*win_resume_nhwindows));
25 winid FDECL((*win_create_nhwindow), (int));
26 void FDECL((*win_clear_nhwindow), (winid));
27 void FDECL((*win_display_nhwindow), (winid, BOOLEAN_P));
28 void FDECL((*win_destroy_nhwindow), (winid));
29 void FDECL((*win_curs), (winid, int, int));
30 void FDECL((*win_putstr), (winid, int, const char *));
31 void FDECL((*win_putmixed), (winid, int, const char *));
32 void FDECL((*win_display_file), (const char *, BOOLEAN_P));
33 void FDECL((*win_start_menu), (winid));
34 void FDECL((*win_add_menu), (winid, int, const ANY_P *, CHAR_P, CHAR_P,
35 int, const char *, BOOLEAN_P));
36 void FDECL((*win_end_menu), (winid, const char *));
37 int FDECL((*win_select_menu), (winid, int, MENU_ITEM_P **));
38 char FDECL((*win_message_menu), (CHAR_P, int, const char *));
39 void NDECL((*win_update_inventory));
40 void NDECL((*win_mark_synch));
41 void NDECL((*win_wait_synch));
43 void FDECL((*win_cliparound), (int, int));
46 void FDECL((*win_update_positionbar), (char *));
48 void FDECL((*win_print_glyph), (winid, XCHAR_P, XCHAR_P, int, int));
49 void FDECL((*win_raw_print), (const char *));
50 void FDECL((*win_raw_print_bold), (const char *));
51 int NDECL((*win_nhgetch));
52 int FDECL((*win_nh_poskey), (int *, int *, int *));
53 void NDECL((*win_nhbell));
54 int NDECL((*win_doprev_message));
55 char FDECL((*win_yn_function), (const char *, const char *, CHAR_P));
56 void FDECL((*win_getlin), (const char *, char *));
57 int NDECL((*win_get_ext_cmd));
58 void FDECL((*win_number_pad), (int));
59 void NDECL((*win_delay_output));
61 void FDECL((*win_change_color), (int, long, int));
63 void FDECL((*win_change_background), (int));
64 short FDECL((*win_set_font_name), (winid, char *));
66 char *NDECL((*win_get_color_string));
69 /* other defs that really should go away (they're tty specific) */
70 void NDECL((*win_start_screen));
71 void NDECL((*win_end_screen));
73 void FDECL((*win_outrip), (winid, int, time_t));
74 void FDECL((*win_preference_update), (const char *));
75 char *FDECL((*win_getmsghistory), (BOOLEAN_P));
76 void FDECL((*win_putmsghistory), (const char *, BOOLEAN_P));
77 void NDECL((*win_status_init));
78 void NDECL((*win_status_finish));
79 void FDECL((*win_status_enablefield),
80 (int, const char *, const char *, BOOLEAN_P));
81 void FDECL((*win_status_update), (int, genericptr_t, int, int, int, unsigned long *));
82 boolean NDECL((*win_can_suspend));
89 NEARDATA struct window_procs windowprocs;
92 * If you wish to only support one window system and not use procedure
93 * pointers, add the appropriate #ifdef below.
96 #define init_nhwindows (*windowprocs.win_init_nhwindows)
97 #define player_selection (*windowprocs.win_player_selection)
98 #define askname (*windowprocs.win_askname)
99 #define get_nh_event (*windowprocs.win_get_nh_event)
100 #define exit_nhwindows (*windowprocs.win_exit_nhwindows)
101 #define suspend_nhwindows (*windowprocs.win_suspend_nhwindows)
102 #define resume_nhwindows (*windowprocs.win_resume_nhwindows)
103 #define create_nhwindow (*windowprocs.win_create_nhwindow)
104 #define clear_nhwindow (*windowprocs.win_clear_nhwindow)
105 #define display_nhwindow (*windowprocs.win_display_nhwindow)
106 #define destroy_nhwindow (*windowprocs.win_destroy_nhwindow)
107 #define curs (*windowprocs.win_curs)
108 #define putstr (*windowprocs.win_putstr)
109 #define putmixed (*windowprocs.win_putmixed)
110 #define display_file (*windowprocs.win_display_file)
111 #define start_menu (*windowprocs.win_start_menu)
112 #define add_menu (*windowprocs.win_add_menu)
113 #define end_menu (*windowprocs.win_end_menu)
114 #define select_menu (*windowprocs.win_select_menu)
115 #define message_menu (*windowprocs.win_message_menu)
117 #define mark_synch (*windowprocs.win_mark_synch)
118 #define wait_synch (*windowprocs.win_wait_synch)
120 #define cliparound (*windowprocs.win_cliparound)
123 #define update_positionbar (*windowprocs.win_update_positionbar)
125 #define print_glyph (*windowprocs.win_print_glyph)
126 #define raw_print (*windowprocs.win_raw_print)
127 #define raw_print_bold (*windowprocs.win_raw_print_bold)
128 #define nhgetch (*windowprocs.win_nhgetch)
129 #define nh_poskey (*windowprocs.win_nh_poskey)
130 #define nhbell (*windowprocs.win_nhbell)
131 #define nh_doprev_message (*windowprocs.win_doprev_message)
132 #define getlin (*windowprocs.win_getlin)
133 #define get_ext_cmd (*windowprocs.win_get_ext_cmd)
134 #define number_pad (*windowprocs.win_number_pad)
135 #define delay_output (*windowprocs.win_delay_output)
137 #define change_color (*windowprocs.win_change_color)
139 #define change_background (*windowprocs.win_change_background)
140 #define set_font_name (*windowprocs.win_set_font_name)
142 #define get_color_string (*windowprocs.win_get_color_string)
145 /* 3.4.2: There is a real yn_function() in the core now, which does
146 * some buffer length validation on the parameters prior to
147 * invoking the window port routine. yn_function() is in cmd.c
149 /* #define yn_function (*windowprocs.win_yn_function) */
151 /* other defs that really should go away (they're tty specific) */
152 #define start_screen (*windowprocs.win_start_screen)
153 #define end_screen (*windowprocs.win_end_screen)
155 #define outrip (*windowprocs.win_outrip)
156 #define preference_update (*windowprocs.win_preference_update)
157 #define getmsghistory (*windowprocs.win_getmsghistory)
158 #define putmsghistory (*windowprocs.win_putmsghistory)
159 /* there is a status_initialize() in botl.c,
160 * which calls win_status_init() directly; same with status_finish.
162 #define status_enablefield (*windowprocs.win_status_enablefield)
163 #define status_update (*windowprocs.win_status_update)
167 * Window port preference capability bits.
168 * Some day this might be better in its own wincap.h file.
170 /* clang-format off */
171 #define WC_COLOR 0x00000001L /* 01 Port can display things in color */
172 #define WC_HILITE_PET 0x00000002L /* 02 supports hilite pet */
173 #define WC_ASCII_MAP 0x00000004L /* 03 supports an ascii map */
174 #define WC_TILED_MAP 0x00000008L /* 04 supports a tiled map */
175 #define WC_PRELOAD_TILES 0x00000010L /* 05 supports pre-loading tiles */
176 #define WC_TILE_WIDTH 0x00000020L /* 06 prefer this width of tile */
177 #define WC_TILE_HEIGHT 0x00000040L /* 07 prefer this height of tile */
178 #define WC_TILE_FILE 0x00000080L /* 08 alternative tile file name */
179 #define WC_INVERSE 0x00000100L /* 09 Port supports inverse video */
180 #define WC_ALIGN_MESSAGE 0x00000200L /* 10 supports mesg alignment top|b|l|r */
181 #define WC_ALIGN_STATUS 0x00000400L /* 11 supports status alignmt top|b|l|r */
182 #define WC_VARY_MSGCOUNT 0x00000800L /* 12 supports varying message window */
183 #define WC_FONT_MAP 0x00001000L /* 13 supports spec of map window font */
184 #define WC_FONT_MESSAGE 0x00002000L /* 14 supports spec of message font */
185 #define WC_FONT_STATUS 0x00004000L /* 15 supports spec of status font */
186 #define WC_FONT_MENU 0x00008000L /* 16 supports spec of menu font */
187 #define WC_FONT_TEXT 0x00010000L /* 17 supports spec of text window font */
188 #define WC_FONTSIZ_MAP 0x00020000L /* 18 supports spec of map font size */
189 #define WC_FONTSIZ_MESSAGE 0x040000L /* 19 supports spec of mesg font size */
190 #define WC_FONTSIZ_STATUS 0x0080000L /* 20 supports spec of status font size */
191 #define WC_FONTSIZ_MENU 0x00100000L /* 21 supports spec of menu font size */
192 #define WC_FONTSIZ_TEXT 0x00200000L /* 22 supports spec of text font size */
193 #define WC_SCROLL_MARGIN 0x00400000L /* 23 supports setting map scroll marg */
194 #define WC_SPLASH_SCREEN 0x00800000L /* 24 supports display of splash screen */
195 #define WC_POPUP_DIALOG 0x01000000L /* 25 supports queries in popup dialogs */
196 #define WC_SCROLL_AMOUNT 0x02000000L /* 26 scroll this amount at scroll marg */
197 #define WC_EIGHT_BIT_IN 0x04000000L /* 27 8-bit character input */
198 #define WC_PERM_INVENT 0x08000000L /* 28 supports persistent inventory win */
199 #define WC_MAP_MODE 0x10000000L /* 29 map_mode option */
200 #define WC_WINDOWCOLORS 0x20000000L /* 30 background color for mesg window */
201 #define WC_PLAYER_SELECTION 0x40000000L /* 31 supports player selection */
203 #define WC_MOUSE_SUPPORT 0x80000000UL /* 32 mouse support */
205 #define WC_MOUSE_SUPPORT 0x80000000L /* 32 mouse support */
209 #define WC2_FULLSCREEN 0x0001L /* 01 display full screen */
210 #define WC2_SOFTKEYBOARD 0x0002L /* 02 software keyboard */
211 #define WC2_WRAPTEXT 0x0004L /* 03 wrap long lines of text */
212 #define WC2_HILITE_STATUS 0x0008L /* 04 hilite fields in status */
213 #define WC2_SELECTSAVED 0x0010L /* 05 saved game selection menu */
214 #define WC2_DARKGRAY 0x0020L /* 06 use bold black for black glyphs */
215 #define WC2_HITPOINTBAR 0x0040L /* 07 show bar representing hit points */
216 #define WC2_FLUSH_STATUS 0x0080L /* 08 call status_update(BL_FLUSH)
217 * after updating status window fields */
218 #define WC2_RESET_STATUS 0x0100L /* 09 call status_update(BL_RESET) to
219 * indicate 'draw everything' */
220 #define WC2_TERM_SIZE 0x0200L /* 10 support setting terminal size */
221 #define WC2_STATUSLINES 0x0400L /* 16 switch between 2 or 3 lines of status */
222 #define WC2_WINDOWBORDERS 0x0800L /* 11 display borders on nh windows */
223 #define WC2_PETATTR 0x1000L /* 12 attributes for hilite_pet */
224 #define WC2_GUICOLOR 0x2000L /* 13 display colours outside map win */
225 /* pline() can overload the display attributes argument passed to putstr()
226 with one or more flags and at most one of bold/blink/inverse/&c */
227 #define WC2_URGENT_MESG 0x4000L /* 14 putstr(WIN_MESSAGE) supports urgency
228 * via non-display attribute flag */
229 #define WC2_SUPPRESS_HIST 0x8000L /* 15 putstr(WIN_MESSAGE) supports history
230 * suppression via non-disp attr */
234 #define ALIGN_RIGHT 2
236 #define ALIGN_BOTTOM 4
238 /* player_selection */
240 #define VIA_PROMPTS 1
242 /* map_mode settings - deprecated */
243 #define MAP_MODE_TILES 0
244 #define MAP_MODE_ASCII4x6 1
245 #define MAP_MODE_ASCII6x8 2
246 #define MAP_MODE_ASCII8x8 3
247 #define MAP_MODE_ASCII16x8 4
248 #define MAP_MODE_ASCII7x12 5
249 #define MAP_MODE_ASCII8x12 6
250 #define MAP_MODE_ASCII16x12 7
251 #define MAP_MODE_ASCII12x16 8
252 #define MAP_MODE_ASCII10x18 9
253 #define MAP_MODE_ASCII_FIT_TO_SCREEN 10
254 #define MAP_MODE_TILES_FIT_TO_SCREEN 11
257 #define WC_SND_SOUND 0x0001L /* 01 Port has some sound capabilities */
258 #define WC_SND_SPEAKER 0x0002L /* 02 Sound supported via built-in speaker */
259 #define WC_SND_STEREO 0x0004L /* 03 Stereo sound supported */
260 #define WC_SND_RAW 0x0008L /* 04 Raw sound supported */
261 #define WC_SND_WAVE 0x0010L /* 05 Wave support */
262 #define WC_SND_MIDI 0x0020L /* 06 Midi support */
268 unsigned long wc_bit;
271 /* Macro for the currently active Window Port whose function
272 pointers have been loaded */
273 #define WINDOWPORT(wn) \
274 (windowprocs.name && !strncmpi((wn), windowprocs.name, strlen((wn))))
276 /* role selection by player_selection(); this ought to be in the core... */
283 #define RS_menu_arg(x) (ROLE_RANDOM - ((x) + 1)) /* 0..5 -> -3..-8 */
285 /* Choose_windows() may be called multiple times; these constants tell the
286 * init function whether the window system is coming or going. */
288 #define WININIT_UNDO 1
291 /* Setup phases for window chain elements.
292 void * rv = X_procs_chain(int, int, void *, void *, void *);
293 Xprivate* ALLOC n 0 0 0
294 - INIT n self next nextdata
296 Xprivate* is anything window chain entry type X wants back
297 n is the link count (starting with 1)
298 self is the Xprivate* returned earlier
299 next is struct winprocs * or struct chainprocs * for the next link
300 nextdata is the Xprivate* for the next link in the chain
302 #define WINCHAIN_ALLOC 0
303 #define WINCHAIN_INIT 1
305 /* clang-format on */
309 extern FILE *wc_tracelogf; /* Expose log file for additional debugging. */
312 const char *name; /* Names should start with [a-z]. Names must
313 * not start with '-'. Names starting with
314 * '+' are reserved for processors. */
315 unsigned long wincap; /* window port capability options supported */
316 unsigned long wincap2; /* additional window port capability options */
317 void FDECL((*win_init_nhwindows), (CARGS, int *, char **));
318 void FDECL((*win_player_selection), (CARGS));
319 void FDECL((*win_askname), (CARGS));
320 void FDECL((*win_get_nh_event), (CARGS));
321 void FDECL((*win_exit_nhwindows), (CARGS, const char *));
322 void FDECL((*win_suspend_nhwindows), (CARGS, const char *));
323 void FDECL((*win_resume_nhwindows), (CARGS));
324 winid FDECL((*win_create_nhwindow), (CARGS, int));
325 void FDECL((*win_clear_nhwindow), (CARGS, winid));
326 void FDECL((*win_display_nhwindow), (CARGS, winid, BOOLEAN_P));
327 void FDECL((*win_destroy_nhwindow), (CARGS, winid));
328 void FDECL((*win_curs), (CARGS, winid, int, int));
329 void FDECL((*win_putstr), (CARGS, winid, int, const char *));
330 void FDECL((*win_putmixed), (CARGS, winid, int, const char *));
331 void FDECL((*win_display_file), (CARGS, const char *, BOOLEAN_P));
332 void FDECL((*win_start_menu), (CARGS, winid));
333 void FDECL((*win_add_menu), (CARGS, winid, int, const ANY_P *, CHAR_P,
334 CHAR_P, int, const char *, BOOLEAN_P));
335 void FDECL((*win_end_menu), (CARGS, winid, const char *));
336 int FDECL((*win_select_menu), (CARGS, winid, int, MENU_ITEM_P **));
337 char FDECL((*win_message_menu), (CARGS, CHAR_P, int, const char *));
338 void FDECL((*win_update_inventory), (CARGS));
339 void FDECL((*win_mark_synch), (CARGS));
340 void FDECL((*win_wait_synch), (CARGS));
342 void FDECL((*win_cliparound), (CARGS, int, int));
345 void FDECL((*win_update_positionbar), (CARGS, char *));
347 void FDECL((*win_print_glyph), (CARGS, winid, XCHAR_P, XCHAR_P, int, int));
348 void FDECL((*win_raw_print), (CARGS, const char *));
349 void FDECL((*win_raw_print_bold), (CARGS, const char *));
350 int FDECL((*win_nhgetch), (CARGS));
351 int FDECL((*win_nh_poskey), (CARGS, int *, int *, int *));
352 void FDECL((*win_nhbell), (CARGS));
353 int FDECL((*win_doprev_message), (CARGS));
354 char FDECL((*win_yn_function),
355 (CARGS, const char *, const char *, CHAR_P));
356 void FDECL((*win_getlin), (CARGS, const char *, char *));
357 int FDECL((*win_get_ext_cmd), (CARGS));
358 void FDECL((*win_number_pad), (CARGS, int));
359 void FDECL((*win_delay_output), (CARGS));
361 void FDECL((*win_change_color), (CARGS, int, long, int));
363 void FDECL((*win_change_background), (CARGS, int));
364 short FDECL((*win_set_font_name), (CARGS, winid, char *));
366 char *FDECL((*win_get_color_string), (CARGS));
369 /* other defs that really should go away (they're tty specific) */
370 void FDECL((*win_start_screen), (CARGS));
371 void FDECL((*win_end_screen), (CARGS));
373 void FDECL((*win_outrip), (CARGS, winid, int, time_t));
374 void FDECL((*win_preference_update), (CARGS, const char *));
375 char *FDECL((*win_getmsghistory), (CARGS, BOOLEAN_P));
376 void FDECL((*win_putmsghistory), (CARGS, const char *, BOOLEAN_P));
377 void FDECL((*win_status_init), (CARGS));
378 void FDECL((*win_status_finish), (CARGS));
379 void FDECL((*win_status_enablefield),
380 (CARGS, int, const char *, const char *, BOOLEAN_P));
381 void FDECL((*win_status_update), (CARGS, int, genericptr_t, int, int, int, unsigned long *));
382 boolean FDECL((*win_can_suspend), (CARGS));
384 #endif /* WINCHAIN */
388 * window port routines available in sys/share/safeproc.c
390 extern struct window_procs *FDECL(get_safe_procs, (int));
391 extern void FDECL(safe_init_nhwindows, (int *, char **));
392 extern void NDECL(safe_player_selection);
393 extern void NDECL(safe_askname);
394 extern void NDECL(safe_get_nh_event);
395 extern void FDECL(safe_exit_nhwindows, (const char *));
396 extern void FDECL(safe_suspend_nhwindows, (const char *));
397 extern void NDECL(safe_resume_nhwindows);
398 extern winid FDECL(safe_create_nhwindow, (int));
399 extern void FDECL(safe_clear_nhwindow, (winid));
400 extern void FDECL(safe_display_nhwindow, (winid, BOOLEAN_P));
401 extern void FDECL(safe_destroy_nhwindow, (winid));
402 extern void FDECL(safe_curs, (winid, int, int));
403 extern void FDECL(safe_putstr, (winid, int, const char *));
404 extern void FDECL(safe_putmixed, (winid, int, const char *));
405 extern void FDECL(safe_display_file, (const char *, BOOLEAN_P));
406 extern void FDECL(safe_start_menu, (winid));
407 extern void FDECL(safe_add_menu, (winid, int, const ANY_P *, CHAR_P, CHAR_P,
408 int, const char *, BOOLEAN_P));
409 extern void FDECL(safe_end_menu, (winid, const char *));
410 extern int FDECL(safe_select_menu, (winid, int, MENU_ITEM_P **));
411 extern char FDECL(safe_message_menu, (CHAR_P, int, const char *));
412 extern void NDECL(safe_update_inventory);
413 extern void NDECL(safe_mark_synch);
414 extern void NDECL(safe_wait_synch);
416 extern void FDECL(safe_cliparound, (int, int));
419 extern void FDECL(safe_update_positionbar, (char *));
421 extern void FDECL(safe_print_glyph, (winid, XCHAR_P, XCHAR_P, int, int));
422 extern void FDECL(safe_raw_print, (const char *));
423 extern void FDECL(safe_raw_print_bold, (const char *));
424 extern int NDECL(safe_nhgetch);
425 extern int FDECL(safe_nh_poskey, (int *, int *, int *));
426 extern void NDECL(safe_nhbell);
427 extern int NDECL(safe_doprev_message);
428 extern char FDECL(safe_yn_function, (const char *, const char *, CHAR_P));
429 extern void FDECL(safe_getlin, (const char *, char *));
430 extern int NDECL(safe_get_ext_cmd);
431 extern void FDECL(safe_number_pad, (int));
432 extern void NDECL(safe_delay_output);
434 extern void FDECL(safe_change_color, (int, long, int));
436 extern void FDECL(safe_change_background, (int));
437 extern short FDECL(safe_set_font_name, (winid, char *));
439 extern char *NDECL(safe_get_color_string);
441 extern void NDECL(safe_start_screen);
442 extern void NDECL(safe_end_screen);
443 extern void FDECL(safe_outrip, (winid, int, time_t));
444 extern void FDECL(safe_preference_update, (const char *));
445 extern char *FDECL(safe_getmsghistory, (BOOLEAN_P));
446 extern void FDECL(safe_putmsghistory, (const char *, BOOLEAN_P));
447 extern void NDECL(safe_status_init);
448 extern void NDECL(safe_status_finish);
449 extern void FDECL(safe_status_enablefield,
450 (int, const char *, const char *, BOOLEAN_P));
451 extern void FDECL(safe_status_update, (int, genericptr_t, int, int, int, unsigned long *));
452 extern boolean NDECL(safe_can_suspend);
453 extern void FDECL(stdio_raw_print, (const char *));
454 extern void FDECL(stdio_nonl_raw_print, (const char *));
455 extern void FDECL(stdio_raw_print_bold, (const char *));
456 extern void NDECL(stdio_wait_synch);
457 extern int NDECL(stdio_nhgetch);
458 #endif /* SAFEPROCS */
459 #endif /* WINPROCS_H */