diff options
author | Michael Vogt <mvo@debian.org> | 2013-10-11 22:16:55 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-10-11 22:16:55 +0200 |
commit | db78c60c6a726ed70fa8b0984090b80840444016 (patch) | |
tree | 471b8e385a8296bce5568bb99ea6b01e1a0a8c88 /apt-pkg | |
parent | 31f97d7b862ccf3de93b30a15f24d76e806031a3 (diff) |
deal with nr_terminal_rows unavailable
Diffstat (limited to 'apt-pkg')
-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(); |