Make wincon's PDC_set_keyboard_binary() actually work; retain processed

input mode status if not explicitly set. In other words, ^C will cause a
SIGINT in non-raw mode. (This matches the behavior of OS/2 and some
versions of DOS -- others need fixing.) Suggested by
https://stackoverflow.com/questions/67276939/ To Do: Some other console
attributes are currently ignored, but could be used.
This commit is contained in:
William McBrine
2021-05-12 16:02:48 -04:00
parent 9bd15bcfc8
commit 793556fff3

View File

@@ -215,7 +215,13 @@ static KPTAB ext_kptab[] =
void PDC_set_keyboard_binary(bool on)
{
DWORD mode;
PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
GetConsoleMode(pdc_con_in, &mode);
SetConsoleMode(pdc_con_in, !on ? (mode | ENABLE_PROCESSED_INPUT) :
(mode & ~ENABLE_PROCESSED_INPUT));
}
/* check if a key or mouse event is waiting */
@@ -635,13 +641,17 @@ bool PDC_has_mouse(void)
int PDC_mouse_set(void)
{
/* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear
all other flags, including the extended flags;
If turning off the mouse: Set QuickEdit Mode to the status it
had on startup, and clear all other flags */
DWORD mode;
SetConsoleMode(pdc_con_in, SP->_trap_mbe ?
(ENABLE_MOUSE_INPUT|0x0088) : (pdc_quick_edit|0x0088));
/* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear
all other flags, except processed input mode;
If turning off the mouse: Set QuickEdit Mode to the status it
had on startup, and clear all other flags, except etc. */
GetConsoleMode(pdc_con_in, &mode);
mode = (mode & 1) | 0x0088;
SetConsoleMode(pdc_con_in, mode | (SP->_trap_mbe ?
ENABLE_MOUSE_INPUT : pdc_quick_edit));
memset(&old_mouse_status, 0, sizeof(old_mouse_status));