Handle SIGWINCH

This commit is contained in:
Eelco Dolstra 2017-08-25 15:57:49 +02:00
parent ec9e0c03c3
commit db1d45037c
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 39 additions and 8 deletions

View file

@ -6,8 +6,6 @@
#include <map>
#include <atomic>
#include <sys/ioctl.h>
namespace nix {
static std::string getS(const std::vector<Logger::Field> & fields, size_t n)
@ -99,15 +97,10 @@ private:
Sync<State> state_;
int width = 0;
public:
ProgressBar()
{
struct winsize ws;
if (ioctl(1, TIOCGWINSZ, &ws) == 0)
width = ws.ws_col;
}
~ProgressBar()
@ -270,7 +263,7 @@ public:
}
}
writeToStderr("\r" + ansiTruncate(line, width) + "\e[K");
writeToStderr("\r" + ansiTruncate(line, getWindowSize().second) + "\e[K");
}
std::string getStatus(State & state)