Source:NetHack 5.0.0/include/wintty.h
Jump to navigation
Jump to search
Below is the full text to wintty.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/wintty.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 wintty.h $NHDT-Date: 1656014599 2022/06/23 20:03:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.55 $ */ 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. #ifndef WINDOW_STRUCTS 9. #define WINDOW_STRUCTS 10. 11. #ifdef TTY_PERM_INVENT 12. 13. enum { tty_perminv_minrow = 28, tty_perminv_mincol = 79 }; 14. /* for static init of zerottycell, put pointer first */ 15. union ttycellcontent { 16. glyph_info *gi; 17. char ttychar; 18. }; 19. struct tty_perminvent_cell { 20. Bitfield(refresh, 1); 21. Bitfield(text, 1); 22. Bitfield(glyph, 1); 23. union ttycellcontent content; 24. uint32 color; /* adjusted color 0 = ignore 25. * 1-16 = NetHack color + 1 26. * 17..16,777,233 = 24-bit color + 17 27. */ 28. }; 29. #endif 30. 31. /* menu structure */ 32. typedef struct tty_mi { 33. struct tty_mi *next; 34. anything identifier; /* user identifier */ 35. long count; /* user count */ 36. char *str; /* description string (including accelerator) */ 37. glyph_info glyphinfo; /* glyph */ 38. int attr; /* string attribute */ 39. int color; /* string color */ 40. boolean selected; /* TRUE if selected by user */ 41. unsigned itemflags; /* item flags */ 42. char selector; /* keyboard accelerator */ 43. char gselector; /* group accelerator */ 44. } tty_menu_item; 45. 46. /* descriptor for tty-based windows */ 47. struct WinDesc { 48. int flags; /* window flags */ 49. xint16 type; /* type of window */ 50. boolean active; /* true if window is active */ 51. boolean blanked; /* for erase_tty_screen(); not used [yet?] */ 52. short offx, offy; /* offset from topleft of display */ 53. long rows, cols; /* dimensions */ 54. long curx, cury; /* current cursor position */ 55. long maxrow, maxcol; /* the maximum size used -- for MENU wins; 56. * maxcol is also used by WIN_MESSAGE for 57. * tracking the ^P command */ 58. unsigned long mbehavior; /* menu behavior flags (MENU) */ 59. short *datlen; /* allocation size for *data */ 60. char **data; /* window data [row][column] */ 61. char *morestr; /* string to display instead of default */ 62. tty_menu_item *mlist; /* menu information (MENU) */ 63. tty_menu_item **plist; /* menu page pointers (MENU) */ 64. long plist_size; /* size of allocated plist (MENU) */ 65. long npages; /* number of pages in menu (MENU) */ 66. long nitems; /* total number of items (MENU) */ 67. short how; /* menu mode - pick 1 or N (MENU) */ 68. char menu_ch; /* menu char (MENU) */ 69. #ifdef TTY_PERM_INVENT 70. struct tty_perminvent_cell **cells; 71. #endif 72. }; 73. 74. /* window flags */ 75. #define WIN_CANCELLED 1 76. #define WIN_STOP 1 /* for NHW_MESSAGE; stops output; sticks until 77. * next input request or reversed by WIN_NOSTOP */ 78. #define WIN_LOCKHISTORY 2 /* for NHW_MESSAGE; suppress history updates */ 79. #define WIN_NOSTOP 4 /* current message has been designated as urgent; 80. * prevents WIN_STOP from becoming set if current 81. * message triggers --More-- and user types ESC 82. * (current message won't have been seen yet) */ 83. 84. /* topline states */ 85. #define TOPLINE_EMPTY 0 /* empty */ 86. #define TOPLINE_NEED_MORE 1 /* non-empty, need --More-- */ 87. #define TOPLINE_NON_EMPTY 2 /* non-empty, no --More-- required */ 88. #define TOPLINE_SPECIAL_PROMPT 3 /* special prompt state */ 89. 90. /* descriptor for tty-based displays -- all the per-display data */ 91. struct DisplayDesc { 92. short rows, cols; /* width and height of tty display */ 93. short curx, cury; /* current cursor position on the screen */ 94. uint32 color; /* current color */ 95. uint32 colorflags; /* NH_BASIC_COLOR or 24-bit color */ 96. uint32 framecolor; /* current background color */ 97. int attrs; /* attributes in effect */ 98. int toplin; /* flag for topl stuff */ 99. int rawprint; /* number of raw_printed lines since synch */ 100. int inmore; /* non-zero if more() is active */ 101. int inread; /* non-zero if reading a character */ 102. int intr; /* non-zero if inread was interrupted */ 103. winid lastwin; /* last window used for I/O */ 104. char dismiss_more; /* extra character accepted at --More-- */ 105. int topl_utf8; /* non-zero if utf8 in str */ 106. int mixed; /* we are processing mixed output */ 107. }; 108. 109. #endif /* WINDOW_STRUCTS */ 110. 111. #ifdef STATUS_HILITES 112. struct tty_status_fields { 113. int idx; 114. int color; 115. int attr; 116. int x, y; 117. size_t lth; 118. boolean valid; 119. boolean dirty; 120. boolean redraw; 121. boolean sanitycheck; /* was 'last_in_row' */ 122. }; 123. #endif 124. 125. #define MAXWIN 20 /* maximum number of windows, cop-out */ 126. 127. /* tty dependent window types */ 128. #ifdef NHW_BASE 129. #undef NHW_BASE 130. #endif 131. #define NHW_BASE (NHW_LAST_TYPE + 1) 132. 133. /* external declarations */ 134. 135. extern struct window_procs tty_procs; 136. 137. /* port specific variable declarations */ 138. extern winid BASE_WINDOW; 139. 140. extern struct WinDesc *wins[MAXWIN]; 141. 142. extern struct DisplayDesc *ttyDisplay; /* the tty display descriptor */ 143. 144. extern char morc; /* last character typed to xwaitforspace */ 145. extern char defmorestr[]; /* default --more-- prompt */ 146. 147. /* port specific external function references */ 148. 149. /* ### getline.c ### */ 150. 151. extern void xwaitforspace(const char *); 152. 153. /* ### termcap.c, video.c ### */ 154. 155. /* 156. * TERM or NO_TERMS 157. * 158. * The tty windowport interface relies on lower-level support routines 159. * to actually manipulate the terminal/display. Those are the right place 160. * for doing strange and arcane things such as outputting escape sequences 161. * to select a color or whatever. wintty.c should concern itself with WHERE 162. * to put stuff in a window. 163. 164. * The TERM routines are found in: 165. * 166. * !NO_TERMS: termcap.c 167. * 168. * NO_TERMS: 169. * WINCON sys/windows/consoletty.c 170. * MSDOS sys/msdos/video.c 171. * 172. */ 173. extern void backsp(void); 174. extern void cl_end(void); 175. extern void cl_eos(void); 176. extern void graph_on(void); 177. extern void graph_off(void); 178. extern void home(void); 179. extern void standoutbeg(void); 180. extern void standoutend(void); 181. extern int term_attr_fixup(int); 182. extern void term_clear_screen(void); 183. extern void term_curs_set(int); 184. extern void term_end_attr(int attr); 185. extern void term_end_color(void); 186. extern void term_end_extracolor(void); 187. extern void term_end_raw_bold(void); 188. extern void term_end_screen(void); 189. extern void term_start_attr(int attr); 190. extern void term_start_bgcolor(int color); 191. extern void term_start_color(int color); 192. extern void term_start_extracolor(uint32, uint16); 193. extern void term_start_raw_bold(void); 194. extern void term_start_screen(void); 195. extern void term_startup(int *, int *); 196. extern void term_shutdown(void); 197. 198. extern int xputc(int); 199. extern void xputs(const char *); 200. #if 0 201. extern void revbeg(void); 202. extern void boldbeg(void); 203. extern void blinkbeg(void); 204. extern void dimbeg(void); 205. extern void m_end(void); 206. #endif 207. #if defined(SCREEN_VGA) || defined(SCREEN_8514) || defined(SCREEN_VESA) 208. extern void xputg(const glyph_info *, const glyph_info *); 209. #endif 210. 211. /* ### topl.c ### */ 212. 213. extern void show_topl(const char *); 214. extern void remember_topl(void); 215. extern void addtopl(const char *); 216. extern void more(void); 217. extern void update_topl(const char *); 218. extern void putsyms(const char *); 219. 220. /* ### wintty.c ### */ 221. 222. #ifdef CLIPPING 223. extern void setclipped(void); 224. #endif 225. extern void docorner(int, int, int); 226. extern void end_glyphout(void); 227. extern void g_putch(int); 228. #ifdef ENHANCED_SYMBOLS 229. #if defined(WIN32) || defined(UNIX) || defined(MSDOS) 230. extern void g_pututf8(uint8 *); 231. #endif 232. #endif /* ENHANCED_SYMBOLS */ 233. extern void erase_tty_screen(void); 234. extern void win_tty_init(int); 235. 236. /* tty interface */ 237. extern void tty_init_nhwindows(int *, char **); 238. extern void tty_preference_update(const char *); 239. extern void tty_player_selection(void); 240. extern void tty_askname(void); 241. extern void tty_get_nh_event(void); 242. extern void tty_exit_nhwindows(const char *); 243. extern void tty_suspend_nhwindows(const char *); 244. extern void tty_resume_nhwindows(void); 245. extern winid tty_create_nhwindow(int); 246. extern void tty_clear_nhwindow(winid); 247. extern void tty_display_nhwindow(winid, boolean); 248. extern void tty_dismiss_nhwindow(winid); 249. extern void tty_destroy_nhwindow(winid); 250. extern void tty_curs(winid, int, int); 251. extern void tty_putstr(winid, int, const char *); 252. extern void tty_putmixed(winid window, int attr, const char *str); 253. extern void tty_display_file(const char *, boolean); 254. extern void tty_start_menu(winid, unsigned long); 255. extern void tty_add_menu(winid, const glyph_info *, const ANY_P *, char, 256. char, int, int, const char *, unsigned int); 257. extern void tty_end_menu(winid, const char *); 258. extern int tty_select_menu(winid, int, MENU_ITEM_P **); 259. extern char tty_message_menu(char, int, const char *); 260. extern void tty_mark_synch(void); 261. extern void tty_wait_synch(void); 262. #ifdef CLIPPING 263. extern void tty_cliparound(int, int); 264. #endif 265. #ifdef POSITIONBAR 266. extern void tty_update_positionbar(char *); 267. #endif 268. extern void tty_print_glyph(winid, coordxy, coordxy, const glyph_info *, 269. const glyph_info *); 270. extern void tty_raw_print(const char *); 271. extern void tty_raw_print_bold(const char *); 272. extern int tty_nhgetch(void); 273. extern int tty_nh_poskey(coordxy *, coordxy *, int *); 274. extern void tty_nhbell(void); 275. extern int tty_doprev_message(void); 276. extern char tty_yn_function(const char *, const char *, char); 277. extern void tty_getlin(const char *, char *); 278. extern int tty_get_ext_cmd(void); 279. extern void tty_number_pad(int); 280. extern void tty_delay_output(void); 281. #ifdef CHANGE_COLOR 282. extern void tty_change_color(int color, long rgb, int reverse); 283. #ifdef MACOS9 284. extern void tty_change_background(int white_or_black); 285. extern short set_tty_font_name(winid, char *); 286. #endif 287. extern char *tty_get_color_string(void); 288. #endif 289. extern void tty_status_enablefield(int, const char *, const char *, boolean); 290. extern void tty_status_init(void); 291. extern void tty_status_update(int, genericptr_t, int, int, 292. int, unsigned long *); 293. 294. extern void genl_outrip(winid, int, time_t); 295. 296. extern char *tty_getmsghistory(boolean); 297. extern void tty_putmsghistory(const char *, boolean); 298. extern void tty_update_inventory(int); 299. extern win_request_info *tty_ctrl_nhwindow(winid, int, win_request_info *); 300. 301. #ifdef TTY_PERM_INVENT 302. extern void tty_refresh_inventory(int start, int stop, int y); 303. #endif 304. 305. /* termcap is implied if NO_TERMS is not defined */ 306. #ifndef NO_TERMS 307. #ifndef NO_TERMCAP_HEADERS 308. #include <curses.h> 309. #ifdef clear_screen /* avoid a conflict */ 310. #undef clear_screen 311. #endif 312. #include <term.h> 313. #ifdef bell 314. #undef bell 315. #endif 316. #ifdef color_names 317. #undef color_names 318. #endif 319. #ifdef tone 320. #undef tone 321. #endif 322. #ifdef hangup 323. #undef hangup 324. #endif 325. #else 326. extern int tgetent(char *, const char *); 327. extern void tputs(const char *, int, int (*)(int)); 328. extern int tgetnum(const char *); 329. extern int tgetflag(const char *); 330. extern char *tgetstr(const char *, char **); 331. extern char *tgoto(const char *, int, int); 332. #endif /* NO_TERMCAP_HEADERS */ 333. #else /* ?NO_TERMS */ 334. #ifdef MACOS9 335. #ifdef putchar 336. #undef putchar 337. #undef putc 338. #endif 339. #define putchar term_putc 340. #define fflush term_flush 341. #define puts term_puts 342. extern int term_putc(int c); 343. extern int term_flush(void *desc); 344. extern int term_puts(const char *str); 345. #endif /* MACOS9 */ 346. #if defined(MSDOS) || defined(WIN32) 347. #if defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST) || defined(WIN32) 348. #undef putchar 349. #undef putc 350. #undef puts 351. #define putchar(x) xputc(x) /* these are in video.c, nttty.c */ 352. #define putc(x) xputc(x) 353. #define puts(x) xputs(x) 354. #endif /*SCREEN_BIOS || SCREEN_DJGPPFAST || WIN32 */ 355. #ifdef POSITIONBAR 356. extern void video_update_positionbar(char *); 357. #endif 358. #endif /*MSDOS*/ 359. #endif /* NO_TERMS */ 360. 361. #endif /* WINTTY_H */