The value is 1074295912 (0x40087468). Then I used the following Ruby
code based on something I found in the archives:
TIOCGWINSZ = 0x40087468
str = [0, 0, 0, 0].pack(‘SSSS’)
if STDIN.ioctl(TIOCGWINSZ, str) >= 0
rows, cols, xpixels, ypixels = str.unpack(“SSSS”)
p rows, cols, xpixels, ypixels
else
puts “Unable to get window size”
end
This returns the correct values:
[55, 132, 792, 770]
That is, 55 rows, 132 columns. I’d like to know if there’s a more
portable way of doing this… About the only semi-portable way I can
think of is wrapping this up in a C extension; at least that way
(most) people can compile it locally. Suggestions?
{
rows, cols, xpixels, ypixels = str.unpack(“SSSS”)
portable way of doing this… About the only semi-portable way I can
think of is wrapping this up in a C extension; at least that way
(most) people can compile it locally. Suggestions?
Thanks, James. That seems to cover just about all platforms, although
it introduces another dependency or two (HighLine itself, plus
HighLine’s own dependencies). I guess that’s the way it is though…
HighLine’s own dependencies). I guess that’s the way it is though…
Cheers,
Greg
I use highline in a bunch of internal projects for CLI gui’s, it
totally rocks(thx JEGII&Gregory!). But I want these to be standalone
gems with no dependencies so I embed highline in my own gems. Its
only a few files and easy to embed so it makes sense to ship it with
the gem that needs it.
Cheers-
– Ezra Z.
– Lead Rails Evangelist
– [email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.