From 5f0c39134d29b16ce6e864d9ad1a88c959786466 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 29 Oct 2024 15:15:31 +0100 Subject: PDCurses: filter out bogus double keypresses in combination with CTRL (refs #20) * Has been observed on PDCursesMod/WinGUI when pressing CTRL+Shift+6 on an US layout. I would expect code 30 (^^) to be inserted, instead PDCurses reports two keypresses (6^^). The first one is now filtered out since this will not be fixed upstream. See also https://github.com/Bill-Gray/PDCursesMod/issues/323 * Since AltGr on German layouts is reported as CTRL+ALT, we must be careful not to filter those out as well. * This is active on all PDCurses variants - who knows which other platforms will behave similarily. * You still cannot insert code 0 via CTRL+@ since PDCurses doesn't report it, but ncurses does not allow that either. This _could_ be synthesized by evaluating the modifier flags, though. --- src/interface-curses/interface.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index b1fa88b..075c9c7 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -1705,6 +1705,18 @@ teco_interface_event_loop_iter(void) /* unhandled function key */ return; +#ifdef __PDCURSES__ + /* + * Especially PDCurses/WinGUI likes to report two keypresses, + * e.g. for CTRL+Shift+6 (CTRL+^). + * Make sure we don't filter out AltGr, which may be reported as CTRL+ALT. + */ + if ((PDC_get_key_modifiers() & + (PDC_KEY_MODIFIER_CONTROL | PDC_KEY_MODIFIER_ALT)) == PDC_KEY_MODIFIER_CONTROL && + !TECO_IS_CTL(key)) + return; +#endif + /* * NOTE: There's also wget_wch(), but it requires * a widechar version of Curses. -- cgit v1.2.3