Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > ruby-ncurses related problems

Reply
Thread Tools

ruby-ncurses related problems

 
 
Stanislaw Halik
Guest
Posts: n/a
 
      11-08-2006
Heya,

I'm trying to learn the Ncurses module. However, nonblocking getch()
doesn't work. A simple test case:

-->--
#!/usr/bin/env ruby
require 'ncurses'
Ncurses.initscr
Ncurses.start_color
Ncurses.noecho
Ncurses.cbreak
Ncurses.noraw
Ncurses.stdscr.nodelay(true)
Ncurses.stdscr.keypad(true)
Ncurses.refresh
while ch = Ncurses.getch
Ncurses.printw ch.to_s
Ncurses.refresh
end
--<--

prints '10' every time no characters are in the buffer. There's no
constant defined to be a '10' in both ncurses.h and the Ruby wrapper.
According to getch(3), it's supposed to return an 'ERR' constant, being
'-1'. It, however, returns '10' for some reason.

Now i'm out of luck. There's no support contact listed on ruby-ncurses
project's site and the Curses module seems obsolete - it doesn't
implement w*printw()-related functions which i like using much.

Is there some other ncurses module that actually works?

 
Reply With Quote
 
 
 
 
Michael W. Ryder
Guest
Posts: n/a
 
      11-08-2006
Stanislaw Halik wrote:
> Heya,
>
> I'm trying to learn the Ncurses module. However, nonblocking getch()
> doesn't work. A simple test case:
>
> -->--
> #!/usr/bin/env ruby
> require 'ncurses'
> Ncurses.initscr
> Ncurses.start_color
> Ncurses.noecho
> Ncurses.cbreak
> Ncurses.noraw
> Ncurses.stdscr.nodelay(true)
> Ncurses.stdscr.keypad(true)
> Ncurses.refresh
> while ch = Ncurses.getch
> Ncurses.printw ch.to_s
> Ncurses.refresh
> end
> --<--
>
> prints '10' every time no characters are in the buffer. There's no
> constant defined to be a '10' in both ncurses.h and the Ruby wrapper.
> According to getch(3), it's supposed to return an 'ERR' constant, being
> '-1'. It, however, returns '10' for some reason.
>


Isn't 10 an ASCII CR (or is it LF)?


> Now i'm out of luck. There's no support contact listed on ruby-ncurses
> project's site and the Curses module seems obsolete - it doesn't
> implement w*printw()-related functions which i like using much.
>
> Is there some other ncurses module that actually works?
>

 
Reply With Quote
 
 
 
 
Stanislaw Halik
Guest
Posts: n/a
 
      11-08-2006
On Wed, Nov 08, 2006, Michael W. Ryder wrote:
>> I'm trying to learn the Ncurses module. However, nonblocking getch()
>> doesn't work. A simple test case:


>> -->--
>> #!/usr/bin/env ruby
>> require 'ncurses'
>> Ncurses.initscr
>> Ncurses.start_color
>> Ncurses.noecho
>> Ncurses.cbreak
>> Ncurses.noraw
>> Ncurses.stdscr.nodelay(true)
>> Ncurses.stdscr.keypad(true)
>> Ncurses.refresh
>> while ch = Ncurses.getch
>> Ncurses.printw ch.to_s
>> Ncurses.refresh
>> end
>> --<--


>> prints '10' every time no characters are in the buffer. There's no
>> constant defined to be a '10' in both ncurses.h and the Ruby wrapper.
>> According to getch(3), it's supposed to return an 'ERR' constant, being
>> '-1'. It, however, returns '10' for some reason.

> Isn't 10 an ASCII CR (or is it LF)?


It is. However, the Return key isn't pressed at the time.

Besides, I found a bug in the standard Curses module: macro wrapping the
return value of getch() treats it as an unsigned integer.

/* def getch */
static VALUE
curses_getch(obj)
VALUE obj;
{
rb_read_check(stdin);
curses_stdscr();
return UINT2NUM(getch());
~~~~~~~~
}

For the value of EOF (-1, as present in ncurses), it wraps around. Where
should I report it?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How should multiple (related) projects be arranged (structured) and configured so that they can share code, have a related package structure and enable proper unittesting, and ensuring no namespace collisions ToddLMorgan@gmail.com Python 14 04-21-2006 04:03 PM
Culture and date related problems papaja ASP .Net 0 12-02-2005 07:17 PM
How should threads be terminated? (related to 'Help with thread related tracebacks') Maxwell Hammer Python 7 06-18-2005 04:20 PM
Paging related problems Franck Diastein ASP .Net 0 01-12-2005 10:07 AM
Strange problems some how related to w3svc moondaddy ASP .Net 0 10-19-2004 08:11 PM



Advertisments