how do I tell the size of a pseudoterm window?
Dave Cohrs
dave at cs.wisc.edu
Fri Dec 2 09:29:42 AEST 1988
In article <2081 at vedge.UUCP> lai at vedge.UUCP (David Lai) asks about
window sizes.
In 4.3BSD and related systems (SunOS 4.0 and Ultrix too), the current
size of a window is kept as part of the per-tty information, and you
can get/set it via a couple ioctls:
#include <sys/ioctl.h>
int
getwinsz()
{
struct winsize ws;
ioctl(f, TIOCGWINSZ, &ws);
printf("current window size: %d x %d chars, %d x %d pixels\n",
ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel);
return 0;
}
The ioctl to set the window size is TIOCSWINSZ (f would be the fd of
your tty). If you want to be signal()ed when some process changes
your window size, you use the SIGWINCH signal.
signal(SIGWINCH, getwinsz); /* your types may vary */
In this case, getwinsz() will be called whenever someone, like xterm
changes your window size.
There is an equivalent but different pair of ioctls on older SunOS's.
There doesn't appear to be such functionality in SystemV (they have
a different philosophy about what a window is, I think).
The TERMCAP variable won't automatically change. If you have X, then
you have a "resize" program, and you can use it to change your TERMCAP
variable. Of course, if you have an "ls" that look as your window
size, it should use the ioctl() as well, not just TERMCAP. I suppose
you could hack your shell to change the TERMCAP variable for you.
dave cohrs
--
Dave Cohrs
+1 608 262-6617 UW-Madison Computer Sciences Department
dave at cs.wisc.edu ...!{harvard,rutgers,ucbvax}!uwvax!dave
More information about the Comp.unix.wizards
mailing list