ruby / curses

Ruby binding for curses, ncurses, and PDCurses. Formerly part of the ruby standard library.
Other
296 stars 34 forks source link

I think there is an error in https://github.com/ruby/curses/blob/master/sample/form.rb #79

Closed rubyFeedback closed 1 year ago

rubyFeedback commented 1 year ago

I just tested this example:

https://github.com/ruby/curses/blob/master/sample/form.rb

https://github.com/ruby/curses/blob/master/sample/form.rb

However had it crashed for me:

001_form.rb:46:in `driver': Unknown command (Curses::UnknownCommandError)
from 001_form.rb:46:in <main>

(I renamed it locally to 001_form.rb - makes it easier for me to test the examples when I number them.)

The line was:

else
   form.driver(ch)

I added some debug statement. I could cause this error by hitting the "Ende" (End) key.

The key value for this was:

360

Is this the regular behaviour of curses to crash like that?

To me it is a bit strange that form.driver(ch) would not work.

I did not test it with other keys but I assume that some other keys also cause this issue.

Edit: Actually I tested it with page down too. That also led to the same problem, hopefully it can be reproduced by someone else.

shugo commented 1 year ago

It's the expected behavior of Form#driver because the underlying form_driver() causes an error when the given code is unknown. I've fixed sample/form.rb to ignore Curses::UnknownCommandError.