On Wed, May 15, 2002 at 03:40:01AM +0900, Ian Macdonald wrote: > Hi, > > I would like to obtain the current terminal size (rows x columns) from > within Ruby, but I can't figure out a reasonable way to do it. > > Something tells me I should be able to use the termios library for > this, but I can't quite figure out how to do it. Dunno how portable it is (I don't usually do this sort of thing), but the following works on i386 Linux: TIOCGWINSZ = 0x5413 str = [ 0, 0, 0, 0 ].pack("SSSS") if $stdin.ioctl(TIOCGWINSZ, str) >= 0 then rows, cols, xpixels, ypixels = str.unpack("SSSS") p rows, cols, xpixels, ypixels else puts "Unable to get window size" end Paul