mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-13 22:40:03 -04:00
fix(console-writer): rewinding was broken in rewrite mode
This commit is contained in:
parent
799f981f91
commit
eecc01bcbf
@ -155,24 +155,13 @@ console_writer::console_writer(std::ostream& os, progress_mode pg_mode,
|
|||||||
|
|
||||||
void console_writer::rewind(int next_rewind_lines) {
|
void console_writer::rewind(int next_rewind_lines) {
|
||||||
if (!statebuf_.empty()) {
|
if (!statebuf_.empty()) {
|
||||||
int lines = 0;
|
|
||||||
|
|
||||||
switch (mode_) {
|
|
||||||
case NORMAL:
|
|
||||||
lines = rewind_lines_;
|
|
||||||
break;
|
|
||||||
case REWRITE:
|
|
||||||
lines = 4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& os = log_stream();
|
auto& os = log_stream();
|
||||||
|
|
||||||
os << '\r';
|
os << '\r';
|
||||||
|
|
||||||
int num_erase = rewind_lines_ - next_rewind_lines;
|
int num_erase = rewind_lines_ - next_rewind_lines;
|
||||||
|
|
||||||
for (int i = 0; i < lines; ++i) {
|
for (int i = 0; i < rewind_lines_; ++i) {
|
||||||
os << "\x1b[A";
|
os << "\x1b[A";
|
||||||
if (num_erase > 0) {
|
if (num_erase > 0) {
|
||||||
os << "\x1b[2K";
|
os << "\x1b[2K";
|
||||||
@ -349,7 +338,7 @@ void console_writer::update(progress& p, bool last) {
|
|||||||
|
|
||||||
std::lock_guard lock(log_mutex());
|
std::lock_guard lock(log_mutex());
|
||||||
|
|
||||||
rewind(9 + ctxs.size());
|
rewind((mode_ == NORMAL ? 9 : 4) + ctxs.size());
|
||||||
|
|
||||||
statebuf_ = oss.str();
|
statebuf_ = oss.str();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user