From 060882c315b50f0803a5b64a9bb1d0e2e0476e0f Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Sat, 20 Apr 1996 01:28:20 +0000 Subject: Make the DITEM_RECREATE option work properly. --- gnu/lib/libdialog/checklist.c | 16 +++++++++------- gnu/lib/libdialog/menubox.c | 16 +++++++++------- gnu/lib/libdialog/radiolist.c | 17 +++++++++-------- 3 files changed, 27 insertions(+), 22 deletions(-) (limited to 'gnu/lib/libdialog') diff --git a/gnu/lib/libdialog/checklist.c b/gnu/lib/libdialog/checklist.c index c90ce9adb49c..4be328276310 100644 --- a/gnu/lib/libdialog/checklist.c +++ b/gnu/lib/libdialog/checklist.c @@ -38,14 +38,14 @@ static int list_width, check_x, item_x; */ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int width, - int list_height, int item_no, void *it, unsigned char *result) + int list_height, int cnt, void *it, unsigned char *result) { int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0, - l, k, scroll = 0, max_choice, *status; + l, k, scroll = 0, max_choice, item_no = 0, *status; int redraw_menu = FALSE; char okButton, cancelButton; WINDOW *dialog, *list; - unsigned char **items; + unsigned char **items = NULL; dialogMenuItem *ditems; /* Allocate space for storing item on/off status */ @@ -55,19 +55,22 @@ dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int wi exit(-1); } +draw: /* Previous calling syntax, e.g. just a list of strings? */ - if (item_no >= 0) { + if (cnt >= 0) { items = it; ditems = NULL; + item_no = cnt; /* Initializes status */ for (i = 0; i < item_no; i++) status[i] = !strcasecmp(items[i*3 + 2], "on"); } /* It's the new specification format - fake the rest of the code out */ else { - item_no = abs(item_no); + item_no = abs(cnt); ditems = it; - items = (unsigned char **)alloca((item_no * 3) * sizeof(unsigned char *)); + if (!items) + items = (unsigned char **)alloca((item_no * 3) * sizeof(unsigned char *)); /* Initializes status */ for (i = 0; i < item_no; i++) { @@ -108,7 +111,6 @@ dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int wi x = (COLS - width)/2; y = (LINES - height)/2; -draw: #ifdef HAVE_NCURSES if (use_shadow) draw_shadow(stdscr, y, x, height, width); diff --git a/gnu/lib/libdialog/menubox.c b/gnu/lib/libdialog/menubox.c index ca963bf5c932..9e36601f56d7 100644 --- a/gnu/lib/libdialog/menubox.c +++ b/gnu/lib/libdialog/menubox.c @@ -37,30 +37,33 @@ static int menu_width, tag_x, item_x; */ int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int width, int menu_height, - int item_no, void *it, unsigned char *result, int *ch, int *sc) + int cnt, void *it, unsigned char *result, int *ch, int *sc) { int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0, - l, k, scroll = 0, max_choice, redraw_menu = FALSE; + l, k, scroll = 0, max_choice, item_no, redraw_menu = FALSE; char okButton, cancelButton; WINDOW *dialog, *menu; - unsigned char **items; + unsigned char **items = NULL; dialogMenuItem *ditems; +draw: if (ch) /* restore menu item info */ choice = *ch; if (sc) scroll = *sc; /* If item_no is a positive integer, use old item specification format */ - if (item_no >= 0) { + if (cnt >= 0) { items = it; ditems = NULL; + item_no = cnt; } /* It's the new specification format - fake the rest of the code out */ else { - item_no = abs(item_no); + item_no = abs(cnt); ditems = it; - items = (unsigned char **)alloca((item_no * 2) * sizeof(unsigned char *)); + if (!items) + items = (unsigned char **)alloca((item_no * 2) * sizeof(unsigned char *)); /* Initializes status */ for (i = 0; i < item_no; i++) { @@ -99,7 +102,6 @@ dialog_menu(unsigned char *title, unsigned char *prompt, int height, int width, x = DialogX ? DialogX : (COLS - width)/2; y = DialogY ? DialogY : (LINES - height)/2; -draw: #ifdef HAVE_NCURSES if (use_shadow) draw_shadow(stdscr, y, x, height, width); diff --git a/gnu/lib/libdialog/radiolist.c b/gnu/lib/libdialog/radiolist.c index 4d40e0b1adcb..daa88817c6a5 100644 --- a/gnu/lib/libdialog/radiolist.c +++ b/gnu/lib/libdialog/radiolist.c @@ -38,14 +38,14 @@ static int list_width, check_x, item_x; */ int dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height, - int item_no, void *it, unsigned char *result) + int cnt, void *it, unsigned char *result) { int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0, - l, k, scroll = 0, max_choice, *status, was_on = 0; + l, k, scroll = 0, max_choice, *status, item_no = 0, was_on = 0; int redraw_menu = FALSE; char okButton, cancelButton; WINDOW *dialog, *list; - unsigned char **items; + unsigned char **items = NULL; dialogMenuItem *ditems; /* Allocate space for storing item on/off status */ @@ -55,11 +55,12 @@ dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int wi exit(-1); } +draw: /* Previous calling syntax, e.g. just a list of strings? */ - if (item_no >= 0) { + if (cnt >= 0) { items = it; ditems = NULL; - + item_no = cnt; /* Initializes status */ for (i = 0; i < item_no; i++) { status[i] = !strcasecmp(items[i*3 + 2], "on"); @@ -73,9 +74,10 @@ dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int wi } /* It's the new specification format - fake the rest of the code out */ else { - item_no = abs(item_no); + item_no = abs(cnt); ditems = it; - items = (unsigned char **)alloca((item_no * 3) * sizeof(unsigned char *)); + if (!items) + items = (unsigned char **)alloca((item_no * 3) * sizeof(unsigned char *)); /* Initializes status */ for (i = 0; i < item_no; i++) { status[i] = ditems[i].checked ? ditems[i].checked(&ditems[i]) : FALSE; @@ -121,7 +123,6 @@ dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int wi x = DialogX ? DialogX : (COLS - width)/2; y = DialogY ? DialogY : (LINES - height)/2; -draw: #ifdef HAVE_NCURSES if (use_shadow) draw_shadow(stdscr, y, x, height, width); -- cgit v1.2.3