summaryrefslogtreecommitdiff
path: root/Source/CursesDialog
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r--Source/CursesDialog/ccmake.cxx19
-rw-r--r--Source/CursesDialog/cmCursesForm.cxx22
-rw-r--r--Source/CursesDialog/cmCursesForm.h4
3 files changed, 27 insertions, 18 deletions
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index ae4c0f6c9d..56611440a6 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -9,8 +9,6 @@
#include <string>
#include <vector>
-#include <unistd.h>
-
#include "cmsys/Encoding.hxx"
#include "cmCursesColor.h"
@@ -58,22 +56,7 @@ extern "C" {
static void onsig(int /*unused*/)
{
if (cmCursesForm::CurrentForm) {
- endwin();
- if (initscr() == nullptr) {
- static const char errmsg[] = "Error: ncurses initialization failed\n";
- auto r = write(STDERR_FILENO, errmsg, sizeof(errmsg) - 1);
- static_cast<void>(r);
- exit(1);
- }
- noecho(); /* Echo off */
- cbreak(); /* nl- or cr not needed */
- keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
- refresh();
- int x;
- int y;
- getmaxyx(stdscr, y, x);
- cmCursesForm::CurrentForm->Render(1, 1, x, y);
- cmCursesForm::CurrentForm->UpdateStatusBar();
+ cmCursesForm::CurrentForm->HandleResize();
}
signal(SIGWINCH, onsig);
}
diff --git a/Source/CursesDialog/cmCursesForm.cxx b/Source/CursesDialog/cmCursesForm.cxx
index bd65c4a082..0c32964cd1 100644
--- a/Source/CursesDialog/cmCursesForm.cxx
+++ b/Source/CursesDialog/cmCursesForm.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCursesForm.h"
+#include <unistd.h>
+
cmsys::ofstream cmCursesForm::DebugFile;
bool cmCursesForm::Debug = false;
@@ -43,3 +45,23 @@ void cmCursesForm::LogMessage(const char* msg)
cmCursesForm::DebugFile << msg << std::endl;
}
+
+void cmCursesForm::HandleResize()
+{
+ endwin();
+ if (initscr() == nullptr) {
+ static const char errmsg[] = "Error: ncurses initialization failed\n";
+ auto r = write(STDERR_FILENO, errmsg, sizeof(errmsg) - 1);
+ static_cast<void>(r);
+ exit(1);
+ }
+ noecho(); /* Echo off */
+ cbreak(); /* nl- or cr not needed */
+ keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
+ refresh();
+ int x;
+ int y;
+ getmaxyx(stdscr, y, x);
+ this->Render(1, 1, x, y);
+ this->UpdateStatusBar();
+}
diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h
index 93459b9bb5..3a1eb25541 100644
--- a/Source/CursesDialog/cmCursesForm.h
+++ b/Source/CursesDialog/cmCursesForm.h
@@ -55,6 +55,10 @@ public:
static cmCursesForm* CurrentForm;
+ // Description:
+ // Handle resizing the form with curses.
+ void HandleResize();
+
protected:
static cmsys::ofstream DebugFile;
static bool Debug;