From: ewt Date: Fri, 13 Dec 1996 17:07:45 +0000 (+0000) Subject: added suspend callback X-Git-Tag: v0-9~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b7c1b763899c24c94c828713c46fc11ecd0b188e;p=thirdparty%2Fnewt.git added suspend callback --- diff --git a/newt.c b/newt.c index 2c79a33..c777ace 100644 --- a/newt.c +++ b/newt.c @@ -107,6 +107,12 @@ static char * version = "Newt windowing library version " VERSION "GNU Public Library. " "Written by Erik Troan\n"; +static newtSuspendCallback suspendCallback = NULL; + +void newtSetSuspendCallback(newtSuspendCallback cb) { + suspendCallback = cb; +} + void newtRefresh(void) { SLsmg_refresh(); } @@ -212,7 +218,11 @@ int newtGetKey(void) { char buf[10], * chptr = buf; struct keymap * curr; - key = SLang_getkey(); + do { + key = SLang_getkey(); + if (key == NEWT_KEY_SUSPEND && suspendCallback) + suspendCallback(); + } while (key == NEWT_KEY_SUSPEND); switch (key) { case 0x7f: diff --git a/newt.h b/newt.h index 2f16c38..b4e887e 100644 --- a/newt.h +++ b/newt.h @@ -48,10 +48,10 @@ struct newtColors { typedef struct newtComponent * newtComponent; - extern struct newtColors newtDefaultColorPalette; typedef void (*newtCallback)(newtComponent, void *); +typedef void (*newtSuspendCallback)(void); int newtInit(void); int newtFinished(void); @@ -66,6 +66,7 @@ void newtPopWindow(void); void newtSetColors(struct newtColors colors); void newtRefresh(void); void newtSuspend(void); +void newtSetSuspendCallback(newtSuspendCallback cb); void newtResume(void); void newtPushHelpLine(char * text); void newtRedrawHelpLine(void); @@ -151,6 +152,7 @@ void newtFormDestroy(newtComponent form); #define NEWT_KEY_TAB '\t' #define NEWT_KEY_ENTER '\r' +#define NEWT_KEY_SUSPEND '\032' /* ctrl - z*/ #define NEWT_KEY_RETURN NEWT_KEY_ENTER #define NEWT_KEY_EXTRA_BASE 0x8000 diff --git a/test.c b/test.c index 236c655..da028d0 100644 --- a/test.c +++ b/test.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "newt.h" @@ -21,6 +22,12 @@ void disableCallback(newtComponent co, void * data) { newtRefresh(); } +void suspend(void) { + newtSuspend(); + raise(SIGTSTP); + newtResume(); +} + void main(void) { newtComponent b1, b2, r1, r2, r3, e2, e3, l1, l2, l3, scale; newtComponent lb, t, rsf, answer; @@ -35,6 +42,8 @@ void main(void) { newtInit(); newtCls(); + newtSetSuspendCallback(suspend); + newtDrawRootText(0, 0, "Newt test program"); newtPushHelpLine(NULL);