summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:51:26 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:51:26 +0000
commitd7827acababa05db7e901d2dfeb27538ef6a6142 (patch)
treea6a79c3cdeea76b81fa50335ee8306327fe888cf /cmdline
parent7a7fa5f07e59bd17415cb0321d1f98527c2cfea4 (diff)
winch support
Author: jgg Date: 1998-11-12 05:30:07 GMT winch support
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/acqprogress.cc4
-rw-r--r--cmdline/acqprogress.h6
-rw-r--r--cmdline/apt-get.cc24
3 files changed, 28 insertions, 6 deletions
diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc
index 82bb6fac6..ccc322084 100644
--- a/cmdline/acqprogress.cc
+++ b/cmdline/acqprogress.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acqprogress.cc,v 1.1 1998/11/11 23:45:52 jgg Exp $
+// $Id: acqprogress.cc,v 1.2 1998/11/12 05:30:07 jgg Exp $
/* ######################################################################
Acquire Progress - Command line progress meter
@@ -18,7 +18,7 @@
// AcqTextStatus::AcqTextStatus - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-AcqTextStatus::AcqTextStatus(unsigned int ScreenWidth,unsigned int Quiet) :
+AcqTextStatus::AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet) :
ScreenWidth(ScreenWidth), Quiet(Quiet)
{
}
diff --git a/cmdline/acqprogress.h b/cmdline/acqprogress.h
index 898eddeca..9dd5c60cf 100644
--- a/cmdline/acqprogress.h
+++ b/cmdline/acqprogress.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acqprogress.h,v 1.1 1998/11/11 23:45:55 jgg Exp $
+// $Id: acqprogress.h,v 1.2 1998/11/12 05:30:09 jgg Exp $
/* ######################################################################
Acquire Progress - Command line progress meter
@@ -14,7 +14,7 @@
class AcqTextStatus : public pkgAcquireStatus
{
- unsigned int ScreenWidth;
+ unsigned int &ScreenWidth;
char BlankLine[300];
unsigned long ID;
unsigned long Quiet;
@@ -30,7 +30,7 @@ class AcqTextStatus : public pkgAcquireStatus
void Pulse(pkgAcquire *Owner);
- AcqTextStatus(unsigned int ScreenWidth,unsigned int Quiet);
+ AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet);
};
#endif
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 2ed05b8aa..8daaf05f4 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-get.cc,v 1.7 1998/11/12 04:10:56 jgg Exp $
+// $Id: apt-get.cc,v 1.8 1998/11/12 05:30:10 jgg Exp $
/* ######################################################################
apt-get - Cover for dpkg
@@ -39,6 +39,9 @@
#include "acqprogress.h"
#include <fstream.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <signal.h>
/*}}}*/
ostream c0out;
@@ -801,6 +804,20 @@ void GetInitialize()
_config->Set("APT::Get::Fix-Broken",false);
}
/*}}}*/
+// SigWinch - Window size change signal handler /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+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
+}
+ /*}}}*/
int main(int argc,const char *argv[])
{
@@ -845,6 +862,11 @@ int main(int argc,const char *argv[])
c0out.rdbuf(devnull.rdbuf());
if (_config->FindI("quiet",0) > 1)
c1out.rdbuf(devnull.rdbuf());
+
+ // Setup the signals
+ signal(SIGPIPE,SIG_IGN);
+ signal(SIGWINCH,SigWinch);
+ SigWinch(0);
// Match the operation
struct