How do I get vi to know my window size?

Dave Hylands dhylands at gmail.com
Tue Sep 19 02:54:11 UTC 2006


Hi,

I'm using busybox-1.1.2 under linux-2.6.17 on a gumstix.

When I run the vi from busybox over my serial line, it thinks that my
terminal is 80x24

My vi config options are set like this:
CONFIG_VI=y
CONFIG_FEATURE_VI_COLON=y
# CONFIG_FEATURE_VI_YANKMARK is not set
CONFIG_FEATURE_VI_SEARCH=y
CONFIG_FEATURE_VI_USE_SIGNALS=y
# CONFIG_FEATURE_VI_DOT_CMD is not set
# CONFIG_FEATURE_VI_READONLY is not set
# CONFIG_FEATURE_VI_SETOPTS is not set
# CONFIG_FEATURE_VI_SET is not set
CONFIG_FEATURE_VI_WIN_RESIZE=y
# CONFIG_FEATURE_VI_OPTIMIZE_CURSOR is not set

I dug through the code a bit to find the get_terminal_width_height function.

I then coded up a simple test program:

#include <stdio.h>
#include <termios.h>
#include <sys/ioctl.h>

int main( int argc, char **argv )
{
    struct winsize win = { 0, 0, 0, 0 };
    int ret = ioctl(fileno(stdin), TIOCGWINSZ, &win);

    printf( "Width = %d, Height = %d\n", win.ws_col, win.ws_row );
    return 0;
}

and when I run it, it reports 0 and 0 (which explains why
get_teminal_width_height reports 80x24).

If I ssh into the gumstix then running the above program reports the
correct size, and running vi works as expected.

My terminal type in both cases is vt100, and the TERM environment
variable is set appropriately.

So, is it possible to get the terminal size correct when using a serial port?

Any insight would be appreciated.

-- 
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/



More information about the busybox mailing list