curses KEY_* constants

Discussion in 'Python' started by Bill Green, Aug 24, 2010.

  1. Bill Green

    Bill Green Guest


    According to the documentation for the curses module, there are a number of
    constants defined for various special keys (such as KEY_DOWN, KEY_UP,
    KEY_BACKSPACE, etc.). However, these do not exist on my system (NetBSD 5).

    Looking at _cursesmodule.c, the code that sets up the KEY_ variables is #defined
    out on NetBSD (in initcurses() at line 2860 for Python 2.7). Does anyone know
    why this is so?

    Bill Green, Aug 24, 2010
    1. Advertisements

  2. Bill Green

    Bill Green Guest

    I perhaps should have mentioned I linked the Python curses module against
    ncurses rather than BSD curses. Perhaps NetBSD's curses doesn't support this
    feature, and that's why it's not included there.

    In any case, I removed the relevant #defines in _cursesmodule.c and got a
    Python that includes all the KEY_ constants in the curses module, but these
    constants (for the arrow keys at least) seem not to match the actual
    Bill Green, Aug 24, 2010
    1. Advertisements

  3. Bill Green

    Bill Green Guest

    After looking at the documentation again I've realized I needed to enable keypad
    mode on the window for curses to catch the escape codes, and now everything's

    It seems to me that _cursesmodule.c should check at compile time to
    see if the platform is NetBSD AND ncurses isn't being used.

    Bill Green, Aug 24, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.