summaryrefslogtreecommitdiffstats
path: root/Source/CursesDialog
diff options
context:
space:
mode:
authorSylvain Joubert <joubert.sy@gmail.com>2019-10-23 14:32:31 (GMT)
committerSylvain Joubert <joubert.sy@gmail.com>2019-10-25 12:58:23 (GMT)
commit3300070cc2e7cadcb0fe2a77d67d2099bf22e7ba (patch)
tree721ec8b55fd1c2aeb7efaca00fc03f077544688a /Source/CursesDialog
parent5a3f539cd50621298d15df639c29a9c09aace443 (diff)
downloadCMake-3300070cc2e7cadcb0fe2a77d67d2099bf22e7ba.zip
CMake-3300070cc2e7cadcb0fe2a77d67d2099bf22e7ba.tar.gz
CMake-3300070cc2e7cadcb0fe2a77d67d2099bf22e7ba.tar.bz2
ccmake: Display an ASCII progress bar in the status bar
The status bar is now only used to display the progress. The status log are not shown anymore since for the most cases they went by too quickly to be read. As for cases when a process is long enough to display and read a log, it would probably be a previous unrelated message.
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx28
1 files changed, 12 insertions, 16 deletions
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 6b71e8a..3f7ee89 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -469,14 +469,18 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
void cmCursesMainForm::UpdateProgress(const std::string& msg, float prog)
{
- char tmp[1024];
- const char* cmsg = tmp;
if (prog >= 0) {
- sprintf(tmp, "%s %i%%", msg.c_str(), static_cast<int>(100 * prog));
- } else {
- cmsg = msg.c_str();
+ 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->UpdateStatusBar(cmsg);
this->PrintKeys(1);
curses_move(1, 1);
touchwin(stdscr);
@@ -489,11 +493,7 @@ int cmCursesMainForm::Configure(int noconfigure)
int yi;
getmaxyx(stdscr, yi, xi);
- curses_move(1, 1);
- this->UpdateStatusBar("Configuring, please wait...");
- this->PrintKeys(1);
- touchwin(stdscr);
- refresh();
+ this->UpdateProgress("Configuring", 0);
this->CMakeInstance->SetProgressCallback(
[this](const std::string& msg, float prog) {
this->UpdateProgress(msg, prog);
@@ -563,11 +563,7 @@ int cmCursesMainForm::Generate()
int yi;
getmaxyx(stdscr, yi, xi);
- curses_move(1, 1);
- this->UpdateStatusBar("Generating, please wait...");
- this->PrintKeys(1);
- touchwin(stdscr);
- refresh();
+ this->UpdateProgress("Generating", 0);
this->CMakeInstance->SetProgressCallback(
[this](const std::string& msg, float prog) {
this->UpdateProgress(msg, prog);