How do I get vi to know my window size?

Rob Landley rob at landley.net
Thu Sep 21 19:17:53 UTC 2006


On Wednesday 20 September 2006 9:53 pm, Rich Felker wrote:
> On Wed, Sep 20, 2006 at 07:49:33PM -0400, Rob Landley wrote:
> > Anyway, I can teach bbsh that when it's launched interactive, do the 
probing 
> > thing if standard querying doesn't work to determine terminal size.  
That'll 
> > set $LINES and $COLUMNS for its child programs, and svn 16167 should 
> > theoretically be able to take it from there...
> 
> How do you avoid eating (and possibly choking on) user keystrokes
> already in the input buffer?

You poll() and either don't do it or read them first.  It's a heuristic, 
working around the general badness of in-band signaling.  It's not going to 
be perfect.

> The only way I can think to avoid that is 
> with some sort of tricky extra buffering layer.

No, poll() with a timeout of 0 and skip if the heuristic if there's input 
waiting.  You also need to do something like that if somebody goes "cat 
script | bbsh".  (And you want to make sure that stdin and stdout point to 
the same device, although that's part of the standard "interactive" check, 
hence doing this when you're in interactive mode.  There was more, I thought 
this through on the busride home yesterday, my notes around around here 
somewhere...)

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list