From: ewt Date: Sat, 3 Jan 1998 23:00:28 +0000 (+0000) Subject: 1) patch from Bruce Perens which makes newt easier to build on debian X-Git-Tag: r0-21~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=139f06bc9e943c63e5d3c7e9a4ad87aefc38b532;p=thirdparty%2Fnewt.git 1) patch from Bruce Perens which makes newt easier to build on debian 2) whiptail patch from Bruce which adds --infobox --- diff --git a/Makefile b/Makefile index 3b94bc4..8ce0ab2 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ LIBS = -lslang -lm #-lefence SHLIBS = -lslang -lm -lc -CFLAGS = $(RPM_OPT_FLAGS) -Wall +CFLAGS = $(RPM_OPT_FLAGS) -Wall -I/usr/include/slang ifeq ($(RPM_OPT_FLAGS),) -CFLAGS += -g -O2 +CFLAGS += -g # -O2 -I/usr/include/slang endif VERSION = 0.21 diff --git a/button.c b/button.c index cb60d41..35081bc 100644 --- a/button.c +++ b/button.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/checkbox.c b/checkbox.c index ba3e190..1c798af 100644 --- a/checkbox.c +++ b/checkbox.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/dialogboxes.c b/dialogboxes.c index 1fadb71..fd9d269 100644 --- a/dialogboxes.c +++ b/dialogboxes.c @@ -372,10 +372,14 @@ int messageBox(char * text, int height, int width, int type, int flags) { newtFormAddComponent(form, tb); - if (type == MSGBOX_MSG) { + switch ( type ) { + case MSGBOX_INFO: + break; + case MSGBOX_MSG: yes = makeButton((width - 8) / 2, height - 1 - buttonHeight, "Ok"); newtFormAddComponent(form, yes); - } else { + break; + default: yes = makeButton((width - 16) / 3, height - 1 - buttonHeight, "Yes"); no = makeButton(((width - 16) / 3) * 2 + 9, height - 1 - buttonHeight, "No"); @@ -385,11 +389,20 @@ int messageBox(char * text, int height, int width, int type, int flags) { newtFormSetCurrent(form, no); } - newtRunForm(form); - answer = newtFormGetCurrent(form); + if ( type != MSGBOX_INFO ) { + newtRunForm(form); + + answer = newtFormGetCurrent(form); + + if (answer == no) + return DLG_CANCEL; + } + else { + newtDrawForm(form); + newtRefresh(); + } + - if (answer == no) - return DLG_CANCEL; return DLG_OKAY; } diff --git a/dialogboxes.h b/dialogboxes.h index 0cf17c2..b9ae127 100644 --- a/dialogboxes.h +++ b/dialogboxes.h @@ -5,6 +5,7 @@ #define MSGBOX_MSG 0 #define MSGBOX_YESNO 1 +#define MSGBOX_INFO 2 #define FLAG_NOITEM (1 << 0) #define FLAG_NOCANCEL (1 << 1) diff --git a/entry.c b/entry.c index 43e598e..12f22e3 100644 --- a/entry.c +++ b/entry.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/form.c b/form.c index de7d5e1..7bf8f48 100644 --- a/form.c +++ b/form.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/label.c b/label.c index c945d5a..5c253cd 100644 --- a/label.c +++ b/label.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/listbox.c b/listbox.c index 3fb300d..249db8d 100644 --- a/listbox.c +++ b/listbox.c @@ -3,7 +3,7 @@ and contributed to newt for use under the LGPL license. Copyright (C) 1996, 1997 Elliot Lee */ -#include +#include #include #include #include diff --git a/newt.c b/newt.c index 48c957c..817af3b 100644 --- a/newt.c +++ b/newt.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/scale.c b/scale.c index fc53370..e9327db 100644 --- a/scale.c +++ b/scale.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/scrollbar.c b/scrollbar.c index 57e7e63..ff2337c 100644 --- a/scrollbar.c +++ b/scrollbar.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/showchars.c b/showchars.c index 0fc117f..71d0adb 100644 --- a/showchars.c +++ b/showchars.c @@ -1,4 +1,4 @@ -#include +#include void printall(int offset) { int n = 0; diff --git a/showkey.c b/showkey.c index 51d9193..0db804b 100644 --- a/showkey.c +++ b/showkey.c @@ -1,5 +1,5 @@ #include -#include +#include int main(void) { char n = 0; diff --git a/textbox.c b/textbox.c index 4a4757d..640defc 100644 --- a/textbox.c +++ b/textbox.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/whiptail.c b/whiptail.c index 95680ec..fb93a92 100644 --- a/whiptail.c +++ b/whiptail.c @@ -10,8 +10,8 @@ #include "dialogboxes.h" #include "newt.h" -enum mode { MODE_NONE, MODE_MSGBOX, MODE_YESNO, MODE_CHECKLIST, MODE_INPUTBOX, - MODE_RADIOLIST, MODE_MENU, MODE_GAUGE }; +enum mode { MODE_NONE, MODE_INFOBOX, MODE_MSGBOX, MODE_YESNO, MODE_CHECKLIST, + MODE_INPUTBOX, MODE_RADIOLIST, MODE_MENU, MODE_GAUGE }; #define OPT_MSGBOX 1000 #define OPT_CHECKLIST 1001 @@ -21,6 +21,7 @@ enum mode { MODE_NONE, MODE_MSGBOX, MODE_YESNO, MODE_CHECKLIST, MODE_INPUTBOX, #define OPT_MENU 1005 #define OPT_RADIOLIST 1006 #define OPT_GAUGE 1007 +#define OPT_INFOBOX 1008 static void usage(void) { fprintf(stderr, "whiptail: bad parametrs (see man dialog(1) for details)\n"); @@ -60,6 +61,7 @@ int main(int argc, char ** argv) { { "fb", '\0', 0, 0, OPT_FULLBUTTONS }, { "fullbuttons", '\0', 0, 0, OPT_FULLBUTTONS }, { "gauge", '\0', 0, 0, OPT_GAUGE }, + { "infobox", '\0', 0, 0, OPT_INFOBOX }, { "menu", '\0', 0, 0, OPT_MENU }, { "msgbox", '\0', 0, 0, OPT_MSGBOX }, { "nocancel", '\0', 0, &noCancel, 0 }, @@ -78,6 +80,11 @@ int main(int argc, char ** argv) { optArg = poptGetOptArg(optCon); switch (arg) { + case OPT_INFOBOX: + if (mode != MODE_NONE) usage(); + mode = MODE_INFOBOX; + break; + case OPT_MENU: if (mode != MODE_NONE) usage(); mode = MODE_MENU; @@ -163,6 +170,10 @@ int main(int argc, char ** argv) { rc = messageBox(text, height, width, MSGBOX_MSG, flags); break; + case MODE_INFOBOX: + rc = messageBox(text, height, width, MSGBOX_INFO, flags); + break; + case MODE_YESNO: rc = messageBox(text, height, width, MSGBOX_YESNO, flags); break;