head 1.4; access; symbols pkgsrc-2013Q2:1.4.0.38 pkgsrc-2013Q2-base:1.4 pkgsrc-2012Q4:1.4.0.36 pkgsrc-2012Q4-base:1.4 pkgsrc-2011Q4:1.4.0.34 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q2:1.4.0.32 pkgsrc-2011Q2-base:1.4 pkgsrc-2009Q4:1.4.0.30 pkgsrc-2009Q4-base:1.4 pkgsrc-2008Q4:1.4.0.28 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.4.0.26 pkgsrc-2008Q3-base:1.4 cube-native-xorg:1.4.0.24 cube-native-xorg-base:1.4 pkgsrc-2008Q2:1.4.0.22 pkgsrc-2008Q2-base:1.4 pkgsrc-2008Q1:1.4.0.20 pkgsrc-2008Q1-base:1.4 pkgsrc-2007Q4:1.4.0.18 pkgsrc-2007Q4-base:1.4 pkgsrc-2007Q3:1.4.0.16 pkgsrc-2007Q3-base:1.4 pkgsrc-2007Q2:1.4.0.14 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.12 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.10 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.8 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.4.0.6 pkgsrc-2006Q2-base:1.4 pkgsrc-2006Q1:1.4.0.4 pkgsrc-2006Q1-base:1.4 pkgsrc-2005Q4:1.4.0.2 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.3.0.24 pkgsrc-2005Q3-base:1.3 pkgsrc-2005Q2:1.3.0.22 pkgsrc-2005Q2-base:1.3 pkgsrc-2005Q1:1.3.0.20 pkgsrc-2005Q1-base:1.3 pkgsrc-2004Q4:1.3.0.18 pkgsrc-2004Q4-base:1.3 pkgsrc-2004Q3:1.3.0.16 pkgsrc-2004Q3-base:1.3 pkgsrc-2004Q2:1.3.0.14 pkgsrc-2004Q2-base:1.3 pkgsrc-2004Q1:1.3.0.12 pkgsrc-2004Q1-base:1.3 pkgsrc-2003Q4:1.3.0.10 pkgsrc-2003Q4-base:1.3 netbsd-1-6-1:1.3.0.6 netbsd-1-6-1-base:1.3 netbsd-1-6:1.3.0.8 netbsd-1-6-RELEASE-base:1.3 pkgviews:1.3.0.4 pkgviews-base:1.3 buildlink2:1.3.0.2 buildlink2-base:1.3 netbsd-1-5-PATCH003:1.3 netbsd-1-5-PATCH001:1.3 netbsd-1-5-RELEASE:1.3 netbsd-1-4-PATCH003:1.3 netbsd-1-4-PATCH002:1.2 comdex-fall-1999:1.2 netbsd-1-4-PATCH001:1.2 netbsd-1-4-RELEASE:1.2 netbsd-1-3-PATCH003:1.2; locks; strict; comment @# @; 1.4 date 2005.09.30.22.02.56; author wiz; state dead; branches; next 1.3; 1.3 date 2000.07.28.20.30.11; author jlam; state Exp; branches; next 1.2; 1.2 date 98.08.07.11.10.13; author agc; state Exp; branches; next 1.1; 1.1 date 98.05.26.22.07.20; author tron; state Exp; branches; next ; desc @@ 1.4 log @Update to 1.0.20050911. Changes since 1997 (or 1995?) are too many to mention here, see http://dickey.his.com/dialog/CHANGES for details. Closes PR pkg/30856. @ text @$NetBSD: patch-ab,v 1.3 2000/07/28 20:30:11 jlam Exp $ --- checklist.c.orig Thu Aug 17 19:36:06 1995 +++ checklist.c Fri Jul 28 15:30:22 2000 @@@@ -64,8 +64,8 @@@@ int list_height, int item_no, const char * const * items, int flag, int separate_output) { - int i, x, y, cur_x, cur_y, box_x, box_y; - int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; + int i, j, x, y, cur_x, cur_y, box_x, box_y; + int key = 0, button = 0, choice = 0, d_scroll = 0, max_choice, *status; WINDOW *dialog, *list; checkflag = flag; @@@@ -83,6 +83,26 @@@@ max_choice = MIN (list_height, item_no); + /* Find length of longest item in order to center checklist */ + check_x = 0; + item_x = 0; + 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])); + } + + /* Choose useful default height and width if they are negative */ + if (height < 0) + height = strheight(prompt) + list_height + 4 + 2; + if (width < 0) { + i = strwidth(prompt); + j = ((title != NULL) ? strwidth(title) : 0); + width = MAX (i, j); + width = MAX (width, check_x + 4) + 4; + } + width = MAX (width, MIN_DIALOG_WIDTH); + /* center dialog box on screen */ x = (COLS - width) / 2; y = (LINES - height) / 2; @@@@ -131,14 +151,6 @@@@ 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; @@@@ -171,7 +183,7 @@@@ any item tag in list */ for (i = 0; i < max_choice; i++) if (toupper (key) == - toupper (items[(scroll + i) * 3][0])) + toupper (items[(d_scroll + i) * 3][0])) break; if (i < max_choice || @@@@ -183,35 +195,35 @@@@ i = key - '1'; else if (key == KEY_UP || key == '-') { if (!choice) { - if (!scroll) + if (!d_scroll) continue; /* Scroll list down */ getyx (dialog, cur_y, cur_x); if (list_height > 1) { /* De-highlight current first item */ - print_item (list, items[scroll * 3], - items[scroll * 3 + 1], status[scroll], + print_item (list, items[d_scroll * 3], + items[d_scroll * 3 + 1], status[d_scroll], 0, FALSE); scrollok (list, TRUE); wscrl (list, -1); scrollok (list, FALSE); } - scroll--; - print_item (list, items[scroll * 3], - items[scroll * 3 + 1], - status[scroll], 0, TRUE); + d_scroll--; + print_item (list, items[d_scroll * 3], + items[d_scroll * 3 + 1], + status[d_scroll], 0, TRUE); wnoutrefresh (list); /* print the up/down arrows */ wmove (dialog, box_y, box_x + check_x + 5); - wattrset (dialog, scroll ? uarrow_attr : menubox_attr); - waddch (dialog, scroll ? ACS_UARROW : ACS_HLINE); + wattrset (dialog, d_scroll ? uarrow_attr : menubox_attr); + waddch (dialog, d_scroll ? ACS_UARROW : ACS_HLINE); wmove (dialog, box_y, box_x + check_x + 6); - waddch (dialog, scroll ? '(' : ACS_HLINE); + waddch (dialog, d_scroll ? '(' : ACS_HLINE); wmove (dialog, box_y, box_x + check_x + 7); - waddch (dialog, scroll ? '-' : ACS_HLINE); + waddch (dialog, d_scroll ? '-' : ACS_HLINE); wmove (dialog, box_y, box_x + check_x + 8); - waddch (dialog, scroll ? ')' : ACS_HLINE); + waddch (dialog, d_scroll ? ')' : ACS_HLINE); wattrset (dialog, darrow_attr); wmove (dialog, box_y + list_height + 1, box_x + check_x + 5); @@@@ -232,24 +244,24 @@@@ i = choice - 1; } else if (key == KEY_DOWN || key == '+') { if (choice == max_choice - 1) { - if (scroll + choice >= item_no - 1) + if (d_scroll + choice >= item_no - 1) continue; /* Scroll list up */ getyx (dialog, cur_y, cur_x); if (list_height > 1) { /* De-highlight current last item before scrolling up */ - print_item (list, items[(scroll + max_choice - 1) * 3], - items[(scroll + max_choice - 1) * 3 + 1], - status[scroll + max_choice - 1], + print_item (list, items[(d_scroll + max_choice - 1) * 3], + items[(d_scroll + max_choice - 1) * 3 + 1], + status[d_scroll + max_choice - 1], max_choice - 1, FALSE); scrollok (list, TRUE); scroll (list); scrollok (list, FALSE); } - scroll++; - print_item (list, items[(scroll + max_choice - 1) * 3], - items[(scroll + max_choice - 1) * 3 + 1], - status[scroll + max_choice - 1], + d_scroll++; + print_item (list, items[(d_scroll + max_choice - 1) * 3], + items[(d_scroll + max_choice - 1) * 3 + 1], + status[d_scroll + max_choice - 1], max_choice - 1, TRUE); wnoutrefresh (list); @@@@ -261,21 +273,21 @@@@ waddstr (dialog, "(-)"); wmove (dialog, box_y + list_height + 1, box_x + check_x + 5); - wattrset (dialog, scroll + choice < item_no - 1 ? + wattrset (dialog, d_scroll + choice < item_no - 1 ? darrow_attr : menubox_border_attr); - waddch (dialog, scroll + choice < item_no - 1 ? + waddch (dialog, d_scroll + choice < item_no - 1 ? ACS_DARROW : ACS_HLINE); wmove (dialog, box_y + list_height + 1, box_x + check_x + 6); - waddch (dialog, scroll + choice < item_no - 1 ? + waddch (dialog, d_scroll + choice < item_no - 1 ? '(' : ACS_HLINE); wmove (dialog, box_y + list_height + 1, box_x + check_x + 7); - waddch (dialog, scroll + choice < item_no - 1 ? + waddch (dialog, d_scroll + choice < item_no - 1 ? '+' : ACS_HLINE); wmove (dialog, box_y + list_height + 1, box_x + check_x + 8); - waddch (dialog, scroll + choice < item_no - 1 ? + waddch (dialog, d_scroll + choice < item_no - 1 ? ')' : ACS_HLINE); wmove (dialog, cur_y, cur_x); wrefresh (dialog); @@@@ -284,21 +296,21 @@@@ i = choice + 1; } else if (key == ' ') { /* Toggle item status */ if (flag == FLAG_CHECK) { - status[scroll + choice] = !status[scroll + choice]; + status[d_scroll + choice] = !status[d_scroll + choice]; getyx (dialog, cur_y, cur_x); wmove (list, choice, check_x); wattrset (list, check_selected_attr); - wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' '); + wprintw (list, "[%c]", status[d_scroll + choice] ? 'X' : ' '); } else { - if (!status[scroll + choice]) { + if (!status[d_scroll + choice]) { for (i = 0; i < item_no; i++) status[i] = 0; - status[scroll + choice] = 1; + status[d_scroll + choice] = 1; getyx (dialog, cur_y, cur_x); for (i = 0; i < max_choice; i++) - print_item (list, items[(scroll + i) * 3], - items[(scroll + i) * 3 + 1], - status[scroll + i], i, i == choice); + print_item (list, items[(d_scroll + i) * 3], + items[(d_scroll + i) * 3 + 1], + status[d_scroll + i], i, i == choice); } } wnoutrefresh (list); @@@@ -309,14 +321,14 @@@@ if (i != choice) { /* De-highlight current item */ getyx (dialog, cur_y, cur_x); - print_item (list, items[(scroll + choice) * 3], - items[(scroll + choice) * 3 + 1], - status[scroll + choice], choice, FALSE); + print_item (list, items[(d_scroll + choice) * 3], + items[(d_scroll + choice) * 3 + 1], + status[d_scroll + choice], choice, FALSE); /* Highlight new item */ choice = i; - print_item (list, items[(scroll + choice) * 3], - items[(scroll + choice) * 3 + 1], - status[scroll + choice], choice, TRUE); + print_item (list, items[(d_scroll + choice) * 3], + items[(d_scroll + choice) * 3 + 1], + status[d_scroll + choice], choice, TRUE); wnoutrefresh (list); wmove (dialog, cur_y, cur_x); wrefresh (dialog); @ 1.3 log @Make use of new USE_CURSES functionality. @ text @d1 1 a1 1 $NetBSD$ @ 1.2 log @Add NetBSD RCS Ids. @ text @d3 3 a5 3 --- checklist.c.orig Fri Jan 23 17:37:12 1998 +++ checklist.c Fri Jan 23 18:15:04 1998 @@@@ -64,7 +64,7 @@@@ d10 1 d12 1 a12 1 int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; d15 1 d58 167 @ 1.1 log @New "dialog" package supplied by Johnny C. Lam in PR pkg/4993. @ text @d1 2 @