From: Paul Lutus Date: 2006-09-13T17:20:50+09:00 Subject: Re: getch equivalent of method in ruby ? Michael W. Ryder wrote: > Paul Lutus wrote: >> Michael W. Ryder wrote: >> >>> Paul Lutus wrote: >>>> Googy wrote: >>>> >>>>> Hi, >>>>> >>>>> I need to read some interactive input from keyboard and I am look for >>>>> getch (c equivalent) of method in ruby. >>>> Since you mention "getch()", which is non-standard and only available >>>> on the Windows platform, I have to say there is no equivalent to it in >>>> any portable languages. Another poster recommends manipulating the >>>> input stream on Linux or another Unix, and if you have this option, >>>> that is an obvious way to go, but it isn't portable between platforms. >>>> >>>> The is no platform-portable keystroke-by-keystroke input method. >>>> >>> Curses is platform-portable, uses getch() to get keystrokes, and works >>> with Ruby. >> >> I'll flesh out my reply. There is no platform-portable >> keystroke-by-keystroke input method that doesn't require an external >> utility to get around this limitation, and that takes a different form on >> each platform that you try to implement it on. >> > > ????? Curses is a library that works the same on all platforms. Look into it, as I just did. > There is no need to learn anything new to use it under windows, Unix, etc. This is simply not true. It can almost always be done, but it is by no means point and click. It is an external library that takes different forms and names on different platforms, and if the Ruby application is expected to be seamlessly platform-portable, then it is best not to rely on the existence of something like getch(). -- Paul Lutus http://www.arachnoid.com