diff options
author | ache <ache@FreeBSD.org> | 1994-11-16 14:37:37 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1994-11-16 14:37:37 +0000 |
commit | e26dcdfe6d1edef038874549fad1387f81b491ca (patch) | |
tree | 6d42ce10ce8c7263feab1c0a86525a16826ae40e /gnu/lib/libdialog/checklist.c | |
parent | 0cbabcf40fb04b5e1dd6d21c9febc638f8734018 (diff) | |
download | FreeBSD-src-e26dcdfe6d1edef038874549fad1387f81b491ca.zip FreeBSD-src-e26dcdfe6d1edef038874549fad1387f81b491ca.tar.gz |
Full autosizing support, now you can pass -1, -1 for any
string
Diffstat (limited to 'gnu/lib/libdialog/checklist.c')
-rw-r--r-- | gnu/lib/libdialog/checklist.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gnu/lib/libdialog/checklist.c b/gnu/lib/libdialog/checklist.c index cc83d25..f33dfc2 100644 --- a/gnu/lib/libdialog/checklist.c +++ b/gnu/lib/libdialog/checklist.c @@ -34,7 +34,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, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0, + int i, j, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; WINDOW *dialog, *list; @@ -50,6 +50,22 @@ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, in max_choice = MIN(list_height, item_no); + 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])); + } + if (height < 0) + height = strheight(prompt)+list_height+4+2; + if (width < 0) { + i = strwidth(prompt); + j = strwidth(title); + width = MAX(i,j); + width = MAX(width,check_x+10)+4; + } + /* center dialog box on screen */ x = (COLS - width)/2; y = (LINES - height)/2; |