return i;
}
-int listBox(const char * text, int height, int width, poptContext optCon,
+int listBox(const char * text, int height, int width, int listHeight, poptContext optCon,
int flags, const char *default_item, char ** result) {
newtComponent form = NULL, okay, tb, answer, listBox;
newtComponent cancel = NULL;
const char * arg;
char * end;
- int listHeight;
int numItems = 0;
int allocedItems = 5;
int i, top;
if (itemInfo == NULL)
goto error;
- if (!(arg = poptGetArg(optCon)))
- goto error;
- listHeight = strtoul(arg, &end, 10);
- if (*end)
- goto error;
while ((arg = poptGetArg(optCon))) {
if (allocedItems == numItems) {
return rc;
}
-int checkList(const char * text, int height, int width, poptContext optCon,
- int useRadio, int flags, char *** selections) {
+int checkList(const char * text, int height, int width, int listHeight,
+ poptContext optCon, int useRadio, int flags, char *** selections) {
newtComponent form = NULL, okay, tb, subform, answer;
newtComponent sb = NULL, cancel = NULL;
const char * arg;
char * end;
- int listHeight;
int numBoxes = 0;
int allocedBoxes = 5;
int i;
if (cbInfo == NULL || cbStates == NULL)
goto error;
- if (!(arg = poptGetArg(optCon)))
- goto error;
- listHeight = strtoul(arg, &end, 10);
- if (*end)
- goto error;
while ((arg = poptGetArg(optCon))) {
if (allocedBoxes == numBoxes) {
int max(int a, int b);
int messageBox(const char * text, int height, int width, int type, int flags);
-int checkList(const char * text, int height, int width, poptContext optCon,
+int checkList(const char * text, int height, int width, int list_height, poptContext optCon,
int useRadio, int flags, char *** selections);
-int listBox(const char * text, int height, int width, poptContext optCon,
+int listBox(const char * text, int height, int width, int list_height, poptContext optCon,
int flags, const char *default_item, char ** result);
int inputBox(const char * text, int height, int width, poptContext optCon,
int flags, char ** result);
}
}
-static int menuSize(int * height, int * width, enum mode mode,
- poptContext options) {
+static int menuSize(int * height, int * width, int * listHeight,
+ enum mode mode, poptContext options) {
const char ** argv = poptGetArgs(options);
int h = 0;
int tagWidth = 0;
if ( argv == 0 || *argv == 0 )
return 0;
- argv++;
if ( mode == MODE_MENU )
overhead = 5;
h = min(h, SLtt_Screen_Rows - *height - 4);
*height = *height + h + 1;
+ *listHeight = h;
return 0;
}
/*
* Guess the size of a window, given what will be displayed within it.
*/
-static void guessSize(int * height, int * width, enum mode mode,
- int * flags, int fullButtons,
+static void guessSize(int * height, int * width, int * listHeight,
+ enum mode mode, int * flags, int fullButtons,
const char * title, const char * text,
poptContext options) {
case MODE_MENU:
spaceForButtons(&h, &w, *flags & FLAG_NOCANCEL ? 1 : 2,
fullButtons);
- menuSize(&h, &w, mode, options);
+ menuSize(&h, &w, listHeight, mode, options);
break;
case MODE_YESNO:
case MODE_MSGBOX:
char * end;
int height;
int width;
+ int listHeight = 0;
int fd = -1;
int needSpace = 0;
int noCancel = 0;
width = strtoul(nextArg, &end, 10);
if (*end) usage(WAS_ERROR);
- if (mode == MODE_GAUGE) {
+ switch (mode) {
+ case MODE_MENU:
+ case MODE_RADIOLIST:
+ case MODE_CHECKLIST:
+ if (!(nextArg = poptGetArg(optCon))) usage(WAS_ERROR);
+ listHeight = strtoul(nextArg, &end, 10);
+ if (*end) usage(WAS_ERROR);
+ break;
+
+ case MODE_GAUGE:
fd = dup(0);
if (fd < 0 || close(0) < 0) {
perror("dup/close stdin");
perror("open /dev/tty");
exit(DLG_ERROR);
}
+ break;
}
newtInit();
cleanNewlines(text);
if ( height <= 0 || width <= 0 )
- guessSize(&height, &width, mode, &flags, fullButtons, title, text,
- optCon);
+ guessSize(&height, &width, &listHeight, mode, &flags, fullButtons,
+ title, text, optCon);
width -= 2;
height -= 2;
break;
case MODE_MENU:
- rc = listBox(text, height, width, optCon, flags, default_item, &result);
+ rc = listBox(text, height, width, listHeight, optCon, flags, default_item, &result);
if (rc == DLG_OKAY) {
fprintf(output, "%s", result);
free(result);
break;
case MODE_RADIOLIST:
- rc = checkList(text, height, width, optCon, 1, flags, &selections);
+ rc = checkList(text, height, width, listHeight, optCon, 1, flags, &selections);
if (rc == DLG_OKAY && selections[0]) {
fprintf(output, "%s", selections[0]);
free(selections[0]);
break;
case MODE_CHECKLIST:
- rc = checkList(text, height, width, optCon, 0, flags, &selections);
+ rc = checkList(text, height, width, listHeight, optCon, 0, flags, &selections);
if (!rc) {
for (next = selections; *next; next++) {
char * end;
int height;
int width;
+ int listHeight;
int noCancel = 0;
int noItem = 0;
int scrollText = 0;
return TCL_ERROR;
}
+ switch (mode) {
+ case MODE_MENU:
+ case MODE_RADIOLIST:
+ case MODE_CHECKLIST:
+ if (!(nextArg = poptGetArg(optCon))) {
+ interp->result = "list-height missing";
+ return TCL_ERROR;
+ }
+ listHeight = strtoul(nextArg, &end, 10);
+ if (*end) {
+ interp->result = "list-height is not a number";
+ return TCL_ERROR;
+ }
+ break;
+ }
+
width -= 2;
height -= 2;
newtOpenWindow((80 - width) / 2, (24 - height) / 2, width, height, title);
break;
case MODE_MENU:
- rc = listBox(text, height, width, optCon, flags, default_item, &result);
+ rc = listBox(text, height, width, listHeight, optCon, flags, default_item,
+ &result);
if (rc==DLG_OKAY) {
interp->result = result;
interp->freeProc = TCL_DYNAMIC;
break;
case MODE_RADIOLIST:
- rc = checkList(text, height, width, optCon, 1, flags, &selections);
+ rc = checkList(text, height, width, listHeight, optCon, 1, flags,
+ &selections);
if (rc==DLG_OKAY) {
interp->result = selections[0];
interp->freeProc = TCL_DYNAMIC;
break;
case MODE_CHECKLIST:
- rc = checkList(text, height, width, optCon, 0, flags, &selections);
+ rc = checkList(text, height, width, listHeight, optCon, 0, flags,
+ &selections);
if (rc==DLG_OKAY) {
for (next = selections; *next; next++)