1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

cmCursesLongMessageForm: Factor out helper to draw message to form

This commit is contained in:
Brad King
2020-04-08 14:39:46 -04:00
parent 3d61ff7b10
commit e9b36731e9
2 changed files with 15 additions and 8 deletions

View File

@@ -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()

View File

@@ -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;