Merge 'curses-mouse_support' into NetHack-3.6
Fully support the mouse_support option for curses, via 'O' as well as via config file. At the moment, mouse_support:1 and mouse_support:2 are equivalent. Also, fix the screen-to-map coordinate translation. When the mouse is active and over the map, the pointer's cursor becomes a cross-hair (may very by platform) and the character cell chosen for a click seems to be a few pixels to the right of the center of the '+'.
This commit is contained in:
@@ -187,6 +187,7 @@ classify sources as released, beta, or work-in-progress via NH_DEVEL_STATUS
|
|||||||
if you reach the edge of a level (relatively uncommon) and try to move off,
|
if you reach the edge of a level (relatively uncommon) and try to move off,
|
||||||
report that you can't go farther if the 'mention_walls' option is set
|
report that you can't go farther if the 'mention_walls' option is set
|
||||||
wizard-mode: display effect to show where an unseen wished-for monster landed
|
wizard-mode: display effect to show where an unseen wished-for monster landed
|
||||||
|
curses: enable latent mouse support for ncurses; status for PDCurses unknown
|
||||||
curses+'perm_invent': since persistent inventory is narrow, strip off "a",
|
curses+'perm_invent': since persistent inventory is narrow, strip off "a",
|
||||||
"an", or "the" prefix on inventory entries shown there so that a tiny
|
"an", or "the" prefix on inventory entries shown there so that a tiny
|
||||||
bit more of the interesting portion is visible
|
bit more of the interesting portion is visible
|
||||||
|
|||||||
+1
-6
@@ -38,12 +38,6 @@ extern WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */
|
|||||||
#endif /* !__APPLE__ && !PDCURSES */
|
#endif /* !__APPLE__ && !PDCURSES */
|
||||||
#define CURSES_DARK_GRAY 17
|
#define CURSES_DARK_GRAY 17
|
||||||
#define MAP_SCROLLBARS
|
#define MAP_SCROLLBARS
|
||||||
#ifdef PDCURSES
|
|
||||||
# define getmouse nc_getmouse
|
|
||||||
# ifndef NCURSES_MOUSE_VERSION
|
|
||||||
# define NCURSES_MOUSE_VERSION
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(A_LEFTLINE) && defined(A_LEFT)
|
#if !defined(A_LEFTLINE) && defined(A_LEFT)
|
||||||
#define A_LEFTLINE A_LEFT
|
#define A_LEFTLINE A_LEFT
|
||||||
@@ -169,6 +163,7 @@ extern int curses_read_attrs(const char *attrs);
|
|||||||
extern char *curses_fmt_attrs(char *);
|
extern char *curses_fmt_attrs(char *);
|
||||||
extern int curses_convert_keys(int key);
|
extern int curses_convert_keys(int key);
|
||||||
extern int curses_get_mouse(int *mousex, int *mousey, int *mod);
|
extern int curses_get_mouse(int *mousex, int *mousey, int *mod);
|
||||||
|
extern void curses_mouse_support(int);
|
||||||
|
|
||||||
/* cursdial.c */
|
/* cursdial.c */
|
||||||
|
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ DLB =
|
|||||||
#==========================================
|
#==========================================
|
||||||
|
|
||||||
{$(WCURSES)}.c{$(OBJ)}.o:
|
{$(WCURSES)}.c{$(OBJ)}.o:
|
||||||
@$(cc) $(PDCINCL) $(cflagsBuild) -Fo$@ $<
|
@$(cc) -DPDC_NCMOUSE $(PDCINCL) $(cflagsBuild) -Fo$@ $<
|
||||||
|
|
||||||
#{$(WCURSES)}.txt{$(DAT)}.txt:
|
#{$(WCURSES)}.txt{$(DAT)}.txt:
|
||||||
# @copy $< $@
|
# @copy $< $@
|
||||||
|
|||||||
@@ -838,8 +838,10 @@ curses_init_options()
|
|||||||
|
|
||||||
#ifdef NCURSES_MOUSE_VERSION
|
#ifdef NCURSES_MOUSE_VERSION
|
||||||
if (iflags.wc_mouse_support) {
|
if (iflags.wc_mouse_support) {
|
||||||
mousemask(BUTTON1_CLICKED, NULL);
|
curses_mouse_support(iflags.wc_mouse_support);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
iflags.wc_mouse_support = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ extern long curs_mesg_suppress_turn; /* from cursmesg.c */
|
|||||||
struct window_procs curses_procs = {
|
struct window_procs curses_procs = {
|
||||||
"curses",
|
"curses",
|
||||||
(WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_COLOR | WC_HILITE_PET
|
(WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_COLOR | WC_HILITE_PET
|
||||||
|
#ifdef NCURSES_MOUSE_VERSION /* (this macro name works for PDCURSES too) */
|
||||||
|
| WC_MOUSE_SUPPORT
|
||||||
|
#endif
|
||||||
| WC_PERM_INVENT | WC_POPUP_DIALOG | WC_SPLASH_SCREEN),
|
| WC_PERM_INVENT | WC_POPUP_DIALOG | WC_SPLASH_SCREEN),
|
||||||
(WC2_DARKGRAY | WC2_HITPOINTBAR
|
(WC2_DARKGRAY | WC2_HITPOINTBAR
|
||||||
#if defined(STATUS_HILITES)
|
#if defined(STATUS_HILITES)
|
||||||
@@ -906,6 +909,8 @@ curses_preference_update(const char *pref)
|
|||||||
redo_status = TRUE;
|
redo_status = TRUE;
|
||||||
else if (!strcmp(pref, "align_message"))
|
else if (!strcmp(pref, "align_message"))
|
||||||
redo_main = TRUE;
|
redo_main = TRUE;
|
||||||
|
else if (!strcmp(pref, "mouse_support"))
|
||||||
|
curses_mouse_support(iflags.wc_mouse_support);
|
||||||
|
|
||||||
if (redo_main || redo_status)
|
if (redo_main || redo_status)
|
||||||
curs_reset_windows(redo_main, redo_status);
|
curs_reset_windows(redo_main, redo_status);
|
||||||
|
|||||||
+41
-6
@@ -870,6 +870,13 @@ curses_convert_keys(int key)
|
|||||||
return ret;
|
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)
|
||||||
|
|
||||||
/* Process mouse events. Mouse movement is processed until no further
|
/* Process mouse events. Mouse movement is processed until no further
|
||||||
mouse movement events are available. Returns 0 for a mouse click
|
mouse movement events are available. Returns 0 for a mouse click
|
||||||
@@ -884,12 +891,21 @@ curses_get_mouse(int *mousex, int *mousey, int *mod)
|
|||||||
#ifdef NCURSES_MOUSE_VERSION
|
#ifdef NCURSES_MOUSE_VERSION
|
||||||
MEVENT event;
|
MEVENT event;
|
||||||
|
|
||||||
if (getmouse(&event) == OK) { /* When the user clicks left mouse button */
|
if (getmouse(&event) == OK) { /* True if user has clicked */
|
||||||
if (event.bstate & BUTTON1_CLICKED) {
|
if ((event.bstate & MOUSEBUTTONS) != 0) {
|
||||||
|
/*
|
||||||
|
* The ncurses man page documents wmouse_trafo() incorrectly.
|
||||||
|
* It says that last argument 'TRUE' translates from screen
|
||||||
|
* to window and 'FALSE' translates from window to screen,
|
||||||
|
* but those are backwards. The mouse_trafo() macro calls
|
||||||
|
* last argument 'to_screen', suggesting that the backwards
|
||||||
|
* implementation is the intended behavior and the man page
|
||||||
|
* is describing it wrong.
|
||||||
|
*/
|
||||||
/* See if coords are in map window & convert coords */
|
/* See if coords are in map window & convert coords */
|
||||||
if (wmouse_trafo(mapwin, &event.y, &event.x, TRUE)) {
|
if (wmouse_trafo(mapwin, &event.y, &event.x, FALSE)) {
|
||||||
key = 0; /* Flag mouse click */
|
key = '\0'; /* core uses this to detect a mouse click */
|
||||||
*mousex = event.x;
|
*mousex = event.x + 1; /* +1: screen 0..78 is map 1..79 */
|
||||||
*mousey = event.y;
|
*mousey = event.y;
|
||||||
|
|
||||||
if (curses_window_has_border(MAP_WIN)) {
|
if (curses_window_has_border(MAP_WIN)) {
|
||||||
@@ -897,7 +913,8 @@ curses_get_mouse(int *mousex, int *mousey, int *mod)
|
|||||||
(*mousey)--;
|
(*mousey)--;
|
||||||
}
|
}
|
||||||
|
|
||||||
*mod = CLICK_1;
|
*mod = ((event.bstate & (BUTTON1_CLICKED | BUTTON_CTRL))
|
||||||
|
== BUTTON1_CLICKED) ? CLICK_1 : CLICK_2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -906,6 +923,24 @@ curses_get_mouse(int *mousex, int *mousey, int *mod)
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
curses_mouse_support(mode)
|
||||||
|
int mode; /* 0: off, 1: on, 2: alternate on */
|
||||||
|
{
|
||||||
|
#ifdef NCURSES_MOUSE_VERSION
|
||||||
|
mmask_t result, oldmask, newmask;
|
||||||
|
|
||||||
|
if (!mode)
|
||||||
|
newmask = 0;
|
||||||
|
else
|
||||||
|
newmask = MOUSEBUTTONS; /* buttons 1, 2, and 3 */
|
||||||
|
|
||||||
|
result = mousemask(newmask, &oldmask);
|
||||||
|
nhUse(result);
|
||||||
|
#else
|
||||||
|
nhUse(mode);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_escape_sequence(void)
|
parse_escape_sequence(void)
|
||||||
|
|||||||
@@ -30,5 +30,6 @@ int curses_read_attrs(const char *attrs);
|
|||||||
char *curses_fmt_attrs(char *);
|
char *curses_fmt_attrs(char *);
|
||||||
int curses_convert_keys(int key);
|
int curses_convert_keys(int key);
|
||||||
int curses_get_mouse(int *mousex, int *mousey, int *mod);
|
int curses_get_mouse(int *mousex, int *mousey, int *mod);
|
||||||
|
void curses_mouse_support(int);
|
||||||
|
|
||||||
#endif /* CURSMISC_H */
|
#endif /* CURSMISC_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user