You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
whiptail/newt-0.51.5.patch.2004082000

375 lines
13 KiB
Plaintext

diff -Nur -x '*.orig' -x '*.rej' newt-0.51.5/dialogboxes.c mezzanine_patched_newt-0.51.5/dialogboxes.c
--- newt-0.51.5/dialogboxes.c 2003-01-03 15:54:45.000000000 -0500
+++ mezzanine_patched_newt-0.51.5/dialogboxes.c 2004-08-20 20:13:20.000000000 -0400
@@ -18,15 +18,18 @@
static void addButtons(int height, int width, newtComponent form,
newtComponent * okay, newtComponent * cancel,
+ char * left,
+ char * right,
int flags) {
if (flags & FLAG_NOCANCEL) {
- *okay = makeButton((width - 8) / 2, height - buttonHeight - 1, "Ok");
+ *okay = makeButton(((width - 18) / 3) * 2 + 9,
+ height - buttonHeight - 1, right);
*cancel = NULL;
newtFormAddComponent(form, *okay);
} else {
- *okay = makeButton((width - 18) / 3, height - buttonHeight - 1, "Ok");
- *cancel = makeButton(((width - 18) / 3) * 2 + 9,
- height - buttonHeight - 1, "Cancel");
+ *cancel = makeButton((width - 18) / 3, height - buttonHeight - 1, left);
+ *okay = makeButton(((width - 18) / 3) * 2 + 9,
+ height - buttonHeight - 1, right);
newtFormAddComponents(form, *okay, *cancel, NULL);
}
}
@@ -129,10 +132,11 @@
}
int inputBox(const char * text, int height, int width, poptContext optCon,
- int flags, const char ** result) {
+ char * left, char * right, int flags, const char ** result) {
newtComponent form, entry, okay, cancel, answer, tb;
const char * val;
int rc = DLG_OKAY;
+ int eFlag = (flags & (NEWT_FLAG_HIDDEN|NEWT_FLAG_PASSWORD));
int top;
val = poptGetArg(optCon);
@@ -141,11 +145,11 @@
form = newtForm(NULL, NULL, 0);
entry = newtEntry(1, top + 1, val, width - 2, &val,
- NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
+ NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT | eFlag);
newtFormAddComponents(form, tb, entry, NULL);
- addButtons(height, width, form, &okay, &cancel, flags);
+ addButtons(height, width, form, &okay, &cancel, left, right, flags);
answer = newtRunForm(form);
if (answer == cancel)
@@ -157,7 +161,7 @@
}
int listBox(const char * text, int height, int width, poptContext optCon,
- int flags, const char ** result) {
+ char * left, char * right, int flags, const char ** result) {
newtComponent form, okay, tb, answer, listBox;
newtComponent cancel = NULL;
const char * arg;
@@ -228,7 +232,7 @@
newtFormAddComponents(form, tb, listBox, NULL);
- addButtons(height, width, form, &okay, &cancel, flags);
+ addButtons(height, width, form, &okay, &cancel, left, right, flags);
answer = newtRunForm(form);
if (answer == cancel)
@@ -241,7 +245,8 @@
}
int checkList(const char * text, int height, int width, poptContext optCon,
- int useRadio, int flags, const char *** selections) {
+ int useRadio, char * left, char * right, int flags,
+ const char *** selections) {
newtComponent form, okay, tb, subform, answer;
newtComponent sb = NULL, cancel = NULL;
const char * arg;
@@ -329,7 +334,7 @@
newtFormAddComponents(form, tb, subform, NULL);
- addButtons(height, width, form, &okay, &cancel, flags);
+ addButtons(height, width, form, &okay, &cancel, left, right, flags);
answer = newtRunForm(form);
if (answer == cancel)
@@ -364,7 +369,8 @@
return rc;
}
-int messageBox(const char * text, int height, int width, int type, int flags) {
+int messageBox(const char * text, int height, int width, char *left,
+ char *right, int type, int flags) {
newtComponent form, yes, tb, answer;
newtComponent no = NULL;
int tFlag = (flags & FLAG_SCROLL_TEXT) ? NEWT_FLAG_SCROLL : 0;
@@ -376,7 +382,17 @@
newtTextboxSetText(tb, text);
newtFormAddComponent(form, tb);
-
+
+ /* If left=Cancel and right=Ok, we probably didn't get any --left and
+ * --right arguments passed. Assume we want Yes and No instead. This has
+ * the side effect of not being able to pass in "Cancel" and "Ok" but
+ * I can live with that.
+ */
+ if (!strcmp(left,"Cancel") && !strcmp(right,"Ok")) {
+ left = "Yes";
+ right = "No";
+ }
+
switch ( type ) {
case MSGBOX_INFO:
break;
@@ -385,9 +401,9 @@
newtFormAddComponent(form, yes);
break;
default:
- yes = makeButton((width - 16) / 3, height - 1 - buttonHeight, "Yes");
- no = makeButton(((width - 16) / 3) * 2 + 9, height - 1 - buttonHeight,
- "No");
+ yes = makeButton((width - 18) / 3, height - 1 - buttonHeight, left);
+ no = makeButton(((width - 18) / 3) * 2 + 9, height - 1 - buttonHeight,
+ right);
newtFormAddComponents(form, yes, no, NULL);
if (flags & FLAG_DEFAULT_NO)
diff -Nur -x '*.orig' -x '*.rej' newt-0.51.5/dialogboxes.h mezzanine_patched_newt-0.51.5/dialogboxes.h
--- newt-0.51.5/dialogboxes.h 2003-01-03 15:54:45.000000000 -0500
+++ mezzanine_patched_newt-0.51.5/dialogboxes.h 2004-08-20 20:13:12.000000000 -0400
@@ -16,13 +16,15 @@
#define DLG_OKAY 0
#define DLG_CANCEL 1
-int messageBox(const char * text, int height, int width, int type, int flags);
+int messageBox(const char * text, int height, int width, char *left,
+ char *right, int type, int flags);
int checkList(const char * text, int height, int width, poptContext optCon,
- int useRadio, int flags, const char *** selections);
+ int useRadio, char * left, char * right,
+ int flags, const char *** selections);
int listBox(const char * text, int height, int width, poptContext optCon,
- int flags, const char ** result);
+ char * left, char * right, int flags, const char ** result);
int inputBox(const char * text, int height, int width, poptContext optCon,
- int flags, const char ** result);
+ char * left, char * right, int flags, const char ** result);
int gauge(const char * text, int height, int width, poptContext optCon, int fd,
int flags);
void useFullButtons(int state);
diff -Nur -x '*.orig' -x '*.rej' newt-0.51.5/test.c mezzanine_patched_newt-0.51.5/test.c
--- newt-0.51.5/test.c 2003-01-04 14:15:25.000000000 -0500
+++ mezzanine_patched_newt-0.51.5/test.c 2004-08-20 20:11:39.000000000 -0400
@@ -33,13 +33,13 @@
}
int main(void) {
- newtComponent b1, b2, r1, r2, r3, e2, e3, l1, l2, l3, scale;
+ newtComponent b1, b2, r1, r2, r3, e2, e3, e4, l1, l2, l3, l4, scale;
newtComponent lb, t, rsf, answer, timeLabel;
newtComponent cs[10];
newtComponent f, chklist, e1;
struct callbackInfo cbis[3];
char results[10];
- const char * enr2, * enr3, *scaleVal;
+ const char * enr2, * enr3, * scaleVal, * enr4;
void ** selectedList;
int i, numsel;
char buf[20];
@@ -81,10 +81,11 @@
l1 = newtLabel(3, 6, "Scale:");
l2 = newtLabel(3, 7, "Scrolls:");
l3 = newtLabel(3, 8, "Hidden:");
+ l4 = newtLabel(3, 9, "Password:");
e1 = newtEntry(12, 6, "", 20, &scaleVal, 0);
e2 = newtEntry(12, 7, "Default", 20, &enr2, NEWT_FLAG_SCROLL);
-/* e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_FLAG_HIDDEN); */
- e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_FLAG_PASSWORD);
+ e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_FLAG_HIDDEN);
+ e4 = newtEntry(12, 9, NULL, 20, &enr4, NEWT_FLAG_PASSWORD);
cbis[0].state = &results[0];
cbis[0].en = e1;
@@ -94,7 +95,7 @@
newtFormSetHeight(chklist, 3);
- newtFormAddComponents(f, b1, b2, l1, l2, l3, e1, e2, e3, chklist, NULL);
+ newtFormAddComponents(f, b1, b2, l1, l2, l3, l4, e1, e2, e3, e4, chklist, NULL);
newtFormAddComponents(f, rsf, scale, NULL);
lb = newtListbox(45, 1, 6, NEWT_FLAG_MULTIPLE | NEWT_FLAG_BORDER |
@@ -141,6 +142,7 @@
scaleVal = strdup(scaleVal);
enr2 = strdup(enr2);
enr3 = strdup(enr3);
+ enr4 = strdup(enr4);
selectedList = newtListboxGetSelection(lb, &numsel);
@@ -153,6 +155,7 @@
printf("got string 1: %s\n", scaleVal);
printf("got string 2: %s\n", enr2);
printf("got string 3: %s\n", enr3);
+ printf("got string 4: %s\n", enr4);
printf("\nSelected listbox items (%d):\n", numsel);
if(selectedList) {
diff -Nur -x '*.orig' -x '*.rej' newt-0.51.5/whiptail.c mezzanine_patched_newt-0.51.5/whiptail.c
--- newt-0.51.5/whiptail.c 2003-01-03 15:54:45.000000000 -0500
+++ mezzanine_patched_newt-0.51.5/whiptail.c 2004-08-20 20:13:12.000000000 -0400
@@ -47,16 +47,22 @@
int rc = 1;
int flags = 0;
int defaultNo = 0;
+ int hidden = 0;
+ int password = 0;
int separateOutput = 0;
const char * result;
const char ** selections, ** next;
char * title = NULL;
char * backtitle = NULL;
+ char * left = "Cancel";
+ char * right = "Ok";
struct poptOption optionsTable[] = {
{ "backtitle", '\0', POPT_ARG_STRING, &backtitle, 0 },
{ "checklist", '\0', 0, 0, OPT_CHECKLIST },
{ "clear", '\0', 0, &clear, 0 },
{ "defaultno", '\0', 0, &defaultNo, 0 },
+ { "hidden", '\0', 0, &hidden, 0 },
+ { "password", '\0', 0, &password, 0 },
{ "inputbox", '\0', 0, 0, OPT_INPUTBOX },
{ "fb", '\0', 0, 0, OPT_FULLBUTTONS },
{ "fullbuttons", '\0', 0, 0, OPT_FULLBUTTONS },
@@ -70,6 +76,8 @@
{ "scrolltext", '\0', 0, &scrollText, 0 },
{ "separate-output", '\0', 0, &separateOutput, 0 },
{ "title", '\0', POPT_ARG_STRING, &title, 0 },
+ { "left", '\0', POPT_ARG_STRING, &left, 0 },
+ { "right", '\0', POPT_ARG_STRING, &right, 0 },
{ "yesno", '\0', 0, 0, OPT_YESNO },
{ 0, 0, 0, 0, 0 }
};
@@ -164,32 +172,35 @@
if (noItem) flags |= FLAG_NOITEM;
if (scrollText) flags |= FLAG_SCROLL_TEXT;
if (defaultNo) flags |= FLAG_DEFAULT_NO;
+ if (hidden) flags |= NEWT_FLAG_HIDDEN;
+ if (password) flags |= NEWT_FLAG_PASSWORD;
switch (mode) {
- case MODE_MSGBOX:
- rc = messageBox(text, height, width, MSGBOX_MSG, flags);
+ case MODE_MSGBOX:
+ rc = messageBox(text, height, width, left, right, MSGBOX_MSG, flags);
break;
case MODE_INFOBOX:
- rc = messageBox(text, height, width, MSGBOX_INFO, flags);
+ rc = messageBox(text, height, width, left, right, MSGBOX_INFO, flags);
break;
case MODE_YESNO:
- rc = messageBox(text, height, width, MSGBOX_YESNO, flags);
+ rc = messageBox(text, height, width, left, right, MSGBOX_YESNO, flags);
break;
case MODE_INPUTBOX:
- rc = inputBox(text, height, width, optCon, flags, &result);
+ rc = inputBox(text, height, width, optCon, left, right, flags, &result);
if (!rc) fprintf(stderr, "%s", result);
break;
case MODE_MENU:
- rc = listBox(text, height, width, optCon, flags, &result);
+ rc = listBox(text, height, width, optCon, left, right, flags, &result);
if (!rc) fprintf(stderr, "%s", result);
break;
case MODE_RADIOLIST:
- rc = checkList(text, height, width, optCon, 1, flags, &selections);
+ rc = checkList(text, height, width, optCon, 1, left, right,
+ flags, &selections);
if (!rc) {
fprintf(stderr, "%s", selections[0]);
free(selections);
@@ -197,7 +208,8 @@
break;
case MODE_CHECKLIST:
- rc = checkList(text, height, width, optCon, 0, flags, &selections);
+ rc = checkList(text, height, width, optCon, 0, left, right, flags,
+ &selections);
if (!rc) {
for (next = selections; *next; next++) {
diff -Nur -x '*.orig' -x '*.rej' newt-0.51.5/whiptcl.c mezzanine_patched_newt-0.51.5/whiptcl.c
--- newt-0.51.5/whiptcl.c 2000-02-16 06:34:40.000000000 -0500
+++ mezzanine_patched_newt-0.51.5/whiptcl.c 2004-08-20 20:13:12.000000000 -0400
@@ -72,6 +72,8 @@
char * result;
char ** selections, ** next;
char * title = NULL;
+ char * right = "Ok";
+ char * left = "Cancel";
struct poptOption optionsTable[] = {
{ "checklist", '\0', 0, 0, OPT_CHECKLIST },
{ "defaultno", '\0', 0, &defaultNo, 0 },
@@ -83,6 +85,8 @@
{ "radiolist", '\0', 0, 0, OPT_RADIOLIST },
{ "scrolltext", '\0', 0, &scrollText, 0 },
{ "title", '\0', POPT_ARG_STRING, &title, 0 },
+ { "left", '\0', POPT_ARG_STRING, &left, 0 },
+ { "right", '\0', POPT_ARG_STRING, &right, 0 },
{ "yesno", '\0', 0, 0, OPT_YESNO },
{ 0, 0, 0, 0, 0 }
};
@@ -180,11 +184,11 @@
switch (mode) {
case MODE_MSGBOX:
- rc = messageBox(text, height, width, MSGBOX_MSG, flags);
+ rc = messageBox(text, height, width, left, right, MSGBOX_MSG, flags);
break;
case MODE_YESNO:
- rc = messageBox(text, height, width, MSGBOX_YESNO, flags);
+ rc = messageBox(text, height, width, left, right, MSGBOX_YESNO, flags);
if (rc == DLG_OKAY)
interp->result = "yes";
else
@@ -193,7 +197,7 @@
break;
case MODE_INPUTBOX:
- rc = inputBox(text, height, width, optCon, flags, &result);
+ rc = inputBox(text, height, width, optCon, left, right, flags, &result);
if (!rc) {
interp->result = strdup(result);
interp->freeProc = TCL_DYNAMIC;
@@ -201,7 +205,7 @@
break;
case MODE_MENU:
- rc = listBox(text, height, width, optCon, flags, &result);
+ rc = listBox(text, height, width, optCon, left, right, flags, &result);
if (!rc) {
interp->result = strdup(result);
interp->freeProc = TCL_DYNAMIC;
@@ -209,7 +213,8 @@
break;
case MODE_RADIOLIST:
- rc = checkList(text, height, width, optCon, 1, flags, &selections);
+ rc = checkList(text, height, width, optCon, 1, left, right,
+ flags, &selections);
if (!rc) {
interp->result = strdup(selections[0]);
interp->freeProc = TCL_DYNAMIC;
@@ -217,7 +222,8 @@
break;
case MODE_CHECKLIST:
- rc = checkList(text, height, width, optCon, 0, flags, &selections);
+ rc = checkList(text, height, width, optCon, 0, left, right,
+ flags, &selections);
if (!rc) {
for (next = selections; *next; next++)