Detecting console dimensions

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…

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

On 5/20/06, Pistos C. [email protected] 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.

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.
:frowning: 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