diff --git a/CMakeLists.txt b/CMakeLists.txt index 49667a8..ce8cd17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,7 @@ foreach(lib screen dom component) target_compile_options(${lib} PRIVATE "/W4") target_compile_options(${lib} PRIVATE "/WX") target_compile_options(${lib} PRIVATE "/wd4244") + target_compile_options(${lib} PRIVATE "/wd4267") else() target_compile_options(${lib} PRIVATE "-Wall") target_compile_options(${lib} PRIVATE "-Wextra") diff --git a/include/ftxui/component/event_input_listener.hpp b/include/ftxui/component/event_input_listener.hpp deleted file mode 100644 index f90fdd7..0000000 --- a/include/ftxui/component/event_input_listener.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef FTXUI_COMPONENT_EVENT_INPUT_LISTENER_HPP -#define FTXUI_COMPONENT_EVENT_INPUT_LISTENER_HPP - -#include -#include -#include - -#include "event.hpp" - -#ifdef WIN32 - #include - #include - #include -#endif - -namespace ftxui { - -// Receives input events from the OS and turns them into -// Event objects and sends to a consumer -// -// On NIX systems: -// - uses SIGWINCH for resize -// - uses getchar() for keypresses -// -// On Windows systems: -// - Uses ReadConsoleInput for resize and keypresses -class EventInputListener { - public: - EventInputListener(std::function consumer); - ~EventInputListener(); - - void stop(); - - private: - char readchar(); - void readchar_thread_func(std::function consumer); - - std::atomic quit_{false}; - std::thread readchar_thread_; -#ifndef _WIN32 - using signal_handler_t = void (*)(int); - signal_handler_t old_sigwinch_handler_; -#else - void input_thread_func(std::function consumer); - - std::mutex input_queue_mutex_; - std::condition_variable input_queue_condvar_; - std::deque input_queue_; - std::thread input_event_thread_; -#endif -}; - -} // namespace ftxui - -#endif /* end of include guard: FTXUI_COMPONENT_EVENT_INPUT_LISTENER_HPP */ diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index a7afa64..5c0198f 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -13,7 +13,8 @@ #include "ftxui/screen/string.hpp" #include "ftxui/screen/terminal.hpp" -#if defined(WIN32) + +#if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include @@ -39,7 +40,7 @@ void CharToEventStream(Receiver receiver, Sender sender) { Event::Convert(receiver, sender, c); } -#if defined(WIN32) +#if defined(_WIN32) void Win32EventListener(std::atomic* quit, Sender char_sender, @@ -162,7 +163,7 @@ void ScreenInteractive::PostEvent(Event event) { void ScreenInteractive::Loop(Component* component) { // Save the old terminal configuration and restore it on exit. -#if defined(WIN32) +#if defined(_WIN32) // Enable VT processing on stdout and stdin auto stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); auto stdin_handle = GetStdHandle(STD_INPUT_HANDLE); @@ -217,7 +218,7 @@ void ScreenInteractive::Loop(Component* component) { CharToEventStream, std::move(char_receiver), std::move(event_sender_1)); // Depending on the OS, start a thread that will produce events and/or chars. -#if defined(WIN32) +#if defined(_WIN32) auto event_sender_2 = event_receiver_->MakeSender(); auto event_listener = std::thread(&Win32EventListener, &quit_, std::move(char_sender), diff --git a/src/ftxui/screen/screen.cpp b/src/ftxui/screen/screen.cpp index 85dd670..14aecc5 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -7,7 +7,8 @@ #include "ftxui/screen/string.hpp" #include "ftxui/screen/terminal.hpp" -#if defined(WIN32) + +#if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include @@ -75,7 +76,7 @@ Screen::Screen(int dimx, int dimy) dimx_(dimx), dimy_(dimy), pixels_(dimy, std::vector(dimx)) { -#if defined(WIN32) +#if defined(_WIN32) // The placement of this call is a bit weird, however we can assume that // anybody who instantiates a Screen object eventually wants to output // something to the console. diff --git a/src/ftxui/screen/terminal.cpp b/src/ftxui/screen/terminal.cpp index 2a8b235..58d771d 100644 --- a/src/ftxui/screen/terminal.cpp +++ b/src/ftxui/screen/terminal.cpp @@ -2,7 +2,8 @@ #include -#if defined(WIN32) + +#if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include @@ -18,7 +19,7 @@ namespace ftxui { Terminal::Dimensions Terminal::Size() { #if defined(__EMSCRIPTEN__) return Dimensions{80, 43}; -#elif defined(WIN32) +#elif defined(_WIN32) CONSOLE_SCREEN_BUFFER_INFO csbi; int columns, rows;