aboutsummaryrefslogtreecommitdiff
path: root/win32/termios.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/termios.c')
-rw-r--r--win32/termios.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/win32/termios.c b/win32/termios.c
index 7a107c5bd..fe6f0c546 100644
--- a/win32/termios.c
+++ b/win32/termios.c
@@ -6,7 +6,12 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout)
6 INPUT_RECORD record; 6 INPUT_RECORD record;
7 DWORD nevent_out, mode; 7 DWORD nevent_out, mode;
8 int ret = -1; 8 int ret = -1;
9#if ENABLE_FEATURE_EURO
10 wchar_t uchar;
11 char achar;
12#else
9 char *s; 13 char *s;
14#endif
10 int alt_pressed = FALSE; 15 int alt_pressed = FALSE;
11 DWORD state; 16 DWORD state;
12 17
@@ -22,7 +27,11 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout)
22 if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0) 27 if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0)
23 goto done; 28 goto done;
24 } 29 }
30#if ENABLE_FEATURE_EURO
31 if (!ReadConsoleInputW(cin, &record, 1, &nevent_out))
32#else
25 if (!ReadConsoleInput(cin, &record, 1, &nevent_out)) 33 if (!ReadConsoleInput(cin, &record, 1, &nevent_out))
34#endif
26 goto done; 35 goto done;
27 36
28 if (record.EventType != KEY_EVENT) 37 if (record.EventType != KEY_EVENT)
@@ -40,7 +49,11 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout)
40 alt_pressed = ((state & LEFT_ALT_PRESSED) != 0); 49 alt_pressed = ((state & LEFT_ALT_PRESSED) != 0);
41 } 50 }
42 51
52#if ENABLE_FEATURE_EURO
53 if (!record.Event.KeyEvent.uChar.UnicodeChar) {
54#else
43 if (!record.Event.KeyEvent.uChar.AsciiChar) { 55 if (!record.Event.KeyEvent.uChar.AsciiChar) {
56#endif
44 if (alt_pressed) { 57 if (alt_pressed) {
45 switch (record.Event.KeyEvent.wVirtualKeyCode) { 58 switch (record.Event.KeyEvent.wVirtualKeyCode) {
46 case VK_MENU: 59 case VK_MENU:
@@ -91,11 +104,19 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout)
91 } 104 }
92 continue; 105 continue;
93 } 106 }
107#if ENABLE_FEATURE_EURO
108 uchar = record.Event.KeyEvent.uChar.UnicodeChar;
109 achar = uchar & 0x7f;
110 if (achar != uchar)
111 WideCharToMultiByte(CP_ACP, 0, &uchar, 1, &achar, 1, NULL, NULL);
112 ret = achar;
113#else
94 if ( (record.Event.KeyEvent.uChar.AsciiChar & 0x80) == 0x80 ) { 114 if ( (record.Event.KeyEvent.uChar.AsciiChar & 0x80) == 0x80 ) {
95 s = &record.Event.KeyEvent.uChar.AsciiChar; 115 s = &record.Event.KeyEvent.uChar.AsciiChar;
96 OemToCharBuff(s, s, 1); 116 OemToCharBuff(s, s, 1);
97 } 117 }
98 ret = record.Event.KeyEvent.uChar.AsciiChar; 118 ret = record.Event.KeyEvent.uChar.AsciiChar;
119#endif
99 break; 120 break;
100 } 121 }
101 done: 122 done: