1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-18 17:31:57 +08:00

ccmake: Use incremental rendering for the logs

This should avoid an exponential slowdown in the display time for
projects with lots of output.
This is still slower than cmake due to the ncurses drawing, but it should
now be O(L) in total and not O(L^2) wrt to output length.

Fixes: #20535
This commit is contained in:
Sylvain Joubert
2020-04-06 15:42:24 +02:00
committed by Brad King
parent e9b36731e9
commit 60bfaa8fe6
4 changed files with 33 additions and 11 deletions

View File

@@ -35,6 +35,22 @@ cmCursesLongMessageForm::~cmCursesLongMessageForm()
}
}
void cmCursesLongMessageForm::UpdateContent(std::string const& output,
std::string const& title)
{
this->Title = title;
if (!output.empty() && this->Messages.size() < MAX_CONTENT_SIZE) {
this->Messages.append("\n" + output);
form_driver(this->Form, REQ_NEW_LINE);
this->DrawMessage(output.c_str());
}
this->UpdateStatusBar();
touchwin(stdscr);
refresh();
}
void cmCursesLongMessageForm::UpdateStatusBar()
{
int x;

View File

@@ -27,6 +27,8 @@ public:
cmCursesLongMessageForm(cmCursesLongMessageForm const&) = delete;
cmCursesLongMessageForm& operator=(cmCursesLongMessageForm const&) = delete;
void UpdateContent(std::string const& output, std::string const& title);
// Description:
// Handle user input.
void HandleInput() override;

View File

@@ -453,11 +453,11 @@ void cmCursesMainForm::UpdateProgress(const std::string& msg, float prog)
this->LastProgress.append(progressBarCompleted, '#');
this->LastProgress.append(progressBarWidth - progressBarCompleted, ' ');
this->LastProgress += "] " + msg + "...";
this->DisplayOutputs(std::string());
} else {
this->Outputs.emplace_back(msg);
this->DisplayOutputs(msg);
}
this->DisplayOutputs();
}
int cmCursesMainForm::Configure(int noconfigure)
@@ -589,7 +589,7 @@ void cmCursesMainForm::AddError(const std::string& message,
{
this->Outputs.emplace_back(message);
this->HasNonStatusOutputs = true;
this->DisplayOutputs();
this->DisplayOutputs(message);
}
void cmCursesMainForm::RemoveEntry(const char* value)
@@ -995,18 +995,22 @@ void cmCursesMainForm::ResetOutputs()
this->LastProgress.clear();
}
void cmCursesMainForm::DisplayOutputs()
void cmCursesMainForm::DisplayOutputs(std::string const& newOutput)
{
int xi;
int yi;
getmaxyx(stdscr, yi, xi);
auto newLogForm = new cmCursesLongMessageForm(
this->Outputs, this->LastProgress.c_str(),
cmCursesLongMessageForm::ScrollBehavior::ScrollDown);
CurrentForm = newLogForm;
this->LogForm.reset(newLogForm);
this->LogForm->Render(1, 1, xi, yi);
if (CurrentForm != this->LogForm.get()) {
auto newLogForm = new cmCursesLongMessageForm(
this->Outputs, this->LastProgress.c_str(),
cmCursesLongMessageForm::ScrollBehavior::ScrollDown);
CurrentForm = newLogForm;
this->LogForm.reset(newLogForm);
this->LogForm->Render(1, 1, xi, yi);
} else {
this->LogForm->UpdateContent(newOutput, this->LastProgress);
}
}
const char* cmCursesMainForm::s_ConstHelpMessage =

View File

@@ -129,7 +129,7 @@ protected:
void ResetOutputs();
// Display the current progress and output
void DisplayOutputs();
void DisplayOutputs(std::string const& newOutput);
// Copies of cache entries stored in the user interface
std::vector<cmCursesCacheEntryComposite> Entries;