Project

General

Profile

Actions

Feature #1917

closed

Curses::Window#keypad(true) fails for Curses::Key::ENTER ?

Added by robert (Robert Gleeson) over 15 years ago. Updated over 12 years ago.

Status:
Third Party's Issue
Target version:
-
[ruby-core:24847]

Description

=begin
I am not too sure if this is a bug, my apologizes if it is not.
After creating an instance of Curses::Window, setting keypad to true, it is possible to catch Curses::Key::UP/DOWN/LEFT/RIGHT, but when I try to catch Curses::Key::ENTER, it fails.
On the pressing of enter, "10" char code is returned or "\n", but Curses::Key::ENTER is equal to "343".
Here is an example case:

require 'curses'

Curses::init_screen
w = Curses::Window.new 20,60,0,0
w.box ?|, ?-
w.keypad true
chr = w.getch
w.setpos 2,4
w.addstr %q{Caught enter} if chr == Curses::Key::ENTER
w.addstr %q{Caught "\n"} if chr.chr == "\n"
w.refresh
w.getch
Curses::close_screen

Again, apologizes if this is not a bug, I do not want to waste anyone's time, but it felt odd to me, that other keys, such as Curses::Key::UP/DOWN/LEFT/RIGHT could be caught but not ENTER.
=end

Actions #1

Updated by shyouhei (Shyouhei Urabe) over 12 years ago

  • Project changed from Backport187 to Ruby master
  • Status changed from Open to Assigned
  • Assignee set to shugo (Shugo Maeda)

Updated by shyouhei (Shyouhei Urabe) over 12 years ago

  • Tracker changed from Bug to Feature
  • Description updated (diff)
  • Category set to ext

Sorry for this quite late response... I happened to realize that this is not 1.8.7 specific.
Moved to trunk, assigned to shugo.

Updated by shugo (Shugo Maeda) over 12 years ago

  • Status changed from Assigned to Third Party's Issue

robert (Robert Gleeson) wrote:

After creating an instance of Curses::Window, setting keypad to true, it is possible to catch Curses::Key::UP/DOWN/LEFT/RIGHT, but when I try to catch Curses::Key::ENTER, it fails.
On the pressing of enter, "10" char code is returned or "\n", but Curses::Key::ENTER is equal to "343".
Here is an example case:

The man page for getch(3NCURSES) says:

   Generally, KEY_ENTER denotes the character(s) sent by the Enter key  on
   the numeric keypad:

   ·   the terminal description lists the most useful keys,

   ·   the  Enter  key  on  the regular keyboard is already handled by the
       standard ASCII characters for carriage-return and line-feed,

   ·   depending on whether nl or nonl was called, pressing "Enter" on the
       regular  keyboard may return either a carriage-return or line-feed,
       and finally

   ·   "Enter or send" is the standard description for this key.

So I don't think it's a bug of Ruby's curses binding.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0