From d861e991f015633599a345e839a2454b3bfb1efe Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mar 16 2017 12:36:07 +0000 Subject: support screen resize as hotkey in form (#1432926) --- diff --git a/form.c b/form.c index cc52c2f..24c601d 100644 --- 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 172c7d0..880a431 100644 --- 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)); diff --git a/snack.py b/snack.py index 3708a4e..a9d2b44 100644 --- 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()):