lambert@spectrum.cs.unsw.oz.au (Tim Lambert) (08/01/90)
I have a program that produces very long lines. I wrote a filter that made these lines fit into a transcript window by inserting extra newlines. (The program is appended to this article.) Now the problem. The program uses SIGWINCH to detect when the window changes size, but the DM does not send this signal when it changes the size of a window. If I redefine M1U to send SIGWINCH like this % xdmc "kd m1u echo;dq -c 9010020 ke" everything works correctly (provided I use M1 to resize the window). It seems a bit rude to change the key bindings of a user; after all he/she may use M1 for something besides resizing. Anyone have any suggestions? (And why doesn't the DM send SIGWINCH?) Tim -------------------------------- #include <stdio.h> #include <sgtty.h> #include <signal.h> static int (*oldwinch)(); static struct winsize w; /* signal handler */ static int newwinch(sig) int sig; { if (oldwinch != SIG_IGN && oldwinch != SIG_DFL) (*oldwinch)(sig); ioctl(1,TIOCGWINSZ,&w); (void)signal(sig,newwinch); } main(int argc, char *argv[]) { #define reset ll = 0 int c; int ll; /* current line length */ oldwinch=signal(SIGWINCH,newwinch); ioctl(1,TIOCGWINSZ,&w); while((c=getchar()) != EOF) { putchar(c); if (c=='\n') { reset; } else if (c=='\b') { --ll; } else { if (++ll == w.ws_col) { putchar('\n'); reset; } } } } ------------------------------------------------------