On Thu, Apr 17, 2008 at 06:20:02PM -0700, Gary Johnson wrote:
> On 2008-04-17, Paul LeoNerd Evans <[EMAIL PROTECTED]> wrote:
> > Besides which, it was my understanding that terminfo/termcap really
> > don't have very much to say about keyboard input at all. If you're
> > lucky, they say "Oh, by the way, the <Down> key might send this
> > sequence" and you're on your own to match it.
> 
> That is incorrect.  The terminfo database contains the definitions 
> of a lot of keys.  See "man terminfo" and look at the output of 
> "infocmp xterm.  The getch() function in libraries such as ncurses 
> interpret the character sequences corresponding to those keys and 
> return values such as KEY_DOWN, KEY_UP, etc.  See "man ncurses" and 
> "man curs_getch".

OK.. so we have

  int getch(void);

Please explain the part about that which tells me about the
Shift/Ctrl/Alt modifiers that were held along with the key?

Furthermore, explain where in termcap/terminfo I can find any hint of
knowledge about modifiers?

I would be happier instead with

  int getch_modified(int *modifiers);

Or better yet, the function from my own library:

  termkey_result termkey_getkey(termkey_t *tk, termkey_key *key);

Where

  typedef struct {
    int modifiers;
    termkey_keysym code; // Or Unicode codepoint
    int flags;  // includes TERMKEY_FLAG_SPECIAL to indicate Unicode or special 
function key

    /* Any Unicode character can be UTF-8 encoded in no more than 6 bytes, plus
     * terminating NUL */
    char utf8[7];
  } termkey_key;

Repeatedly calling termkey_getkey() is analogous to repeatedly calling
curses' getch(), except that libtermkey cares about keys, not
characters. It reports all the modifier state of both special keys (e.g.
Ctrl-Shift-Left) and of normal Unicode codepoints (e.g. Ctrl-G).

-- 
Paul "LeoNerd" Evans

[EMAIL PROTECTED]
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/

Attachment: signature.asc
Description: Digital signature

Raspunde prin e-mail lui