Source:NetHack 5.0.0/include/wintype.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to wintype.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/wintype.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  wintype.h       $NHDT-Date: 1717880364 2024/06/08 20:59:24 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.52 $ */
2. /* Copyright (c) David Cohrs, 1991                                */
3. /* NetHack may be freely redistributed.  See license for details. */
4. 
5. #ifndef WINTYPE_H
6. #define WINTYPE_H
7. 
8. typedef int winid; /* a window identifier */
9. 
10. /* generic parameter - must not be any larger than a pointer */
11. typedef union any {
12.     genericptr_t a_void;
13.     struct obj *a_obj;
14.     struct monst *a_monst;
15.     int a_int;
16.     int a_xint16;
17.     int a_xint8;
18.     char a_char;
19.     schar a_schar;
20.     uchar a_uchar;
21.     unsigned int a_uint;
22.     long a_long;
23.     unsigned long a_ulong;
24.     coordxy a_coordxy;
25.     int *a_iptr;
26.     xint16 *a_xint16ptr;
27.     xint8 *a_xint8ptr;
28.     long *a_lptr;
29.     coordxy *a_coordxyptr;
30.     unsigned long *a_ulptr;
31.     unsigned *a_uptr;
32.     const char *a_string;
33.     int (*a_nfunc)(void);
34.     unsigned long a_mask32; /* used by status highlighting */
35.     int64 a_int64;
36.     uint64 a_uint64;
37.     /* add types as needed */
38. } anything;
39. #define ANY_P union any /* avoid typedef in prototypes
40.                          * (buggy old Ultrix compiler) */
41. 
42. /* symbolic names for the data types housed in anything */
43. enum any_types {
44.     ANY_VOID = 1,
45.     ANY_OBJ,         /* struct obj */
46.     ANY_MONST,       /* struct monst (not used) */
47.     ANY_INT,         /* int */
48.     ANY_CHAR,        /* char */
49.     ANY_UCHAR,       /* unsigned char */
50.     ANY_SCHAR,       /* signed char */
51.     ANY_UINT,        /* unsigned int */
52.     ANY_LONG,        /* long */
53.     ANY_ULONG,       /* unsigned long */
54.     ANY_IPTR,        /* pointer to int */
55.     ANY_UPTR,        /* pointer to unsigned int */
56.     ANY_LPTR,        /* pointer to long */
57.     ANY_ULPTR,       /* pointer to unsigned long */
58.     ANY_STR,         /* pointer to null-terminated char string */
59.     ANY_NFUNC,       /* pointer to function taking no args, returning int */
60.     ANY_MASK32,      /* 32-bit mask (stored as unsigned long) */
61. 
62.     ANY_INVALID      /* leave this last */
63. };
64. 
65. /* menu return list */
66. typedef struct mi {
67.     anything item;     /* identifier */
68.     long count;        /* count */
69.     unsigned itemflags; /* item flags */
70. } menu_item;
71. #define MENU_ITEM_P struct mi
72. 
73. /* These would be in sym.h and display.h if they weren't needed to
74.    define the windowproc interface for X11 which doesn't include
75.    most of the main NetHack header files */
76. 
77. struct classic_representation {
78.     int color;
79.     int symidx;
80. };
81. 
82. struct unicode_representation {
83.     uint32 utf32ch;
84.     uint8 *utf8str;
85. };
86. 
87. typedef struct glyph_map_entry {
88.     unsigned glyphflags;
89.     struct classic_representation sym;
90.     uint32 customcolor;
91.     uint16 color256idx;
92.     short int tileidx;
93. #ifdef ENHANCED_SYMBOLS
94.     struct unicode_representation *u;
95. #endif
96. } glyph_map;
97. 
98. /* glyph plus additional info
99.    if you add fields or change the ordering, fix up the following:
100.         g_info initialization in display.c
101.         nul_glyphinfo initialization in display.c
102.  */
103. typedef struct glyphinfo {
104.     int glyph;            /* the display entity */
105.     int ttychar;
106.     uint32 framecolor;
107.     glyph_map gm;
108. } glyph_info;
109. /*#define GLYPH_INFO_P struct glyphinfo //not used*/
110. 
111. /* select_menu() "how" argument types */
112. /* [MINV_PICKMASK in monst.h assumes these have values of 0, 1, 2] */
113. #define PICK_NONE 0 /* user picks nothing (display only) */
114. #define PICK_ONE 1  /* only pick one */
115. #define PICK_ANY 2  /* can pick any amount */
116. 
117. /* window types */
118. /* any additional port specific types should be defined in win*.h */
119. #define NHW_MESSAGE 1
120. #define NHW_STATUS 2
121. #define NHW_MAP 3
122. #define NHW_MENU 4
123. #define NHW_TEXT 5
124. #define NHW_PERMINVENT 6
125. #define NHW_LAST_TYPE NHW_PERMINVENT
126. 
127. /* attribute types for putstr; the same as the ANSI value, for convenience */
128. #define ATR_NONE       0
129. #define ATR_BOLD       1
130. #define ATR_DIM        2
131. #define ATR_ITALIC     3
132. #define ATR_ULINE      4
133. #define ATR_BLINK      5
134. #define ATR_INVERSE    7
135. /* not a display attribute but passed to putstr() as an attribute;
136.    can be masked with one regular display attribute */
137. #define ATR_URGENT    16
138. #define ATR_NOHISTORY 32
139. 
140. /* nh_poskey() modifier types */
141. #define CLICK_1 1
142. #define CLICK_2 2
143. #define NUM_MOUSE_BUTTONS 2
144. 
145. /* invalid winid */
146. #define WIN_ERR ((winid) -1)
147. 
148. /* menu window keyboard commands (may be mapped); menu_shift_right and
149.    menu_shift_left are for interacting with persistent inventory window */
150. /* clang-format off */
151. #define MENU_FIRST_PAGE         '^'
152. #define MENU_LAST_PAGE          '|'
153. #define MENU_NEXT_PAGE          '>'
154. #define MENU_PREVIOUS_PAGE      '<'
155. #define MENU_SHIFT_RIGHT        '}'
156. #define MENU_SHIFT_LEFT         '{'
157. #define MENU_SELECT_ALL         '.'
158. #define MENU_UNSELECT_ALL       '-'
159. #define MENU_INVERT_ALL         '@'
160. #define MENU_SELECT_PAGE        ','
161. #define MENU_UNSELECT_PAGE      '\\'
162. #define MENU_INVERT_PAGE        '~'
163. #define MENU_SEARCH             ':'
164. 
165. #define MENU_ITEMFLAGS_NONE           0x0000000U
166. #define MENU_ITEMFLAGS_SELECTED       0x0000001U
167. #define MENU_ITEMFLAGS_SKIPINVERT     0x0000002U
168. #define MENU_ITEMFLAGS_SKIPMENUCOLORS 0x0000004U
169. 
170. /* 5.0+ enhanced menu flags that not all window ports are likely to
171.  * support initially.
172.  *
173.  * As behavior and appearance modification flags are added, the various
174.  * individual window ports will likely have to be updated to respond
175.  * to the flags in an appropriate way.
176.  */
177. 
178. #define MENU_BEHAVE_STANDARD      0x0000000U
179. #define MENU_BEHAVE_PERMINV       0x0000001U
180. 
181. enum perm_invent_toggles {
182.     toggling_off = -1,
183.     toggling_not =  0,
184.     toggling_on  =  1
185. };
186. 
187. /* perm_invent modes */
188. enum inv_mode_bits {
189.     InvNormal   = 1,
190.     InvShowGold = 2,
191.     InvSparse   = 4, /* must be ORed with Normal or ShowGold to be valid */
192.     InvInUse    = 8
193. };
194. enum inv_modes { /* 'perminv_mode' option settings */
195.     InvOptNone       = 0,           /* no perm_invent */
196.     InvOptOn         = InvNormal,   /* 1 */
197.     InvOptFull       = InvShowGold, /* 2 */
198. #if 1 /*#ifdef TTY_PERM_INVENT*/
199.     /* confusingly-named "sparse mode" shows all inventory letters, even when
200.        their slots are empty; only meaningful for tty's perm_invent */
201.     InvOptOn_grid    = InvNormal | InvSparse,   /* 5 */
202.     InvOptFull_grid  = InvShowGold | InvSparse, /* 6 */
203. #endif
204.     InvOptInUse      = InvInUse,    /* 8 */
205. };
206. 
207. enum to_core_flags {
208.     active           = 0x001,
209.     too_small        = 0x002,
210.     prohibited       = 0x004,
211.     no_init_done     = 0x008,
212.     too_early        = 0x010,
213. };
214. 
215. enum from_core_requests {
216.     invalid_core_request = 0,
217.     set_mode             = 1,
218.     request_settings     = 2,
219.     set_menu_promptstyle = 3,
220. };
221. 
222. struct to_core {
223.     long tocore_flags;
224.     boolean active;
225.     boolean use_update_inventory;    /* disable the newer slot interface */
226.     int maxslot;
227.     int needrows, needcols;
228.     int haverows, havecols;
229. };
230. 
231. struct from_core {
232.     enum from_core_requests core_request;
233.     enum inv_modes invmode;
234.     color_attr menu_promptstyle;
235. };
236. 
237. struct win_request_info_t {
238.     struct to_core tocore;
239.     struct from_core fromcore;
240. };
241. 
242. typedef struct win_request_info_t win_request_info;
243. extern win_request_info zerowri;    /* windows.c */
244. 
245. /* #define CORE_INVENT */
246. 
247. /* In a binary with multiple window interfaces linked in, this is
248.  * a structure to track certain interface capabilities that cannot be
249.  * statically done at compile time. Some of them can be toggled and
250.  * the core needs to know if they are active or not at the time.
251.  */
252. 
253. enum win_display_modes {
254.     wdmode_traditional = 0,
255.     wdmode_tiled
256. };
257. 
258. struct win_settings {
259.     enum win_display_modes wdmode;
260.     uint32 map_frame_color;
261. };
262. 
263. /* clang-format on */
264. 
265. #endif /* WINTYPE_H */