diff options
author | Sylvain Joubert <joubert.sy@gmail.com> | 2019-10-25 12:53:10 (GMT) |
---|---|---|
committer | Sylvain Joubert <joubert.sy@gmail.com> | 2019-10-25 12:58:23 (GMT) |
commit | 1d0e557aed926d4d11cc5cf579363bb7be058688 (patch) | |
tree | 540877134a641a1d2fdb5688e0aeb944f5007eb4 /Source/CursesDialog | |
parent | c168e789dfeeb4e0bd5db96bb17e682a9fd92b1f (diff) | |
download | CMake-1d0e557aed926d4d11cc5cf579363bb7be058688.zip CMake-1d0e557aed926d4d11cc5cf579363bb7be058688.tar.gz CMake-1d0e557aed926d4d11cc5cf579363bb7be058688.tar.bz2 |
ccmake: Display output during configure and generate
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r-- | Source/CursesDialog/cmCursesLongMessageForm.cxx | 13 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesLongMessageForm.h | 4 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.cxx | 58 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.h | 8 |
4 files changed, 61 insertions, 22 deletions
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 4ff3fe4..d980d81 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -136,7 +136,6 @@ void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/, form_driver(this->Form, REQ_BEG_FIELD); this->UpdateStatusBar(); - this->PrintKeys(); touchwin(stdscr); refresh(); } @@ -150,6 +149,7 @@ void cmCursesLongMessageForm::HandleInput() char debugMessage[128]; for (;;) { + this->PrintKeys(); int key = getch(); sprintf(debugMessage, "Message widget handling input, key: %d", key); @@ -170,7 +170,16 @@ void cmCursesLongMessageForm::HandleInput() } this->UpdateStatusBar(); - this->PrintKeys(); + touchwin(stdscr); + wrefresh(stdscr); + } +} + +void cmCursesLongMessageForm::ScrollDown() +{ + if (this->Form) { + form_driver(this->Form, REQ_END_FIELD); + this->UpdateStatusBar(); touchwin(stdscr); wrefresh(stdscr); } diff --git a/Source/CursesDialog/cmCursesLongMessageForm.h b/Source/CursesDialog/cmCursesLongMessageForm.h index 42f9c71..dde5bff 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.h +++ b/Source/CursesDialog/cmCursesLongMessageForm.h @@ -26,6 +26,10 @@ public: void HandleInput() override; // Description: + // Scroll down to the end of the content + void ScrollDown(); + + // Description: // Display form. Use a window of size width x height, starting // at top, left. void Render(int left, int top, int width, int height) override; diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index c76cc42..ba238eb 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -474,20 +474,17 @@ void cmCursesMainForm::UpdateProgress(const std::string& msg, float prog) constexpr int progressBarWidth = 40; int progressBarCompleted = static_cast<int>(progressBarWidth * prog); int percentCompleted = static_cast<int>(100 * prog); - std::string status = (percentCompleted < 100 ? " " : ""); - status += (percentCompleted < 10 ? " " : ""); - status += std::to_string(percentCompleted) + "% ["; - status.append(progressBarCompleted, '#'); - status.append(progressBarWidth - progressBarCompleted, ' '); - status += "] " + msg + "..."; - this->UpdateStatusBar(status.c_str()); + this->LastProgress = (percentCompleted < 100 ? " " : ""); + this->LastProgress += (percentCompleted < 10 ? " " : ""); + this->LastProgress += std::to_string(percentCompleted) + "% ["; + this->LastProgress.append(progressBarCompleted, '#'); + this->LastProgress.append(progressBarWidth - progressBarCompleted, ' '); + this->LastProgress += "] " + msg + "..."; } else { this->Outputs.emplace_back(msg); } - this->PrintKeys(1); - curses_move(1, 1); - touchwin(stdscr); - refresh(); + + this->DisplayOutputs(); } int cmCursesMainForm::Configure(int noconfigure) @@ -496,11 +493,15 @@ int cmCursesMainForm::Configure(int noconfigure) int yi; getmaxyx(stdscr, yi, xi); - this->UpdateProgress("Configuring", 0); - this->CMakeInstance->SetProgressCallback( - [this](const std::string& msg, float prog) { - this->UpdateProgress(msg, prog); - }); + this->ResetOutputs(); + + if (noconfigure == 0) { + this->UpdateProgress("Configuring", 0); + this->CMakeInstance->SetProgressCallback( + [this](const std::string& msg, float prog) { + this->UpdateProgress(msg, prog); + }); + } // always save the current gui values to disk this->FillCacheManagerFromUI(); @@ -508,8 +509,6 @@ int cmCursesMainForm::Configure(int noconfigure) this->CMakeInstance->GetHomeOutputDirectory()); this->LoadCache(nullptr); - this->ResetOutputs(); - // run the generate process this->OkToGenerate = true; int retVal; @@ -544,6 +543,7 @@ int cmCursesMainForm::Configure(int noconfigure) cmSystemTools::ResetErrorOccuredFlag(); CurrentForm = msgs; msgs->Render(1, 1, xx, yy); + msgs->ScrollDown(); msgs->HandleInput(); // If they typed the wrong source directory, we report // an error and exit @@ -566,14 +566,14 @@ int cmCursesMainForm::Generate() int yi; getmaxyx(stdscr, yi, xi); + this->ResetOutputs(); + this->UpdateProgress("Generating", 0); this->CMakeInstance->SetProgressCallback( [this](const std::string& msg, float prog) { this->UpdateProgress(msg, prog); }); - this->ResetOutputs(); - // run the generate process int retVal = this->CMakeInstance->Generate(); @@ -598,6 +598,7 @@ int cmCursesMainForm::Generate() new cmCursesLongMessageForm(this->Outputs, title); CurrentForm = msgs; msgs->Render(1, 1, xx, yy); + msgs->ScrollDown(); msgs->HandleInput(); // If they typed the wrong source directory, we report // an error and exit @@ -619,6 +620,7 @@ void cmCursesMainForm::AddError(const std::string& message, { this->Outputs.emplace_back(message); this->HasNonStatusOutputs = true; + this->DisplayOutputs(); } void cmCursesMainForm::RemoveEntry(const char* value) @@ -1025,8 +1027,24 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr) void cmCursesMainForm::ResetOutputs() { + this->LogForm.reset(); this->Outputs.clear(); this->HasNonStatusOutputs = false; + this->LastProgress.clear(); +} + +void cmCursesMainForm::DisplayOutputs() +{ + int xi; + int yi; + getmaxyx(stdscr, yi, xi); + + auto newLogForm = + new cmCursesLongMessageForm(this->Outputs, this->LastProgress.c_str()); + CurrentForm = newLogForm; + this->LogForm.reset(newLogForm); + this->LogForm->Render(1, 1, xi, yi); + this->LogForm->ScrollDown(); } const char* cmCursesMainForm::s_ConstHelpMessage = diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index c6a0262..598fbdf 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -16,6 +16,7 @@ #include "cmStateTypes.h" class cmake; +class cmCursesLongMessageForm; /** \class cmCursesMainForm * \brief The main page of ccmake @@ -125,13 +126,20 @@ protected: // Clear and reset the output log and state void ResetOutputs(); + // Display the current progress and output + void DisplayOutputs(); + // Copies of cache entries stored in the user interface std::vector<cmCursesCacheEntryComposite> Entries; + // The form used to display logs during processing + std::unique_ptr<cmCursesLongMessageForm> LogForm; // Output produced by the last pass std::vector<std::string> Outputs; // Did the last pass produced outputs of interest (errors, warnings, ...) bool HasNonStatusOutputs; + // Last progress bar + std::string LastProgress; // Command line arguments to be passed to cmake each time // it is run |