Merge branch 'NetHack-3.6'
This commit is contained in:
@@ -877,13 +877,20 @@ curses_convert_keys(int key)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* we treat buttons 2 and 3 as equivalent so that it doesn't matter which
|
||||
one is for right-click and which for middle-click; the core uses CLICK_2
|
||||
for right-click ("not left" click) even though 2 might be middle button;
|
||||
we also support Ctrl+left-click as another way to get "not left" click
|
||||
since Mac is traditionally saddled with a one button mouse or trackpad */
|
||||
#define MOUSEBUTTONS ((BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED) \
|
||||
| BUTTON_CTRL)
|
||||
/*
|
||||
* We treat buttons 2 and 3 as equivalent so that it doesn't matter which
|
||||
* one is for right-click and which for middle-click. The core uses CLICK_2
|
||||
* for right-click ("not left"-click) even though 2 might be middle button.
|
||||
*
|
||||
* BUTTON_CTRL was enabled at one point but was not working as intended.
|
||||
* Ctrl+left_click was generating pairs of duplicated events with Ctrl and
|
||||
* Report_mouse_position bits set (even though Report_mouse_position wasn't
|
||||
* enabled) but no button click bit set. (It sort of worked because Ctrl+
|
||||
* Report_mouse_position wasn't a left click so passed along CLICK_2, but
|
||||
* the duplication made that too annoying to use. Attempting to immediately
|
||||
* drain the second one wasn't working as intended either.)
|
||||
*/
|
||||
#define MOUSEBUTTONS (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)
|
||||
|
||||
/* Process mouse events. Mouse movement is processed until no further
|
||||
mouse movement events are available. Returns 0 for a mouse click
|
||||
|
||||
@@ -101,6 +101,9 @@ struct window_procs safe_procs = {
|
||||
safe_status_update,
|
||||
#endif
|
||||
safe_can_suspend,
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
safe_keyboard_hit
|
||||
#endif
|
||||
};
|
||||
|
||||
struct window_procs *
|
||||
@@ -386,6 +389,14 @@ safe_can_suspend()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
boolean
|
||||
safe_keyboard_hit()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
safe_nhbell()
|
||||
{
|
||||
|
||||
@@ -36,6 +36,12 @@ extern void msmsg(const char *, ...);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
#if defined(UNIX)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TTY_TILES_ESCCODES
|
||||
extern short glyph2tile[];
|
||||
#define TILE_ANSI_COMMAND 'z'
|
||||
@@ -131,6 +137,9 @@ struct window_procs tty_procs = {
|
||||
genl_status_update,
|
||||
#endif
|
||||
genl_can_suspend_yes,
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
tty_keyboard_hit
|
||||
#endif
|
||||
};
|
||||
|
||||
static int maxwin = 0; /* number of windows in use */
|
||||
@@ -3477,6 +3486,7 @@ const char *str;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NEW_KEYBOARD_HIT
|
||||
int
|
||||
tty_nhgetch()
|
||||
{
|
||||
@@ -3531,6 +3541,93 @@ tty_nhgetch()
|
||||
#endif /* TTY_TILES_ESCCODES */
|
||||
return i;
|
||||
}
|
||||
#else /* NEW_KEYBOARD_HIT */
|
||||
#ifdef UNIX
|
||||
static boolean stdin_non_blocking = FALSE;
|
||||
|
||||
int
|
||||
tgetch()
|
||||
{
|
||||
static volatile int nesting = 0;
|
||||
int i;
|
||||
char nestbuf;
|
||||
|
||||
if (stdin_non_blocking) {
|
||||
fcntl(0, F_SETFL, fcntl(0, F_GETFL) & ~O_NONBLOCK);
|
||||
stdin_non_blocking = FALSE;
|
||||
}
|
||||
|
||||
/* kludge alert: Some Unix variants return funny values if getc()
|
||||
* is called, interrupted, and then called again. There
|
||||
* is non-reentrant code in the internal _filbuf() routine, called by
|
||||
* getc().
|
||||
*/
|
||||
i = (++nesting == 1)
|
||||
? getchar()
|
||||
: (read(fileno(stdin), (genericptr_t) &nestbuf, 1) == 1)
|
||||
? (int) nestbuf : EOF;
|
||||
--nesting;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
boolean
|
||||
tkbhit()
|
||||
{
|
||||
int i;
|
||||
if (!stdin_non_blocking) {
|
||||
fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK);
|
||||
stdin_non_blocking = TRUE;
|
||||
}
|
||||
i = getchar();
|
||||
if (i != EOF) ungetc(i, stdin);
|
||||
return (i != EOF);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
tty_nhgetch()
|
||||
{
|
||||
int i;
|
||||
HUPSKIP_RESULT('\033');
|
||||
print_vt_code1(AVTC_INLINE_SYNC);
|
||||
(void) fflush(stdout);
|
||||
/* Note: if raw_print() and wait_synch() get called to report terminal
|
||||
* initialization problems, then wins[] and ttyDisplay might not be
|
||||
* available yet. Such problems will probably be fatal before we get
|
||||
* here, but validate those pointers just in case...
|
||||
*/
|
||||
if (WIN_MESSAGE != WIN_ERR && wins[WIN_MESSAGE])
|
||||
wins[WIN_MESSAGE]->flags &= ~WIN_STOP;
|
||||
if (iflags.debug_fuzzer) {
|
||||
i = randomkey();
|
||||
} else {
|
||||
i = tgetch();
|
||||
}
|
||||
if (!i)
|
||||
i = '\033'; /* map NUL to ESC since nethack doesn't expect NUL */
|
||||
else if (i == EOF)
|
||||
i = '\033'; /* same for EOF */
|
||||
if (ttyDisplay && ttyDisplay->toplin == 1)
|
||||
ttyDisplay->toplin = 2;
|
||||
#ifdef TTY_TILES_ESCCODES
|
||||
{
|
||||
/* hack to force output of the window select code */
|
||||
int tmp = vt_tile_current_window;
|
||||
|
||||
vt_tile_current_window++;
|
||||
print_vt_code2(AVTC_SELECT_WINDOW, tmp);
|
||||
}
|
||||
#endif /* TTY_TILES_ESCCODES */
|
||||
return i;
|
||||
}
|
||||
|
||||
boolean tty_keyboard_hit()
|
||||
{
|
||||
/* tgetch provider needs to also provide tkbhit() */
|
||||
return tkbhit();
|
||||
}
|
||||
#endif /* NEW_KEYBOARD_HIT */
|
||||
|
||||
/*
|
||||
* return a key, or 0, in which case a mouse button was pressed
|
||||
|
||||
@@ -116,6 +116,9 @@ struct window_procs mswin_procs = {
|
||||
mswin_status_init, mswin_status_finish, mswin_status_enablefield,
|
||||
mswin_status_update,
|
||||
genl_can_suspend_yes,
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
mswin_keyboard_hit
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1402,6 +1405,15 @@ mswin_nhgetch()
|
||||
return (key);
|
||||
}
|
||||
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
/* boolean keyboard_hit() -- returns TRUE if input is available */
|
||||
boolean
|
||||
mswin_keyboard_hit()
|
||||
{
|
||||
return mswin_have_input() != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
int nh_poskey(int *x, int *y, int *mod)
|
||||
-- Returns a single character input from the user or a
|
||||
|
||||
@@ -167,6 +167,9 @@ void mswin_raw_print(const char *str);
|
||||
void mswin_raw_print_bold(const char *str);
|
||||
void mswin_raw_print_flush();
|
||||
int mswin_nhgetch(void);
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
boolean mswin_keyboard_hit(void);
|
||||
#endif
|
||||
int mswin_nh_poskey(int *x, int *y, int *mod);
|
||||
void mswin_nhbell(void);
|
||||
int mswin_doprev_message(void);
|
||||
|
||||
Reference in New Issue
Block a user