Minor bug fixes and updates:

* Removed progress bar sample that progresses in reverse direction - This needs a class of its own
* Fixed a casting error in progress_bar class when dealing with max_progress variable
* Minor update to the cursor movement functions in linux
* Updated single include to include these changes
This commit is contained in:
Pranav Srinivas Kumar
2020-05-08 15:14:52 -05:00
parent 66af25ab62
commit 296bde6088
10 changed files with 17 additions and 41 deletions

View File

@@ -183,6 +183,7 @@ private:
}
}
public:
void print_progress(bool from_multi_progress = false) {
const auto max_progress = get_value<details::ProgressBarOption::max_progress>();
if (multi_progress_mode_ && !from_multi_progress) {

View File

@@ -36,10 +36,10 @@ void move_left(int cols) { move(-cols, 0); }
#else
void move_up(int lines) { std::cout << "x1b[" << lines << "A"; }
void move_down(int lines) { std::cout << "x1b[" << lines << "B"; }
void move_right(int cols) { std::cout << "x1b[" << cols << "C"; }
void move_left(int cols) { std::cout << "x1b[" << cols << "D"; }
void move_up(int lines) { std::cout << "\033[" << lines << "A"; }
void move_down(int lines) { std::cout << "\033[" << lines << "B"; }
void move_right(int cols) { std::cout << "\033[" << cols << "C"; }
void move_left(int cols) { std::cout << "\033[" << cols << "D"; }
#endif

View File

@@ -134,7 +134,7 @@ public:
const std::string &lead, const std::string &remainder)
: os(os), bar_width(bar_width), fill(fill), lead(lead), remainder(remainder) {}
std::ostream &write(size_t progress) {
std::ostream &write(float progress) {
auto pos = static_cast<size_t>(progress * bar_width / 100.0);
for (size_t i = 0; i < bar_width; ++i) {
if (i < pos)

View File

@@ -98,6 +98,7 @@ private:
return details::get_value<id>(settings_).value;
}
public:
void print_progress() {
std::lock_guard<std::mutex> lock{mutex_};
auto &hide_bar_when_complete = get_value<details::ProgressBarOption::hide_bar_when_complete>();

View File

@@ -85,6 +85,7 @@ private:
return result;
}
public:
void print_progress() {
std::lock_guard<std::mutex> lock{mutex_};
if (started_)

View File

@@ -193,6 +193,7 @@ private:
}
}
public:
void print_progress(bool from_multi_progress = false) {
std::lock_guard<std::mutex> lock{mutex_};
const auto max_progress = get_value<details::ProgressBarOption::max_progress>();
@@ -221,7 +222,7 @@ private:
get_value<details::ProgressBarOption::fill>(),
get_value<details::ProgressBarOption::lead>(),
get_value<details::ProgressBarOption::remainder>()};
writer.write(progress_ / max_progress * 100);
writer.write(double(progress_) / double(max_progress) * 100.0f);
std::cout << get_value<details::ProgressBarOption::end>();

View File

@@ -182,6 +182,7 @@ private:
}
}
public:
void print_progress() {
std::lock_guard<std::mutex> lock{mutex_};
const auto max_progress = get_value<details::ProgressBarOption::max_progress>();