The Accidental Rubyist

invalid byte sequence in UTF-8

More on key-trapping in ncurses

leave a comment »

The getch() method of ncurses window catches function keys and control keys, but not alt/meta keys which require checking 2 consecutive keys (ESC and char). Manver’s VER (keyboard.rb) does this, but I don’t think it traps Meta+Ctrl and Meta+shift+Ctrl keys.

Also, I faced some problems (with keyboard.rb), when i needed to pass control from one form to another, and have it come back. The previous assignment was obviously overwritten. I’ve modified it and made a method getchar in window.rb. So getchar is a stand-in replacement for getch (if you used lib/ver/window to create your window). It will wait upon an ESC and return meta and meta/ctrl, meta/shift/control combinations in addition to the basic Function keys.

Advertisements

Written by totalrecall

December 16, 2008 at 12:04 pm

Posted in ncurses, rbcurse, ruby

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: