]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
support screen resize as hotkey in form (#1432926)
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 16 Mar 2017 12:31:59 +0000 (13:31 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 16 Mar 2017 12:36:07 +0000 (13:36 +0100)
form.c
snack.c
snack.py

diff --git a/form.c b/form.c
index cc52c2fdfcfb58fd7de919bc153cd97c82960c1c..24c601d41f3772f8c02e4ef04facf0f1431baac7 100644 (file)
--- a/form.c
+++ b/form.c
@@ -1031,6 +1031,18 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es) {
        if (needResize) {
                needResize = 0;
                newtResizeScreen(1);
+
+               /* The application may want to handle the resize */
+               for (i = 0; i < form->numHotKeys; i++) {
+                   if (form->hotKeys[i] == NEWT_KEY_RESIZE) {
+                       es->reason = NEWT_EXIT_HOTKEY;
+                       es->u.key = NEWT_KEY_RESIZE;
+                       done = 1;
+                       break;
+                   }
+               }
+               if (done)
+                   break;
        }
 
        i = select(max + 1, &readSet, &writeSet, &exceptSet, 
diff --git a/snack.c b/snack.c
index 172c7d059ba53f733184c9f9eb46aa852642f322..880a4317b01f9d8c36ecf84c4992145a221f6135 100644 (file)
--- a/snack.c
+++ b/snack.c
@@ -1499,6 +1499,7 @@ MOD_INIT(_snack)
     setitemstring_decref(d, "KEY_F11", PyInt_FromLong(NEWT_KEY_F11));
     setitemstring_decref(d, "KEY_F12", PyInt_FromLong(NEWT_KEY_F12));
     setitemstring_decref(d, "KEY_ESC", PyInt_FromLong(NEWT_KEY_ESCAPE));
+    setitemstring_decref(d, "KEY_RESIZE", PyInt_FromLong(NEWT_KEY_RESIZE));
 
     setitemstring_decref(d, "FLAG_DISABLED", PyInt_FromLong(NEWT_FLAG_DISABLED));
     setitemstring_decref(d, "FLAGS_SET", PyInt_FromLong(NEWT_FLAGS_SET));
index 3708a4e2e5ec351f30331463e685b937b3957e00..a9d2b4403dd62fcaa5976e8592184c7d1b44e068 100644 (file)
--- a/snack.py
+++ b/snack.py
@@ -303,7 +303,7 @@ hotkeys = { "F1" : _snack.KEY_F1, "F2" : _snack.KEY_F2, "F3" : _snack.KEY_F3,
             "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,
+            "INSERT": _snack.KEY_INSERT, "RESIZE": _snack.KEY_RESIZE,
              " " : ord(" ") }
 
 for n in list(hotkeys.keys()):