diff options
-rw-r--r-- | apt-pkg/iprogress.cc | 17 | ||||
-rw-r--r-- | apt-pkg/iprogress.h | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/apt-pkg/iprogress.cc b/apt-pkg/iprogress.cc index 4de8c0492..68a2c7207 100644 --- a/apt-pkg/iprogress.cc +++ b/apt-pkg/iprogress.cc @@ -7,7 +7,7 @@ namespace APT { namespace Progress { -static void SetupTerminalScrollArea(int nr_rows) +void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) { // scroll down a bit to avoid visual glitch when the screen // area shrinks by one row @@ -23,6 +23,7 @@ static void SetupTerminalScrollArea(int nr_rows) std::cout << "\033[u"; static const char *move_cursor_up = "\033[1A"; std::cout << move_cursor_up; + std::flush(std::cout); } @@ -38,16 +39,20 @@ PackageManagerFancy::PackageManagerFancy() void PackageManagerFancy::Started() { - SetupTerminalScrollArea(nr_terminal_rows); + if (nr_terminal_rows > 0) + SetupTerminalScrollArea(nr_terminal_rows); } void PackageManagerFancy::Finished() { - SetupTerminalScrollArea(nr_terminal_rows + 1); + if (nr_terminal_rows > 0) + { + SetupTerminalScrollArea(nr_terminal_rows + 1); - // override the progress line (sledgehammer) - static const char* clear_screen_below_cursor = "\033[J"; - std::cout << clear_screen_below_cursor; + // override the progress line (sledgehammer) + static const char* clear_screen_below_cursor = "\033[J"; + std::cout << clear_screen_below_cursor; + } } void PackageManagerFancy::StatusChanged(std::string PackageName, diff --git a/apt-pkg/iprogress.h b/apt-pkg/iprogress.h index 14fc89bff..f097e0943 100644 --- a/apt-pkg/iprogress.h +++ b/apt-pkg/iprogress.h @@ -30,6 +30,8 @@ namespace Progress { protected: int last_reported_progress; int nr_terminal_rows; + void SetupTerminalScrollArea(int nr_rows); + public: PackageManagerFancy(); virtual void Started(); |