diff options
author | Brad King <brad.king@kitware.com> | 2020-04-08 18:39:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-04-08 18:39:46 (GMT) |
commit | e9b36731e957456cee5ef43e8f80d6cf8bedde96 (patch) | |
tree | a0502cdf87fb89509141e2a82965920c4f60dcb4 /Source/CursesDialog | |
parent | 3d61ff7b1028b00119d4b1388e9fe0fca34499ff (diff) | |
download | CMake-e9b36731e957456cee5ef43e8f80d6cf8bedde96.zip CMake-e9b36731e957456cee5ef43e8f80d6cf8bedde96.tar.gz CMake-e9b36731e957456cee5ef43e8f80d6cf8bedde96.tar.bz2 |
cmCursesLongMessageForm: Factor out helper to draw message to form
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r-- | Source/CursesDialog/cmCursesLongMessageForm.cxx | 19 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesLongMessageForm.h | 4 |
2 files changed, 15 insertions, 8 deletions
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 806e663..91d759e 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -109,8 +109,6 @@ void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/, this->Form = nullptr; } - const char* msg = this->Messages.c_str(); - if (this->Fields[0]) { free_field(this->Fields[0]); this->Fields[0] = nullptr; @@ -123,9 +121,18 @@ void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/, this->Form = new_form(this->Fields); post_form(this->Form); - int i = 0; form_driver(this->Form, REQ_BEG_FIELD); - while (msg[i] != '\0' && i < 60000) { + this->DrawMessage(this->Messages.c_str()); + + this->UpdateStatusBar(); + touchwin(stdscr); + refresh(); +} + +void cmCursesLongMessageForm::DrawMessage(const char* msg) const +{ + int i = 0; + while (msg[i] != '\0' && i < MAX_CONTENT_SIZE) { if (msg[i] == '\n' && msg[i + 1] != '\0') { form_driver(this->Form, REQ_NEW_LINE); } else { @@ -138,10 +145,6 @@ void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/, } else { form_driver(this->Form, REQ_BEG_FIELD); } - - this->UpdateStatusBar(); - touchwin(stdscr); - refresh(); } void cmCursesLongMessageForm::HandleInput() diff --git a/Source/CursesDialog/cmCursesLongMessageForm.h b/Source/CursesDialog/cmCursesLongMessageForm.h index 88efe62..a482e61 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.h +++ b/Source/CursesDialog/cmCursesLongMessageForm.h @@ -47,6 +47,10 @@ public: void UpdateStatusBar() override; protected: + static constexpr int MAX_CONTENT_SIZE = 60000; + + void DrawMessage(const char* msg) const; + std::string Messages; std::string Title; ScrollBehavior Scrolling; |