diff --git a/ChangeLog b/ChangeLog index 5bc9f0254..373d13625 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ +2023-07-28 Simon Sobisch + + * configure.ac: check for mousemask and mmask_t + 2023-07-24 Simon Sobisch * configure.ac: fix for resolving COBCRUN_NAME diff --git a/build_windows/config.h.in b/build_windows/config.h.in index 76d504a22..55a082451 100644 --- a/build_windows/config.h.in +++ b/build_windows/config.h.in @@ -368,6 +368,9 @@ /* #undef HAVE_ATTRIBUTE_CONSTRUCTOR - using DllMain */ #endif +/* Has __attribute__((pure)) */ +/* #undef HAVE_ATTRIBUTE_PURE */ + /* Define to 1 if you have the `canonicalize_file_name' function. */ #if defined(__ORANGEC__) #define HAVE_CANONICALIZE_FILE_NAME 1 @@ -596,6 +599,13 @@ /* #undef HAVE_MOUSEINTERVAL */ #endif +/* curses has mousemask function and mmask_t definition */ +#if CONFIGURED_CURSES != NOCURSES +#define HAVE_MOUSEMASK 1 +#else +/* #undef HAVE_MOUSEMASK */ +#endif + /* Define to 1 if you have the header file. */ #if USED_MATHLIB == MATHLIB_MPIR #define HAVE_MPIR_H 1 diff --git a/configure.ac b/configure.ac index bdccf1656..48e7df66c 100644 --- a/configure.ac +++ b/configure.ac @@ -179,6 +179,7 @@ AH_TEMPLATE([HAVE_RESIZE_TERM], [curses has resize_term function]) AH_TEMPLATE([HAVE_DEFINE_KEY], [curses has define_key function]) AH_TEMPLATE([HAVE_MOUSEINTERVAL], [curses has mouseinterval function]) AH_TEMPLATE([HAVE_HAS_MOUSE], [curses has has_mouse function]) +AH_TEMPLATE([HAVE_MOUSEMASK], [curses has mousemask function and mmask_t definition]) AH_TEMPLATE([HAVE_CURSES_FREEALL], [curses provides function to free all memory]) AH_TEMPLATE([HAVE_USE_LEGACY_CODING], [ncurses has use_legacy_coding function]) AH_TEMPLATE([HAVE_DESIGNATED_INITS], [Has designated initializers]) @@ -1529,6 +1530,28 @@ if test "$USE_CURSES" != no -a "$USE_CURSES" != "not_found"; then [AC_DEFINE([HAVE_HAS_MOUSE], [1]) AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])], []) + + AC_MSG_CHECKING([for curses mousemask function and mmask_t]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #ifdef HAVE_NCURSESW_NCURSES_H + #include + #elif defined (HAVE_NCURSESW_CURSES_H) + #include + #elif defined (HAVE_NCURSES_H) + #include + #elif defined (HAVE_NCURSES_NCURSES_H) + #include + #elif defined (HAVE_PDCURSES_H) + #include + #elif defined (HAVE_CURSES_H) + #include + #endif]], [[ + mmask_t dummy = { 0 }; + mousemask (dummy, NULL); + ]])], + [AC_DEFINE([HAVE_MOUSEMASK], [1]) AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])], + []) fi LIBS="$curr_libs $LIBCOB_LIBS" diff --git a/libcob/ChangeLog b/libcob/ChangeLog index 2edaadf9b..c47fc3186 100644 --- a/libcob/ChangeLog +++ b/libcob/ChangeLog @@ -1,4 +1,9 @@ +2023-07-28 Simon Sobisch + + * screenio.c, common.c: replace use of NCURSES_MOUSE_VERSION by + HAVE_MOUSEMASK + 2023-07-27 Chuck Haatvedt * move.c (cob_move_display_to_packed): fix data corruption caused diff --git a/libcob/common.c b/libcob/common.c index b190b8e3f..eef27ffc1 100644 --- a/libcob/common.c +++ b/libcob/common.c @@ -115,8 +115,6 @@ #include #define COB_GEN_SCREENIO #elif defined (HAVE_PDCURSES_H) -/* will internally define NCURSES_MOUSE_VERSION with - a recent version (for older version define manually): */ #define PDC_NCMOUSE /* use ncurses compatible mouse API */ #include #define COB_GEN_SCREENIO @@ -129,6 +127,12 @@ #endif #endif +#if defined (__PDCURSES__) +/* Note: PDC will internally define NCURSES_MOUSE_VERSION with + a recent version when PDC_NCMOUSE was defined; + for older version define manually! */ +#endif + #if defined (WITH_XML2) #include #include @@ -9219,8 +9223,10 @@ get_screenio_and_mouse_info (char *version_buffer, size_t size, const int verbos mouse_support = _("no"); } } -#elif defined (NCURSES_MOUSE_VERSION) +#elif defined (HAVE_MOUSEMASK) #if defined (__PDCURSES__) + /* CHECKME: that looks wrong - can't we test as above? + Double check with older PDCurses! */ mouse_support = _("yes"); #endif #else diff --git a/libcob/screenio.c b/libcob/screenio.c index b64223f8b..3197019a2 100644 --- a/libcob/screenio.c +++ b/libcob/screenio.c @@ -55,26 +55,18 @@ #include #define WITH_EXTENDED_SCREENIO #elif defined (HAVE_PDCURSES_H) -/* will internally define NCURSES_MOUSE_VERSION with - a recent version (for older version define manually): */ #define PDC_NCMOUSE /* use ncurses compatible mouse API */ #include #define WITH_EXTENDED_SCREENIO #elif defined (HAVE_PDCURSES_CURSES_H) -/* will internally define NCURSES_MOUSE_VERSION with - a recent version (for older version define manually): */ #define PDC_NCMOUSE /* use ncurses compatible mouse API */ #include #define WITH_EXTENDED_SCREENIO #elif defined (HAVE_XCURSES_H) -/* will internally define NCURSES_MOUSE_VERSION with - a recent version (for older version define manually): */ #define PDC_NCMOUSE /* use ncurses compatible mouse API */ #include #define WITH_EXTENDED_SCREENIO #elif defined (HAVE_XCURSES_CURSES_H) -/* will internally define NCURSES_MOUSE_VERSION with - a recent version (for older version define manually): */ #define PDC_NCMOUSE /* use ncurses compatible mouse API */ #include #define WITH_EXTENDED_SCREENIO @@ -87,6 +79,12 @@ #define WITH_EXTENDED_SCREENIO #endif +#if defined (__PDCURSES__) +/* Note: PDC will internally define NCURSES_MOUSE_VERSION with + a recent version when PDC_NCMOUSE was defined; + for older version define manually! */ +#endif + /* work around broken system headers or compile flags defining NCURSES_WIDECHAR / PDC_WIDE but not including the actual definitions */ #if defined (NCURSES_WIDECHAR) && !defined (WACS_HLINE) @@ -106,7 +104,7 @@ #ifdef HAVE_CURSES_FREEALL extern void _nc_freeall (void); #endif -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK static mmask_t cob_mask_accept; /* mask that is returned to COBOL ACCEPT */ static mmask_t cob_mask_routine; /* mask that is returned to COBOL routines (reserved) */ #if defined BUTTON5_PRESSED /* added in NCURSES_MOUSE_VERSION 2 */ @@ -164,7 +162,7 @@ static int accept_cursor_x; static int pending_accept; static int got_sys_char; static unsigned int curr_setting_insert_mode = INT_MAX; -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK static unsigned int curr_setting_mouse_flags = UINT_MAX; #endif #endif @@ -2147,7 +2145,7 @@ find_field_by_pos (const int initial_curs, const int line, const int column) { return -1; } -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK static int mouse_to_exception_code (mmask_t mask) { int fret = -1; @@ -2397,7 +2395,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout) int integer_part_end; char sign; int fix_position = 0; -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK MEVENT mevent; #endif @@ -2429,7 +2427,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout) } } -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK /* prevent warnings about not intialized structure */ memset (&mevent, 0, sizeof (MEVENT)); #endif @@ -2458,7 +2456,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout) goto screen_return; } -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK /* get mouse event here, handle later */ if (keyp == KEY_MOUSE) { getmouse (&mevent); @@ -2722,7 +2720,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout) /* Enter sign */ break; -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK case KEY_MOUSE: { int mline = mevent.y; @@ -3401,7 +3399,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum int status; chtype prompt_char; /* prompt character */ chtype default_prompt_char; -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK MEVENT mevent; #endif @@ -3421,7 +3419,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum origin_y = 0; origin_x = 0; -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK /* prevent warnings about not intialized structure */ memset (&mevent, 0, sizeof (MEVENT)); #endif @@ -3636,7 +3634,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum continue; } -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK /* get mouse event here, handle later */ if (keyp == KEY_MOUSE) { getmouse (&mevent); @@ -3722,7 +3720,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum /* End key. */ fret = 2015; goto field_return; -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK case KEY_MOUSE: { int mline = mevent.y; @@ -3949,7 +3947,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum cob_move_cursor (cline, ccolumn); continue; -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK case KEY_MOUSE: { int mline = mevent.y; @@ -4965,7 +4963,7 @@ cob_settings_screenio (void) #ifdef HAVE_MOUSEINTERVAL mouseinterval (COB_MOUSE_INTERVAL); #endif -#ifdef NCURSES_MOUSE_VERSION +#ifdef HAVE_MOUSEMASK if (curr_setting_mouse_flags != COB_MOUSE_FLAGS) { mmask_t mask_applied = cob_mask_routine; if (COB_MOUSE_FLAGS) {