From: Jakob Kemi Date: Tue, 11 May 2010 13:27:01 +0000 (+0200) Subject: expose more keys to python as shortcuts in dialogs X-Git-Tag: r0-52-12~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2a61dd02bfe7f131a96d71cb6e668c896f65bb46;p=thirdparty%2Fnewt.git expose more keys to python as shortcuts in dialogs --- diff --git a/snack.py b/snack.py index 7fa1d8b..7b27e63 100644 --- a/snack.py +++ b/snack.py @@ -294,10 +294,17 @@ hotkeys = { "F1" : _snack.KEY_F1, "F2" : _snack.KEY_F2, "F3" : _snack.KEY_F3, "F4" : _snack.KEY_F4, "F5" : _snack.KEY_F5, "F6" : _snack.KEY_F6, "F7" : _snack.KEY_F7, "F8" : _snack.KEY_F8, "F9" : _snack.KEY_F9, "F10" : _snack.KEY_F10, "F11" : _snack.KEY_F11, - "F12" : _snack.KEY_F12, "ESC" : _snack.KEY_ESC , " " : ord(" ") } + "F12" : _snack.KEY_F12, "ESC" : _snack.KEY_ESC, + "ENTER": _snack.KEY_ENTER, "SUSPEND" : _snack.KEY_SUSPEND, + "BACKSPACE": _snack.KEY_BACKSPACE, "DELETE": _snack.KEY_DELETE, + "INSERT": _snack.KEY_INSERT, + " " : ord(" ") } for n in hotkeys.keys(): hotkeys[hotkeys[n]] = n +for o,c in [ (ord(c),c) for c in string.ascii_letters+string.digits ]: + hotkeys[c] = o + hotkeys[o] = c class Form: """ Base Form class, from which Grid, etc. inherit diff --git a/snackmodule.c b/snackmodule.c index 67f9e87..d5dcff9 100644 --- a/snackmodule.c +++ b/snackmodule.c @@ -1333,6 +1333,21 @@ void init_snack(void) { PyDict_SetItemString(d, "FORM_EXIT_TIMER", PyString_FromString("timer")); PyDict_SetItemString(d, "FORM_EXIT_FDREADY", PyString_FromString("fdready")); + PyDict_SetItemString(d, "KEY_TAB", PyInt_FromLong(NEWT_KEY_TAB)); + PyDict_SetItemString(d, "KEY_ENTER", PyInt_FromLong(NEWT_KEY_ENTER)); + PyDict_SetItemString(d, "KEY_SUSPEND", PyInt_FromLong(NEWT_KEY_SUSPEND)); + PyDict_SetItemString(d, "KEY_UP", PyInt_FromLong(NEWT_KEY_UP)); + PyDict_SetItemString(d, "KEY_DOWN", PyInt_FromLong(NEWT_KEY_DOWN)); + PyDict_SetItemString(d, "KEY_LEFT", PyInt_FromLong(NEWT_KEY_LEFT)); + PyDict_SetItemString(d, "KEY_RIGHT", PyInt_FromLong(NEWT_KEY_RIGHT)); + PyDict_SetItemString(d, "KEY_BACKSPACE", PyInt_FromLong(NEWT_KEY_BKSPC)); + PyDict_SetItemString(d, "KEY_DELETE", PyInt_FromLong(NEWT_KEY_DELETE)); + PyDict_SetItemString(d, "KEY_HOME", PyInt_FromLong(NEWT_KEY_HOME)); + PyDict_SetItemString(d, "KEY_END", PyInt_FromLong(NEWT_KEY_END)); + PyDict_SetItemString(d, "KEY_UNTAB", PyInt_FromLong(NEWT_KEY_UNTAB)); + PyDict_SetItemString(d, "KEY_PAGEUP", PyInt_FromLong(NEWT_KEY_PGUP)); + PyDict_SetItemString(d, "KEY_PAGEGDOWN", PyInt_FromLong(NEWT_KEY_PGDN)); + PyDict_SetItemString(d, "KEY_INSERT", PyInt_FromLong(NEWT_KEY_INSERT)); PyDict_SetItemString(d, "KEY_F1", PyInt_FromLong(NEWT_KEY_F1)); PyDict_SetItemString(d, "KEY_F2", PyInt_FromLong(NEWT_KEY_F2)); PyDict_SetItemString(d, "KEY_F3", PyInt_FromLong(NEWT_KEY_F3));