Source:NetHack 3.4.3/include/winprocs.h

From NetHackWiki
Jump to: navigation, search

Below is the full text to include/winprocs.h from NetHack 3.4.3. To link to a particular line, write [[winprocs.h#line123]], for example.

  1. /*	SCCS Id: @(#)winprocs.h 3.4	2003/01/08	*/
  2. /* Copyright (c) David Cohrs, 1992				  */
  3. /* NetHack may be freely redistributed.  See license for details. */

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. #ifndef WINPROCS_H
  2. #define WINPROCS_H
  3.  
  4. struct window_procs {
  5. const char *name;
  6. unsigned long wincap;	/* window port capability options supported */
  7. unsigned long wincap2;	/* additional window port capability options supported */
  8. void FDECL((*win_init_nhwindows), (int *, char **));
  9. void NDECL((*win_player_selection));
  10. void NDECL((*win_askname));
  11. void NDECL((*win_get_nh_event)) ;
  12. void FDECL((*win_exit_nhwindows), (const char *));
  13. void FDECL((*win_suspend_nhwindows), (const char *));
  14. void NDECL((*win_resume_nhwindows));
  15. winid FDECL((*win_create_nhwindow), (int));
  16. void FDECL((*win_clear_nhwindow), (winid));
  17. void FDECL((*win_display_nhwindow), (winid, BOOLEAN_P));
  18. void FDECL((*win_destroy_nhwindow), (winid));
  19. void FDECL((*win_curs), (winid,int,int));
  20. void FDECL((*win_putstr), (winid, int, const char *));
  21. void FDECL((*win_display_file), (const char *, BOOLEAN_P));
  22. void FDECL((*win_start_menu), (winid));
  23. void FDECL((*win_add_menu), (winid,int,const ANY_P *,
  24. 		CHAR_P,CHAR_P,int,const char *, BOOLEAN_P));
  25. void FDECL((*win_end_menu), (winid, const char *));
  26. int FDECL((*win_select_menu), (winid, int, MENU_ITEM_P **));
  27. char FDECL((*win_message_menu), (CHAR_P,int,const char *));
  28. void NDECL((*win_update_inventory));
  29. void NDECL((*win_mark_synch));
  30. void NDECL((*win_wait_synch));
  31. #ifdef CLIPPING
  32. void FDECL((*win_cliparound), (int, int));
  33. #endif
  34. #ifdef POSITIONBAR
  35. void FDECL((*win_update_positionbar), (char *));
  36. #endif
  37. void FDECL((*win_print_glyph), (winid,XCHAR_P,XCHAR_P,int));
  38. void FDECL((*win_raw_print), (const char *));
  39. void FDECL((*win_raw_print_bold), (const char *));
  40. int NDECL((*win_nhgetch));
  41. int FDECL((*win_nh_poskey), (int *, int *, int *));
  42. void NDECL((*win_nhbell));
  43. int NDECL((*win_doprev_message));
  44. char FDECL((*win_yn_function), (const char *, const char *, CHAR_P));
  45. void FDECL((*win_getlin), (const char *,char *));
  46. int NDECL((*win_get_ext_cmd));
  47. void FDECL((*win_number_pad), (int));
  48. void NDECL((*win_delay_output));
  49. #ifdef CHANGE_COLOR
  50. void FDECL((*win_change_color), (int,long,int));
  51. #ifdef MAC
  52. void FDECL((*win_change_background), (int));
  53. short FDECL((*win_set_font_name), (winid, char *));
  54. #endif
  55. char * NDECL((*win_get_color_string));
  56. #endif
  57.  
  58. /* other defs that really should go away (they're tty specific) */
  59. void NDECL((*win_start_screen));
  60. void NDECL((*win_end_screen));
  61.  
  62. void FDECL((*win_outrip), (winid,int));
  63. void FDECL((*win_preference_update), (const char *));
  64. };
  65.  
  66. extern NEARDATA struct window_procs windowprocs;

Windowprocs contains function pointers to the implementation supplied by the various window ports. It is declared in Source:Windows.c#line46 and assigned in Source:Windows.c#choose_windows. For the tty port, effectively the values in Source:tty/wintty.c#line44 are used. E. g. player_selection then maps to tty_player_selection, and so on. See also Cmd.c#line1358 for the cmdlist structure with function pointers that are called upon keypresses.

How do the macros in Source:Trampoli.h enter the picture?
  1. /*
  2. * If you wish to only support one window system and not use procedure
  3. * pointers, add the appropriate #ifdef below.
  4. */
  5.  
  6. #define init_nhwindows (*windowprocs.win_init_nhwindows)
  7. #define player_selection (*windowprocs.win_player_selection)
  8. #define askname (*windowprocs.win_askname)
  9. #define get_nh_event (*windowprocs.win_get_nh_event)
  10. #define exit_nhwindows (*windowprocs.win_exit_nhwindows)
  11. #define suspend_nhwindows (*windowprocs.win_suspend_nhwindows)
  12. #define resume_nhwindows (*windowprocs.win_resume_nhwindows)
  13. #define create_nhwindow (*windowprocs.win_create_nhwindow)
  14. #define clear_nhwindow (*windowprocs.win_clear_nhwindow)
  15. #define display_nhwindow (*windowprocs.win_display_nhwindow)
  16. #define destroy_nhwindow (*windowprocs.win_destroy_nhwindow)
  17. #define curs (*windowprocs.win_curs)
  18. #define putstr (*windowprocs.win_putstr)
  19. #define display_file (*windowprocs.win_display_file)
  20. #define start_menu (*windowprocs.win_start_menu)
  21. #define add_menu (*windowprocs.win_add_menu)
  22. #define end_menu (*windowprocs.win_end_menu)
  23. #define select_menu (*windowprocs.win_select_menu)
  24. #define message_menu (*windowprocs.win_message_menu)
  25. #define update_inventory (*windowprocs.win_update_inventory)
  26. #define mark_synch (*windowprocs.win_mark_synch)
  27. #define wait_synch (*windowprocs.win_wait_synch)
  28. #ifdef CLIPPING
  29. #define cliparound (*windowprocs.win_cliparound)
  30. #endif
  31. #ifdef POSITIONBAR
  32. #define update_positionbar (*windowprocs.win_update_positionbar)
  33. #endif
  34. #define print_glyph (*windowprocs.win_print_glyph)
  35. #define raw_print (*windowprocs.win_raw_print)
  36. #define raw_print_bold (*windowprocs.win_raw_print_bold)
  37. #define nhgetch (*windowprocs.win_nhgetch)
  38. #define nh_poskey (*windowprocs.win_nh_poskey)
  39. #define nhbell (*windowprocs.win_nhbell)
  40. #define nh_doprev_message (*windowprocs.win_doprev_message)
  41. #define getlin (*windowprocs.win_getlin)
  42. #define get_ext_cmd (*windowprocs.win_get_ext_cmd)
  43. #define number_pad (*windowprocs.win_number_pad)
  44. #define delay_output (*windowprocs.win_delay_output)
  45. #ifdef CHANGE_COLOR
  46. #define change_color (*windowprocs.win_change_color)
  47. #ifdef MAC
  48. #define change_background (*windowprocs.win_change_background)
  49. #define set_font_name (*windowprocs.win_set_font_name)
  50. #endif
  51. #define get_color_string (*windowprocs.win_get_color_string)
  52. #endif
  53.  
  54. /* 3.4.2: There is a real yn_function() in the core now, which does
  55. *        some buffer length validation on the parameters prior to
  56. *        invoking the window port routine. yn_function() is in cmd.c
  57. */
  58. /* #define yn_function (*windowprocs.win_yn_function) */
  59.  
  60. /* other defs that really should go away (they're tty specific) */
  61. #define start_screen (*windowprocs.win_start_screen)
  62. #define end_screen (*windowprocs.win_end_screen)
  63.  
  64. #define outrip (*windowprocs.win_outrip)
  65. #define preference_update (*windowprocs.win_preference_update)
  66.  
  67. /*
  68. * WINCAP
  69. * Window port preference capability bits.
  70. * Some day this might be better in its own wincap.h file.
  71. */
  72. #define WC_COLOR	 0x01L		/* 01 Port can display things in color       */
  73. #define WC_HILITE_PET	 0x02L		/* 02 supports hilite pet                    */
  74. #define WC_ASCII_MAP	 0x04L		/* 03 supports an ascii map                  */
  75. #define WC_TILED_MAP	 0x08L		/* 04 supports a tiled map                   */
  76. #define WC_PRELOAD_TILES 0x10L		/* 05 supports pre-loading tiles             */
  77. #define WC_TILE_WIDTH	 0x20L		/* 06 prefer this width of tile              */
  78. #define WC_TILE_HEIGHT	 0x40L		/* 07 prefer this height of tile             */
  79. #define WC_TILE_FILE	 0x80L		/* 08 alternative tile file name             */
  80. #define WC_INVERSE	 0x100L		/* 09 Port supports inverse video            */
  81. #define WC_ALIGN_MESSAGE 0x200L		/* 10 supports message alignmt top|b|l|r     */
  82. #define WC_ALIGN_STATUS	 0x400L		/* 11 supports status alignmt top|b|l|r      */
  83. #define WC_VARY_MSGCOUNT 0x800L		/* 12 supports varying message window        */
  84. #define WC_FONT_MAP	 0x1000L	/* 13 supports specification of map win font */
  85. #define WC_FONT_MESSAGE	 0x2000L	/* 14 supports specification of msg win font */
  86. #define WC_FONT_STATUS	 0x4000L	/* 15 supports specification of sts win font */
  87. #define WC_FONT_MENU	 0x8000L	/* 16 supports specification of mnu win font */
  88. #define WC_FONT_TEXT	 0x10000L	/* 17 supports specification of txt win font */
  89. #define WC_FONTSIZ_MAP	 0x20000L	/* 18 supports specification of map win font */
  90. #define WC_FONTSIZ_MESSAGE 0x40000L	/* 19 supports specification of msg win font */
  91. #define WC_FONTSIZ_STATUS 0x80000L	/* 20 supports specification of sts win font */
  92. #define WC_FONTSIZ_MENU	 0x100000L	/* 21 supports specification of mnu win font */
  93. #define WC_FONTSIZ_TEXT	 0x200000L	/* 22 supports specification of txt win font */
  94. #define WC_SCROLL_MARGIN 0x400000L	/* 23 supports setting scroll margin for map */
  95. #define WC_SPLASH_SCREEN 0x800000L	/* 24 supports display of splash screen      */
  96. #define WC_POPUP_DIALOG	 0x1000000L	/* 25 supports queries in pop dialogs        */
  97. #define WC_SCROLL_AMOUNT 0x2000000L	/* 26 scroll this amount at scroll margin    */
  98. #define WC_EIGHT_BIT_IN	 0x4000000L	/* 27 8-bit character input                  */
  99. #define WC_PERM_INVENT	 0x8000000L	/* 28 8-bit character input                  */
  100. #define WC_MAP_MODE	 0x10000000L	/* 29 map_mode option                        */
  101. #define WC_WINDOWCOLORS  0x20000000L	/* 30 background color for message window    */
  102. #define WC_PLAYER_SELECTION  0x40000000L /* 31 background color for message window    */
  103. #define WC_MOUSE_SUPPORT 0x80000000L	/* 32 mouse support                          */
  104. 					/* no free bits */
  105.  
  106. #define WC2_FULLSCREEN		0x01L	/* 01 display full screen                    */
  107. #define WC2_SOFTKEYBOARD	0x02L	/* 02 software keyboard                      */
  108. #define WC2_WRAPTEXT		0x04L	/* 04 wrap long lines of text                */
  109. 					/* 29 free bits */
  110.  
  111. #define ALIGN_LEFT	1
  112. #define ALIGN_RIGHT	2
  113. #define ALIGN_TOP	3
  114. #define ALIGN_BOTTOM	4
  115.  
  116. /* player_selection */
  117. #define VIA_DIALOG	0
  118. #define VIA_PROMPTS	1
  119.  
  120. /* map_mode settings - deprecated */
  121. #define MAP_MODE_TILES		0
  122. #define MAP_MODE_ASCII4x6	1
  123. #define MAP_MODE_ASCII6x8	2
  124. #define MAP_MODE_ASCII8x8	3
  125. #define MAP_MODE_ASCII16x8	4
  126. #define MAP_MODE_ASCII7x12	5
  127. #define MAP_MODE_ASCII8x12	6
  128. #define MAP_MODE_ASCII16x12	7
  129. #define MAP_MODE_ASCII12x16	8
  130. #define MAP_MODE_ASCII10x18	9
  131. #define MAP_MODE_ASCII_FIT_TO_SCREEN 10
  132. #define MAP_MODE_TILES_FIT_TO_SCREEN 11
  133.  
  134. #if 0
  135. #define WC_SND_SOUND	 0x01L		/* 01 Port has some sound capabilities       */
  136. #define WC_SND_SPEAKER	 0x02L		/* 02 Sound supported via built-in speaker   */
  137. #define WC_SND_STEREO	 0x04L		/* 03 Stereo sound supported                 */
  138. #define WC_SND_RAW	 0x08L		/* 04 Raw sound supported                    */
  139. #define WC_SND_WAVE	 0x10L		/* 05 Wave support                           */
  140. #define WC_SND_MIDI	 0x20L		/* 06 Midi support                           */
  141. 					/* 26 free bits */
  142. #endif
  143.  
  144. struct wc_Opt {
  145. 	const char *wc_name;
  146. 	unsigned long wc_bit;
  147. };
  148.  
  149. #endif /* WINPROCS_H */