From 2b9bb5d0c8fc563fec431cf24efb0f985e4b43b7 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Fri, 28 Dec 2018 10:42:15 -0500 Subject: [PATCH] Avoid potential conflict with ncurses by having apps define PDC_NCMOUSE before including curses.h, to invoke the ncurses-style mouse interface, instead of NCURSES_MOUSE_VERSION. (The old way will also still work.) After Simon Sobisch (see PR #33). --- curses.h | 8 ++++++-- man/MANUAL.md | 14 +++++++------- pdcurses/mouse.c | 10 +++++----- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/curses.h b/curses.h index 10ffe884..a615ca36 100644 --- a/curses.h +++ b/curses.h @@ -16,8 +16,8 @@ PDCurses definitions list: (Only define those needed) (Red = 1, Green = 2, Blue = 4) instead of BGR. PDC_WIDE True if building wide-character support. PDC_DLL_BUILD True if building a Windows DLL. - NCURSES_MOUSE_VERSION Use the ncurses mouse API instead - of PDCurses' traditional mouse API. + PDC_NCMOUSE Use the ncurses mouse API instead + of PDCurses' traditional mouse API. PDCurses portable platform definitions list: @@ -216,6 +216,10 @@ typedef struct in the same format as used for mousemask() */ } MEVENT; +#if defined(PDC_NCMOUSE) && !defined(NCURSES_MOUSE_VERSION) +# define NCURSES_MOUSE_VERSION 2 +#endif + #ifdef NCURSES_MOUSE_VERSION # define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT # define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL diff --git a/man/MANUAL.md b/man/MANUAL.md index ef78ade2..cdaf0fa9 100644 --- a/man/MANUAL.md +++ b/man/MANUAL.md @@ -8,8 +8,8 @@ PDCurses definitions list: (Only define those needed) (Red = 1, Green = 2, Blue = 4) instead of BGR. PDC_WIDE True if building wide-character support. PDC_DLL_BUILD True if building a Windows DLL. - NCURSES_MOUSE_VERSION Use the ncurses mouse API instead - of PDCurses' traditional mouse API. + PDC_NCMOUSE Use the ncurses mouse API instead + of PDCurses' traditional mouse API. PDCurses portable platform definitions list: @@ -1782,11 +1782,11 @@ mouse nc_getmouse() returns the current mouse status in an MEVENT struct. This is equivalent to ncurses' getmouse(), renamed to avoid conflict with PDCurses' getmouse(). But if you define - NCURSES_MOUSE_VERSION (preferably as 2) before including - curses.h, it defines getmouse() to nc_getmouse(), along with a - few other redefintions needed for compatibility with ncurses - code. nc_getmouse() calls request_mouse_pos(), which (not - getmouse()) is the classic equivalent. + PDC_NCMOUSE before including curses.h, it defines getmouse() to + nc_getmouse(), along with a few other redefintions needed for + compatibility with ncurses code. nc_getmouse() calls + request_mouse_pos(), which (not getmouse()) is the classic + equivalent. ungetmouse() is the mouse equivalent of ungetch(). However, PDCurses doesn't maintain a queue of mouse events; only one can diff --git a/pdcurses/mouse.c b/pdcurses/mouse.c index ca04c9be..a6acec9a 100644 --- a/pdcurses/mouse.c +++ b/pdcurses/mouse.c @@ -120,11 +120,11 @@ mouse nc_getmouse() returns the current mouse status in an MEVENT struct. This is equivalent to ncurses' getmouse(), renamed to avoid conflict with PDCurses' getmouse(). But if you define - NCURSES_MOUSE_VERSION (preferably as 2) before including - curses.h, it defines getmouse() to nc_getmouse(), along with a - few other redefintions needed for compatibility with ncurses - code. nc_getmouse() calls request_mouse_pos(), which (not - getmouse()) is the classic equivalent. + PDC_NCMOUSE before including curses.h, it defines getmouse() to + nc_getmouse(), along with a few other redefintions needed for + compatibility with ncurses code. nc_getmouse() calls + request_mouse_pos(), which (not getmouse()) is the classic + equivalent. ungetmouse() is the mouse equivalent of ungetch(). However, PDCurses doesn't maintain a queue of mouse events; only one can