summaryrefslogtreecommitdiff
path: root/apt-pkg/iprogress.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-10-11 22:16:55 +0200
committerMichael Vogt <mvo@debian.org>2013-10-11 22:16:55 +0200
commitdb78c60c6a726ed70fa8b0984090b80840444016 (patch)
tree471b8e385a8296bce5568bb99ea6b01e1a0a8c88 /apt-pkg/iprogress.cc
parent31f97d7b862ccf3de93b30a15f24d76e806031a3 (diff)
deal with nr_terminal_rows unavailable
Diffstat (limited to 'apt-pkg/iprogress.cc')
-rw-r--r--apt-pkg/iprogress.cc17
1 files changed, 11 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,