summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Perez de Castro <aperez@igalia.com>2019-08-05 15:44:33 +0300
committerRan Benita <ran234@gmail.com>2019-12-28 16:12:15 +0200
commitabb2f9d978230f2208bff0af1e7107caab2b4abd (patch)
treeae291f642284baeab543169aec2b7f694cff4297
parent5354dee2f7ee99792a38a3a13f85da90c654f7ee (diff)
downloadlibxkbcommon-abb2f9d978230f2208bff0af1e7107caab2b4abd.tar.gz
libxkbcommon-abb2f9d978230f2208bff0af1e7107caab2b4abd.tar.bz2
libxkbcommon-abb2f9d978230f2208bff0af1e7107caab2b4abd.zip
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 <termios.h>, which is not available on Windows.
-rw-r--r--test/common.c27
1 files 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 <limits.h>
#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#ifdef _MSC_VER
#include <io.h>
+#include <windows.h>
#else
#include <unistd.h>
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
#include <termios.h>
+#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