summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1994-11-17 19:21:51 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1994-11-17 19:21:51 +0000
commit04339572bc17c9ffdc05bed8cb0702ee402f7945 (patch)
tree5b6a6d3d48d2b56881366e69324dd90d7c8d4521
parent0cb06fc0095125fe674d3ed9f4dbb296da5f563d (diff)
Notes
-rw-r--r--gnu/lib/libdialog/checklist.c19
-rw-r--r--gnu/lib/libdialog/menubox.c10
-rw-r--r--gnu/lib/libdialog/prgbox.c5
-rw-r--r--gnu/lib/libdialog/radiolist.c12
-rw-r--r--gnu/lib/libdialog/textbox.c6
5 files changed, 34 insertions, 18 deletions
diff --git a/gnu/lib/libdialog/checklist.c b/gnu/lib/libdialog/checklist.c
index f33dfc231fd6..61a636be3c25 100644
--- a/gnu/lib/libdialog/checklist.c
+++ b/gnu/lib/libdialog/checklist.c
@@ -35,7 +35,7 @@ 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, unsigned char **items, unsigned char *result)
{
int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0,
- scroll = 0, max_choice, *status;
+ l, k, scroll = 0, max_choice, *status;
WINDOW *dialog, *list;
/* Allocate space for storing item on/off status */
@@ -54,8 +54,12 @@ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, in
item_x = 0;
/* Find length of longest item in order to center checklist */
for (i = 0; i < item_no; i++) {
- check_x = MAX(check_x, strlen(items[i*3]) + strlen(items[i*3 + 1]) + 6);
- item_x = MAX(item_x, strlen(items[i*3]));
+ l = strlen(items[i*3]);
+ for (j = 0; j < item_no; j++) {
+ k = strlen(items[j*3 + 1]);
+ check_x = MAX(check_x, l + k + 6);
+ }
+ item_x = MAX(item_x, l);
}
if (height < 0)
height = strheight(prompt)+list_height+4+2;
@@ -63,7 +67,7 @@ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, in
i = strwidth(prompt);
j = strwidth(title);
width = MAX(i,j);
- width = MAX(width,check_x+10)+4;
+ width = MAX(width,check_x+4)+4;
}
/* center dialog box on screen */
@@ -122,13 +126,6 @@ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, in
/* draw a box around the list items */
draw_box(dialog, box_y, box_x, list_height+2, list_width+2, menubox_border_attr, menubox_attr);
- check_x = 0;
- item_x = 0;
- /* Find length of longest item in order to center checklist */
- for (i = 0; i < item_no; i++) {
- check_x = MAX(check_x, strlen(items[i*3]) + strlen(items[i*3 + 1]) + 6);
- item_x = MAX(item_x, strlen(items[i*3]));
- }
check_x = (list_width - check_x) / 2;
item_x = check_x + item_x + 6;
diff --git a/gnu/lib/libdialog/menubox.c b/gnu/lib/libdialog/menubox.c
index 3dd29e862c18..fdb9f05116fc 100644
--- a/gnu/lib/libdialog/menubox.c
+++ b/gnu/lib/libdialog/menubox.c
@@ -35,7 +35,7 @@ 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, unsigned char **items, unsigned char *result)
{
int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0,
- scroll = 0, max_choice;
+ l, k, scroll = 0, max_choice;
WINDOW *dialog, *menu;
max_choice = MIN(menu_height, item_no);
@@ -44,8 +44,12 @@ int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int wid
item_x = 0;
/* Find length of longest item in order to center menu */
for (i = 0; i < item_no; i++) {
- tag_x = MAX(tag_x, strlen(items[i*2]) + strlen(items[i*2 + 1]) + 2);
- item_x = MAX(item_x, strlen(items[i*2]));
+ l = strlen(items[i*2]);
+ for (j = 0; j < item_no; j++) {
+ k = strlen(items[j*2 + 1]);
+ tag_x = MAX(tag_x, l + k + 2);
+ }
+ item_x = MAX(item_x, l);
}
if (height < 0)
height = strheight(prompt)+menu_height+4+2;
diff --git a/gnu/lib/libdialog/prgbox.c b/gnu/lib/libdialog/prgbox.c
index 672609995542..0145389d4000 100644
--- a/gnu/lib/libdialog/prgbox.c
+++ b/gnu/lib/libdialog/prgbox.c
@@ -34,6 +34,11 @@ int dialog_prgbox(unsigned char *title, const unsigned char *line, int height, i
FILE *f;
unsigned char *s, buf[MAX_LEN];
+ if (height < 0 || width < 0) {
+ endwin();
+ fprintf(stderr, "\nAutosizing is impossible in dialog_prgbox().\n");
+ exit(-1);
+ }
/* center dialog box on screen */
x = (COLS - width)/2;
y = (LINES - height)/2;
diff --git a/gnu/lib/libdialog/radiolist.c b/gnu/lib/libdialog/radiolist.c
index 8b1cf3c72c04..54fce3896fbb 100644
--- a/gnu/lib/libdialog/radiolist.c
+++ b/gnu/lib/libdialog/radiolist.c
@@ -36,7 +36,7 @@ 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, unsigned char **items, unsigned char *result)
{
int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0,
- scroll = 0, max_choice, *status, was_on = 0;
+ l, k, scroll = 0, max_choice, *status, was_on = 0;
WINDOW *dialog, *list;
/* Allocate space for storing item on/off status */
@@ -62,8 +62,12 @@ int dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, in
item_x = 0;
/* Find length of longest item in order to center radiolist */
for (i = 0; i < item_no; i++) {
- check_x = MAX(check_x, strlen(items[i*3]) + strlen(items[i*3 + 1]) + 6);
- item_x = MAX(item_x, strlen(items[i*3]));
+ l = strlen(items[i*3]);
+ for (j = 0; j < item_no; j++) {
+ k = strlen(items[j*3 + 1]);
+ check_x = MAX(check_x, l + k + 6);
+ }
+ item_x = MAX(item_x, l);
}
if (height < 0)
height = strheight(prompt)+list_height+4+2;
@@ -71,7 +75,7 @@ int dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, in
i = strwidth(prompt);
j = strwidth(title);
width = MAX(i,j);
- width = MAX(width,check_x+10)+4;
+ width = MAX(width,check_x+4)+4;
}
/* center dialog box on screen */
diff --git a/gnu/lib/libdialog/textbox.c b/gnu/lib/libdialog/textbox.c
index 670ea49fe32c..9e010835bc7d 100644
--- a/gnu/lib/libdialog/textbox.c
+++ b/gnu/lib/libdialog/textbox.c
@@ -48,6 +48,12 @@ int dialog_textbox(unsigned char *title, unsigned char *file, int height, int wi
unsigned char search_term[MAX_LEN+1], *tempptr, *found;
WINDOW *dialog, *text;
+ if (height < 0 || width < 0) {
+ endwin();
+ fprintf(stderr, "\nAutosizing is impossible in dialog_textbox().\n");
+ exit(-1);
+ }
+
search_term[0] = '\0'; /* no search term entered yet */
/* Open input file for reading */