How do I get vi to know my window size?

Bernhard Fischer rep.nop at aon.at
Thu Sep 21 17:13:20 UTC 2006


On Wed, Sep 20, 2006 at 03:51:41AM -0400, Paul Fox wrote:
>rob wrote:
> > 
> > Who exactly are you testing the current size _from_?  (Is your xterm 
> > responding to the ansi escape sequence when it tries to display it?)  If so, 
>
>yes, exactly right.  the code i have sends this:
>	ESC "7"  ESC "[r" ESC "[999;999H" ESC "[6n"
>then reads a response that looks like:
>	ESC "[%d;%dR"
>and uses the results to feed TIOCSWINSZ.  then send:
>	ESC "8"

Now that's about all one needs to know :)

The only inconvenient stuff is the termios flags for echo et. al.

Not really tested.. Can someone who initially faced the problem
give it a whirl, please?
TIA,

PS: before somebody asks for a "reset" applet, please consider using
either this alias or write a fancy script to that effect.

$ grep reset ~/.bashrc
# alias reset='echo -e '\''\033c'\'' ; stty sane line 1'

cheers,
Bernhard
>
>the timeout on the read is long -- 10 seconds -- but it's a standalone
>program, and can be killed if the terminal isn't responding.
>
> > I could just add this behavior as a config option to 
> > get_terminal_width_height() in libbb (a fallback for when we get 0/0 as the 
> > size).  The hard part's figuring out when it's safe to do it.  (Hmmm, poll 
>
>i agree, though one might come up with a mechanism that could be turned
>on optionally by the calling program.
>
>paul
>=---------------------
> paul fox, pgf at brightstareng.com
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://busybox.net/cgi-bin/mailman/listinfo/busybox
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: resize.c
Type: text/x-csrc
Size: 1193 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060921/dbcc307b/attachment-0002.c 


More information about the busybox mailing list