updated window_procs
Add a non-string identifier to window_procs for use in runtime identification of the current window port being used. Use a macro WPID to add the identification at the top of the various existing window_procs declarations. It expands to the existing text string, as well as the newly added field wp_id with a wp_ identifier. For example, WPID(tty) expands to: "tty", wp_tty The generated wp_tty must be present in the wp_ids enum at the top of include/winprocs.h. The WINDOWPORT(x) macro has been updated to expand to a simple value comparison (port.wp_id == wp_x), instead of a string comparison.
This commit is contained in:
@@ -7,11 +7,20 @@
|
|||||||
|
|
||||||
#include "botl.h"
|
#include "botl.h"
|
||||||
|
|
||||||
|
enum wp_ids { wp_tty = 1, wp_X11, wp_Qt, wp_mswin, wp_curses,
|
||||||
|
wp_chainin, wp_chainout, wp_safestartup, wp_shim,
|
||||||
|
wp_hup, wp_guistubs, wp_ttystubs,
|
||||||
|
#ifdef OUTDATED_STUFF
|
||||||
|
, wp_mac, wp_Gem, wp_Gnome, wp_amii, wp_amiv
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
/* NB: this MUST match chain_procs below */
|
/* NB: this MUST match chain_procs below */
|
||||||
struct window_procs {
|
struct window_procs {
|
||||||
const char *name; /* Names should start with [a-z]. Names must
|
const char *name; /* Names should start with [a-z]. Names must
|
||||||
* not start with '-'. Names starting with
|
* not start with '-'. Names starting with
|
||||||
* '+' are reserved for processors. */
|
* '+' are reserved for processors. */
|
||||||
|
enum wp_ids wp_id;
|
||||||
unsigned long wincap; /* window port capability options supported */
|
unsigned long wincap; /* window port capability options supported */
|
||||||
unsigned long wincap2; /* additional window port capability options */
|
unsigned long wincap2; /* additional window port capability options */
|
||||||
boolean has_color[CLR_MAX];
|
boolean has_color[CLR_MAX];
|
||||||
@@ -167,6 +176,12 @@ extern
|
|||||||
#define status_update (*windowprocs.win_status_update)
|
#define status_update (*windowprocs.win_status_update)
|
||||||
#define update_invent_slot (*windowprocs.win_update_invent_slot)
|
#define update_invent_slot (*windowprocs.win_update_invent_slot)
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define WPID(name) #name, wp_##name
|
||||||
|
#define WPIDMINUS(name) "-" #name, wp_##name
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* WINCAP
|
* WINCAP
|
||||||
* Window port preference capability bits.
|
* Window port preference capability bits.
|
||||||
@@ -278,8 +293,13 @@ struct wc_Opt {
|
|||||||
|
|
||||||
/* Macro for the currently active Window Port whose function
|
/* Macro for the currently active Window Port whose function
|
||||||
pointers have been loaded */
|
pointers have been loaded */
|
||||||
|
#if 0
|
||||||
|
/* 3.7 The string comparison version isn't used anymore */
|
||||||
#define WINDOWPORT(wn) \
|
#define WINDOWPORT(wn) \
|
||||||
(windowprocs.name && !strncmpi((#wn), windowprocs.name, strlen((#wn))))
|
(windowprocs.name && !strncmpi((#wn), windowprocs.name, strlen((#wn))))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define WINDOWPORT(wn) (windowprocs.wp_id == wp_##wn)
|
||||||
|
|
||||||
/* role selection by player_selection(); this ought to be in the core... */
|
/* role selection by player_selection(); this ought to be in the core... */
|
||||||
#define RS_NAME 0
|
#define RS_NAME 0
|
||||||
@@ -320,6 +340,7 @@ struct chain_procs {
|
|||||||
const char *name; /* Names should start with [a-z]. Names must
|
const char *name; /* Names should start with [a-z]. Names must
|
||||||
* not start with '-'. Names starting with
|
* not start with '-'. Names starting with
|
||||||
* '+' are reserved for processors. */
|
* '+' are reserved for processors. */
|
||||||
|
enum wp_ids wp_id;
|
||||||
unsigned long wincap; /* window port capability options supported */
|
unsigned long wincap; /* window port capability options supported */
|
||||||
unsigned long wincap2; /* additional window port capability options */
|
unsigned long wincap2; /* additional window port capability options */
|
||||||
boolean has_color[CLR_MAX];
|
boolean has_color[CLR_MAX];
|
||||||
|
|||||||
@@ -6304,7 +6304,7 @@ initoptions_finish(void)
|
|||||||
* Option processing can take place before a user-decided WindowPort
|
* Option processing can take place before a user-decided WindowPort
|
||||||
* is even initialized, so check for that too.
|
* is even initialized, so check for that too.
|
||||||
*/
|
*/
|
||||||
if (!WINDOWPORT(safe-startup)) {
|
if (!WINDOWPORT(safestartup)) {
|
||||||
if (iflags.hilite_delta && !wc2_supported("statushilites")) {
|
if (iflags.hilite_delta && !wc2_supported("statushilites")) {
|
||||||
raw_printf("Status highlighting not supported for %s interface.",
|
raw_printf("Status highlighting not supported for %s interface.",
|
||||||
windowprocs.name);
|
windowprocs.name);
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ choose_windows(const char *s)
|
|||||||
free((genericptr_t) tmps) /*, tmps = 0*/ ;
|
free((genericptr_t) tmps) /*, tmps = 0*/ ;
|
||||||
|
|
||||||
if (windowprocs.win_raw_print == def_raw_print
|
if (windowprocs.win_raw_print == def_raw_print
|
||||||
|| WINDOWPORT(safe-startup))
|
|| WINDOWPORT(safestartup))
|
||||||
nh_terminate(EXIT_SUCCESS);
|
nh_terminate(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +539,7 @@ static void hup_void_fdecl_constchar_p(const char *);
|
|||||||
static perminvent_info *hup_update_invent_slot(winid, int, perminvent_info *);
|
static perminvent_info *hup_update_invent_slot(winid, int, perminvent_info *);
|
||||||
|
|
||||||
static struct window_procs hup_procs = {
|
static struct window_procs hup_procs = {
|
||||||
"hup", 0L, 0L,
|
WPID(hup), 0L, 0L,
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
hup_init_nhwindows,
|
hup_init_nhwindows,
|
||||||
hup_void_ndecl, /* player_selection */
|
hup_void_ndecl, /* player_selection */
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
#error You cannot compile this with both GUISTUB and TTYSTUB defined.
|
#error You cannot compile this with both GUISTUB and TTYSTUB defined.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct window_procs mswin_procs = { "-guistubs" };
|
struct window_procs mswin_procs = { WPIDMINUS(guistubs) };
|
||||||
|
|
||||||
#ifdef QT_GRAPHICS
|
#ifdef QT_GRAPHICS
|
||||||
struct window_procs Qt_procs = { "-guistubs" };
|
struct window_procs Qt_procs = { WPIDMINUS(guistubs) };
|
||||||
int qt_tilewidth, qt_tileheight, qt_fontsize, qt_compact_mode;
|
int qt_tilewidth, qt_tileheight, qt_fontsize, qt_compact_mode;
|
||||||
#endif
|
#endif
|
||||||
void
|
void
|
||||||
@@ -59,7 +59,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
HANDLE hConIn;
|
HANDLE hConIn;
|
||||||
HANDLE hConOut;
|
HANDLE hConOut;
|
||||||
struct window_procs tty_procs = { "-ttystubs" };
|
struct window_procs tty_procs = { WPIDMINUS(ttystubs) };
|
||||||
#ifdef CURSES_GRAPHICS
|
#ifdef CURSES_GRAPHICS
|
||||||
char erase_char, kill_char;
|
char erase_char, kill_char;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -893,7 +893,7 @@ safe_routines(void)
|
|||||||
* Get a set of valid safe windowport function
|
* Get a set of valid safe windowport function
|
||||||
* pointers during early startup initialization.
|
* pointers during early startup initialization.
|
||||||
*/
|
*/
|
||||||
if (!WINDOWPORT(safe-startup))
|
if (!WINDOWPORT(safestartup))
|
||||||
windowprocs = *get_safe_procs(1);
|
windowprocs = *get_safe_procs(1);
|
||||||
if (!GUILaunched)
|
if (!GUILaunched)
|
||||||
windowprocs.win_nhgetch = windows_console_custom_nhgetch;
|
windowprocs.win_nhgetch = windows_console_custom_nhgetch;
|
||||||
@@ -1316,7 +1316,7 @@ tty_self_recover_prompt(void)
|
|||||||
c = 'n';
|
c = 'n';
|
||||||
ct = 0;
|
ct = 0;
|
||||||
saved_procs = windowprocs;
|
saved_procs = windowprocs;
|
||||||
if (!WINDOWPORT(safe-startup))
|
if (!WINDOWPORT(safestartup))
|
||||||
windowprocs = *get_safe_procs(2); /* arg 2 uses no-newline variant */
|
windowprocs = *get_safe_procs(2); /* arg 2 uses no-newline variant */
|
||||||
windowprocs.win_nhgetch = windows_console_custom_nhgetch;
|
windowprocs.win_nhgetch = windows_console_custom_nhgetch;
|
||||||
raw_print("\n");
|
raw_print("\n");
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ win32_abort(void)
|
|||||||
exit_nhwindows((char *) 0);
|
exit_nhwindows((char *) 0);
|
||||||
iflags.window_inited = FALSE;
|
iflags.window_inited = FALSE;
|
||||||
}
|
}
|
||||||
if (!WINDOWPORT(mswin) && !WINDOWPORT(safe-startup))
|
if (!WINDOWPORT(mswin) && !WINDOWPORT(safestartup))
|
||||||
safe_routines();
|
safe_routines();
|
||||||
if (wizard) {
|
if (wizard) {
|
||||||
raw_print("Execute debug breakpoint wizard?");
|
raw_print("Execute debug breakpoint wizard?");
|
||||||
|
|||||||
@@ -1033,7 +1033,7 @@ static void Qt_positionbar(char *) {}
|
|||||||
} // namespace nethack_qt_
|
} // namespace nethack_qt_
|
||||||
|
|
||||||
struct window_procs Qt_procs = {
|
struct window_procs Qt_procs = {
|
||||||
"Qt",
|
WPID(Qt),
|
||||||
(WC_COLOR | WC_HILITE_PET
|
(WC_COLOR | WC_HILITE_PET
|
||||||
| WC_ASCII_MAP | WC_TILED_MAP
|
| WC_ASCII_MAP | WC_TILED_MAP
|
||||||
| WC_FONT_MAP | WC_TILE_FILE | WC_TILE_WIDTH | WC_TILE_HEIGHT
|
| WC_FONT_MAP | WC_TILE_FILE | WC_TILE_WIDTH | WC_TILE_HEIGHT
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ static XtSignalId X11_sig_id;
|
|||||||
|
|
||||||
/* Interface definition, for windows.c */
|
/* Interface definition, for windows.c */
|
||||||
struct window_procs X11_procs = {
|
struct window_procs X11_procs = {
|
||||||
"X11",
|
WPID(X11),
|
||||||
( WC_COLOR | WC_INVERSE | WC_HILITE_PET | WC_ASCII_MAP | WC_TILED_MAP
|
( WC_COLOR | WC_INVERSE | WC_HILITE_PET | WC_ASCII_MAP | WC_TILED_MAP
|
||||||
| WC_PLAYER_SELECTION | WC_PERM_INVENT | WC_MOUSE_SUPPORT ),
|
| WC_PLAYER_SELECTION | WC_PERM_INVENT | WC_MOUSE_SUPPORT ),
|
||||||
/* status requires VIA_WINDOWPORT(); WC2_FLUSH_STATUS ensures that */
|
/* status requires VIA_WINDOWPORT(); WC2_FLUSH_STATUS ensures that */
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ chainin_update_invent_slot(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct window_procs chainin_procs = {
|
struct window_procs chainin_procs = {
|
||||||
"-chainin", 0, /* wincap */
|
WPIDMINUS(chainin), 0, /* wincap */
|
||||||
0, /* wincap2 */
|
0, /* wincap2 */
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -717,7 +717,7 @@ chainout_update_invent_slot(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct chain_procs chainout_procs = {
|
struct chain_procs chainout_procs = {
|
||||||
"-chainout", 0, /* wincap */
|
WPIDMINUS(chainout), 0, /* wincap */
|
||||||
0, /* wincap2 */
|
0, /* wincap2 */
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ static char *dummy_get_color_string(void);
|
|||||||
|
|
||||||
/* Interface definition, for windows.c */
|
/* Interface definition, for windows.c */
|
||||||
struct window_procs curses_procs = {
|
struct window_procs curses_procs = {
|
||||||
"curses",
|
WPID(curses),
|
||||||
(WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_COLOR | WC_INVERSE
|
(WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_COLOR | WC_INVERSE
|
||||||
| WC_HILITE_PET
|
| WC_HILITE_PET
|
||||||
#ifdef NCURSES_MOUSE_VERSION /* (this macro name works for PDCURSES too) */
|
#ifdef NCURSES_MOUSE_VERSION /* (this macro name works for PDCURSES too) */
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct window_procs safe_procs = {
|
struct window_procs safe_procs = {
|
||||||
"safe-startup", 0L, 0L,
|
WPID(safestartup), 0L, 0L,
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
|
||||||
safe_init_nhwindows, safe_player_selection, safe_askname,
|
safe_init_nhwindows, safe_player_selection, safe_askname,
|
||||||
safe_get_nh_event,
|
safe_get_nh_event,
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ DECLB(perminvent_info *, shim_update_invent_slot,
|
|||||||
|
|
||||||
/* Interface definition used in windows.c */
|
/* Interface definition used in windows.c */
|
||||||
struct window_procs shim_procs = {
|
struct window_procs shim_procs = {
|
||||||
"shim",
|
WPID(shim),
|
||||||
(0
|
(0
|
||||||
| WC_ASCII_MAP
|
| WC_ASCII_MAP
|
||||||
| WC_COLOR | WC_HILITE_PET | WC_INVERSE | WC_EIGHT_BIT_IN),
|
| WC_COLOR | WC_HILITE_PET | WC_INVERSE | WC_EIGHT_BIT_IN),
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ extern void msmsg(const char *, ...);
|
|||||||
|
|
||||||
/* Interface definition, for windows.c */
|
/* Interface definition, for windows.c */
|
||||||
struct window_procs tty_procs = {
|
struct window_procs tty_procs = {
|
||||||
"tty",
|
WPID(tty),
|
||||||
(0
|
(0
|
||||||
#ifdef TTY_PERM_INVENT
|
#ifdef TTY_PERM_INVENT
|
||||||
| WC_PERM_INVENT
|
| WC_PERM_INVENT
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ strbuf_t raw_print_strbuf = { 0 };
|
|||||||
|
|
||||||
/* Interface definition, for windows.c */
|
/* Interface definition, for windows.c */
|
||||||
struct window_procs mswin_procs = {
|
struct window_procs mswin_procs = {
|
||||||
"MSWIN",
|
WPID(mswin),
|
||||||
WC_COLOR | WC_HILITE_PET | WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_INVERSE
|
WC_COLOR | WC_HILITE_PET | WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_INVERSE
|
||||||
| WC_SCROLL_AMOUNT | WC_SCROLL_MARGIN | WC_MAP_MODE | WC_FONT_MESSAGE
|
| WC_SCROLL_AMOUNT | WC_SCROLL_MARGIN | WC_MAP_MODE | WC_FONT_MESSAGE
|
||||||
| WC_FONT_STATUS | WC_FONT_MENU | WC_FONT_TEXT | WC_FONT_MAP
|
| WC_FONT_STATUS | WC_FONT_MENU | WC_FONT_TEXT | WC_FONT_MAP
|
||||||
|
|||||||
Reference in New Issue
Block a user