diff options
author | Ron Yorston <rmy@pobox.com> | 2023-07-01 12:52:24 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-07-01 12:52:24 +0100 |
commit | b5248881cd0d0bd6aa49fdef742d847aed6866b6 (patch) | |
tree | c1b3dfc8fda1657addd09cd7f517b40e9743e216 | |
parent | 40217f5588a34d9ddf456307bcd79ce3ef8af2c0 (diff) | |
download | busybox-w32-b5248881cd0d0bd6aa49fdef742d847aed6866b6.tar.gz busybox-w32-b5248881cd0d0bd6aa49fdef742d847aed6866b6.tar.bz2 busybox-w32-b5248881cd0d0bd6aa49fdef742d847aed6866b6.zip |
win32: revert to previous console input method by default
Although the input method used for euro support is no longer
required for that reason it does provide a more lightweight
workaround for the problem with ReadConsoleInputA and UTF8.
Repurpose FEATURE_EURO_INPUT as FEATURE_UTF8_INPUT.
-rw-r--r-- | Config.in | 13 | ||||
-rw-r--r-- | win32/termios.c | 8 | ||||
-rw-r--r-- | win32/winansi.c | 10 |
3 files changed, 19 insertions, 12 deletions
@@ -438,6 +438,7 @@ config FEATURE_UTF8_MANIFEST | |||
438 | depends on FEATURE_RESOURCES | 438 | depends on FEATURE_RESOURCES |
439 | help | 439 | help |
440 | Include a manifest which sets the process code page to UTF-8. | 440 | Include a manifest which sets the process code page to UTF-8. |
441 | Users who enable this may also wish to enable FEATURE_UTF8_INPUT. | ||
441 | 442 | ||
442 | config FEATURE_ICON | 443 | config FEATURE_ICON |
443 | bool "Include application icon in binary" | 444 | bool "Include application icon in binary" |
@@ -473,14 +474,14 @@ config FEATURE_EURO | |||
473 | requires the OEM code page to be 858. If the OEM code page of | 474 | requires the OEM code page to be 858. If the OEM code page of |
474 | the console is 850 when BusyBox starts it's changed to 858. | 475 | the console is 850 when BusyBox starts it's changed to 858. |
475 | 476 | ||
476 | config FEATURE_EURO_INPUT | 477 | config FEATURE_UTF8_INPUT |
477 | bool "Allow euro on input, even in code pages without euro support" | 478 | bool "Allow UTF8 console input (0.8 kb)" |
478 | default n | 479 | default n |
479 | depends on PLATFORM_MINGW32 && FEATURE_EURO | 480 | depends on PLATFORM_MINGW32 |
480 | help | 481 | help |
481 | Allow the euro character to be entered in the console even if the | 482 | Allow characters entered in the console to be encoded as UTF8. |
482 | current code page doesn't support it. It isn't necessary to | 483 | This may be useful in conjunction with the UTF8 manifest which |
483 | enable this setting if the code page in use has euro support. | 484 | is supported in Window 10 and 11. |
484 | 485 | ||
485 | config TERMINAL_MODE | 486 | config TERMINAL_MODE |
486 | int "Default setting for terminal mode" | 487 | int "Default setting for terminal mode" |
diff --git a/win32/termios.c b/win32/termios.c index 23184e901..7d6adaafe 100644 --- a/win32/termios.c +++ b/win32/termios.c | |||
@@ -34,7 +34,7 @@ int64_t FAST_FUNC windows_read_key(int fd, char *buf UNUSED_PARAM, int timeout) | |||
34 | INPUT_RECORD record; | 34 | INPUT_RECORD record; |
35 | DWORD nevent_out, mode; | 35 | DWORD nevent_out, mode; |
36 | int ret = -1; | 36 | int ret = -1; |
37 | #if ENABLE_FEATURE_EURO_INPUT | 37 | #if !ENABLE_FEATURE_UTF8_INPUT |
38 | wchar_t uchar; | 38 | wchar_t uchar; |
39 | char achar; | 39 | char achar; |
40 | #endif | 40 | #endif |
@@ -54,7 +54,7 @@ int64_t FAST_FUNC windows_read_key(int fd, char *buf UNUSED_PARAM, int timeout) | |||
54 | if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0) | 54 | if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0) |
55 | goto done; | 55 | goto done; |
56 | } | 56 | } |
57 | #if ENABLE_FEATURE_EURO_INPUT | 57 | #if !ENABLE_FEATURE_UTF8_INPUT |
58 | if (!ReadConsoleInputW(cin, &record, 1, &nevent_out)) | 58 | if (!ReadConsoleInputW(cin, &record, 1, &nevent_out)) |
59 | #else | 59 | #else |
60 | if (!readConsoleInput_utf8(cin, &record, 1, &nevent_out)) | 60 | if (!readConsoleInput_utf8(cin, &record, 1, &nevent_out)) |
@@ -73,7 +73,7 @@ int64_t FAST_FUNC windows_read_key(int fd, char *buf UNUSED_PARAM, int timeout) | |||
73 | } | 73 | } |
74 | alt_pressed = state & LEFT_ALT_PRESSED; | 74 | alt_pressed = state & LEFT_ALT_PRESSED; |
75 | 75 | ||
76 | #if ENABLE_FEATURE_EURO_INPUT | 76 | #if !ENABLE_FEATURE_UTF8_INPUT |
77 | if (!record.Event.KeyEvent.uChar.UnicodeChar) { | 77 | if (!record.Event.KeyEvent.uChar.UnicodeChar) { |
78 | #else | 78 | #else |
79 | if (!record.Event.KeyEvent.uChar.AsciiChar) { | 79 | if (!record.Event.KeyEvent.uChar.AsciiChar) { |
@@ -119,7 +119,7 @@ int64_t FAST_FUNC windows_read_key(int fd, char *buf UNUSED_PARAM, int timeout) | |||
119 | ret &= ~0x80; | 119 | ret &= ~0x80; |
120 | goto done; | 120 | goto done; |
121 | } | 121 | } |
122 | #if ENABLE_FEATURE_EURO_INPUT | 122 | #if !ENABLE_FEATURE_UTF8_INPUT |
123 | uchar = record.Event.KeyEvent.uChar.UnicodeChar; | 123 | uchar = record.Event.KeyEvent.uChar.UnicodeChar; |
124 | achar = uchar & 0x7f; | 124 | achar = uchar & 0x7f; |
125 | if (achar != uchar) | 125 | if (achar != uchar) |
diff --git a/win32/winansi.c b/win32/winansi.c index 83ce076c0..479e5ca40 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -749,8 +749,12 @@ BOOL conToCharBuffA(LPSTR s, DWORD len) | |||
749 | CPINFO acp_info, con_info; | 749 | CPINFO acp_info, con_info; |
750 | WCHAR *buf; | 750 | WCHAR *buf; |
751 | 751 | ||
752 | // if acp is UTF8 then we got UTF8 via readConsoleInput_utf8 | 752 | if (acp == conicp |
753 | if (acp == conicp || acp == CP_UTF8) | 753 | #if ENABLE_FEATURE_UTF8_INPUT |
754 | // if acp is UTF8 then we got UTF8 via readConsoleInput_utf8 | ||
755 | || acp == CP_UTF8 | ||
756 | #endif | ||
757 | ) | ||
754 | return TRUE; | 758 | return TRUE; |
755 | 759 | ||
756 | if (!s || !GetCPInfo(acp, &acp_info) || !GetCPInfo(conicp, &con_info) || | 760 | if (!s || !GetCPInfo(acp, &acp_info) || !GetCPInfo(conicp, &con_info) || |
@@ -1173,6 +1177,7 @@ int mingw_isatty(int fd) | |||
1173 | return result; | 1177 | return result; |
1174 | } | 1178 | } |
1175 | 1179 | ||
1180 | #if ENABLE_FEATURE_UTF8_INPUT | ||
1176 | // intentionally also converts invalid values (surrogate halfs, too big) | 1181 | // intentionally also converts invalid values (surrogate halfs, too big) |
1177 | static int toutf8(DWORD cp, unsigned char *buf) { | 1182 | static int toutf8(DWORD cp, unsigned char *buf) { |
1178 | if (cp <= 0x7f) { | 1183 | if (cp <= 0x7f) { |
@@ -1343,3 +1348,4 @@ BOOL readConsoleInput_utf8(HANDLE h, INPUT_RECORD *r, DWORD len, DWORD *got) | |||
1343 | *got = 1; | 1348 | *got = 1; |
1344 | return TRUE; | 1349 | return TRUE; |
1345 | } | 1350 | } |
1351 | #endif | ||