Source:NetHack 5.0.0/include/winprocs.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to winprocs.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/winprocs.h#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1. /* NetHack 5.0	winprocs.h	$NHDT-Date: 1736530208 2025/01/10 09:30:08 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.83 $ */
2. /* Copyright (c) David Cohrs, 1992                                */
3. /* NetHack may be freely redistributed.  See license for details. */
4. 
5. #ifndef WINPROCS_H
6. #define WINPROCS_H
7. 
8. #include "botl.h"
9. #ifndef CLR_MAX
10. #include "color.h"
11. #endif
12. 
13. enum wp_ids { wp_tty = 1, wp_X11, wp_Qt, wp_mswin, wp_curses,
14.               wp_chainin, wp_chainout, wp_shim,
15.               wp_hup, wp_guistubs, wp_ttystubs,
16. #if defined(AMIGA)
17.               wp_amii, wp_amiv,
18. #endif
19. #ifdef OUTDATED_STUFF
20.               wp_mac, wp_Gem, wp_Gnome,
21. #endif
22.               wp_trace  // XXX do we need this?  should chainin/out get an id? TBD
23. };
24. 
25. /* NB: this MUST match chain_procs below */
26. struct window_procs {
27.     const char *name;     /* Names should start with [a-z].  Names must
28.                            * not start with '-'.  Names starting with
29.                            * '+' are reserved for processors. */
30.     enum wp_ids wp_id;
31.     unsigned long wincap; /* window port capability options supported */
32.     unsigned long wincap2; /* additional window port capability options */
33.     boolean has_color[CLR_MAX];
34.     void (*win_init_nhwindows)(int *, char **);
35.     void (*win_player_selection)(void);
36.     void (*win_askname)(void);
37.     void (*win_get_nh_event)(void);
38.     void (*win_exit_nhwindows)(const char *);
39.     void (*win_suspend_nhwindows)(const char *);
40.     void (*win_resume_nhwindows)(void);
41.     winid (*win_create_nhwindow)(int);
42.     void (*win_clear_nhwindow)(winid);
43.     void (*win_display_nhwindow)(winid, boolean);
44.     void (*win_destroy_nhwindow)(winid);
45.     void (*win_curs)(winid, int, int);
46.     void (*win_putstr)(winid, int, const char *);
47.     void (*win_putmixed)(winid, int, const char *);
48.     void (*win_display_file)(const char *, boolean);
49.     void (*win_start_menu)(winid, unsigned long);
50.     void (*win_add_menu)(winid, const glyph_info *, const ANY_P *,
51.                          char, char, int, int,
52.                          const char *, unsigned int);
53.     void (*win_end_menu)(winid, const char *);
54.     int (*win_select_menu)(winid, int, MENU_ITEM_P **);
55.     char (*win_message_menu)(char, int, const char *);
56.     void (*win_mark_synch)(void);
57.     void (*win_wait_synch)(void);
58. #ifdef CLIPPING
59.     void (*win_cliparound)(int, int);
60. #endif
61. #ifdef POSITIONBAR
62.     void (*win_update_positionbar)(char *);
63. #endif
64.     void (*win_print_glyph)(winid, coordxy, coordxy,
65.                             const glyph_info *, const glyph_info *);
66.     void (*win_raw_print)(const char *);
67.     void (*win_raw_print_bold)(const char *);
68.     int (*win_nhgetch)(void);
69.     int (*win_nh_poskey)(coordxy *, coordxy *, int *);
70.     void (*win_nhbell)(void);
71.     int (*win_doprev_message)(void);
72.     char (*win_yn_function)(const char *, const char *, char);
73.     void (*win_getlin)(const char *, char *);
74.     int (*win_get_ext_cmd)(void);
75.     void (*win_number_pad)(int);
76.     void (*win_delay_output)(void);
77. #ifdef CHANGE_COLOR
78.     void (*win_change_color)(int, long, int);
79. #ifdef MACOS9
80.     void (*win_change_background)(int);
81.     short (*win_set_font_name)(winid, char *);
82. #endif
83.     char *(*win_get_color_string)(void);
84. #endif
85. 
86.     void (*win_outrip)(winid, int, time_t);
87.     void (*win_preference_update)(const char *);
88.     char *(*win_getmsghistory)(boolean);
89.     void (*win_putmsghistory)(const char *, boolean);
90.     void (*win_status_init)(void);
91.     void (*win_status_finish)(void);
92.     void (*win_status_enablefield)(int, const char *, const char *,
93.                                    boolean);
94.     void (*win_status_update)(int, genericptr_t, int, int, int,
95.                               unsigned long *);
96.     boolean (*win_can_suspend)(void);
97.     void (*win_update_inventory)(int);
98.     win_request_info *(*win_ctrl_nhwindow)(winid, int, win_request_info *);
99. };
100. 
101. extern
102. #ifdef HANGUPHANDLING
103.     volatile
104. #endif
105.     NEARDATA struct window_procs windowprocs;
106. 
107. /*
108.  * If you wish to only support one window system and not use procedure
109.  * pointers, add the appropriate #ifdef below.
110.  * XXX which is what?
111.  */
112. 
113. #define init_nhwindows (*windowprocs.win_init_nhwindows)
114. #define player_selection (*windowprocs.win_player_selection)
115. #define askname (*windowprocs.win_askname)
116. #define get_nh_event (*windowprocs.win_get_nh_event)
117. #define exit_nhwindows (*windowprocs.win_exit_nhwindows)
118. #define suspend_nhwindows (*windowprocs.win_suspend_nhwindows)
119. #define resume_nhwindows (*windowprocs.win_resume_nhwindows)
120. #define create_nhwindow (*windowprocs.win_create_nhwindow)
121. #define clear_nhwindow (*windowprocs.win_clear_nhwindow)
122. #define display_nhwindow (*windowprocs.win_display_nhwindow)
123. #define destroy_nhwindow (*windowprocs.win_destroy_nhwindow)
124. #define curs (*windowprocs.win_curs)
125. #define putstr (*windowprocs.win_putstr)
126. #define putmixed (*windowprocs.win_putmixed)
127. #define display_file (*windowprocs.win_display_file)
128. #define start_menu (*windowprocs.win_start_menu)
129. #define end_menu (*windowprocs.win_end_menu)
130. /* 5.0: There are real add_menu() and select_menu in the core now.
131.  *      add_menu does some common activities, such as menu_colors.
132.  *      select_menu does some before and after activities.
133.  *      add_menu() and select_menu() are in windows.c
134.  */
135. /* #define add_menu (*windowprocs.win_add_menu) */
136. /* #define select_menu (*windowprocs.win_select_menu) */
137. #define message_menu (*windowprocs.win_message_menu)
138. 
139. #define mark_synch (*windowprocs.win_mark_synch)
140. #define wait_synch (*windowprocs.win_wait_synch)
141. #ifdef CLIPPING
142. #define cliparound (*windowprocs.win_cliparound)
143. #endif
144. #ifdef POSITIONBAR
145. #define update_positionbar (*windowprocs.win_update_positionbar)
146. #endif
147. #define print_glyph (*windowprocs.win_print_glyph)
148. #define raw_print (*windowprocs.win_raw_print)
149. #define raw_print_bold (*windowprocs.win_raw_print_bold)
150. #define nhgetch (*windowprocs.win_nhgetch)
151. #define nh_poskey (*windowprocs.win_nh_poskey)
152. #define nhbell (*windowprocs.win_nhbell)
153. #define nh_doprev_message (*windowprocs.win_doprev_message)
154. /* 5.0: There is a real getlin() in the core now, which does
155.  *      some before and after activities.
156.  *      [alternative fix for menu search via ':'.]
157.  *      getlin() is in windows.c
158.  */
159. /* #define getlin (*windowprocs.win_getlin) */
160. #define get_ext_cmd (*windowprocs.win_get_ext_cmd)
161. #define number_pad (*windowprocs.win_number_pad)
162. #define nh_delay_output (*windowprocs.win_delay_output)
163. #ifdef CHANGE_COLOR
164. #define change_color (*windowprocs.win_change_color)
165. #ifdef MACOS9
166. #define change_background (*windowprocs.win_change_background)
167. #define set_font_name (*windowprocs.win_set_font_name)
168. #endif
169. #define get_color_string (*windowprocs.win_get_color_string)
170. #endif
171. 
172. /* 3.4.2: There is a real yn_function() in the core now, which does
173.  *        some buffer length validation on the parameters prior to
174.  *        invoking the window port routine. yn_function() is in cmd.c
175.  */
176. /* #define yn_function (*windowprocs.win_yn_function) */
177. 
178. #define outrip (*windowprocs.win_outrip)
179. #define preference_update (*windowprocs.win_preference_update)
180. #define getmsghistory (*windowprocs.win_getmsghistory)
181. #define putmsghistory (*windowprocs.win_putmsghistory)
182. /* there is a status_initialize() in botl.c,
183.  * which calls win_status_init() directly; same with status_finish.
184.  */
185. #define status_enablefield (*windowprocs.win_status_enablefield)
186. #define status_update (*windowprocs.win_status_update)
187. #define ctrl_nhwindow (*windowprocs.win_ctrl_nhwindow)
188. 
189. /*
190.  *
191.  */
192. #define WPID(name) #name, wp_##name
193. #define WPIDMINUS(name) "-" #name, wp_##name
194. 
195. /*
196.  * WINCAP
197.  * Window port preference capability bits.
198.  * Some day this might be better in its own wincap.h file.
199.  */
200. /* clang-format off */
201. #define WC_COLOR         0x00000001L /* 01 Port can display things in color  */
202. #define WC_HILITE_PET    0x00000002L /* 02 supports hilite pet               */
203. #define WC_ASCII_MAP     0x00000004L /* 03 supports an ascii map             */
204. #define WC_TILED_MAP     0x00000008L /* 04 supports a tiled map              */
205. #define WC_PRELOAD_TILES 0x00000010L /* 05 supports pre-loading tiles        */
206. #define WC_TILE_WIDTH    0x00000020L /* 06 prefer this width of tile         */
207. #define WC_TILE_HEIGHT   0x00000040L /* 07 prefer this height of tile        */
208. #define WC_TILE_FILE     0x00000080L /* 08 alternative tile file name        */
209. #define WC_INVERSE       0x00000100L /* 09 Port supports inverse video       */
210. #define WC_ALIGN_MESSAGE 0x00000200L /* 10 supports mesg alignment top|b|l|r */
211. #define WC_ALIGN_STATUS  0x00000400L /* 11 supports status alignmt top|b|l|r */
212. #define WC_VARY_MSGCOUNT 0x00000800L /* 12 supports varying message window   */
213. #define WC_FONT_MAP      0x00001000L /* 13 supports spec of map window font  */
214. #define WC_FONT_MESSAGE  0x00002000L /* 14 supports spec of message font     */
215. #define WC_FONT_STATUS   0x00004000L /* 15 supports spec of status font      */
216. #define WC_FONT_MENU     0x00008000L /* 16 supports spec of menu font        */
217. #define WC_FONT_TEXT     0x00010000L /* 17 supports spec of text window font */
218. #define WC_FONTSIZ_MAP   0x00020000L /* 18 supports spec of map font size    */
219. #define WC_FONTSIZ_MESSAGE 0x040000L /* 19 supports spec of mesg font size   */
220. #define WC_FONTSIZ_STATUS 0x0080000L /* 20 supports spec of status font size */
221. #define WC_FONTSIZ_MENU  0x00100000L /* 21 supports spec of menu font size   */
222. #define WC_FONTSIZ_TEXT  0x00200000L /* 22 supports spec of text font size   */
223. #define WC_SCROLL_MARGIN 0x00400000L /* 23 supports setting map scroll marg  */
224. #define WC_SPLASH_SCREEN 0x00800000L /* 24 supports display of splash screen */
225. #define WC_POPUP_DIALOG  0x01000000L /* 25 supports queries in popup dialogs */
226. #define WC_SCROLL_AMOUNT 0x02000000L /* 26 scroll this amount at scroll marg */
227. #define WC_EIGHT_BIT_IN  0x04000000L /* 27 8-bit character input             */
228. #define WC_PERM_INVENT   0x08000000L /* 28 supports persistent inventory win */
229. #define WC_MAP_MODE      0x10000000L /* 29 map_mode option                   */
230. #define WC_WINDOWCOLORS  0x20000000L /* 30 background color for mesg window  */
231. #define WC_PLAYER_SELECTION 0x40000000L /* 31 supports player selection      */
232. #ifdef NHSTDC
233. #define WC_MOUSE_SUPPORT 0x80000000UL /* 32 mouse support                    */
234. #else
235. #define WC_MOUSE_SUPPORT 0x80000000L /* 32 mouse support                     */
236. #endif
237.                                      /* no free bits */
238. 
239. #define WC2_FULLSCREEN    0x0001L /* 01 display full screen             */
240. #define WC2_SOFTKEYBOARD  0x0002L /* 02 software keyboard               */
241. #define WC2_WRAPTEXT      0x0004L /* 03 wrap long lines of text         */
242. #define WC2_HILITE_STATUS 0x0008L /* 04 hilite fields in status         */
243. #define WC2_SELECTSAVED   0x0010L /* 05 saved game selection menu       */
244. #define WC2_DARKGRAY      0x0020L /* 06 use bold black for black glyphs */
245. #define WC2_HITPOINTBAR   0x0040L /* 07 show bar representing hit points */
246. #define WC2_FLUSH_STATUS  0x0080L /* 08 call status_update(BL_FLUSH)
247.                                    *    after updating status window fields */
248. #define WC2_RESET_STATUS  0x0100L /* 09 call status_update(BL_RESET) to
249.                                    *    indicate 'draw everything'      */
250. #define WC2_TERM_SIZE     0x0200L /* 10 support setting terminal size   */
251. #define WC2_STATUSLINES   0x0400L /* 11 switch between 2|3 lines of status */
252. #define WC2_WINDOWBORDERS 0x0800L /* 12 display borders on nh windows   */
253. #define WC2_PETATTR       0x1000L /* 13 attributes for hilite_pet       */
254. #define WC2_GUICOLOR      0x2000L /* 14 display colours outside map win */
255. /* pline() can overload the display attributes argument passed to putstr()
256.    with one or more flags and at most one of bold/blink/inverse/&c */
257. #define WC2_URGENT_MESG   0x4000L  /* 15 putstr(WIN_MESSAGE) supports urgency
258.                                     *    via non-display attribute flag  */
259. #define WC2_SUPPRESS_HIST 0x8000L  /* 16 putstr(WIN_MESSAGE) supports history
260.                                     *    suppression via non-disp attr   */
261. #define WC2_MENU_SHIFT   0x010000L /* 17 horizontal menu scrolling */
262. #define WC2_U_UTF8STR    0x020000L /* 18 utf8str support */
263. #define WC2_EXTRACOLORS  0x040000L /* 19 color support beyond NH_BASIC_COLOR */
264.                                    /* 13 free bits */
265. #define WC2_EXTRASTATUS  0x080000L /* 20 optional weaponstatus, armorstatus,
266.                                     *    terrainstatus */
267.                                    /* 12 free bits */
268. 
269. #define ALIGN_LEFT   1
270. #define ALIGN_RIGHT  2
271. #define ALIGN_TOP    3
272. #define ALIGN_BOTTOM 4
273. 
274. /* player_selection */
275. #define VIA_DIALOG  0
276. #define VIA_PROMPTS 1
277. 
278. /* map_mode settings - deprecated */
279. #define MAP_MODE_TILES      0
280. #define MAP_MODE_ASCII4x6   1
281. #define MAP_MODE_ASCII6x8   2
282. #define MAP_MODE_ASCII8x8   3
283. #define MAP_MODE_ASCII16x8  4
284. #define MAP_MODE_ASCII7x12  5
285. #define MAP_MODE_ASCII8x12  6
286. #define MAP_MODE_ASCII16x12 7
287. #define MAP_MODE_ASCII12x16 8
288. #define MAP_MODE_ASCII10x18 9
289. #define MAP_MODE_ASCII_FIT_TO_SCREEN 10
290. #define MAP_MODE_TILES_FIT_TO_SCREEN 11
291. 
292. struct wc_Opt {
293.     const char *wc_name;
294.     unsigned long wc_bit;
295. };
296. 
297. /* Macro for the currently active Window Port whose function
298.    pointers have been loaded */
299. #if 0
300. /* 5.0 The string comparison version isn't used anymore */
301. #define WINDOWPORT(wn) \
302.     (windowprocs.name && !strncmpi((#wn), windowprocs.name, strlen((#wn))))
303. #endif
304. 
305. #define WINDOWPORT(wn) (windowprocs.wp_id == wp_##wn)
306. 
307. /* role selection by player_selection(); this ought to be in the core... */
308. #define RS_NAME    0
309. #define RS_ROLE    1
310. #define RS_RACE    2
311. #define RS_GENDER  3
312. #define RS_ALGNMNT 4
313. #define RS_filter  5
314. #define RS_menu_arg(x) (ROLE_RANDOM - ((x) + 1)) /* 0..5 -> -3..-8 */
315. 
316. /* Choose_windows() may be called multiple times; these constants tell the
317.  * init function whether the window system is coming or going. */
318. #define WININIT      0
319. #define WININIT_UNDO 1
320. 
321. #ifdef WINCHAIN
322. /* Setup phases for window chain elements.
323.         void *  rv = X_procs_chain(int, int, void *, void *, void *);
324.                 Xprivate*          ALLOC n      0       0       0
325.                 -                  INIT  n   self    next    nextdata
326.    where:
327.         Xprivate* is anything window chain entry type X wants back
328.         n is the link count (starting with 1)
329.         self is the Xprivate* returned earlier
330.         next is struct winprocs * or struct chainprocs * for the next link
331.         nextdata is the Xprivate* for the next link in the chain
332. */
333. #define WINCHAIN_ALLOC 0
334. #define WINCHAIN_INIT  1
335. 
336. /* clang-format on */
337. 
338. #define CARGS void *
339. 
340. extern FILE *wc_tracelogf; /* Expose log file for additional debugging. */
341. 
342. struct chain_procs {
343.     const char *name;     /* Names should start with [a-z].  Names must
344.                            * not start with '-'.  Names starting with
345.                            * '+' are reserved for processors. */
346.     enum wp_ids wp_id;
347.     unsigned long wincap; /* window port capability options supported */
348.     unsigned long wincap2; /* additional window port capability options */
349.     boolean has_color[CLR_MAX];
350.     void (*win_init_nhwindows)(CARGS, int *, char **);
351.     void (*win_player_selection)(CARGS);
352.     void (*win_askname)(CARGS);
353.     void (*win_get_nh_event)(CARGS);
354.     void (*win_exit_nhwindows)(CARGS, const char *);
355.     void (*win_suspend_nhwindows)(CARGS, const char *);
356.     void (*win_resume_nhwindows)(CARGS);
357.     winid (*win_create_nhwindow)(CARGS, int);
358.     void (*win_clear_nhwindow)(CARGS, winid);
359.     void (*win_display_nhwindow)(CARGS, winid, boolean);
360.     void (*win_destroy_nhwindow)(CARGS, winid);
361.     void (*win_curs)(CARGS, winid, int, int);
362.     void (*win_putstr)(CARGS, winid, int, const char *);
363.     void (*win_putmixed)(CARGS, winid, int, const char *);
364.     void (*win_display_file)(CARGS, const char *, boolean);
365.     void (*win_start_menu)(CARGS, winid, unsigned long);
366.     void (*win_add_menu)(CARGS, winid, const glyph_info *,
367.                          const ANY_P *, char, char, int,
368.                          int, const char *, unsigned int);
369.     void (*win_end_menu)(CARGS, winid, const char *);
370.     int (*win_select_menu)(CARGS, winid, int, MENU_ITEM_P **);
371.     char (*win_message_menu)(CARGS, char, int, const char *);
372.     void (*win_mark_synch)(CARGS);
373.     void (*win_wait_synch)(CARGS);
374. #ifdef CLIPPING
375.     void (*win_cliparound)(CARGS, int, int);
376. #endif
377. #ifdef POSITIONBAR
378.     void (*win_update_positionbar)(CARGS, char *);
379. #endif
380.     void (*win_print_glyph)(CARGS, winid, coordxy, coordxy,
381.                             const glyph_info *,
382.                             const glyph_info *);
383.     void (*win_raw_print)(CARGS, const char *);
384.     void (*win_raw_print_bold)(CARGS, const char *);
385.     int (*win_nhgetch)(CARGS);
386.     int (*win_nh_poskey)(CARGS, coordxy *, coordxy *, int *);
387.     void (*win_nhbell)(CARGS);
388.     int (*win_doprev_message)(CARGS);
389.     char (*win_yn_function)
390.                (CARGS, const char *, const char *, char);
391.     void (*win_getlin)(CARGS, const char *, char *);
392.     int (*win_get_ext_cmd)(CARGS);
393.     void (*win_number_pad)(CARGS, int);
394.     void (*win_delay_output)(CARGS);
395. #ifdef CHANGE_COLOR
396.     void (*win_change_color)(CARGS, int, long, int);
397. #ifdef MACOS9
398.     void (*win_change_background)(CARGS, int);
399.     short (*win_set_font_name)(CARGS, winid, char *);
400. #endif
401.     char *(*win_get_color_string)(CARGS);
402. #endif
403. 
404.     void (*win_outrip)(CARGS, winid, int, time_t);
405.     void (*win_preference_update)(CARGS, const char *);
406.     char *(*win_getmsghistory)(CARGS, boolean);
407.     void (*win_putmsghistory)(CARGS, const char *, boolean);
408.     void (*win_status_init)(CARGS);
409.     void (*win_status_finish)(CARGS);
410.     void (*win_status_enablefield)
411.                (CARGS, int, const char *, const char *, boolean);
412.     void (*win_status_update)(CARGS, int, genericptr_t, int, int, int,
413.                               unsigned long *);
414.     boolean (*win_can_suspend)(CARGS);
415.     void (*win_update_inventory)(CARGS, int);
416.     win_request_info *(*win_ctrl_nhwindow)(CARGS, winid, int,
417.                                            win_request_info *);
418. };
419. #endif /* WINCHAIN */
420. 
421. #endif /* WINPROCS_H */