+PackageManagerFancy::PackageManagerFancy()
+ : child_pty(-1)
+{
+ // setup terminal size
+ old_SIGWINCH = signal(SIGWINCH, PackageManagerFancy::staticSIGWINCH);
+ instances.push_back(this);
+}
+std::vector<PackageManagerFancy*> PackageManagerFancy::instances;
+
+PackageManagerFancy::~PackageManagerFancy()
+{
+ instances.erase(find(instances.begin(), instances.end(), this));
+ signal(SIGWINCH, old_SIGWINCH);
+}
+
+void PackageManagerFancy::staticSIGWINCH(int signum)
+{
+ std::vector<PackageManagerFancy *>::const_iterator I;
+ for(I = instances.begin(); I != instances.end(); ++I)
+ (*I)->HandleSIGWINCH(signum);
+}
+
+PackageManagerFancy::TermSize
+PackageManagerFancy::GetTerminalSize()
+{
+ struct winsize win;
+ PackageManagerFancy::TermSize s = { 0, 0 };
+
+ // FIXME: get from "child_pty" instead?
+ if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) != 0)
+ return s;
+
+ if(_config->FindB("Debug::InstallProgress::Fancy", false) == true)
+ std::cerr << "GetTerminalSize: " << win.ws_row << " x " << win.ws_col << std::endl;
+
+ s.rows = win.ws_row;
+ s.columns = win.ws_col;
+ return s;
+}
+