Tim Pease wrote:
> On 8/7/07, James Edward Gray II <james / grayproductions.net> wrote:
>> Can anyone provide an equivalent technique that works on Solaris?
>>
> 
> $ cat t.rb
> def terminal_size
>   m = %r/rows\s(?:=\s)?(\d+);.*columns\s(?:=\s)?(\d+);/.match(`stty -a`)
>   [Integer(m[2]), Integer(m[1])]
> end
> 
> puts terminal_size.inspect
> 
> $ uname -a
> SunOS hedwig 5.9 Generic_112233-12 sun4u sparc SUNW,Sun-Blade-1500
> 
> $ ruby t.rb
> [80, 36]
> 
> 
> And on the Linux box ...
> 
> $ uname -a
> Linux pong 2.6.21-1.3228.fc7 #1 SMP Tue Jun 12 15:37:31 EDT 2007 i686
> i686 i386 GNU/Linux
> 
> $ ruby t.rb
> [80, 24]
> 
How's this:

[alex@panama ~/noodling/ruby]$ ruby t.rb
[157, 62]
[alex@panama ~/noodling/ruby]$ cat t.rb
def terminal_size
   %r{([^;]*rows[^;]*;)([^;]*columns[^;]*;)}.match(`stty 
-a`)[1..-1].map{|i| i.gsub(/\D/, '').to_i}.reverse
end

puts terminal_size.inspect


'Scuse the line break, but it works on FreeBSD, Linux and Cygwin+OCI...

-- 
Alex