summaryrefslogtreecommitdiffstats
path: root/Source/CursesDialog
diff options
context:
space:
mode:
authorDuncan Ogilvie <mr.exodia.tpodt@gmail.com>2022-01-14 16:31:28 (GMT)
committerBrad King <brad.king@kitware.com>2022-01-18 21:35:39 (GMT)
commit9278c6e01a1ce1b93b51522d1bee50eceaf86c3c (patch)
tree8e4c28b06b67f63b06d74b7903f5144cad94f348 /Source/CursesDialog
parentb97c12babbc87324b8005cf7e81640e1f3c0ecf6 (diff)
downloadCMake-9278c6e01a1ce1b93b51522d1bee50eceaf86c3c.zip
CMake-9278c6e01a1ce1b93b51522d1bee50eceaf86c3c.tar.gz
CMake-9278c6e01a1ce1b93b51522d1bee50eceaf86c3c.tar.bz2
ccmake: Add Windows support using PDCurses
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r--Source/CursesDialog/ccmake.cxx4
-rw-r--r--Source/CursesDialog/cmCursesForm.cxx9
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.cxx6
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx6
4 files changed, 24 insertions, 1 deletions
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) {