How do I get vi to know my window size?

Paul Fox pgf at brightstareng.com
Wed Sep 20 00:51:41 PDT 2006


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"

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


More information about the busybox mailing list