diff options
author | Michael Vogt <mvo@ubuntu.com> | 2014-05-05 16:03:03 +0200 |
---|---|---|
committer | Michael Vogt <mvo@ubuntu.com> | 2014-05-05 16:03:03 +0200 |
commit | 98c934f2723d63d00908803ad47ab1359081ec2d (patch) | |
tree | df7c21f028089b99d63289d784ee5bd23d54d380 /apt-private/private-output.cc | |
parent | a298a1dc595c548e6c10b48b8e69d987e5be1c42 (diff) | |
parent | a11f6c973bc0dc226d8953e3edb6333d526c3143 (diff) |
Merge remote-tracking branch 'upstream/debian/sid' into debian/sid
Diffstat (limited to 'apt-private/private-output.cc')
-rw-r--r-- | apt-private/private-output.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index 757999167..7f3eef6c2 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -22,6 +22,7 @@ #include <iostream> #include <langinfo.h> #include <unistd.h> +#include <signal.h> #include <apti18n.h> /*}}}*/ @@ -32,8 +33,24 @@ std::ostream c0out(0); std::ostream c1out(0); std::ostream c2out(0); std::ofstream devnull("/dev/null"); + + unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */ +// SigWinch - Window size change signal handler /*{{{*/ +// --------------------------------------------------------------------- +/* */ +static void SigWinch(int) +{ + // Riped from GNU ls +#ifdef TIOCGWINSZ + struct winsize ws; + + if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5) + ScreenWidth = ws.ws_col - 1; +#endif +} + /*}}}*/ bool InitOutput() /*{{{*/ { if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1) @@ -47,6 +64,10 @@ bool InitOutput() /*{{{*/ if (_config->FindI("quiet",0) > 1) c1out.rdbuf(devnull.rdbuf()); + // deal with window size changes + signal(SIGWINCH,SigWinch); + SigWinch(0); + if(!isatty(1)) { _config->Set("APT::Color", "false"); |