From abb2f9d978230f2208bff0af1e7107caab2b4abd Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Mon, 5 Aug 2019 15:44:33 +0300 Subject: MSVC: Provide implementations of test_{dis,en}able_stdin_echo This provides implementations of the test_enable_stdin_echo and test_disable_stdin_echo which do not require , which is not available on Windows. --- test/common.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/test/common.c b/test/common.c index 446ce58..15a4fe0 100644 --- a/test/common.c +++ b/test/common.c @@ -34,14 +34,15 @@ #include #include +#include +#include #ifdef _MSC_VER #include +#include #else #include -#endif -#include -#include #include +#endif #include "test.h" #include "utils.h" @@ -468,6 +469,25 @@ test_print_state_changes(enum xkb_state_component changed) printf("]\n"); } +#ifdef _MSC_VER +void +test_disable_stdin_echo(void) +{ + HANDLE stdin_handle = GetStdHandle(STD_INPUT_HANDLE); + DWORD mode = 0; + GetConsoleMode(stdin_handle, &mode); + SetConsoleMode(stdin_handle, mode & ~ENABLE_ECHO_INPUT); +} + +void +test_enable_stdin_echo(void) +{ + HANDLE stdin_handle = GetStdHandle(STD_INPUT_HANDLE); + DWORD mode = 0; + GetConsoleMode(stdin_handle, &mode); + SetConsoleMode(stdin_handle, mode | ENABLE_ECHO_INPUT); +} +#else void test_disable_stdin_echo(void) { @@ -489,3 +509,4 @@ test_enable_stdin_echo(void) (void) tcsetattr(STDIN_FILENO, TCSADRAIN, &termios); } } +#endif -- cgit v1.2.1