how do I tell the size of a pseudoterm window?
Bob Pendleton
bpendlet at esunix.UUCP
Sat Dec 3 06:33:05 AEST 1988
>From article <2081 at vedge.UUCP>, by lai at vedge.UUCP (David Lai):
> 2 problems:
This works under Ultrix and SunOS, you mileage may vary.
> 1) How is a program able to tell the size of a pseudoterm's window.
This gets it
(void) ioctl(0, TIOCGWINSZ, &tty_winsize);
This passes it on
(void) ioctl(slave_tty, TIOCSWINSZ, &tty_winsize);
This passes on the SIGWINCH signal
(void) ioctl(slave_tty, TIOCGPGRP, (char *) &pgrp);
(void) killpg(pgrp, SIGWINCH);
> Is there a termcap entry which specifies that the screen can be
> resized? (The termcap man pages dont mention it).
I couldn't find one. Anyone knows, I'd like to see it.
> How does a program
> get 'signalled' when a resize occurs (ie. like vi doing a redraw after
> a resize) ?
SIGWINCH. catch it using something like
(void) signal(SIGWINCH, change_window);
Where change_window is a procedure that tells you about it.
>
> 2) How can the termcap be modified automatically when a 'resize' occurs, when
> not in a program (ie at the shell prompt)? This would be useful so that
> the next 'ls' or other such commands would output an appropriate number
> of columns.
You could fake a new termcap as a variable in the environment that
gives the current size of the window. But, if the shell doesn't pass
it along you will never see it.
One trouble is that csh, at least the one I'm using under SunOS,
doesn't pass on SIGWINCH, and doesn't do anything with it. So if you
are running under csh, you can't get it so you can't do anything with
it. to get around this I run emacs directly under an xterm. And some
day I'll get things fixed so I can run emacs directly as an X
application and throw away xterm.
>
> I am looking for a general case solution which should be able to be
> applied to various windowing systems. Does this involve a special
> tty/pty driver?
No, the existing one seem to work just fine. But figuring out how to
use it is another story. :-) Reading xterm, ile, or rlogin might help
you understand it better.
Study the pty/tty driver and SIGWINCH, the information you need is all
there, it's just well hidden.
I hope this is useful.
Bob P.
--
Bob Pendleton, speaking only for myself.
UUCP Address: decwrl!esunix!bpendlet or utah-cs!esunix!bpendlet
Reality is what you make of it.
More information about the Comp.unix.wizards
mailing list