Forum: Ruby Detecting console dimensions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
316017672dfe1c4e8e22843348ee32d4?d=identicon&s=25 Sy Ali (Guest)
on 2006-05-20 06:39
(Received via mailing list)
Is there a simple way for a ruby script to know the size of the space
it has to work with  Would I be forced to use ncurses or some such?

I see that i have environment variables like COLUMNS and ROWS .. but I
don't know how to get this information into a script.  For example,
ENV['ROWS'] does not work..
A402df36168b81b31c17adcbb5ae8cf4?d=identicon&s=25 Pistos Christou (pistos)
on 2006-05-21 04:47
Sy Ali wrote:
> Is there a simple way for a ruby script to know the size of the space
> it has to work with  Would I be forced to use ncurses or some such?

Any particular reason not to use curses?  Because it would get you what
you want really easily, and you can just drop out of curses mode again
and continue your script...

Pistos
316017672dfe1c4e8e22843348ee32d4?d=identicon&s=25 Sy Ali (Guest)
on 2006-05-21 15:32
(Received via mailing list)
On 5/20/06, Pistos Christou <jesusrubsyou.5.pistos@geoshell.com> wrote:
> Sy Ali wrote:
> > Is there a simple way for a ruby script to know the size of the space
> > it has to work with  Would I be forced to use ncurses or some such?
>
> Any particular reason not to use curses?  Because it would get you what
> you want really easily, and you can just drop out of curses mode again
> and continue your script...

Yes, there are a few reasons why I'm gun-shy.

* Learning something new (which distracts from my learning other things)
* Adding a dependancy to the script.
* Assuming ncurses works, and works the same, everywhere.
A402df36168b81b31c17adcbb5ae8cf4?d=identicon&s=25 Pistos Christou (pistos)
on 2006-05-21 23:29
Sy Ali wrote:
> Yes, there are a few reasons why I'm gun-shy.
> * Learning something new (which distracts from my learning other things)
> * Adding a dependancy to the script.
> * Assuming ncurses works, and works the same, everywhere.

You're right that it's not everywhere.  In particular, Debian (and
spinoffs) want to make curses a separate package than the Ruby package.
:(  But, AFAIK, it works the same everywhere with the exception of the
Windows platform.

The learning part is trivial, because I could tell you the three to five
lines you need to get the dimensions.

Anyway, hope you figure out your problem.

Pistos
This topic is locked and can not be replied to.