<<< Date Index >>>     <<< Thread Index >>>

Re: [Mutt] #3350: inconsistent handling of key bindings/codes



On Sun, Apr 04, 2010 at 07:55:11AM -0700, Michael Elkins wrote:
> Thanks for the information.
> 
> I'm almost able to get this working.  Using use_extended_names(TRUE) now
> returns a single keycode for ctrl+<UP> (kUP5).  However, both tigetstr()
> and key_defined() don't report that kUP5 is available (see attached
> program).

I didn't explain it very well - but am attaching a working version of your
program.

-- 
Thomas E. Dickey <dickey@xxxxxxxxxxxxxxxxxxxx>
http://invisible-island.net
ftp://invisible-island.net
#include <stdlib.h>
#include <ncursesw/ncurses.h>

static struct key {
        char *name;
        int code;
} Keys[] = {
        { "kUP5", 0 },
        { "kDN5", 0 },
        { 0, 0 }
};

int main(void)
{
        int i;
        use_extended_names(TRUE);
        initscr();
        cbreak();
        noecho();
        nonl();
        keypad(stdscr,TRUE);

        for (i = 0; Keys[i].name != 0; ++i) {
                int code;
                char *s = tigetstr(Keys[i].name);
                if (s && (long)(s) != -1) {
                        printw("tigetstr for %s=%s\n", Keys[i].name, s);
                        code = key_defined(s);
                        if (code > 0) {
                                Keys[i].code = code;
                        }
                }
        }
        addstr("press a key");
        int ch = getch();
        endwin();
        printf("keypress=%d\n", ch);
        for (i=0;Keys[i].name;++i) {
                printf("key=%s, code=%d\n", Keys[i].name, Keys[i].code);
        }
        exit(0);
}

Attachment: signature.asc
Description: Digital signature