From: Wichert Akkerman Date: Wed, 13 Oct 1999 15:52:49 +0000 (+0000) Subject: fix crash in dselect on window resize X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=661b148489b40177ad6650a0ea73c1967d7b1fa5;p=dpkg fix crash in dselect on window resize --- diff --git a/ChangeLog b/ChangeLog index 22874b8f..20232f03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Oct 13 17:51:17 CEST 1999 Wichert Akkerman + + * Merge patch from Ben Collins to fix windowresizing in dselect + Tue Oct 12 17:15:08 CEST 1999 Wichert Akkerman * don't die if we can't open a package in dpkg-scanpackages, just print diff --git a/dselect/dselect.h b/dselect/dselect.h index e1113091..f8242727 100644 --- a/dselect/dselect.h +++ b/dselect/dselect.h @@ -27,6 +27,17 @@ #include +#if defined(SIGWINCH) && defined(TIOCGWINSZ) && defined(NCURSES_VERSION) +#define CAN_RESIZE 1 +#else +#define CAN_RESIZE 0 +#endif + +#if CAN_RESIZE +static RETSIGTYPE adjust(int sig); +static int interrupted; +#endif + struct helpmenuentry { char key; const struct helpmessage *msg; diff --git a/dselect/main.cc b/dselect/main.cc index dbad037b..84ae6f38 100644 --- a/dselect/main.cc +++ b/dselect/main.cc @@ -96,6 +96,32 @@ static void usage(void) { stdout)) werr("stdout"); } +#if CAN_RESIZE +/* + * This uses functions that are "unsafe", but it seems to work on SunOS and + * Linux. The 'wrefresh(curscr)' is needed to force the refresh to start from + * the top of the screen -- some xterms mangle the bitmap while resizing. + * + * Borrowed from the ncurses example view.c + */ +static RETSIGTYPE adjust(int sig) +{ + if (waiting || sig == 0) { + struct winsize size; + + if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) { + resizeterm(size.ws_row, size.ws_col); + wrefresh(curscr); /* Linux needs this */ + show_all(); + } + interrupted = FALSE; + } else { + interrupted = TRUE; + } + (void) signal(SIGWINCH, adjust); /* some systems need this */ +} +#endif /* CAN_RESIZE */ + /* These are called by C code, so need to have C calling convention */ extern "C" { @@ -280,6 +306,10 @@ urqresult urq_quit(void) { int main(int, const char *const *argv) { jmp_buf ejbuf; +#if CAN_RESIZE + (void) signal(SIGWINCH, adjust); /* arrange interrupts to resize */ +#endif + if (setjmp(ejbuf)) { /* expect warning about possible clobbering of argv */ cursesoff(); error_unwind(ehflag_bombout); exit(2); diff --git a/dselect/pkglist.cc b/dselect/pkglist.cc index cdc3a2b0..81f17109 100644 --- a/dselect/pkglist.cc +++ b/dselect/pkglist.cc @@ -493,6 +493,10 @@ pkginfo **packagelist::display() { if (debug) fprintf(debug,"packagelist[%p]::display() entering loop\n",this); for (;;) { +#if CAN_RESIZE + if (interrupted) + adjust(0); +#endif if (whatinfo_height) wcursyncup(whatinfowin); if (doupdate() == ERR) ohshite("doupdate failed"); signallist= this;