Fix Windows UTF16 char. (#538)

Windows output UTF16 unicode char, but FTXUI works using UTF8. Do the
conversion.

This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/495
This commit is contained in:
Arthur Sonzogni 2022-12-28 11:47:11 +01:00 committed by GitHub
parent 60b9e491db
commit abd5b2a503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,7 @@
#include "ftxui/component/terminal_input_parser.hpp" // for TerminalInputParser #include "ftxui/component/terminal_input_parser.hpp" // for TerminalInputParser
#include "ftxui/dom/node.hpp" // for Node, Render #include "ftxui/dom/node.hpp" // for Node, Render
#include "ftxui/dom/requirement.hpp" // for Requirement #include "ftxui/dom/requirement.hpp" // for Requirement
#include "ftxui/screen/string.hpp"
#include "ftxui/screen/terminal.hpp" // for Size, Dimensions #include "ftxui/screen/terminal.hpp" // for Size, Dimensions
#if defined(_WIN32) #if defined(_WIN32)
@ -104,7 +105,11 @@ void EventListener(std::atomic<bool>* quit, Sender<Task> out) {
// ignore UP key events // ignore UP key events
if (key_event.bKeyDown == FALSE) if (key_event.bKeyDown == FALSE)
continue; continue;
parser.Add((char)key_event.uChar.UnicodeChar); std::wstring wstring;
wstring += key_event.uChar.UnicodeChar;
for(auto it : to_string(wstring)) {
parser.Add(it);
}
} break; } break;
case WINDOW_BUFFER_SIZE_EVENT: case WINDOW_BUFFER_SIZE_EVENT:
out->Send(Event::Special({0})); out->Send(Event::Special({0}));