]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
expose more keys to python as shortcuts in dialogs
authorJakob Kemi <jakob.kemi@gmail.com>
Tue, 11 May 2010 13:27:01 +0000 (15:27 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 11 May 2010 13:27:01 +0000 (15:27 +0200)
snack.py
snackmodule.c

index 7fa1d8bebc37355b00884f322bb91634b6f5fbe5..7b27e635c61f34326a8009047316c43f7bdeb907 100644 (file)
--- 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
index 67f9e878f49a47a52c24f00ea77d056a5f872cb3..d5dcff98ed4aee0c97c1a5624117e06ea90f37bf 100644 (file)
@@ -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));