diff options
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | Source/CursesDialog/ccmake.cxx | 4 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesForm.cxx | 9 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesLongMessageForm.cxx | 6 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.cxx | 6 |
5 files changed, 34 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f7a510..428b040 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -674,10 +674,10 @@ macro (CMAKE_BUILD_UTILITIES) if (UNIX) include(${CMake_SOURCE_DIR}/Source/Checks/Curses.cmake) set(BUILD_CursesDialog_DEFAULT "${CMakeCheckCurses_COMPILED}") - option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" "${BUILD_CursesDialog_DEFAULT}") - else() - set(BUILD_CursesDialog 0) + elseif(WIN32) + set(BUILD_CursesDialog_DEFAULT "OFF") endif() + option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" "${BUILD_CursesDialog_DEFAULT}") endif () if(BUILD_CursesDialog) if(UNIX) @@ -690,6 +690,13 @@ macro (CMAKE_BUILD_UTILITIES) ) set(BUILD_CursesDialog 0) endif() + elseif(WIN32) + # FIXME: Add support for system-provided pdcurses. + add_subdirectory(Utilities/cmpdcurses) + set(CURSES_LIBRARY cmpdcurses) + set(CURSES_INCLUDE_PATH "") # cmpdcurses has usage requirements + set(CMAKE_USE_SYSTEM_FORM 0) + set(HAVE_CURSES_USE_DEFAULT_COLORS 1) endif() endif() if(BUILD_CursesDialog) diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 5661144..1f7776c 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -51,6 +51,7 @@ static const char* cmDocumentationOptions[][2] = { cmCursesForm* cmCursesForm::CurrentForm = nullptr; +#ifndef _WIN32 extern "C" { static void onsig(int /*unused*/) @@ -61,6 +62,7 @@ static void onsig(int /*unused*/) signal(SIGWINCH, onsig); } } +#endif // _WIN32 int main(int argc, char const* const* argv) { @@ -126,7 +128,9 @@ int main(int argc, char const* const* argv) keypad(stdscr, true); /* Use key symbols as KEY_DOWN */ cmCursesColor::InitColors(); +#ifndef _WIN32 signal(SIGWINCH, onsig); +#endif // _WIN32 int x; int y; diff --git a/Source/CursesDialog/cmCursesForm.cxx b/Source/CursesDialog/cmCursesForm.cxx index 0c32964..ef36b45 100644 --- a/Source/CursesDialog/cmCursesForm.cxx +++ b/Source/CursesDialog/cmCursesForm.cxx @@ -2,7 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCursesForm.h" -#include <unistd.h> +#include <cstdlib> +#ifndef _WIN32 +# include <unistd.h> +#endif // _WIN32 cmsys::ofstream cmCursesForm::DebugFile; bool cmCursesForm::Debug = false; @@ -51,8 +54,12 @@ void cmCursesForm::HandleResize() endwin(); if (initscr() == nullptr) { static const char errmsg[] = "Error: ncurses initialization failed\n"; +#ifdef _WIN32 + fprintf(stderr, "%s", errmsg); +#else auto r = write(STDERR_FILENO, errmsg, sizeof(errmsg) - 1); static_cast<void>(r); +#endif // _WIN32 exit(1); } noecho(); /* Echo off */ diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 7f1815f..9b3a649 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -177,6 +177,12 @@ void cmCursesLongMessageForm::HandleInput() this->PrintKeys(); int key = getch(); +#ifdef _WIN32 + if (key == KEY_RESIZE) { + HandleResize(); + } +#endif // _WIN32 + snprintf(debugMessage, sizeof(debugMessage), "Message widget handling input, key: %d", key); cmCursesForm::LogMessage(debugMessage); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 0012a25..11b3b35 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -686,6 +686,12 @@ void cmCursesMainForm::HandleInput() } int key = getch(); +#ifdef _WIN32 + if (key == KEY_RESIZE) { + HandleResize(); + } +#endif // _WIN32 + getmaxyx(stdscr, y, x); // If window too small, handle 'q' only if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) { |