diff options
author | Michael Vogt <mvo@debian.org> | 2013-12-10 08:13:42 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-12-10 08:13:42 +0100 |
commit | 35808e7a512d577e418b5e164d4fd5b58feaf42a (patch) | |
tree | 0a55465ec6aa6b6fefdac5ccf7f8f01b3c9e998c /apt-pkg/install-progress.cc | |
parent | f31d34ee967cb1637c0efeb408c76a2c26bbdc07 (diff) | |
parent | ce34af08ad6866869147e3525fa6c89d8dcb4601 (diff) |
Merge remote-tracking branch 'upstream/debian/sid' into feature/source-deb822
Diffstat (limited to 'apt-pkg/install-progress.cc')
-rw-r--r-- | apt-pkg/install-progress.cc | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index 09b1bef9e..b82b7efde 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -10,6 +10,7 @@ #include <sstream> #include <fcntl.h> + namespace APT { namespace Progress { @@ -221,6 +222,14 @@ bool PackageManagerProgressDeb822Fd::StatusChanged(std::string PackageName, return true; } +int PackageManagerFancy::GetNumberTerminalRows() +{ + struct winsize win; + if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) != 0) + return -1; + + return win.ws_row; +} void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) { @@ -248,23 +257,32 @@ void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) } PackageManagerFancy::PackageManagerFancy() - : nr_terminal_rows(-1) { - struct winsize win; - if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) == 0) - { - nr_terminal_rows = win.ws_row; - } + // setup terminal size + old_SIGWINCH = signal(SIGWINCH, HandleSIGWINCH); +} + +PackageManagerFancy::~PackageManagerFancy() +{ + signal(SIGWINCH, old_SIGWINCH); +} + +void PackageManagerFancy::HandleSIGWINCH(int) +{ + int nr_terminal_rows = GetNumberTerminalRows(); + SetupTerminalScrollArea(nr_terminal_rows); } void PackageManagerFancy::Start() { + int nr_terminal_rows = GetNumberTerminalRows(); if (nr_terminal_rows > 0) SetupTerminalScrollArea(nr_terminal_rows); } void PackageManagerFancy::Stop() { + int nr_terminal_rows = GetNumberTerminalRows(); if (nr_terminal_rows > 0) { SetupTerminalScrollArea(nr_terminal_rows + 1); @@ -284,7 +302,7 @@ bool PackageManagerFancy::StatusChanged(std::string PackageName, HumanReadableAction)) return false; - int row = nr_terminal_rows; + int row = GetNumberTerminalRows(); static string save_cursor = "\033[s"; static string restore_cursor = "\033[u"; |