From 1ef6786a82740cc37b76bd775bf8fa8049158699 Mon Sep 17 00:00:00 2001 From: John Marino Date: Wed, 4 Nov 2015 16:19:03 +0100 Subject: [PATCH] Vendor branch: Update dialog 1.2-20121230 => 1.2-20150920 The README.DELETED file is getting moved to trunk. --- contrib/dialog/CHANGES | 181 +++++++++++++++++++++++- contrib/dialog/README.DELETED | 16 --- contrib/dialog/VERSION | 2 +- contrib/dialog/argv.c | 30 ++-- contrib/dialog/arrows.c | 11 +- contrib/dialog/buildlist.c | 41 +++--- contrib/dialog/buttons.c | 11 +- contrib/dialog/calendar.c | 5 +- contrib/dialog/checklist.c | 43 +++--- contrib/dialog/dialog.1 | 279 +++++++++++++++++++++---------------- contrib/dialog/dialog.3 | 273 ++++++++++++++++++++++++++++--------- contrib/dialog/dialog.c | 112 ++++++++++----- contrib/dialog/dialog.h | 17 ++- contrib/dialog/dlg_keys.c | 8 +- contrib/dialog/editbox.c | 9 +- contrib/dialog/formbox.c | 15 +- contrib/dialog/guage.c | 91 +++++++++---- contrib/dialog/inputstr.c | 310 ++++++++++++++++++++++++------------------ contrib/dialog/menubox.c | 17 ++- contrib/dialog/mixedform.c | 15 +- contrib/dialog/mouse.c | 24 ++-- contrib/dialog/prgbox.c | 8 +- contrib/dialog/progressbox.c | 19 ++- contrib/dialog/rangebox.c | 5 +- contrib/dialog/timebox.c | 5 +- contrib/dialog/trace.c | 6 +- contrib/dialog/treeview.c | 41 ++---- contrib/dialog/ui_getc.c | 34 ++++- contrib/dialog/util.c | 92 ++++++++++--- 29 files changed, 1141 insertions(+), 579 deletions(-) delete mode 100644 contrib/dialog/README.DELETED diff --git a/contrib/dialog/CHANGES b/contrib/dialog/CHANGES index 1d4b6190ea..67193641d7 100644 --- a/contrib/dialog/CHANGES +++ b/contrib/dialog/CHANGES @@ -1,9 +1,186 @@ --- $Id: CHANGES,v 1.451 2012/12/30 15:43:24 tom Exp $ +-- $Id: CHANGES,v 1.521 2015/09/20 23:48:54 tom Exp $ -- Thomas E. Dickey This version of dialog was originally from a Debian snapshot. I've done this to it: +2015/09/20 + + decrease table value for minimum number of arguments for the widgets + which use --no-items option (report by Raven Singularity). + + update configure macros: + + use $SHELL consistently, deprecate non-POSIX shell + + PKG_CONFIG may simply be unset - fix + + add option to allow changing ABI version, from ncurses6. + +2015/05/28 + + fixes for two autoconf macros, CF_ADD_INCDIR and CF_NCURSES_CONFIG + from work on ncurses. + + build-fix for NetBSD curses (patch by Matthias Scheler). + +2015/05/13 + + add configure option --with-install-prefix, like ncurses. + + add --with-screen and related configure options from ncurses-examples + to allow building with ncurses6 test-packages. + + update configure macros for improved coding style from lynx changes. + + updated ro.po from + http://translationproject.org/latest/dialog/ + + update config.guess, config.sub + > patches by Florent Rougon: + + fix two bugs in the "--file" option. + + When the number of arguments read from the included file is 0, the + code used to just skip over '--file' and its argument instead of + removing them from the argument list, causing "Error: Unknown + option --file" later on. + + In the alternative case (at least one argument read from the file), + the previous code used to do '--j;' in order to "force rescan" of + the inserted arguments. However, control then flowed to outer + blocks where a '++j;' counteracted this measure, causing "Error: + Unknown option --msgbox" (for instance) later on. + + modify escaping in argv.c to be more uniform, whether or not the + backslash is found within a parameter. + +2015/02/25 + + modify gauge widget to keep from erasing a second gauge widget, e.g., + via the "--and-widget" option. This is a cosmetic change to match + behavior of dialog 1.0 (report by Jason Orendorf). + + add configure option "--with-man2html" + + add configure options for versioned symbols, from ongoing work on + ncurses. + + update configure macros, e.g., for shared libraries + +2015/01/25 + + suppress highlighting of character which denotes an abbreviation or + shortcut for the OK/Cancel and other buttons for these widgets, which + use abbreviations for the list shown on the screen: buildlist, + checklist/radiobox, menubox, treeview (Debian #775295). + + add grid up/left and down/right bindings in editbox.c as synonyms for + field prev and next, respectively when handling the OK/Cancel buttons + (Debian #775294). + +2014/09/11 + + correct malloc-size for change to prgbox. + +2014/09/10 + + fixes to make "-c" option work when passing command to shell for the + prgbox widget, for example in samples/prgbox2 (report by Korantin + Auguste). + +2014/09/08 + + fix an out-of-bounds array index in buildlist widget (report by + Cade Foster). + +2014/09/01 + + add configure check for groff, needed for html/ps/pdf output. + + update configure-script macros: + + CF_ACVERSION_CHECK - work around another gratuitous incompatibility + introduced in 2.69 + + CF_ADD_CFLAGS - workaround for ash-shell, e.g., with Minix + + CF_ADD_LIBS - filter out duplicates + + CF_CURSES_FUNCS - improve workaround for weak-linkage, seems to fix + tests with NetBSD 6.1 + + CF_INTEL_COMPILER - clean up the -no-gcc option which was leftover + from testing. + + CF_LIB_SUFFIX - change suffix for AIX shared libraries to ".so". + + CF_MAKEFLAGS - workaround for GNU make 4.0 incompatibility with + previous releases. + + CF_XOPEN_SOURCE - add cases for Minix, UnixWare and improve the + workaround for Solaris. + + improve comparison in compare_cache() function, in case difference + between pointers does not fit in int's. + + updated de.po, es.po, hu.po, lv.po from + http://translationproject.org/latest/dialog/ + + update config.guess, config.sub + +2014/02/19 + + cleanup of manpages prompted by Gislason's comments. + + several changes to manpages to improve presentation (patches by + Bjarni I. Gislason, Debian #739180, Debian #739181) + + use "\/" when transitioning from italic to normal font + + correct an instance of "e.g,." + + use "\e" rather than "\\" to present a literal "\" + + improve formatting of table header + + remove some excess space-characters + + change a reference 0-9 to use "through" as the connector + + use "\&" to separate "." from a space to make the space shorter + + change a list's TP macro parameters to make the hanging text align + better with the adjacent paragraph + + add comma in a few places before "and" in a list + + separate units from numbers with a nonfillable space + + replace "-" with en-dash in a few places + + corrected argument indices after "--args" and "--file" to rescan the + argument list after removing/substituting those options. + + fix loops for "--file" option to handle cases with zero or no tokens at + all substituted (Redhat #1066168). + + add gd.po from + http://translationproject.org/latest/dialog/ + +2014/01/12 + + improve calculation for amount to scroll in programbox when an "Ok" + button might obscure part of the data (report by Florent Rougon). + + modify program to permit --separate-output to be used with buildlist + and treeview widgets (report by Florent Rougon). + + add list-height parameter to manpage description of --buildlist + (report by Florent Rougon). + + minor fixes to dialog.1 manpage; the reported problem was actually + fixed in 20120703 (Debian #726233, patch by Bjarni Ingi Gislason). + + add a "Hello World" example to dialog.3 manpage (prompted by + discussions with Dustin Oprea, Kevin Ingwersen). + + correct comparison in dlg_lookup_key() so that using "bindkey" with + a "*" wildcard parameter works as documented (report by Stewart + Benedict). + + updated configure macros, fixes for clang and mingw. + + update config.guess, config.sub + +2013/09/28 + + fix a regression in gauge widget from 2013/09/28 changes; + dlg_reallocate_gauge() failed when no --title option was given + (report by Tritonas Insomnia). + +2013/09/23 + + fix samples/inputbox6-utf8, which had depended unnecessarily on bash. + + improve memory caching for wide-character manipulation in gauge + widget (report by Devin Teske). + + add dlg_reallocate_gauge (discussion with Devin Teske). + + updated configure macros to use msys changes from ncurses. + + update config.guess, config.sub + +2013/09/02 + + modify makefile rule to make the ".png" filenames created by groff + predictable. + + add option --help-tags to allow scripts to get the item's tag field + consistently from help- and help-item button results rather than + getting the item's text for the latter (discussion with Florent + Rougon). + + correct manpage discussion of DIALOG_ITEM_HELP versus --item-help, + as well as --help-button return status (report by Florent Rougon). + + correct limit used for --hline option (report by Devin Teske, + cf: 2011/06/30). + + do not print empty "[]" if a --hline option was given with an empty + value (report by Devin Teske). + + miscellaneous configure script fixes/updates. In particular, add + option --with-shared which builds shared libraries without a libtool + dependency. + + add FreeBSD port-files for test-builds. + + update lt.po, add fa.po from + http://translationproject.org/latest/dialog/ + + update config.guess, config.sub + +2013/05/23 + + modify ifdef in arrows.c to work around packages which use the + wide-character ncursesw headers with the ncurses library (report + by Aleksey Cheusov). + + correct workaround for xterm alternate-screen to work with/without + the fix made in ncurses that makes putp() always write to the + standard output (Debian #708829). + + improve limit-checks for checklist, in case the dialog is resized + (report by Ilya A Arkhipov). + + add --last-key option (adapted from patch by Jordi Pujol, Debian + #697607). + +2013/03/15 + + update zh_TW.po, add an.po from + http://translationproject.org/latest/dialog/ + 2012/12/30 - release 1.2 + improve some older changelog entries to help with HTML'izing content. + various fixes/improvments for scrollbar appearance. @@ -282,7 +459,7 @@ to it: separate ncurses' header files. + CF_DISABLE_RPATH_HACK, fix garbled message + CF_LD_RPATH_OPT, add mirbsd - + CF_MAKEFLAGS, filter out GNU make's entering/leaving messages. + + CF_MAKEFLAGS, filter out GNU make's entering/leaving messages. This only appeared when using the macro in a dpkg script, though it should have in other cases. + CF_RPATH_HACK, add a check for libraries not found, e.g., from diff --git a/contrib/dialog/README.DELETED b/contrib/dialog/README.DELETED deleted file mode 100644 index 54b620f604..0000000000 --- a/contrib/dialog/README.DELETED +++ /dev/null @@ -1,16 +0,0 @@ -aclocal.m4 -config.guess -config.hin -config.sub -configure -configure.in -dialog-config.in -dialog.lsm -dialog.pl -headers-sh.in -install-sh -makefile.in -package/ -po/ -rename.sh -samples/ diff --git a/contrib/dialog/VERSION b/contrib/dialog/VERSION index c3a82bb61b..dc1e4a95a7 100644 --- a/contrib/dialog/VERSION +++ b/contrib/dialog/VERSION @@ -1 +1 @@ -11:0:0 1.2 20121230 +12:0:0 1.2 20150920 diff --git a/contrib/dialog/argv.c b/contrib/dialog/argv.c index 7416054543..cd610c2584 100644 --- a/contrib/dialog/argv.c +++ b/contrib/dialog/argv.c @@ -1,9 +1,9 @@ /* - * $Id: argv.c,v 1.2 2012/11/30 20:28:23 tom Exp $ + * $Id: argv.c,v 1.5 2015/05/13 00:34:39 tom Exp $ * * argv - Reusable functions for argv-parsing. * - * Copyright 2011,2012 Thomas E. Dickey + * Copyright 2011-2014,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -37,6 +37,7 @@ dlg_string_to_argv(char *blob) size_t length = strlen(blob); char **result = 0; + DLG_TRACE(("# dlg_string_to_argv:\n#\t%s\n", blob)); for (pass = 0; pass < 2; ++pass) { bool inparm = FALSE; bool quoted = FALSE; @@ -54,18 +55,12 @@ dlg_string_to_argv(char *blob) ++count; inparm = TRUE; } - } else if (blob[n] == '\\') { - if (quoted && !isspace(UCH(blob[n + 1]))) { + } else if (!quoted && isspace(UCH(blob[n]))) { + if (inparm) { if (pass) { - *param++ = blob[n]; - *param++ = blob[n + 1]; + *param++ = '\0'; } - } - ++n; - } else if (!quoted && isspace(UCH(blob[n]))) { - inparm = FALSE; - if (pass) { - *param++ = '\0'; + inparm = FALSE; } } else { if (!inparm) { @@ -74,6 +69,10 @@ dlg_string_to_argv(char *blob) ++count; inparm = TRUE; } + if (blob[n] == '\\') { + if (++n == length) + break; /* The string is terminated by a backslash */ + } if (pass) { *param++ = blob[n]; } @@ -91,6 +90,13 @@ dlg_string_to_argv(char *blob) *param = '\0'; } } +#ifdef HAVE_DLG_TRACE + if (result != 0) { + for (n = 0; result[n] != 0; ++n) { + DLG_TRACE(("#\targv[%d] = %s\n", (int) n, result[n])); + } + } +#endif return result; } diff --git a/contrib/dialog/arrows.c b/contrib/dialog/arrows.c index 22d29a1eaf..44a90dfdcb 100644 --- a/contrib/dialog/arrows.c +++ b/contrib/dialog/arrows.c @@ -1,9 +1,9 @@ /* - * $Id: arrows.c,v 1.49 2012/12/30 22:33:28 tom Exp $ + * $Id: arrows.c,v 1.51 2013/09/02 15:10:09 tom Exp $ * * arrows.c -- draw arrows to indicate end-of-range for lists * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2012,2013 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -74,9 +74,10 @@ dlg_draw_helpline(WINDOW *win, bool decorations) int bottom; if (dialog_vars.help_line != 0 + && dialog_vars.help_line[0] != 0 && (bottom = getmaxy(win) - 1) > 0) { chtype attr = A_NORMAL; - const int *cols = dlg_index_columns(dialog_vars.help_line); + int cols = dlg_count_columns(dialog_vars.help_line); int other = decorations ? (ON_LEFT + ON_RIGHT) : 0; int avail = (getmaxx(win) - other - 2); int limit = dlg_count_real_columns(dialog_vars.help_line) + 2; @@ -86,7 +87,7 @@ dlg_draw_helpline(WINDOW *win, bool decorations) other = decorations ? ON_LEFT : 0; (void) wmove(win, bottom, other + (avail - limit) / 2); waddch(win, '['); - dlg_print_text(win, dialog_vars.help_line, cols[limit], &attr); + dlg_print_text(win, dialog_vars.help_line, cols, &attr); waddch(win, ']'); wmove(win, cur_y, cur_x); } @@ -233,7 +234,7 @@ dlg_draw_scrollbar(WINDOW *win, (void) wattrset(win, position_indicator_attr); wattron(win, A_REVERSE); -#if defined(WACS_BLOCK) && defined(NCURSES_VERSION) +#if defined(WACS_BLOCK) && defined(NCURSES_VERSION) && defined(USE_WIDE_CURSES) wvline_set(win, WACS_BLOCK, bar_last - bar_y); #else wvline(win, ACS_BLOCK, bar_last - bar_y); diff --git a/contrib/dialog/buildlist.c b/contrib/dialog/buildlist.c index 362b75fd6e..4c942ab88c 100644 --- a/contrib/dialog/buildlist.c +++ b/contrib/dialog/buildlist.c @@ -1,9 +1,9 @@ /* - * $Id: buildlist.c,v 1.56 2012/12/31 00:38:57 tom Exp $ + * $Id: buildlist.c,v 1.61 2015/01/25 23:52:45 tom Exp $ * * buildlist.c -- implements the buildlist dialog * - * Copyright 2012 Thomas E. Dickey + * Copyright 2012-2014,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -118,7 +118,9 @@ print_1_list(ALL_DATA * data, for (i = j = 0; j < max_rows; i++) { int ii = i + moi->top_index; - if (ii >= data->item_no) { + if (ii < 0) { + continue; + } else if (ii >= data->item_no) { break; } else if (!(selected ^ (data->items[ii].state != 0))) { print_item(data, @@ -472,6 +474,8 @@ dlg_buildlist(const char *title, (void) order_mode; + dialog_state.plain_buttons = TRUE; + /* * Unlike other uses of --visit-items, we have two windows to visit. */ @@ -1027,6 +1031,7 @@ dialog_buildlist(const char *title, bool separate_output = dialog_vars.separate_output; bool show_status = FALSE; int current = 0; + char *help_result; listitems = dlg_calloc(DIALOG_LISTITEM, (size_t) item_no + 1); assert_ptr(listitems, "dialog_buildlist"); @@ -1060,31 +1065,16 @@ dialog_buildlist(const char *title, show_status = TRUE; break; case DLG_EXIT_HELP: - dlg_add_result("HELP "); - show_status = dialog_vars.help_status; - if (USE_ITEM_HELP(listitems[current].help)) { - if (show_status) { - if (separate_output) { - dlg_add_string(listitems[current].help); - dlg_add_separator(); - } else { - dlg_add_quoted(listitems[current].help); - } + dlg_add_help_listitem(&result, &help_result, &listitems[current]); + if ((show_status = dialog_vars.help_status)) { + if (separate_output) { + dlg_add_string(help_result); + dlg_add_separator(); } else { - dlg_add_string(listitems[current].help); + dlg_add_quoted(help_result); } - result = DLG_EXIT_ITEM_HELP; } else { - if (show_status) { - if (separate_output) { - dlg_add_string(listitems[current].name); - dlg_add_separator(); - } else { - dlg_add_quoted(listitems[current].name); - } - } else { - dlg_add_string(listitems[current].name); - } + dlg_add_string(help_result); } break; } @@ -1102,6 +1092,7 @@ dialog_buildlist(const char *title, } } } + dlg_add_last_key(-1); } dlg_free_columns(&listitems[0].text, (int) sizeof(DIALOG_LISTITEM), item_no); diff --git a/contrib/dialog/buttons.c b/contrib/dialog/buttons.c index d37cfe5011..6e565526e5 100644 --- a/contrib/dialog/buttons.c +++ b/contrib/dialog/buttons.c @@ -1,9 +1,9 @@ /* - * $Id: buttons.c,v 1.94 2012/12/30 20:51:01 tom Exp $ + * $Id: buttons.c,v 1.96 2015/01/25 23:52:54 tom Exp $ * * buttons.c -- draw buttons, e.g., OK/Cancel * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2014,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -29,6 +29,7 @@ #endif #define MIN_BUTTON (-dialog_state.visit_cols) +#define CHR_BUTTON (!dialog_state.plain_buttons) static void center_label(char *buffer, int longest, const char *label) @@ -213,7 +214,7 @@ print_button(WINDOW *win, char *label, int hotkey, int y, int x, int selected) ? button_active_attr : button_inactive_attr); (void) waddstr(win, ">"); - (void) wmove(win, y, x + ((int) strspn(label, " ")) + 1); + (void) wmove(win, y, x + ((int) (strspn) (label, " ")) + 1); } /* @@ -374,7 +375,9 @@ dlg_draw_buttons(WINDOW *win, for (n = 0; labels[n] != 0; n++) { center_label(buffer, longest, labels[n]); mouse_mkbutton(y, x, dlg_count_columns(buffer), n); - print_button(win, buffer, hotkeys[n], y, x, + print_button(win, buffer, + CHR_BUTTON ? hotkeys[n] : -1, + y, x, (selected == n) || (n == 0 && selected < 0)); if (selected == n) getyx(win, final_y, final_x); diff --git a/contrib/dialog/calendar.c b/contrib/dialog/calendar.c index dab461759d..0a7061adf8 100644 --- a/contrib/dialog/calendar.c +++ b/contrib/dialog/calendar.c @@ -1,9 +1,9 @@ /* - * $Id: calendar.c,v 1.66 2012/07/01 18:13:07 Zoltan.Kelemen Exp $ + * $Id: calendar.c,v 1.67 2013/03/17 15:03:41 tom Exp $ * * calendar.c -- implements the calendar box * - * Copyright 2001-2011,2012 Thomas E. Dickey + * Copyright 2001-2012,2013 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -681,6 +681,7 @@ dialog_calendar(const char *title, dlg_add_result(buffer); dlg_add_separator(); + dlg_add_last_key(-1); return CleanupResult(result, dialog, prompt, &save_vars); } diff --git a/contrib/dialog/checklist.c b/contrib/dialog/checklist.c index b15b47b631..2273eee39e 100644 --- a/contrib/dialog/checklist.c +++ b/contrib/dialog/checklist.c @@ -1,9 +1,9 @@ /* - * $Id: checklist.c,v 1.148 2012/12/24 02:08:58 tom Exp $ + * $Id: checklist.c,v 1.154 2015/01/25 23:53:06 tom Exp $ * * checklist.c -- implements the checklist box * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2013,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -205,6 +205,8 @@ dlg_checklist(const char *title, const char **buttons = dlg_ok_labels(); const char *widget_name; + dialog_state.plain_buttons = TRUE; + memset(&all, 0, sizeof(all)); all.items = items; all.item_no = item_no; @@ -293,6 +295,7 @@ dlg_checklist(const char *title, all.use_height = 1; max_choice = MIN(all.use_height, item_no); + max_choice = MAX(max_choice, 1); /* create new window for the list */ all.list = dlg_sub_window(dialog, all.use_height, all.use_width, @@ -346,8 +349,9 @@ dlg_checklist(const char *title, + all.check_x + 4); /* ensure we are scrolled to show the current choice */ - if (choice >= (max_choice + scrollamt)) { - scrollamt = choice - max_choice + 1; + scrollamt = MIN(scrollamt, max_choice + item_no - 1); + if (choice >= (max_choice + scrollamt - 1)) { + scrollamt = MAX(0, choice - max_choice + 1); choice = max_choice - 1; } print_list(&all, choice, scrollamt, max_choice); @@ -605,6 +609,7 @@ dialog_checklist(const char *title, && (dialog_vars.separate_output)); bool show_status = FALSE; int current = 0; + char *help_result; listitems = dlg_calloc(DIALOG_LISTITEM, (size_t) item_no + 1); assert_ptr(listitems, "dialog_checklist"); @@ -638,31 +643,16 @@ dialog_checklist(const char *title, show_status = TRUE; break; case DLG_EXIT_HELP: - dlg_add_result("HELP "); - show_status = dialog_vars.help_status; - if (USE_ITEM_HELP(listitems[current].help)) { - if (show_status) { - if (separate_output) { - dlg_add_string(listitems[current].help); - dlg_add_separator(); - } else { - dlg_add_quoted(listitems[current].help); - } + dlg_add_help_listitem(&result, &help_result, &listitems[current]); + if ((show_status = dialog_vars.help_status)) { + if (separate_output) { + dlg_add_string(help_result); + dlg_add_separator(); } else { - dlg_add_string(listitems[current].help); + dlg_add_quoted(help_result); } - result = DLG_EXIT_ITEM_HELP; } else { - if (show_status) { - if (separate_output) { - dlg_add_string(listitems[current].name); - dlg_add_separator(); - } else { - dlg_add_quoted(listitems[current].name); - } - } else { - dlg_add_string(listitems[current].name); - } + dlg_add_string(help_result); } break; } @@ -683,6 +673,7 @@ dialog_checklist(const char *title, } } } + dlg_add_last_key(separate_output); } dlg_free_columns(&listitems[0].text, (int) sizeof(DIALOG_LISTITEM), item_no); diff --git a/contrib/dialog/dialog.1 b/contrib/dialog/dialog.1 index 2d6218b4e9..5920c613ca 100644 --- a/contrib/dialog/dialog.1 +++ b/contrib/dialog/dialog.1 @@ -1,6 +1,6 @@ '\" t -.\" $Id: dialog.1,v 1.164 2012/12/30 23:32:18 tom Exp $ -.\" Copyright 2005-2011,2012 Thomas E. Dickey +.\" $Id: dialog.1,v 1.185 2015/05/13 20:11:04 tom Exp $ +.\" Copyright 2005-2014,2015 Thomas E. Dickey .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU Lesser General Public License, version 2.1 @@ -31,9 +31,11 @@ .RS +7 .PP .nf +.ft CW .. .de Ee .fi +.ft R .RE .. .\" Bulleted paragraph @@ -41,7 +43,7 @@ .IP \(bu 4 .. . -.TH \*D 1 "" "$Date: 2012/12/30 23:32:18 $" +.TH \*D 1 "" "$Date: 2015/05/13 20:11:04 $" .SH NAME dialog \- display dialog boxes from shell scripts .SH SYNOPSIS @@ -56,7 +58,7 @@ dialog \- display dialog boxes from shell scripts \fIbox-options\fP .SH DESCRIPTION \fB\*L\fP -is a program that will let you to present a variety of questions or +is a program that will let you present a variety of questions or display messages using dialog boxes from a shell script. These types of dialog boxes are implemented (though not all are necessarily compiled into \fB\*p\fR): @@ -145,6 +147,7 @@ interprets the following text as a file descriptor number rather than a filename. . .SS \fBCommon Options\fP +Most of the common options are reset before processing each widget. . .IP "\fB--ascii-lines Rather than draw graphics lines around boxes, @@ -179,36 +182,36 @@ To compare the effects, use these: .ES All three widgets visible, staircase effect, ordered 1,2,3: .Ex -\*p \\ - --begin 2 2 --yesno "" 0 0 \\ - --and-widget --begin 4 4 --yesno "" 0 0 \\ +\*p \e + --begin 2 2 --yesno "" 0 0 \e + --and-widget --begin 4 4 --yesno "" 0 0 \e --and-widget --begin 6 6 --yesno "" 0 0 .Ee . .ES Only the last widget is left visible: .Ex -\*p \\ - --clear --begin 2 2 --yesno "" 0 0 \\ - --and-widget --clear --begin 4 4 --yesno "" 0 0 \\ +\*p \e + --clear --begin 2 2 --yesno "" 0 0 \e + --and-widget --clear --begin 4 4 --yesno "" 0 0 \e --and-widget --begin 6 6 --yesno "" 0 0 .Ee . .ES All three widgets visible, staircase effect, ordered 3,2,1: .Ex -\*p \\ - --keep-window --begin 2 2 --yesno "" 0 0 \\ - --and-widget --keep-window --begin 4 4 --yesno "" 0 0 \\ +\*p \e + --keep-window --begin 2 2 --yesno "" 0 0 \e + --and-widget --keep-window --begin 4 4 --yesno "" 0 0 \e --and-widget --begin 6 6 --yesno "" 0 0 .Ee . .ES First and third widget visible, staircase effect, ordered 3,1: .Ex -\*p \\ - --keep-window --begin 2 2 --yesno "" 0 0 \\ - --and-widget --clear --begin 4 4 --yesno "" 0 0 \\ +\*p \e + --keep-window --begin 2 2 --yesno "" 0 0 \e + --and-widget --clear --begin 4 4 --yesno "" 0 0 \e --and-widget --begin 6 6 --yesno "" 0 0 .Ee .IP @@ -217,10 +220,12 @@ cursor home after the dialog program has exited, use the \fBclear\fR\ (1) command. . .IP "\fB--colors" -Interpret embedded "\\Z" sequences in the dialog text +Interpret embedded "\eZ" sequences in the dialog text by the following character, which tells \fB\*p\fP to set colors or video attributes: -0 through 7 are the ANSI used in curses: +.RS +.bP +0 through 7 are the ANSI color numbers used in curses: black, red, green, @@ -229,12 +234,18 @@ blue, magenta, cyan and white respectively. +.bP Bold is set by 'b', reset by 'B'. +.bP Reverse is set by 'r', reset by 'R'. +.bP Underline is set by 'u', reset by 'U'. -The settings are cumulative, e.g., "\\Zb\\Z1" makes the following text +.bP +The settings are cumulative, e.g., "\eZb\eZ1" makes the following text bold (perhaps bright) red. -Restore normal settings with "\\Zn". +.bP +Restore normal settings with "\eZn". +.RE . .IP "\fB--column-separator \fIstring" Tell \fB\*p\fP to split data for radio/checkboxes and menus on the @@ -318,11 +329,19 @@ or if an unrecognized option is given. .IP "\fB--help-button" Show a help-button after "OK" and "Cancel" buttons, i.e., in checklist, radiolist and menu boxes. -If "\fB--item-help\fR" is also given, on exit -the return status will be the same as for the "OK" button, -and the item-help text will be written to \fB\*p\fP's output after the token "HELP". -Otherwise, the return status will indicate that the Help button was pressed, -and no message printed. +.IP +On exit, the return status will indicate that the Help button was pressed. +\fB\*L\fP will also write a message to its output after the token "HELP": +.RS +.bP +If "\fB--item-help\fR" is also given, the item-help text will be written. +.bP +Otherwise, the item's tag (the first field) will be written. +.RE +.IP +.IP +You can use the \fB--help-tags\fP option and/or set the DIALOG_ITEM_HELP +environment variable to modify these messages and exit-status. . .IP "\fB--help-label \fIstring" Override the label used for "Help" buttons. @@ -334,6 +353,11 @@ after the item-help "HELP" information. This can be used to reconstruct the state of a checklist after processing the help request. . +.IP "\fB--help-tags" +Modify the messages written on exit for \fB--help-button\fP +by making them always just the item's tag. +This does not affect the exit status code. +. .IP "\fB--hfile \fIfilename" Display the given file using a textbox when the user presses F1. . @@ -384,6 +408,12 @@ marked with "\fB--keep-window\fR", even if they are not \fBtailboxbg\fR widgets. That causes them to be repainted in reverse order. See the discussion of the "\fB--clear\fR" option for examples. . +.IP "\fB--last-key" +At exit, report the last key which the user entered. +This is the curses key code rather than a symbol or literal character. +It can be used by scripts to distinguish between two keys which are +bound to the same action. +. .IP "\fB--max-input \fIsize" Limit input strings to the given size. If not specified, the limit is 2048. @@ -430,7 +460,7 @@ See also "\fB--ascii-lines\fR". Do not enable the mouse. . .IP "\fB--no-nl-expand -Do not convert "\\n" substrings of the message/prompt text into +Do not convert "\en" substrings of the message/prompt text into literal newlines. . .IP "\fB--no-ok" @@ -470,7 +500,7 @@ but error messages may also be written there, depending on your script. .IP "\fB--separator \fIstring" .IP "\fB--output-separator\fIstring" Specify a string that will separate the output on \fB\*p\fP's output from -checklists, rather than a newline (for --separate-output) or a space. +checklists, rather than a newline (for \fB--separate-output\fP) or a space. This applies to other widgets such as forms and editboxes which normally use a newline. . @@ -498,7 +528,8 @@ draw a scrollbar on its right-margin. This does not respond to the mouse. . .IP "\fB--separate-output" -For checklist widgets, output result one line at a time, with no quoting. +For certain widgets (buildlist, checklist, treeview), +output result one line at a time, with no quoting. This facilitates parsing by another program. . .IP "\fB--separate-widget \fIstring" @@ -610,20 +641,20 @@ Override the label used for "Yes" buttons. .\" ************************************************************************ .SS Box Options All dialog boxes have at least three parameters: -.TP 5 +.TP 7 \fItext\fP the caption or contents of the box. -.TP 5 +.TP 7 \fIheight\fP the height of the dialog box. -.TP 5 +.TP 7 \fIwidth\fP the width of the dialog box. .PP Other parameters depend on the box type. . . -.IP "\fB--buildlist \fItext height width \fR[ \fItag item status \fR] \fI..." +.IP "\fB--buildlist \fItext height width list-height \fR[ \fItag item status \fR] \fI..." A \fBbuildlist\fP dialog displays two lists, side-by-side. The list on the left shows unselected items. The list on the right shows selected items. @@ -647,7 +678,7 @@ If \fB--visit-items\fP is given, tab-traversal uses four states (Left/Right/OK/Cancel). .RE .IP -Whether or not \fB--visit--items\fP is given, +Whether or not \fB--visit-items\fP is given, it is possible to move the highlight between the two lists using the default "^" (left-column) and "$" (right-column) keys. .IP @@ -667,7 +698,7 @@ month, day and year in separately adjustable windows. If the values for day, month or year are missing or negative, the current date's corresponding values are used. You can increment or decrement any of those using the -left-, up-, right- and down-arrows. +left-, up-, right-, and down-arrows. Use vi-style h, j, k and l for moving around the array of days in a month. Use tab or backtab to move between windows. If the year is given as zero, the current date is used as an initial value. @@ -862,7 +893,7 @@ There are only a few differences between them: The entries are not automatically centered but left adjusted. .TP 2. -An extra button (called \fIRename\fP) is implied to rename +An extra button (called \fIRename\/\fP) is implied to rename the current item when it is pressed. .TP 3. @@ -888,9 +919,8 @@ menu. The \fIitem\fP is a short description of the option that the entry represents. The user can move between the menu entries by pressing the cursor keys, the first letter of the \fItag\fP -as a hot-key, or the number keys -.IR 1-9 ". There are" -\fImenu-height\fP +as a hot-key, or the number keys \fI1\fP through \fI9\fP. +There are \fImenu-height\fP entries displayed in the menu at one time, but the menu will be scrolled if there are more entries than that. .IP @@ -921,7 +951,7 @@ A box displays a meter along the bottom of the box. The meter indicates the percentage. .IP -It also displays a list of the \fItag\fP- and \fIitem\fP-values at the +It also displays a list of the \fItag\/\fP- and \fIitem\/\fP-values at the top of the box. See \*l(3) for the tag values. .IP @@ -1057,7 +1087,7 @@ but an ESC exit status may be returned. . . .nf -.IP "\fB--rangebox \fItext height width list-height min-value max-value default-value" +.IP "\fB--rangebox \fItext height width min-value max-value default-value" .fi Allow the user to select from a range of values, e.g., using a slider. The dialog shows the current value as a bar (like the gauge dialog). @@ -1126,7 +1156,7 @@ and \fIHOME/END\fR keys available on most keyboards. If the lines are too long to be displayed in the box, the \fILEFT/RIGHT\fP keys can be used to scroll the text region horizontally. -You may also use vi-style keys h, j, k, l in place of the cursor keys, +You may also use vi-style keys h, j, k, and l in place of the cursor keys, and B or N in place of the page-up and page-down keys. Scroll up/down using vi-style 'k' and 'j', or arrow-keys. Scroll left/right using vi-style 'h' and 'l', or arrow-keys. @@ -1176,10 +1206,9 @@ appropriate places. The \fItext\fP string can also contain the sub-string -.I -"\en" +.RI """" \en """" or newline characters -\fI`\en'\fP +.RI ` \en ' to control line breaking explicitly. This dialog box is useful for asking questions that require the user to answer either yes or no. @@ -1214,8 +1243,9 @@ Beep after a user has completed a widget by pressing one of the buttons. 1. Create a sample configuration file by typing: .LP -.in +1i -"\*p --create-rc " +.Ex +\*p --create-rc \fIfile\fP +.Ee .TP 4 2. At start, @@ -1277,9 +1307,10 @@ may have separate keybindings from the main widget because the subwindows are registered using a different name. .TS center tab(/) ; -l l l +lI lI lI +_ _ _ l l l . -\fIWidget\fR/\fIWindow name\fR/\fISubwindow Name\fR +Widget/Window name/Subwindow Name calendar/calendar checklist/checklist editbox/editbox/editbox2 @@ -1295,6 +1326,7 @@ tailbox/tailbox textbox/textbox/searchbox timebox/timebox yesno/yesno +_ .TE .PP Some widgets are actually other widgets, @@ -1302,9 +1334,10 @@ using internal settings to modify the behavior. Those use the same widget name as the actual widget: .TS center tab(/) ; -l l +lI lI +_ _ l l . -\fIWidget\fR/\fIActual Widget\fR +Widget/Actual Widget dselect/fselect infobox/msgbox inputmenu/menu @@ -1314,6 +1347,7 @@ passwordform/form prgbox/progressbox programbox/progressbox tailboxbg/tailbox +_ .TE .SS Built-in Bindings This manual page does not list the key bindings for each widget, @@ -1333,7 +1367,7 @@ widgets, e.g., when using multiple tailboxbg widgets. Some users may wish to use the same key for traversing within the editing part as for traversing between buttons. The form widget is written to support this sort of redefinition of -the keys, by adding a special group in dlgk_keys.h +the keys, by adding a special group in \fBdlgk_keys.h\fP for "form" (left/right/next/prev). Here is an example binding demonstrating how to do this: .Ex @@ -1379,13 +1413,13 @@ to use. \fBDIALOG_OK\fP Define any of these variables to change the exit code on Cancel (1), -error (-1), +error (\-1), ESC (255), Extra (3), Help (2), Help with \fB--item-help\fP (2), or OK (0). -Normally shell scripts cannot distinguish between -1 and 255. +Normally shell scripts cannot distinguish between \-1 and 255. .TP 15 \fBDIALOG_TTY\fP Set this variable to "1" to provide compatibility with older versions @@ -1405,9 +1439,7 @@ The default values and corresponding environment variables that can override them are: .TP 5 0 -if -.BR \*p " is exited by pressing the " Yes " or " OK -button (DIALOG_OK). +if the \fBYES\fP or \fBOK\fP button is pressed (DIALOG_OK). .TP 5 1 if the @@ -1417,7 +1449,9 @@ button is pressed (DIALOG_CANCEL). 2 if the .BR Help -button is pressed (DIALOG_HELP). +button is pressed (DIALOG_HELP), +.br +except as noted below about DIALOG_ITEM_HELP. .TP 5 3 if the @@ -1427,13 +1461,21 @@ button is pressed (DIALOG_EXTRA). 4 if the .BR Help -button is pressed (DIALOG_HELP), -or the \fB--item-help\fP option is set -when the \fBHelp\fP button is pressed (DIALOG_ITEM_HELP), +button is pressed, +.br +and the \fB--item-help\fP option is set +.br +and the DIALOG_ITEM_HELP environment variable is set to 4. +.IP +While any of the exit-codes can be overridden using environment variables, +this special case was introduced in 2004 to simplify compatibility. +\fB\*L\fP uses DIALOG_ITEM_HELP(4) internally, +but unless the environment variable is also set, +it changes that to DIALOG_HELP(2) on exit. .TP 5 --1 +\-1 if errors occur inside \fB\*p\fP (DIALOG_ERROR) -or \fB\*p\fP is exited by pressing the \fIESC\fP key (DIALOG_ESC). +or \fB\*p\fP exits because the \fIESC\fP key (DIALOG_ESC) was pressed. . .\" ************************************************************************ .SH PORTABILITY @@ -1460,12 +1502,14 @@ The \fB\*p\fP program maps those deprecated options to the preferred ones. They include: .RS .TS -l l +tab(/) ; +lI lI _ _ l l. -\fIOption\fR \fITreatment\fR -\fB--beep-after\fP ignored -\fB--guage\fP mapped to \fB--gauge\fP +Option/Treatment +\fB--beep-after\fP/ignored +\fB--guage\fP/mapped to \fB--gauge\fP +_ .TE .RE .SS XDIALOG @@ -1478,22 +1522,24 @@ The \fB\*p\fP program ignores these options which are recognized by \fBXdialog\fP: .RS .TS -l l +tab(/) ; +lI lI _ _ l l. -\fIOption\fR \fITreatment\fR -\fB--allow-close\fP ignored -\fB--auto-placement\fP ignored -\fB--fixed-font\fP ignored -\fB--icon\fP ignored -\fB--keep-colors\fP ignored -\fB--no-close\fP ignored -\fB--no-cr-wrap\fP ignored -\fB--screen-center\fP ignored -\fB--separator\fP mapped to \fB--separate-output\fP -\fB--smooth\fP ignored -\fB--under-mouse\fP ignored -\fB--wmclass\fP ignored +Option/Treatment +\fB--allow-close\fP/ignored +\fB--auto-placement\fP/ignored +\fB--fixed-font\fP/ignored +\fB--icon\fP/ignored +\fB--keep-colors\fP/ignored +\fB--no-close\fP/ignored +\fB--no-cr-wrap\fP/ignored +\fB--screen-center\fP/ignored +\fB--separator\fP/mapped to \fB--separate-output\fP +\fB--smooth\fP/ignored +\fB--under-mouse\fP/ignored +\fB--wmclass\fP/ignored +_ .TE .RE .PP @@ -1502,12 +1548,13 @@ There are some differences not shown in the manpage. For example, the html documentation states .RS .PP -Note: former Xdialog releases used the "\n" (line feed) as a -results separator for the checklist widget; this has been -changed to "/" in Xdialog v1.5.0 so to make it compatible with -(c)dialog. In your old scripts using the Xdialog checklist, you -will then have to add the --separate-output option before the ---checklist one. +Note: former Xdialog releases used the "\en" (line feed) as a +results separator for the checklist widget; +this has been changed to "/" in Xdialog v1.5.0 +to make it compatible with (c)dialog. +In your old scripts using the Xdialog checklist, you +will then have to add the \fB--separate-output\fP option before the +\fB--checklist\fP one. .RE .PP \fB\*L\fP has not used a different separator; @@ -1517,25 +1564,23 @@ Then there is \fBwhiptail\fP. For practical purposes, it is maintained by Debian (very little work is done by its upstream developers). Its documentation (README.whiptail) claims -.RS -.sp -.nf +.Ex whiptail(1) is a lightweight replacement for \*p(1), to provide dialog boxes for shell scripts. It is built on the newt windowing library rather than the ncurses library, allowing -it to be smaller in embedded enviroments such as installers, +it to be smaller in embedded environments such as installers, rescue disks, etc. -.sp + whiptail is designed to be drop-in compatible with \*p, but has less features: some dialog boxes are not implemented, such as tailbox, timebox, calendarbox, etc. -.fi -.RE +.Ee .PP Comparing actual sizes (Debian testing, 2007/1/10): -The total of sizes for \fBwhiptail\fP, the newt, popt and slang libraries is 757kb. -The comparable number for \fB\*p\fP (counting ncurses) is 520kb. +The total of sizes for \fBwhiptail\fP, +the newt, popt and slang libraries is 757\ KB. +The comparable number for \fB\*p\fP (counting ncurses) is 520\ KB. Disregard the first paragraph. .PP The second paragraph is misleading, since \fBwhiptail\fP @@ -1570,21 +1615,23 @@ The \fB\*p\fP program ignores or maps these options which are recognized by \fBwhiptail\fP: .RS .TS -l l +tab(/) ; +lI lI _ _ l l. -\fIOption\fR \fITreatment\fR -\fB--cancel-button\fP mapped to \fB--cancel-label\fP -\fB--fb\fP ignored -\fB--fullbutton\fP ignored -\fB--no-button\fP mapped to \fB--no-label\fP -\fB--nocancel\fP mapped to \fB--no-cancel\fP -\fB--noitem\fP mapped to \fB--no-items\fP -\fB--notags\fP mapped to \fB--no-tags\fP -\fB--ok-button\fP mapped to \fB--ok-label\fP -\fB--scrolltext\fP mapped to \fB--scrollbar\fP -\fB--topleft\fP mapped to \fB--begin 0 0\fP -\fB--yes-button\fP mapped to \fB--yes-label\fP +Option/Treatment +\fB--cancel-button\fP/mapped to \fB--cancel-label\fP +\fB--fb\fP/ignored +\fB--fullbutton\fP/ignored +\fB--no-button\fP/mapped to \fB--no-label\fP +\fB--nocancel\fP/mapped to \fB--no-cancel\fP +\fB--noitem\fP/mapped to \fB--no-items\fP +\fB--notags\fP/mapped to \fB--no-tags\fP +\fB--ok-button\fP/mapped to \fB--ok-label\fP +\fB--scrolltext\fP/mapped to \fB--scrollbar\fP +\fB--topleft\fP/mapped to \fB--begin 0 0\fP +\fB--yes-button\fP/mapped to \fB--yes-label\fP +_ .TE .RE .LP @@ -1611,13 +1658,13 @@ thereby getting better resolution. Perhaps. .SH AUTHOR .LP -Thomas E. Dickey (updates for 0.9b and beyond) +Thomas E.\& Dickey (updates for 0.9b and beyond) .SH CONTRIBUTORS -Kiran Cherupally - the mixed form and mixed gauge widgets. +Kiran Cherupally \(en the mixed form and mixed gauge widgets. .LP -Tobias C. Rittweiler +Tobias C.\& Rittweiler .LP -Valery Reznic - the form and progressbox widgets. +Valery Reznic \(en the form and progressbox widgets. .LP Yura Kalinichenko adapted the gauge widget as "pause". .PP @@ -1625,10 +1672,10 @@ This is a rewrite (except as needed to provide compatibility) of the earlier version of \fB\*p 0.9a\fP, which lists as authors: .bP -Savio Lam - version 0.3, "dialog" +Savio Lam \(en version 0.3, "dialog" .bP -Stuart Herbert - patch for version 0.4 +Stuart Herbert \(en patch for version 0.4 .bP -Marc Ewing - the gauge widget. +Marc Ewing \(en the gauge widget. .bP -Pasquale De Marco "Pako" - version 0.9a, "cdialog" +Pasquale De Marco "Pako" \(en version 0.9a, "cdialog" diff --git a/contrib/dialog/dialog.3 b/contrib/dialog/dialog.3 index b37a25b07a..5b05f48bc2 100644 --- a/contrib/dialog/dialog.3 +++ b/contrib/dialog/dialog.3 @@ -1,6 +1,6 @@ '\" t -.\" $Id: dialog.3,v 1.90 2012/12/23 22:16:50 tom Exp $ -.\" Copyright 2005-2011,2012 Thomas E. Dickey +.\" $Id: dialog.3,v 1.101 2014/09/01 16:05:44 tom Exp $ +.\" Copyright 2005-2013,2014 Thomas E. Dickey .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU Lesser General Public License, version 2.1 @@ -39,7 +39,7 @@ .de bP .IP \(bu 4 .. -.TH \*D 3 "" "$Date: 2012/12/23 22:16:50 $" +.TH \*D 3 "" "$Date: 2014/09/01 16:05:44 $" .SH NAME dialog \- widgets and utilities for the \*p program .SH SYNOPSIS @@ -47,12 +47,12 @@ dialog \- widgets and utilities for the \*p program .br \ \ \ or .br -.B cc `\*p-config --cflags` file ... `\*p-config --libs` ] +.B cc $(\*p-config --cflags) file ... $(\*p-config --libs) ] .sp .B #include <\*l.h> .PP \fB\*L\fP -is a program that will let you to present a variety of questions or +is a program that will let you present a variety of questions or display messages using dialog boxes from a shell script. It is built from the \fB\*l\fP library, which consists of several widgets @@ -63,12 +63,29 @@ or the main program. This manpage documents the features from \fI<\*l.h>\fP which are likely to be important to developers using the widgets directly. Some hints are also given for developing new widgets. +.PP +Here is a \fB\*l\fP version of \fIHello World\/\fP: +.RS +.nf +int main(void) +{ + int status; + init_dialog(stdin, stdout); + status = dialog_yesno( + "Hello, in dialog-format", + "Hello World!", + 0, 0); + end_dialog(); + return status; +} +.fi +.RE . .\" ************************************************************************ .SH DEFINITIONS Exit codes (passed back to the main program for its use) are defined with a "\fIDLG_EXIT_\fP prefix. -The defined constants can be mapped using environment variables +The efined constants can be mapped using environment variables as described in \fB\*p\fP(1), e.g., \fIDLG_EXIT_OK\fP corresponds to \fI$DIALOG_OK\fP. .PP @@ -78,12 +95,13 @@ are named with the "\fICHR_\fP" prefix, e.g., .PP Colors and video attributes are categorized and associated with settings in the configuration file -(see the discussion of \fI$DIALOGRC\fP in \fB\*p\fP(1)). +(see the discussion of \fI$DIALOGRC\fP in \fB\*p\/\fP(1)). The \fIDIALOG_ATR(n)\fP macro is used for defining the references to the combined color and attribute table \fBdlg_color_table[]\fP. .PP The \fB\*p\fP application passes its command-line parameters -to the widget functions. Some of those parameters are single values, +to the widget functions. +Some of those parameters are single values, but some of the widgets accept data as an array of values. Those include checklist/radiobox, menubox and formbox. When the \fB--item-help\fP option is given, an extra column @@ -94,7 +112,7 @@ macros are used to hide this difference from the calling application. Most of the other definitions found in \fI<\*l.h>\fP are used for convenience in building the library or main program. These include definitions based on the generated \fI\fP header. - +. .\" ************************************************************************ .SH DATA STRUCTURES All of the global data for the \fB\*l\fP library is stored in @@ -127,9 +145,15 @@ sizing (specifying 0 for height and width). It represents width / height. The default is 9, which means 9 characters wide to every 1 line high. .\" --------------------------------------------------------------------------- +.IP \fIDIALOG_STATE.finish_string +When set to true, this allows calls to \fBdlg_finish_string\fP to discard the +corresponding data which is created to speed up layout computations for the +given string parameter. +The \fBgauge\fP widget uses this feature. +.\" --------------------------------------------------------------------------- .IP \fIDIALOG_STATE.getc_callbacks This is setup in \fIui_getc.c\fP to record windows which must be polled -for input, e.g,. to handle the background tailbox widget. +for input, e.g., to handle the background tailbox widget. One window is designated as the foreground or control window. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_STATE.getc_redirect @@ -196,14 +220,14 @@ If this option is not given, the default separator string is a tab character. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_STATE.tab_len -This corresponds to the command-line option "\fB--tab-len\fP \fInumber\fP". +This corresponds to the command-line option "\fB--tab-len\fP \fInumber\/\fP". Specify the number of spaces that a tab character occupies if the "\fB--tab-correct\fP" option is given. The default is 8. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_STATE.trace_output -This corresponds to the command-line option "\fB--trace\fP \fIfile\fP". +This corresponds to the command-line option "\fB--trace\fP \fIfile\/\fP". It is the file pointer to which trace messages are written. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_STATE.use_colors @@ -235,7 +259,7 @@ It causes line-drawing to be done with ASCII characters, e.g., "+" and "-". See \fIDIALOG_VARS.no_lines\fP. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.backtitle -This corresponds to the command-line option "\fB--backtitle\fP \fIbacktitle\fP". +This corresponds to the command-line option "\fB--backtitle\fP \fIbacktitle\/\fP". It specifies a \fIbacktitle\fP string to be displayed on the backdrop, at the top of the screen. @@ -249,19 +273,19 @@ This corresponds to the command-line option "\fB--beep\fP". It is obsolete. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.begin_set -This is true if the command-line option "\fB--begin y x\fP" was used. +This is true if the command-line option "\fB--begin\fP \fIy x\/\fP" was used. It specifies the position of the upper left corner of a dialog box on the screen. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.begin_x This corresponds to the \fIx\fP value from -the command-line option "\fB--begin\fP \fIy x\fP" (second value). +the command-line option "\fB--begin\fP \fIy x\/\fP" (second value). .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.begin_y This corresponds to the \fIy\fP value from -the command-line option "\fB--begin\fP \fIy x\fP" (first value). +the command-line option "\fB--begin\fP \fIy x\/\fP" (first value). .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.cancel_label -This corresponds to the command-line option "\fB--cancel-label\fP \fIstring\fP". +This corresponds to the command-line option "\fB--cancel-label\fP \fIstring\/\fP". The given \fIstring\fP overrides the label used for "Cancel" buttons. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.cant_kill @@ -276,7 +300,7 @@ SIGHUP is disabled for the background process. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.colors This corresponds to the command-line option "\fB--colors\fP". -If true, interpret embedded "\\Z" sequences in the dialog text +If true, interpret embedded "\eZ" sequences in the dialog text by the following character, which tells \fB\*p\fP to set colors or video attributes: 0 through 7 are the ANSI codes used in curses: @@ -291,9 +315,9 @@ white respectively. Bold is set by 'b', reset by 'B'. Reverse is set by 'r', reset by 'R'. Underline is set by 'u', reset by 'U'. -The settings are cumulative, e.g., "\\Zb\\Z1" makes the following text +The settings are cumulative, e.g., "\eZb\eZ1" makes the following text bright red. -Restore normal settings with "\\Zn". +Restore normal settings with "\eZn". .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.column_separator This corresponds to the command-line option "\fB--column-separator\fP". @@ -312,7 +336,7 @@ in the source code of your script without affecting the way it will look in the dialog. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.date_format -This corresponds to the command-line option "\fB--date-format\fP \fIstring\fP". +This corresponds to the command-line option "\fB--date-format\fP \fIstring\/\fP". If the host provides \fBstrftime\fP, and the value is nonnull, the calendar widget uses this to format its output. .\" --------------------------------------------------------------------------- @@ -321,7 +345,7 @@ This is set by the command-line option "\fB--default-button\fP. It is used by \fBdlg_default_button\fP. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.default_item -This corresponds to the command-line option "\fB--default-item\fP \fIstring\fP". +This corresponds to the command-line option "\fB--default-item\fP \fIstring\/\fP". The given string is used as the default item in a checklist, form or menu box. Normally the first item in the box is the default. @@ -355,7 +379,7 @@ If true, some widgets show an extra button, between "OK" and "Cancel" buttons. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.extra_label -This corresponds to the command-line option "\fB--extra-label\fP \fIstring\fP". +This corresponds to the command-line option "\fB--extra-label\fP \fIstring\/\fP". The given string overrides the label used for "Extra" buttons. Note: for inputmenu widgets, this defaults to "Rename". .\" --------------------------------------------------------------------------- @@ -375,16 +399,16 @@ Otherwise, the return status will indicate that the Help button was pressed, and no message printed. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.help_file -This corresponds to the command-line option "\fB--hfile\fP \fIstring\fP". +This corresponds to the command-line option "\fB--hfile\fP \fIstring\/\fP". The given filename is passed to \fBdialog_helpfile\fP when the user presses F1. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.help_label -This corresponds to the command-line option "\fB--help-label\fP \fIstring\fP". +This corresponds to the command-line option "\fB--help-label\fP \fIstring\/\fP". The given string overrides the label used for "Help" buttons. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.help_line -This corresponds to the command-line option "\fB--hline\fP \fIstring\fP". +This corresponds to the command-line option "\fB--hline\fP \fIstring\/\fP". The given string is displayed in the bottom of dialog windows, like a subtitle. .\" --------------------------------------------------------------------------- @@ -396,6 +420,14 @@ after the item-help "HELP" information. This can be used to reconstruct the state of a checklist after processing the help request. .\" --------------------------------------------------------------------------- +.IP \fIDIALOG_VARS.help_tags +This corresponds to the command-line option "\fB--help-tags\fP". +If true, +\fBdlg_add_help_formitem\fP and +\fBdlg_add_help_listitem\fP use the item's tag value consistently +rather than using the tag's help-text value +when \fIDIALOG_VARS.item_help\fP is set. +.\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.input_length This is nonzero if \fIDIALOG_VARS.input_result\fP is allocated, versus being a pointer to the user's local variables. @@ -407,7 +439,7 @@ implements a menu versus a inputmenu widget. .IP \fIDIALOG_VARS.input_result This may be either a user-supplied buffer, or a buffer dynamically allocated by the library, -depending on \fIDIALOG_VARS.input_length\fP: +depending on \fIDIALOG_VARS.input_length\/\fP: .RS .bP If \fIDIALOG_VARS.input_length\fP is zero, @@ -445,7 +477,7 @@ screen, for the currently selected item. .IP \fIDIALOG_VARS.keep_tite This is set by the command-line option "\fB--keep-tite\fP" to tell \fB\*p\fP to not attempt to cancel the terminal initialization -(termcap \fIti\fP/\fIte\fP) sequences which correspond to xterm's alternate-screen +(termcap \fIti\/\fP/\,\fIte\/\fP) sequences which correspond to xterm's alternate-screen switching. Normally \fB\*p\fP does this to avoid flickering when run several times in a script. @@ -457,8 +489,11 @@ This is useful for keeping the window contents visible when several widgets are run in the same process. Note that curses will clear the screen when starting a new process. .\" --------------------------------------------------------------------------- +.IP \fIDIALOG_VARS.last_key +This corresponds to the command-line option "\fB--last-key\fP". +.\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.max_input -This corresponds to the command-line option "\fB--max-input\fP \fIsize\fP". +This corresponds to the command-line option "\fB--max-input\fP \fIsize\/\fP". Limit input strings to the given size. If not specified, the limit is 2048. .\" --------------------------------------------------------------------------- @@ -470,7 +505,7 @@ This tells \fB\*p\fP to read shorter rows from data, omitting the "list". .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.no_label -This corresponds to the command-line option "\fB--no-label\fP \fIstring\fP". +This corresponds to the command-line option "\fB--no-label\fP \fIstring\/\fP". The given string overrides the label used for "No" buttons. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.no_lines @@ -480,7 +515,7 @@ See \fIDIALOG_VARS.ascii_lines\fP. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.no_nl_expand This corresponds to the command-line option "\fB--no-nl-expand\fP". -If false, \fBdlg_trim_string\fP converts literal "\\n" substrings +If false, \fBdlg_trim_string\fP converts literal "\en" substrings in a message into newlines. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.no_tags @@ -501,9 +536,9 @@ Here is a table showing how the no_tags and no_items values interact: .TS tab(/); l l l l l -_ _ _ _ _ -l l l c c. +l l l n n. Widget/Fields Shown/Fields Read/.no_items/.no_tags +_ buildlist/item/tag,item/0/0* buildlist/item/tag,item/0/1 buildlist/tag/tag/1/0* @@ -559,7 +594,7 @@ This corresponds to the command-line option "\fB--nook\fP. \fB\*L\fP will suppress the "ok" (or "yes") button from the widget. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.ok_label -This corresponds to the command-line option "\fB--ok-label\fP \fIstring\fP". +This corresponds to the command-line option "\fB--ok-label\fP \fIstring\/\fP". The given string overrides the label used for "OK" buttons. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.print_siz @@ -579,7 +614,7 @@ This facilitates parsing by another program. .IP \fIDIALOG_VARS.single_quoted This corresponds to the command-line option "\fB--single-quoted\fP". If true, -Use single-quoting as needed (and no quotes if unneeded) for the +use single-quoting as needed (and no quotes if unneeded) for the output of checklist's as well as the item-help text. If this option is not set, \fB\*p\fP uses double quotes around each item. The latter requires occasional use of backslashes to make the output useful in @@ -593,7 +628,7 @@ printing the resulting size if it is larger than the screen. (This option is obsolete, since all new-window calls are checked). .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.sleep_secs -This corresponds to the command-line option "\fB--sleep\fP \fIsecs\fP". +This corresponds to the command-line option "\fB--sleep\fP \fIsecs\/\fP". This option is implemented in the main program, not the library. If nonzero, this is the number of seconds after to delay after processing a dialog box. .\" --------------------------------------------------------------------------- @@ -603,17 +638,17 @@ If true, convert each tab character of the text to one or more spaces. Otherwise, tabs are rendered according to the curses library's interpretation. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.time_format -This corresponds to the command-line option "\fB--time-format\fP \fIstring\fP". +This corresponds to the command-line option "\fB--time-format\fP \fIstring\/\fP". If the host provides \fBstrftime\fP, and the value is nonnull, the timebox widget uses this to format its output. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.timeout_secs -This corresponds to the command-line option "\fB--timeout\fP \fIsecs\fP". +This corresponds to the command-line option "\fB--timeout\fP \fIsecs\/\fP". If nonzero, timeout input requests (exit with error code) if no user response within the given number of seconds. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.title -This corresponds to the command-line option "\fB--title\fP \fItitle\fP". +This corresponds to the command-line option "\fB--title\fP \fItitle\/\fP". Specifies a \fItitle\fP string to be displayed at the top of the dialog box. @@ -632,7 +667,7 @@ This is useful as a visual aid, i.e., the cursor position helps some users. .\" --------------------------------------------------------------------------- .IP \fIDIALOG_VARS.yes_label -This corresponds to the command-line option "\fB--yes-label\fP \fIstring\fP". +This corresponds to the command-line option "\fB--yes-label\fP \fIstring\/\fP". The given string overrides the label used for "Yes" buttons. . .\" ************************************************************************ @@ -640,7 +675,7 @@ The given string overrides the label used for "Yes" buttons. .SH WIDGETS Functions that implement major functionality for the command-line \fB\*p\fP program, e.g., widgets, have names beginning "\fIdialog_\fP". - +.PP All dialog boxes have at least three parameters: .TP 5 \fItitle\fP @@ -683,7 +718,7 @@ is the number of rows in \fIitems\fP. .B char ** \fIitems is an array of strings which is viewed either as a list of rows .RS -\fItag item status \fR +\fItag item status\fR .RE .IP or @@ -759,7 +794,7 @@ is the number of rows in \fIitems\fP. .B int \fIitems is an array of strings which is viewed either as a list of rows .RS -\fItag item status \fR +\fItag item status\fR .RE .IP or @@ -876,6 +911,7 @@ implements the "\fB--gauge\fP" option. Alternatively, a simpler or customized gauge widget can be setup using \fBdlg_allocate_gauge\fP, +\fBdlg_reallocate_gauge\fP, \fBdlg_update_gauge\fP and \fBdlg_free_gauge\fP. .RS @@ -1056,7 +1092,7 @@ is an array of strings which is viewed as a list of \fItag\fP and \fIitem\fP val The \fItag\fP values are listed, one per row, in the list at the top of the widget. .IP -The \fIitem\fP values are decoded: digits 0-9 are the following strings +The \fIitem\fP values are decoded: digits 0 through 9 are the following strings .RS .IP 0 Succeeded @@ -1383,6 +1419,63 @@ function to call when input ends, e.g., to free caller's additional data. .RE .\" --------------------------------------------------------------------------- .TP 5 +.B dlg_add_help_formitem +This is a utility function used enforce consistent behavior for +the \fIDIALOG_VARS.help_tags\fP and \fIDIALOG_VARS.item_help\fP variables. +.RS +.TP 5 +.B int *\fIresult\fP +this is updated to DLG_EXIT_ITEM_HELP if \fIDIALOG_VARS.item_help\fP is set. +.TP 5 +.B char **\fItag\fP +the tag- or help-text is stored here. +.TP 5 +.B DIALOG_FORMITEM *\fIitem\fP +contains the list item to use for tag- or help-text. +.RE +.\" --------------------------------------------------------------------------- +.TP 5 +.B dlg_add_help_listitem +This is a utility function used enforce consistent behavior for +the \fIDIALOG_VARS.help_tags\fP and \fIDIALOG_VARS.item_help\fP variables. +.RS +.TP 5 +.B int *\fIresult\fP +this is updated to DLG_EXIT_ITEM_HELP if \fIDIALOG_VARS.item_help\fP is set. +.TP 5 +.B char **\fItag\fP +the tag- or help-text is stored here. +.TP 5 +.B DIALOG_LISTITEM *\fIitem\fP +contains the list item to use for tag- or help-text. +.RE +.\" --------------------------------------------------------------------------- +.TP 5 +.B dlg_add_last_key +Report the last key entered by the user. +This implements the \fB--last-key\fP command-line option, +using \fBdialog_vars.last_key\fP. +.RS +.TP 5 +.B int \fImode +controls the way the last key report is separated from other results: +.RS +.TP 5 +-2 +(no separator) +.TP 5 +-1 +(separator after the key name) +.TP 5 +0 +(separator is optionally before the key name) +.TP 5 +1 +(same as -1) +.RE +.RE +.\" --------------------------------------------------------------------------- +.TP 5 .B dlg_add_quoted Add a quoted string to the result buffer (see \fBdlg_add_result\fP). If no quotes are necessary, none are used. @@ -1808,7 +1901,7 @@ is a list of (pointers to) button labels terminated by a null pointer. .\" --------------------------------------------------------------------------- .TP 5 .B dlg_checklist -This entrypoint provides the \fB--checklist\fP or \fP--radiolist\fP +This entrypoint provides the \fB--checklist\fP or \fB--radiolist\fP functionality without the limitations of \fB\*p\fP's command-line syntax (compare to \fBdialog_checklist\fP). .RS @@ -1945,7 +2038,7 @@ is the string to measure. .TP 5 .B dlg_count_real_columns Returns the number of columns used for a string, -accounting for "\\Z" sequences which can be used for +accounting for "\eZ" sequences which can be used for coloring the text if \fBdialog_vars.colors\fP is set. This is not necessarily the number of bytes in a string. .RS @@ -2128,11 +2221,14 @@ on the top corners of this box. .TP 5 .B WINDOW * \fIwin is the window to update. +.TP 5 .B chtype \fIon_left is used to color the upper/left edges of the box, i.e., the tee-element and horizontal line +.TP 5 .B chtype \fIon_right is used to color the right edge of the box, i.e., the tee-element +.TP 5 .B chtype \fIon_inside is used to fill-color the inside of the box .RE @@ -2219,7 +2315,7 @@ is the index within the list of the selected button. is true if the buttons are arranged in a column rather than a row. .TP 5 .B int \fIlimit -is the number of columns (or rows if \fIvertical\fP) allowed for the display. +is the number of columns (or rows if \fIvertical\/\fP) allowed for the display. .RE .\" --------------------------------------------------------------------------- .TP 5 @@ -2370,13 +2466,13 @@ If it is null, then only built-in bindings are dumped. Remove one or more items from an argument vector. .RS .TP 5 -.B int *argcp +.B int * \fIargcp in/out parameter giving the length of the argument vector. -.B char ***argvp +.B char *** \fIargvp in/out parameter pointing to the argument vector. -.B int start +.B int \fIstart starting index. -.B int count +.B int \fIcount number of arguments to remove. .RE .\" --------------------------------------------------------------------------- @@ -2490,10 +2586,23 @@ is the character-offset to find. .RE .\" --------------------------------------------------------------------------- .TP 5 +.B dlg_finish_string +If \fIDIALOG_STATE.finish_string\fP is true, +this function discards data used to speed up layout computations. +.RS +.TP 5 +.B const char * \fIstring +is the address of the string whose data should be discarded. +The address rather than contents is used as the unique identifier because +some of the caching is used for editable input-fields. +.RE +.\" --------------------------------------------------------------------------- +.TP 5 .B dlg_flush_getc Cancel the local data saved by \fBdlg_last_getc\fP. .\" --------------------------------------------------------------------------- -.IP dlg_editbox +.TP 5 +.B dlg_editbox This entrypoint provides the \fB--editbox\fP functionality without the limitations of \fB\*p\fP's command-line syntax (compare to \fBdialog_editbox\fP). @@ -2825,7 +2934,7 @@ Free the memory associated with mouse regions. .\" --------------------------------------------------------------------------- .TP 5 .B dlg_mouse_mkbigregion -Creates a region on which the mouse-clicks will return a specifed code. +Creates a region on which the mouse-clicks will return a specified code. .RS .TP 5 .B int \fIy @@ -3056,8 +3165,8 @@ a curses-ordinate from a dialog-ordinate. .\" --------------------------------------------------------------------------- .TP 5 .B dlg_parse_bindkey -Parse the parameters of the "bindkeys" configuration-file entry. This -expects widget name which may be "*", followed by curses key definition and +Parse the parameters of the "bindkeys" configuration-file entry. +This expects widget name which may be "*", followed by curses key definition and then \fB\*p\fP key definition. .RS .TP 5 @@ -3274,6 +3383,38 @@ Display the background title if \fBdialog_vars.backtitle\fP is non-null. The background title is shown at the top of the screen. .\" --------------------------------------------------------------------------- .TP 5 +.B dlg_reallocate_gauge +Allocates or reallocates a gauge widget (see \fBdlg_allocate_gauge\fP). +Use \fBdlg_update_gauge\fP to display the result. +.RS +.TP 5 +.B void ** \fIobjptr +If the pointer referenced by this parameter is null, the function creates +a new gauge widget using \fBdlg_allocate_gauge\fP. +Otherwise, it updates the title and cprompt values, reusing the window +from the previous call on this function. +As a side-effect, the function stores the updated object-pointer via +the \fIobjptr\fP parameter. +.TP 5 +.B const char * \fItitle +is the title string to display at the top of the widget. +.TP 5 +.B const char * \fIcprompt +is the prompt text shown within the widget. +.TP 5 +.B int \fIheight +is the desired height of the box. +If zero, the height is adjusted to use the available screen size. +.TP 5 +.B int \fIwidth +is the desired width of the box. +If zero, the height is adjusted to use the available screen size. +.TP 5 +.B int \fIpercent +is the percentage to show in the progress bar. +.RE +.\" --------------------------------------------------------------------------- +.TP 5 .B dlg_register_buttons The widget developer should call this function after \fBdlg_register_window\fP, for the list of button labels associated with the widget. @@ -3513,10 +3654,10 @@ translate the parameters into a printable representation, log it on a "chr" line. .RS .TP 5 -.B int ch +.B int \fIch is the nominal keycode value. .TP 5 -.B int fkey +.B int \fIfkey is nonzero if the value is really a function key. Some of these may be values declared in the DLG_KEYS_ENUM. .RE @@ -3540,7 +3681,7 @@ It uses an extra level of parentheses to work with a variable number of parameters, e.g., .ES .EX -DLG_TRACE(("this is dialog version %s\\n", dialog_version())); +DLG_TRACE(("this is dialog version %s\en", dialog_version())); .EE .\" --------------------------------------------------------------------------- .TP 5 @@ -3608,8 +3749,8 @@ item (cursor) when it returns. .B dlg_trim_string The \fBdialog\fP program uses this in each widget to adjust the message string, -which may contain the newline character (referred to as '\\n') -and/or the special substring "\\n" +which may contain the newline character (referred to as '\en') +and/or the special substring "\en" (which can be translated into a newline character). .IP There are several optional features: @@ -3618,21 +3759,21 @@ There are several optional features: Unless \fBdialog_vars.no_nl_expand\fP is set, .RS .bP -If it has "\\n" substrings, +If it has "\en" substrings, the function preserves extra spaces. For instance, spaces following a newline (substring or character) are preserved to use as an indentation. .bP -The function changes embedded "\\n" substrings to '\\n' characters. +The function changes embedded "\en" substrings to '\en' characters. .RE .bP If \fBdialog_vars.no_nl_expand\fP is not set, -or if there are no "\\n" substrings, +or if there are no "\en" substrings, this function strips all extra spaces to simplify justification. .bP If \fBdialog_vars.cr_wrap\fP is set, -the function preserves '\\n' newline characters. -Otherwise, each '\\n' newline character is converted to a space. +the function preserves '\en' newline characters. +Otherwise, each '\en' newline character is converted to a space. .bP Unless \fBdialog_vars.nocollapse\fP is set, each tab character is converted to a space, @@ -3684,4 +3825,4 @@ Return a list of buttons for Yes/No labels. . .\" ************************************************************************ .SH AUTHOR -Thomas E. Dickey +Thomas E.\& Dickey diff --git a/contrib/dialog/dialog.c b/contrib/dialog/dialog.c index 66f2c91311..1677ff9055 100644 --- a/contrib/dialog/dialog.c +++ b/contrib/dialog/dialog.c @@ -1,9 +1,9 @@ /* - * $Id: dialog.c,v 1.228 2012/12/30 21:59:39 tom Exp $ + * $Id: dialog.c,v 1.240 2015/09/20 23:48:54 tom Exp $ * * cdialog - Display simple dialog boxes from shell scripts * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2014,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -71,6 +71,7 @@ typedef enum { ,o_help_label ,o_help_line ,o_help_status + ,o_help_tags ,o_icon ,o_ignore ,o_infobox @@ -82,6 +83,7 @@ typedef enum { ,o_keep_colors ,o_keep_tite ,o_keep_window + ,o_last_key ,o_max_input ,o_menu ,o_mixedform @@ -228,6 +230,7 @@ static const Options options[] = { { "help-button", o_help_button, 1, "" }, { "help-label", o_help_label, 1, "" }, { "help-status", o_help_status, 1, "" }, + { "help-tags", o_help_tags, 1, "" }, { "hfile", o_help_file, 1, "" }, { "hline", o_help_line, 1, "" }, { "icon", o_icon, 1, NULL }, @@ -241,6 +244,7 @@ static const Options options[] = { { "keep-colors", o_keep_colors, 1, NULL }, { "keep-tite", o_keep_tite, 1, "" }, { "keep-window", o_keep_window, 1, "" }, + { "last-key", o_last_key, 1, "" }, { "max-input", o_max_input, 1, "" }, { "menu", o_menu, 2, " ..." }, { "mixedform", o_mixedform, 2, "
..." }, @@ -371,6 +375,7 @@ unescape_argv(int *argcp, char ***argvp) fprintf(stderr, " arg%d:%s\n", k, (*argvp)[k]); } changed = dlg_eat_argv(argcp, argvp, j, 1); + --j; } else if (!strcmp((*argvp)[j], "--file")) { if (++count_includes > limit_includes) dlg_exiterr("Too many --file options"); @@ -409,41 +414,58 @@ unescape_argv(int *argcp, char ***argvp) blob[length] = '\0'; list = dlg_string_to_argv(blob); - if ((added = dlg_count_argv(list)) != 0) { - if (added > 2) { - size_t need = (size_t) (*argcp + added + 1); - if (doalloc) { - *argvp = dlg_realloc(char *, need, *argvp); - assert_ptr(*argvp, "unescape_argv"); - } else { - char **newp = dlg_malloc(char *, need); - assert_ptr(newp, "unescape_argv"); - for (n = 0; n < *argcp; ++n) { - newp[n] = (*argvp)[n]; - } - *argvp = newp; - doalloc = TRUE; + added = dlg_count_argv(list); + if (added > 2) { + /* *argcp arguments before the expansion of --file + - 2 for the removal of '--file ' + + added for the arguments contained in + + 1 for the terminating NULL pointer */ + size_t need = (size_t) (*argcp + added - 1); + if (doalloc) { + *argvp = dlg_realloc(char *, need, *argvp); + assert_ptr(*argvp, "unescape_argv"); + } else { + char **newp = dlg_malloc(char *, need); + assert_ptr(newp, "unescape_argv"); + for (n = 0; n < *argcp; ++n) { + newp[n] = (*argvp)[n]; } - dialog_opts = dlg_realloc(bool, need, dialog_opts); - assert_ptr(dialog_opts, "unescape_argv"); + /* The new array is not NULL-terminated yet. */ + *argvp = newp; + doalloc = TRUE; } - for (n = *argcp; n >= j + 2; --n) { + dialog_opts = dlg_realloc(bool, need, dialog_opts); + assert_ptr(dialog_opts, "unescape_argv"); + + /* Shift the arguments after '--file ' + right by (added - 2) positions */ + for (n = *argcp - 1; n >= j + 2; --n) { (*argvp)[n + added - 2] = (*argvp)[n]; dialog_opts[n + added - 2] = dialog_opts[n]; } - for (n = 0; n < added; ++n) { - (*argvp)[n + j] = list[n]; - dialog_opts[n + j] = FALSE; + } else if (added < 2) { + /* 0 or 1 argument read from the included file + -> shift the arguments after '--file ' + left by (2 - added) positions */ + for (n = j + added; n + 2 - added < *argcp; ++n) { + (*argvp)[n] = (*argvp)[n + 2 - added]; + dialog_opts[n] = dialog_opts[n + 2 - added]; } - *argcp += added - 2; - free(list); } + /* Copy the inserted arguments to *argvp */ + for (n = 0; n < added; ++n) { + (*argvp)[n + j] = list[n]; + dialog_opts[n + j] = FALSE; + } + *argcp += added - 2; + (*argvp)[*argcp] = 0; /* Write the NULL terminator */ + free(list); /* No-op if 'list' is NULL */ + /* Force rescan starting from the first inserted argument */ + --j; + continue; } else { dlg_exiterr("Cannot open --file %s", filename); } - (*argvp)[*argcp] = 0; - ++j; - continue; } else { dlg_exiterr("No value given for --file"); } @@ -490,7 +512,7 @@ isOption(const char *arg) } } } else if (!strncmp(arg, "--", (size_t) 2) && isalpha(UCH(arg[2]))) { - if (strlen(arg) == strspn(arg, OptionChars)) { + if (strlen(arg) == (strspn) (arg, OptionChars)) { result = TRUE; } else { dlg_exiterr("Invalid option \"%s\"", arg); @@ -1095,10 +1117,10 @@ static const Mode modes[] = {o_msgbox, 4, 4, call_msgbox}, {o_infobox, 4, 4, call_infobox}, {o_textbox, 4, 4, call_textbox}, - {o_menu, 7, 0, call_menu}, - {o_inputmenu, 7, 0, call_inputmenu}, - {o_checklist, 8, 0, call_checklist}, - {o_radiolist, 8, 0, call_radiolist}, + {o_menu, 6, 0, call_menu}, + {o_inputmenu, 6, 0, call_inputmenu}, + {o_checklist, 7, 0, call_checklist}, + {o_radiolist, 7, 0, call_radiolist}, {o_inputbox, 4, 5, call_inputbox}, {o_passwordbox, 4, 5, call_passwordbox}, #ifdef HAVE_DLG_GAUGE @@ -1272,7 +1294,7 @@ Help(void) static const char *const tbl_1[] = { "cdialog (ComeOn Dialog!) version %s", - "Copyright 2000-2011,2012 Thomas E. Dickey", + "Copyright 2000-2014,2015 Thomas E. Dickey", "This is free software; see the source for copying conditions. There is NO", "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.", "", @@ -1460,6 +1482,9 @@ process_common_options(int argc, char **argv, int offset, bool output) case o_help_status: dialog_vars.help_status = TRUE; break; + case o_help_tags: + dialog_vars.help_tags = TRUE; + break; case o_extra_button: dialog_vars.extra_button = TRUE; break; @@ -1469,6 +1494,9 @@ process_common_options(int argc, char **argv, int offset, bool output) case o_keep_window: dialog_vars.keep_window = TRUE; break; + case o_last_key: + dialog_vars.last_key = TRUE; + break; case o_no_shadow: dialog_state.use_shadow = FALSE; break; @@ -1844,10 +1872,20 @@ main(int argc, char *argv[]) Usage("Expected a box option"); } - if (lookupOption(argv[offset], 2) != o_checklist - && dialog_vars.separate_output) { - sprintf(temp, "Expected --checklist, not %.20s", argv[offset]); - Usage(temp); + if (dialog_vars.separate_output) { + switch (lookupOption(argv[offset], 2)) { +#ifdef HAVE_XDIALOG2 + case o_buildlist: + case o_treeview: +#endif + case o_checklist: + break; + default: + sprintf(temp, + "Unexpected widget with --separate-output %.20s", + argv[offset]); + Usage(temp); + } } if (dialog_state.aspect_ratio == 0) diff --git a/contrib/dialog/dialog.h b/contrib/dialog/dialog.h index 91ccfa1622..0653ad3ef9 100644 --- a/contrib/dialog/dialog.h +++ b/contrib/dialog/dialog.h @@ -1,9 +1,9 @@ /* - * $Id: dialog.h,v 1.259 2012/12/30 22:37:17 tom Exp $ + * $Id: dialog.h,v 1.268 2015/01/25 23:53:19 tom Exp $ * * dialog.h -- common declarations for all dialog modules * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2013,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -445,6 +445,10 @@ typedef struct { /* 1.1-20110106 */ bool no_mouse; /* option "--no-mouse" */ int visit_cols; /* option "--visit-items" */ + /* 1.2-20130922 */ + bool finish_string; /* caching optimization for gauge */ + /* 1.2-20150125 */ + bool plain_buttons; /* true to suppress button-label highlight */ } DIALOG_STATE; extern DIALOG_STATE dialog_state; @@ -520,6 +524,10 @@ typedef struct { /* 1.1-20121218 */ bool no_tags; /* option "--no-tags" */ bool no_items; /* option "--no-items" */ + /* 1.2-20130315 */ + bool last_key; /* option "--last-key" */ + /* 1.2-20130902 */ + bool help_tags; /* option "--help-tags" */ } DIALOG_VARS; #define USE_ITEM_HELP(s) (dialog_vars.item_help && (s) != 0) @@ -685,6 +693,7 @@ extern void dlg_free_formitems(DIALOG_FORMITEM * /*items*/); /* guage.c */ extern void * dlg_allocate_gauge(const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */); +extern void * dlg_reallocate_gauge(void * /* objptr */, const char * /* title */, const char * /* cprompt */, int /* height */, int /* width */, int /* percent */); extern void dlg_free_gauge(void * /* objptr */); extern void dlg_update_gauge(void * /* objptr */, int /* percent */); @@ -697,6 +706,7 @@ extern int dlg_count_wchars(const char * /*string*/); extern int dlg_edit_offset(char * /*string*/, int /*offset*/, int /*x_last*/); extern int dlg_find_index(const int * /*list*/, int /*limit*/, int /*to_find*/); extern int dlg_limit_columns(const char * /*string*/, int /*limit*/, int /*offset*/); +extern void dlg_finish_string(const char * /* string */); extern void dlg_show_string(WINDOW * /*win*/, const char * /*string*/, int /*offset*/, chtype /*attr*/, int /*y_base*/, int /*x_base*/, int /*x_last*/, bool /*hidden*/, bool /*force*/); /* menubox.c */ @@ -716,6 +726,7 @@ extern int dlg_treeview(const char * /*title*/, const char * /*cprompt*/, int /* extern int dlg_getc(WINDOW * /*win*/, int * /*fkey*/); extern int dlg_getc_callbacks(int /*ch*/, int /*fkey*/, int * /*result*/); extern int dlg_last_getc(void); +extern void dlg_add_last_key(int /*mode*/); extern void dlg_add_callback(DIALOG_CALLBACK * /*p*/); extern void dlg_add_callback_ref(DIALOG_CALLBACK ** /*p*/, DIALOG_FREEBACK /* cleanup */); extern void dlg_flush_getc(void); @@ -746,6 +757,8 @@ extern int dlg_defaultno_button(void); extern int dlg_default_button(void); extern int dlg_max_input(int /*max_len*/); extern int dlg_print_scrolled(WINDOW * /* win */, const char * /* prompt */, int /* offset */, int /* height */, int /* width */, int /* pauseopt */); +extern void dlg_add_help_formitem(int * /* result */, char ** /* tag */, DIALOG_FORMITEM * /* item */); +extern void dlg_add_help_listitem(int * /* result */, char ** /* tag */, DIALOG_LISTITEM * /* item */); extern void dlg_add_quoted(char * /*string*/); extern void dlg_add_result(const char * /*string*/); extern void dlg_add_separator(void); diff --git a/contrib/dialog/dlg_keys.c b/contrib/dialog/dlg_keys.c index 4b59f6b3a8..f451dbd4fb 100644 --- a/contrib/dialog/dlg_keys.c +++ b/contrib/dialog/dlg_keys.c @@ -1,9 +1,9 @@ /* - * $Id: dlg_keys.c,v 1.34 2011/10/14 00:41:08 tom Exp $ + * $Id: dlg_keys.c,v 1.35 2014/01/12 18:21:52 tom Exp $ * * dlg_keys.c -- runtime binding support for dialog * - * Copyright 2006-2009,2011 Thomas E. Dickey + * Copyright 2006-2011,2014 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -230,7 +230,9 @@ dlg_lookup_key(WINDOW *win, int curses_key, int *fkey) } } for (p = all_bindings; p != 0; p = p->link) { - if (p->win == win || (p->win == 0 && !strcmp(p->name, name))) { + if (p->win == win || + (p->win == 0 && + (!strcmp(p->name, name) || !strcmp(p->name, WILDNAME)))) { int function_key = (*fkey != 0); for (q = p->binding; q->is_function_key >= 0; ++q) { if (p->buttons diff --git a/contrib/dialog/editbox.c b/contrib/dialog/editbox.c index 7488d65298..e1165642c1 100644 --- a/contrib/dialog/editbox.c +++ b/contrib/dialog/editbox.c @@ -1,9 +1,9 @@ /* - * $Id: editbox.c,v 1.61 2012/07/01 18:13:32 Zoltan.Kelemen Exp $ + * $Id: editbox.c,v 1.63 2015/01/25 22:57:49 tom Exp $ * * editbox.c -- implements the edit box * - * Copyright 2007-2011,2012 Thomas E. Dickey + * Copyright 2007-2013,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -637,10 +637,14 @@ dlg_editbox(const char *title, /* handle functionkeys */ if (fkey) { switch (key) { + case DLGK_GRID_UP: + case DLGK_GRID_LEFT: case DLGK_FIELD_PREV: show_buttons = TRUE; state = dlg_prev_ok_buttonindex(state, sTEXT); break; + case DLGK_GRID_RIGHT: + case DLGK_GRID_DOWN: case DLGK_FIELD_NEXT: show_buttons = TRUE; state = dlg_next_ok_buttonindex(state, sTEXT); @@ -710,6 +714,7 @@ dlg_editbox(const char *title, dlg_add_result((*list)[n]); dlg_add_separator(); } + dlg_add_last_key(-1); } free(buffer); dlg_restore_vars(&save_vars); diff --git a/contrib/dialog/formbox.c b/contrib/dialog/formbox.c index 5cd8bd4868..b0b207fb90 100644 --- a/contrib/dialog/formbox.c +++ b/contrib/dialog/formbox.c @@ -1,9 +1,9 @@ /* - * $Id: formbox.c,v 1.84 2012/12/30 20:31:53 tom Exp $ + * $Id: formbox.c,v 1.87 2013/09/02 17:02:05 tom Exp $ * * formbox.c -- implements the form (i.e, some pairs label/editbox) * - * Copyright 2003-2011,2012 Thomas E. Dickey + * Copyright 2003-2012,2013 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -915,6 +915,7 @@ dialog_form(const char *title, DIALOG_FORMITEM *listitems; DIALOG_VARS save_vars; bool show_status = FALSE; + char *help_result; dlg_save_vars(&save_vars); dialog_vars.separate_output = TRUE; @@ -954,14 +955,9 @@ dialog_form(const char *title, show_status = TRUE; break; case DLG_EXIT_HELP: - dlg_add_result("HELP "); + dlg_add_help_formitem(&result, &help_result, &listitems[choice]); show_status = dialog_vars.help_status; - if (USE_ITEM_HELP(listitems[choice].help)) { - dlg_add_string(listitems[choice].help); - result = DLG_EXIT_ITEM_HELP; - } else { - dlg_add_string(listitems[choice].name); - } + dlg_add_string(help_result); if (show_status) dlg_add_separator(); break; @@ -973,6 +969,7 @@ dialog_form(const char *title, dlg_add_separator(); } } + dlg_add_last_key(-1); } dlg_free_formitems(listitems); diff --git a/contrib/dialog/guage.c b/contrib/dialog/guage.c index 4c5c8c03f5..db7285afae 100644 --- a/contrib/dialog/guage.c +++ b/contrib/dialog/guage.c @@ -1,9 +1,9 @@ /* - * $Id: guage.c,v 1.65 2012/11/30 10:43:31 tom Exp $ + * $Id: guage.c,v 1.69 2015/02/26 02:07:12 tom Exp $ * * guage.c -- implements the gauge dialog * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2013,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -39,7 +39,7 @@ typedef struct _my_obj { DIALOG_CALLBACK obj; /* has to be first in struct */ struct _my_obj *next; WINDOW *text; - const char *title; + char *title; char *prompt; char prompt_buf[MY_LEN]; int percent; @@ -121,7 +121,7 @@ repaint_text(MY_OBJ * obj) WINDOW *dialog = obj->obj.win; int i, x; - if (dialog != 0 && obj->obj.input != 0) { + if (dialog != 0) { (void) werase(dialog); dlg_draw_box2(dialog, 0, 0, obj->height, obj->width, dialog_attr, border_attr, border2_attr); @@ -187,6 +187,8 @@ handle_input(DIALOG_CALLBACK * cb) if (dialog_state.pipe_input == 0) { status = -1; + delink(obj); + dlg_remove_callback(cb); } else if ((status = read_data(buf, dialog_state.pipe_input)) > 0) { if (isMarker(buf)) { @@ -231,6 +233,7 @@ handle_input(DIALOG_CALLBACK * cb) result = TRUE; repaint_text(obj); } else { + repaint_text(obj); result = FALSE; } @@ -273,61 +276,97 @@ void dlg_update_gauge(void *objptr, int percent) { MY_OBJ *obj = (MY_OBJ *) objptr; + bool save_finish_string = dialog_state.finish_string; + dialog_state.finish_string = TRUE; curs_set(0); obj->percent = percent; repaint_text(obj); + dialog_state.finish_string = save_finish_string; } /* - * Allocates a new object and fills it as per the arguments + * (Re)Allocates an object and fills it as per the arguments */ void * -dlg_allocate_gauge(const char *title, - const char *cprompt, - int height, - int width, - int percent) +dlg_reallocate_gauge(void *objptr, + const char *title, + const char *cprompt, + int height, + int width, + int percent) { - int x, y; char *prompt = dlg_strclone(cprompt); - WINDOW *dialog; - MY_OBJ *obj = 0; + MY_OBJ *obj = objptr; + bool save_finish_string = dialog_state.finish_string; + dialog_state.finish_string = TRUE; dlg_tab_correct_str(prompt); - dlg_auto_size(title, prompt, &height, &width, MIN_HIGH, MIN_WIDE); - dlg_print_size(height, width); - dlg_ctl_size(height, width); + if (objptr == 0) { + /* create a new object */ + obj = dlg_calloc(MY_OBJ, 1); + assert_ptr(obj, "dialog_gauge"); - /* center dialog box on screen */ - x = dlg_box_x_ordinate(width); - y = dlg_box_y_ordinate(height); + dlg_auto_size(title, prompt, &height, &width, MIN_HIGH, MIN_WIDE); + dlg_print_size(height, width); + dlg_ctl_size(height, width); - dialog = dlg_new_window(height, width, y, x); + } else { + /* reuse an existing object */ + obj = objptr; + height = obj->height; + width = obj->width; + } - obj = dlg_calloc(MY_OBJ, 1); - assert_ptr(obj, "dialog_gauge"); + if (obj->obj.win == 0) { + /* center dialog box on screen */ + int x = dlg_box_x_ordinate(width); + int y = dlg_box_y_ordinate(height); + WINDOW *dialog = dlg_new_window(height, width, y, x); + obj->obj.win = dialog; + } obj->obj.input = dialog_state.pipe_input; - obj->obj.win = dialog; obj->obj.keep_win = TRUE; obj->obj.bg_task = TRUE; obj->obj.handle_getc = handle_my_getc; obj->obj.handle_input = handle_input; - obj->title = title; + if (obj->title == 0 || strcmp(obj->title, title)) { + dlg_finish_string(obj->title); + free(obj->title); + obj->title = dlg_strclone(title); + } + + dlg_finish_string(obj->prompt); + free(obj->prompt); + obj->prompt = prompt; obj->percent = percent; obj->height = height; obj->width = width; - obj->next = all_objects; - all_objects = obj; + /* if this was a new object, link it into the list */ + if (objptr == 0) { + obj->next = all_objects; + all_objects = obj; + } + dialog_state.finish_string = save_finish_string; return (void *) obj; } +void * +dlg_allocate_gauge(const char *title, + const char *cprompt, + int height, + int width, + int percent) +{ + return dlg_reallocate_gauge(NULL, title, cprompt, height, width, percent); +} + void dlg_free_gauge(void *objptr) { diff --git a/contrib/dialog/inputstr.c b/contrib/dialog/inputstr.c index a9e90c59da..080ec1f901 100644 --- a/contrib/dialog/inputstr.c +++ b/contrib/dialog/inputstr.c @@ -1,9 +1,9 @@ /* - * $Id: inputstr.c,v 1.72 2012/12/30 22:11:37 tom Exp $ + * $Id: inputstr.c,v 1.84 2014/09/01 16:11:08 tom Exp $ * * inputstr.c -- functions for input/display of a string * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2013,2014 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -51,7 +51,7 @@ typedef struct _cache { struct _cache *next; #if USE_CACHING - struct _cache *cache_at; /* unique: associate caches by CACHE */ + int cache_num; /* tells what type of data is in list[] */ const char *string_at; /* unique: associate caches by char* */ #endif size_t s_len; /* strlen(string) - we add 1 for EOS */ @@ -65,6 +65,14 @@ typedef struct _cache { static CACHE *cache_list; +typedef enum { + cInxCols + ,cCntWideBytes + ,cCntWideChars + ,cInxWideChars + ,cMAX +} CACHE_USED; + #ifdef HAVE_TSEARCH static void *sorted_cache; #endif @@ -89,21 +97,45 @@ have_locale(void) #endif #ifdef HAVE_TSEARCH + +#if 0 +static void +show_tsearch(const void *nodep, const VISIT which, const int depth) +{ + const CACHE *p = *(CACHE * const *) nodep; + (void) depth; + if (which == postorder || which == leaf) { + dlg_trace_msg("\tcache %p %p:%s\n", p, p->string, p->string); + } +} + +static void +trace_cache(const char *fn, int ln) +{ + dlg_trace_msg("trace_cache %s@%d\n", fn, ln); + twalk(sorted_cache, show_tsearch); +} + +#else +#define trace_cache(fn, ln) /* nothing */ +#endif + +#define CMP(a,b) (((a) > (b)) ? 1 : (((a) < (b)) ? -1 : 0)) + static int compare_cache(const void *a, const void *b) { const CACHE *p = (const CACHE *) a; const CACHE *q = (const CACHE *) b; - int result = 0; - result = (int) (p->cache_at - q->cache_at); + int result = CMP(p->cache_num, q->cache_num); if (result == 0) - result = (int) (p->string_at - q->string_at); + result = CMP(p->string_at, q->string_at); return result; } #endif static CACHE * -find_cache(CACHE * cache, const char *string) +find_cache(int cache_num, const char *string) { CACHE *p; @@ -112,7 +144,7 @@ find_cache(CACHE * cache, const char *string) CACHE find; memset(&find, 0, sizeof(find)); - find.cache_at = cache; + find.cache_num = cache_num; find.string_at = string; if ((pp = tfind(&find, &sorted_cache, compare_cache)) != 0) { @@ -122,8 +154,7 @@ find_cache(CACHE * cache, const char *string) } #else for (p = cache_list; p != 0; p = p->next) { - if (p->cache_at == cache - && p->string_at == string) { + if (p->string_at == string) { break; } } @@ -131,8 +162,8 @@ find_cache(CACHE * cache, const char *string) return p; } -static void -make_cache(CACHE * cache, const char *string) +static CACHE * +make_cache(int cache_num, const char *string) { CACHE *p; @@ -141,43 +172,30 @@ make_cache(CACHE * cache, const char *string) p->next = cache_list; cache_list = p; - p->cache_at = cache; + p->cache_num = cache_num; p->string_at = string; - *cache = *p; #ifdef HAVE_TSEARCH (void) tsearch(p, &sorted_cache, compare_cache); #endif + return p; } -static void -load_cache(CACHE * cache, const char *string) -{ - CACHE *p; - - if ((p = find_cache(cache, string)) != 0) { - *cache = *p; - } else { - make_cache(cache, string); - } -} - -static void -save_cache(CACHE * cache, const char *string) +static CACHE * +load_cache(int cache_num, const char *string) { CACHE *p; - if ((p = find_cache(cache, string)) != 0) { - CACHE *q = p->next; - *p = *cache; - p->next = q; + if ((p = find_cache(cache_num, string)) == 0) { + p = make_cache(cache_num, string); } + return p; } #else +static CACHE my_cache; #define SAME_CACHE(c,s,l) (c->string != 0) -#define load_cache(cache, string) /* nothing */ -#define save_cache(cache, string) /* nothing */ -#endif /* USE_WIDE_CURSES */ +#define load_cache(cache, string) &my_cache +#endif /* USE_CACHING */ /* * If the given string has not changed, we do not need to update the index. @@ -188,32 +206,34 @@ same_cache2(CACHE * cache, const char *string, unsigned i_len) { unsigned need; size_t s_len = strlen(string); + bool result = TRUE; + + if (cache->s_len == 0 + || cache->s_len < s_len + || cache->list == 0 + || !SAME_CACHE(cache, string, (size_t) s_len)) { + + need = (i_len + 1); + if (cache->list == 0) { + cache->list = dlg_malloc(int, need); + } else if (cache->i_len < i_len) { + cache->list = dlg_realloc(int, need, cache->list); + } + assert_ptr(cache->list, "load_cache"); + cache->i_len = i_len; - if (cache->s_len != 0 - && cache->s_len >= s_len - && cache->list != 0 - && SAME_CACHE(cache, string, (size_t) s_len)) { - return TRUE; - } - - need = (i_len + 1); - if (cache->list == 0) { - cache->list = dlg_malloc(int, need); - } else if (cache->i_len < i_len) { - cache->list = dlg_realloc(int, need, cache->list); - } - cache->i_len = i_len; + if (cache->s_len >= s_len && cache->string != 0) { + strcpy(cache->string, string); + } else { + if (cache->string != 0) + free(cache->string); + cache->string = dlg_strclone(string); + } + cache->s_len = s_len; - if (cache->s_len >= s_len && cache->string != 0) { - strcpy(cache->string, string); - } else { - if (cache->string != 0) - free(cache->string); - cache->string = dlg_strclone(string); + result = FALSE; } - cache->s_len = s_len; - - return FALSE; + return result; } #ifdef USE_WIDE_CURSES @@ -225,23 +245,24 @@ static bool same_cache1(CACHE * cache, const char *string, size_t i_len) { size_t s_len = strlen(string); + bool result = TRUE; - if (cache->s_len == s_len - && SAME_CACHE(cache, string, (size_t) s_len)) { - return TRUE; - } + if (cache->s_len != s_len + || !SAME_CACHE(cache, string, (size_t) s_len)) { - if (cache->s_len >= s_len && cache->string != 0) { - strcpy(cache->string, string); - } else { - if (cache->string != 0) - free(cache->string); - cache->string = dlg_strclone(string); - } - cache->s_len = s_len; - cache->i_len = i_len; + if (cache->s_len >= s_len && cache->string != 0) { + strcpy(cache->string, string); + } else { + if (cache->string != 0) + free(cache->string); + cache->string = dlg_strclone(string); + } + cache->s_len = s_len; + cache->i_len = i_len; - return FALSE; + result = FALSE; + } + return result; } #endif /* USE_CACHING */ @@ -256,29 +277,26 @@ dlg_count_wcbytes(const char *string, size_t len) int result; if (have_locale()) { - static CACHE cache; - - load_cache(&cache, string); - if (!same_cache1(&cache, string, len)) { + CACHE *cache = load_cache(cCntWideBytes, string); + if (!same_cache1(cache, string, len)) { while (len != 0) { size_t code = 0; - const char *src = cache.string; + const char *src = cache->string; mbstate_t state; - char save = cache.string[len]; + char save = cache->string[len]; - cache.string[len] = '\0'; + cache->string[len] = '\0'; memset(&state, 0, sizeof(state)); code = mbsrtowcs((wchar_t *) 0, &src, len, &state); - cache.string[len] = save; + cache->string[len] = save; if ((int) code >= 0) { break; } --len; } - cache.i_len = len; - save_cache(&cache, string); + cache->i_len = len; } - result = (int) cache.i_len; + result = (int) cache->i_len; } else { result = (int) len; } @@ -293,34 +311,32 @@ int dlg_count_wchars(const char *string) { int result; - #ifdef USE_WIDE_CURSES + if (have_locale()) { - static CACHE cache; size_t len = strlen(string); + CACHE *cache = load_cache(cCntWideChars, string); - load_cache(&cache, string); - if (!same_cache1(&cache, string, len)) { - const char *src = cache.string; + if (!same_cache1(cache, string, len)) { + const char *src = cache->string; mbstate_t state; - int part = dlg_count_wcbytes(cache.string, len); - char save = cache.string[part]; + int part = dlg_count_wcbytes(cache->string, len); + char save = cache->string[part]; size_t code; wchar_t *temp = dlg_calloc(wchar_t, len + 1); if (temp != 0) { - cache.string[part] = '\0'; + cache->string[part] = '\0'; memset(&state, 0, sizeof(state)); code = mbsrtowcs(temp, &src, (size_t) part, &state); - cache.i_len = ((int) code >= 0) ? wcslen(temp) : 0; - cache.string[part] = save; + cache->i_len = ((int) code >= 0) ? wcslen(temp) : 0; + cache->string[part] = save; free(temp); - save_cache(&cache, string); } else { - cache.i_len = 0; + cache->i_len = 0; } } - result = (int) cache.i_len; + result = (int) cache->i_len; } else #endif /* USE_WIDE_CURSES */ { @@ -336,15 +352,14 @@ dlg_count_wchars(const char *string) const int * dlg_index_wchars(const char *string) { - static CACHE cache; unsigned len = (unsigned) dlg_count_wchars(string); unsigned inx; + CACHE *cache = load_cache(cInxWideChars, string); - load_cache(&cache, string); - if (!same_cache2(&cache, string, len)) { + if (!same_cache2(cache, string, len)) { const char *current = string; - cache.list[0] = 0; + cache->list[0] = 0; for (inx = 1; inx <= len; ++inx) { #ifdef USE_WIDE_CURSES if (have_locale()) { @@ -355,17 +370,16 @@ dlg_index_wchars(const char *string) if (width <= 0) width = 1; /* FIXME: what if we have a control-char? */ current += width; - cache.list[inx] = cache.list[inx - 1] + width; + cache->list[inx] = cache->list[inx - 1] + width; } else #endif /* USE_WIDE_CURSES */ { (void) current; - cache.list[inx] = (int) inx; + cache->list[inx] = (int) inx; } } - save_cache(&cache, string); } - return cache.list; + return cache->list; } /* @@ -392,13 +406,12 @@ dlg_find_index(const int *list, int limit, int to_find) const int * dlg_index_columns(const char *string) { - static CACHE cache; unsigned len = (unsigned) dlg_count_wchars(string); unsigned inx; + CACHE *cache = load_cache(cInxCols, string); - load_cache(&cache, string); - if (!same_cache2(&cache, string, len)) { - cache.list[0] = 0; + if (!same_cache2(cache, string, len)) { + cache->list[0] = 0; #ifdef USE_WIDE_CURSES if (have_locale()) { size_t num_bytes = strlen(string); @@ -411,7 +424,7 @@ dlg_index_columns(const char *string) int result; if (string[inx_wchars[inx]] == TAB) { - result = ((cache.list[inx] | 7) + 1) - cache.list[inx]; + result = ((cache->list[inx] | 7) + 1) - cache->list[inx]; } else { memset(&state, 0, sizeof(state)); memset(temp, 0, sizeof(temp)); @@ -432,9 +445,9 @@ dlg_index_columns(const char *string) result = printable ? (int) wcslen(printable) : 1; } } - cache.list[inx + 1] = result; + cache->list[inx + 1] = result; if (inx != 0) - cache.list[inx + 1] += cache.list[inx]; + cache->list[inx + 1] += cache->list[inx]; } } else #endif /* USE_WIDE_CURSES */ @@ -443,24 +456,23 @@ dlg_index_columns(const char *string) chtype ch = UCH(string[inx]); if (ch == TAB) - cache.list[inx + 1] = - ((cache.list[inx] | 7) + 1) - cache.list[inx]; + cache->list[inx + 1] = + ((cache->list[inx] | 7) + 1) - cache->list[inx]; else if (isprint(ch)) - cache.list[inx + 1] = 1; + cache->list[inx + 1] = 1; else { const char *printable; printable = unctrl(ch); - cache.list[inx + 1] = (printable - ? (int) strlen(printable) - : 1); + cache->list[inx + 1] = (printable + ? (int) strlen(printable) + : 1); } if (inx != 0) - cache.list[inx + 1] += cache.list[inx]; + cache->list[inx + 1] += cache->list[inx]; } } - save_cache(&cache, string); } - return cache.list; + return cache->list; } /* @@ -478,6 +490,7 @@ dlg_count_columns(const char *string) } else { result = (int) strlen(string); } + dlg_finish_string(string); return result; } @@ -732,22 +745,59 @@ dlg_show_string(WINDOW *win, } } +/* + * Discard cached data for the given string. + */ +void +dlg_finish_string(const char *string) +{ +#if USE_CACHING + if ((string != 0) && dialog_state.finish_string) { + CACHE *p = cache_list; + CACHE *q = 0; + CACHE *r; + + while (p != 0) { + if (p->string_at == string) { +#ifdef HAVE_TSEARCH + if (tdelete(p, &sorted_cache, compare_cache) == 0) { + continue; + } + trace_cache(__FILE__, __LINE__); +#endif + if (p->string != 0) + free(p->string); + if (p->list != 0) + free(p->list); + if (p == cache_list) { + cache_list = p->next; + r = cache_list; + } else { + q->next = p->next; + r = q; + } + free(p); + p = r; + } else { + q = p; + p = p->next; + } + } + } +#else + (void) string; +#endif +} + #ifdef NO_LEAKS void _dlg_inputstr_leaks(void) { #if USE_CACHING + dialog_state.finish_string = TRUE; + trace_cache(__FILE__, __LINE__); while (cache_list != 0) { - CACHE *next = cache_list->next; -#ifdef HAVE_TSEARCH - tdelete(cache_list, &sorted_cache, compare_cache); -#endif - if (cache_list->string != 0) - free(cache_list->string); - if (cache_list->list != 0) - free(cache_list->list); - free(cache_list); - cache_list = next; + dlg_finish_string(cache_list->string_at); } #endif /* USE_CACHING */ } diff --git a/contrib/dialog/menubox.c b/contrib/dialog/menubox.c index 31174435f8..19f3d5a18f 100644 --- a/contrib/dialog/menubox.c +++ b/contrib/dialog/menubox.c @@ -1,9 +1,9 @@ /* - * $Id: menubox.c,v 1.145 2012/12/30 21:11:02 tom Exp $ + * $Id: menubox.c,v 1.149 2015/01/25 23:53:43 tom Exp $ * * menubox.c -- implements the menu box * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2013,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public Licens, version 2.1e @@ -191,19 +191,16 @@ input_menu_edit(ALL_DATA * data, static int handle_button(int code, DIALOG_LISTITEM * items, int choice) { + char *help_result; + switch (code) { case DLG_EXIT_OK: /* FALLTHRU */ case DLG_EXIT_EXTRA: dlg_add_string(items[choice].name); break; case DLG_EXIT_HELP: - dlg_add_result("HELP "); - if (USE_ITEM_HELP(items[choice].help)) { - dlg_add_string(items[choice].help); - code = DLG_EXIT_ITEM_HELP; - } else { - dlg_add_string(items[choice].name); - } + dlg_add_help_listitem(&code, &help_result, &items[choice]); + dlg_add_string(help_result); break; } return code; @@ -353,6 +350,8 @@ dlg_menu(const char *title, bool is_inputmenu = ((rename_menutext != 0) && (rename_menutext != dlg_dummy_menutext)); + dialog_state.plain_buttons = TRUE; + all.items = items; all.item_no = item_no; diff --git a/contrib/dialog/mixedform.c b/contrib/dialog/mixedform.c index 05ba7b1cf2..3da422f37d 100644 --- a/contrib/dialog/mixedform.c +++ b/contrib/dialog/mixedform.c @@ -1,9 +1,9 @@ /* - * $Id: mixedform.c,v 1.9 2011/10/10 00:49:43 tom Exp $ + * $Id: mixedform.c,v 1.12 2013/09/02 17:02:05 tom Exp $ * * mixedform.c -- implements the mixed form (i.e, typed pairs label/editbox) * - * Copyright 2007-2010,2011 Thomas E. Dickey + * Copyright 2007-2011,2013 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -54,6 +54,7 @@ dialog_mixedform(const char *title, DIALOG_FORMITEM *listitems; DIALOG_VARS save_vars; bool show_status = FALSE; + char *help_result; dlg_save_vars(&save_vars); dialog_vars.separate_output = TRUE; @@ -93,14 +94,9 @@ dialog_mixedform(const char *title, show_status = TRUE; break; case DLG_EXIT_HELP: - dlg_add_result("HELP "); + dlg_add_help_formitem(&result, &help_result, &listitems[choice]); show_status = dialog_vars.help_status; - if (USE_ITEM_HELP(listitems[choice].help)) { - dlg_add_string(listitems[choice].help); - result = DLG_EXIT_ITEM_HELP; - } else { - dlg_add_string(listitems[choice].name); - } + dlg_add_string(help_result); if (show_status) dlg_add_separator(); break; @@ -112,6 +108,7 @@ dialog_mixedform(const char *title, dlg_add_separator(); } } + dlg_add_last_key(-1); } dlg_free_formitems(listitems); diff --git a/contrib/dialog/mouse.c b/contrib/dialog/mouse.c index 6a431e160d..33af6a4747 100644 --- a/contrib/dialog/mouse.c +++ b/contrib/dialog/mouse.c @@ -1,9 +1,9 @@ /* - * $Id: mouse.c,v 1.20 2012/12/21 10:00:30 tom Exp $ + * $Id: mouse.c,v 1.21 2015/05/13 20:56:28 tom Exp $ * * mouse.c -- mouse support for dialog * - * Copyright 2002-2007,2012 Thomas E. Dickey + * Copyright 2002-2012,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -91,16 +91,16 @@ dlg_mouse_mkregion(int y, int x, int height, int width, int code) butPtr->next = regionList; regionList = butPtr; } - if (butPtr != 0) { - butPtr->mode = -1; - butPtr->step_x = 0; - butPtr->step_y = 0; - butPtr->y = basey + y; - butPtr->Y = basey + y + height; - butPtr->x = basex + x; - butPtr->X = basex + x + width; - butPtr->code = basecode + code; - } + + butPtr->mode = -1; + butPtr->step_x = 0; + butPtr->step_y = 0; + butPtr->y = basey + y; + butPtr->Y = basey + y + height; + butPtr->x = basex + x; + butPtr->X = basex + x + width; + butPtr->code = basecode + code; + return butPtr; } diff --git a/contrib/dialog/prgbox.c b/contrib/dialog/prgbox.c index cbb1458278..5c8b13f7bd 100644 --- a/contrib/dialog/prgbox.c +++ b/contrib/dialog/prgbox.c @@ -1,9 +1,9 @@ /* - * $Id: prgbox.c,v 1.9 2012/12/02 23:40:30 tom Exp $ + * $Id: prgbox.c,v 1.11 2014/09/11 07:56:41 tom Exp $ * * prgbox.c -- implements the prg box * - * Copyright 2011,2012 Thomas E. Dickey + * Copyright 2011-2012,2014 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -67,8 +67,8 @@ dlg_popen(const char *command, const char *type) * given command. Also, it needs the command to be parsed into * tokens. */ - if ((blob = malloc(4 + strlen(command))) != 0) { - sprintf(blob, "-c %s", command); + if ((blob = malloc(10 + strlen(command))) != 0) { + sprintf(blob, "sh -c \"%s\"", command); argv = dlg_string_to_argv(blob); execvp("sh", argv); } diff --git a/contrib/dialog/progressbox.c b/contrib/dialog/progressbox.c index d9d0620333..0c0aab1aeb 100644 --- a/contrib/dialog/progressbox.c +++ b/contrib/dialog/progressbox.c @@ -1,10 +1,10 @@ /* - * $Id: progressbox.c,v 1.23 2012/12/21 10:00:05 tom Exp $ + * $Id: progressbox.c,v 1.24 2014/01/12 20:53:44 tom Exp $ * * progressbox.c -- implements the progress box * - * Copyright 2005 Valery Reznic - * Copyright 2006-2012 Thomas E. Dickey + * Copyright 2005 Valery Reznic + * Copyright 2006-2012,2014 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -272,8 +272,17 @@ dlg_progressbox(const char *title, } if (pauseopt) { - scrollok(text, TRUE); - wscrl(text, 1 + MARGIN); + int need = 1 + MARGIN; + int base = thigh - need; + if (i >= base) { + i -= base; + if (i > need) + i = need; + if (i > 0) { + scrollok(text, TRUE); + } + wscrl(text, i); + } (void) wrefresh(text); result = pause_for_ok(dialog, height, width); } else { diff --git a/contrib/dialog/rangebox.c b/contrib/dialog/rangebox.c index b907741496..c218966736 100644 --- a/contrib/dialog/rangebox.c +++ b/contrib/dialog/rangebox.c @@ -1,9 +1,9 @@ /* - * $Id: rangebox.c,v 1.16 2012/12/19 21:38:00 tom Exp $ + * $Id: rangebox.c,v 1.17 2013/03/17 16:02:00 tom Exp $ * * rangebox.c -- implements the rangebox dialog * - * Copyright 2012 Thomas E. Dickey + * Copyright 2012,2013 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -409,6 +409,7 @@ dialog_rangebox(const char *title, sprintf(buffer, "%d", cur_value); dlg_add_result(buffer); dlg_add_separator(); + dlg_add_last_key(-1); dlg_del_window(dialog); dlg_mouse_free_regions(); diff --git a/contrib/dialog/timebox.c b/contrib/dialog/timebox.c index bcba36afb0..38abeecc75 100644 --- a/contrib/dialog/timebox.c +++ b/contrib/dialog/timebox.c @@ -1,9 +1,9 @@ /* - * $Id: timebox.c,v 1.53 2012/12/17 01:55:13 tom Exp $ + * $Id: timebox.c,v 1.54 2013/03/17 15:03:41 tom Exp $ * * timebox.c -- implements the timebox dialog * - * Copyright 2001-2011,2012 Thomas E. Dickey + * Copyright 2001-2012,2013 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -412,6 +412,7 @@ dialog_timebox(const char *title, dlg_add_result(buffer); dlg_add_separator(); + dlg_add_last_key(-1); return CleanupResult(result, dialog, prompt, &save_vars); } diff --git a/contrib/dialog/trace.c b/contrib/dialog/trace.c index 50ccfac6df..6736793d4e 100644 --- a/contrib/dialog/trace.c +++ b/contrib/dialog/trace.c @@ -1,9 +1,9 @@ /* - * $Id: trace.c,v 1.20 2011/10/18 10:47:26 tom Exp $ + * $Id: trace.c,v 1.21 2015/05/29 00:17:11 Matthias.Scheler Exp $ * * trace.c -- implements screen-dump and keystroke-logging * - * Copyright 2007-2010,2011 Thomas E. Dickey + * Copyright 2007-2011,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -93,7 +93,7 @@ dlg_trace_win(WINDOW *win) wchar_t *uc; if (win_wch(win, &cch) == ERR - || (uc = wunctrl(&cch)) == 0 + || (uc = wunctrl((&cch))) == 0 || uc[1] != 0 || wcwidth(uc[0]) <= 0) { buffer[0] = '.'; diff --git a/contrib/dialog/treeview.c b/contrib/dialog/treeview.c index 3e344c8658..c1fda152f6 100644 --- a/contrib/dialog/treeview.c +++ b/contrib/dialog/treeview.c @@ -1,9 +1,9 @@ /* - * $Id: treeview.c,v 1.20 2012/12/24 02:10:05 tom Exp $ + * $Id: treeview.c,v 1.25 2015/01/25 23:54:02 tom Exp $ * * treeview.c -- implements the treeview dialog * - * Copyright 2012 Thomas E. Dickey + * Copyright 2012-2013,2015 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -194,7 +194,7 @@ dlg_treeview(const char *title, int old_width = width; #endif ALL_DATA all; - int i, j, key2, found, x, y, cur_x, cur_y, box_x, box_y; + int i, j, key2, found, x, y, cur_y, box_x, box_y; int key = 0, fkey; int button = dialog_state.visit_items ? -1 : dlg_default_button(); int choice = dlg_default_listitem(items); @@ -215,6 +215,8 @@ dlg_treeview(const char *title, states = " *"; num_states = (int) strlen(states); + dialog_state.plain_buttons = TRUE; + memset(&all, 0, sizeof(all)); all.items = items; all.item_no = item_no; @@ -280,7 +282,7 @@ dlg_treeview(const char *title, dlg_print_autowrap(dialog, prompt, height, width); all.use_width = width - 4; - getyx(dialog, cur_y, cur_x); + cur_y = getcury(dialog); box_y = cur_y + 1; box_x = (width - all.use_width) / 2 - 1; @@ -579,6 +581,7 @@ dialog_treeview(const char *title, int *depths; bool show_status = FALSE; int current = 0; + char *help_result; listitems = dlg_calloc(DIALOG_LISTITEM, (size_t) item_no + 1); assert_ptr(listitems, "dialog_treeview"); @@ -617,31 +620,16 @@ dialog_treeview(const char *title, show_status = TRUE; break; case DLG_EXIT_HELP: - dlg_add_result("HELP "); - show_status = dialog_vars.help_status; - if (USE_ITEM_HELP(listitems[current].help)) { - if (show_status) { - if (dialog_vars.separate_output) { - dlg_add_string(listitems[current].help); - dlg_add_separator(); - } else { - dlg_add_quoted(listitems[current].help); - } + dlg_add_help_listitem(&result, &help_result, &listitems[current]); + if ((show_status = dialog_vars.help_status)) { + if (dialog_vars.separate_output) { + dlg_add_string(help_result); + dlg_add_separator(); } else { - dlg_add_string(listitems[current].help); + dlg_add_quoted(help_result); } - result = DLG_EXIT_ITEM_HELP; } else { - if (show_status) { - if (dialog_vars.separate_output) { - dlg_add_string(listitems[current].name); - dlg_add_separator(); - } else { - dlg_add_quoted(listitems[current].name); - } - } else { - dlg_add_string(listitems[current].name); - } + dlg_add_string(help_result); } break; } @@ -662,6 +650,7 @@ dialog_treeview(const char *title, } } } + dlg_add_last_key(-1); } dlg_free_columns(&listitems[0].text, (int) sizeof(DIALOG_LISTITEM), item_no); diff --git a/contrib/dialog/ui_getc.c b/contrib/dialog/ui_getc.c index 085b45c452..33e571fd0e 100644 --- a/contrib/dialog/ui_getc.c +++ b/contrib/dialog/ui_getc.c @@ -1,9 +1,9 @@ /* - * $Id: ui_getc.c,v 1.66 2012/11/30 01:56:14 tom Exp $ + * $Id: ui_getc.c,v 1.67 2013/03/24 23:53:19 tom Exp $ * * ui_getc.c - user interface glue for getc() * - * Copyright 2001-2011,2012 Thomas E. Dickey + * Copyright 2001-2012,2013 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -284,6 +284,36 @@ dlg_flush_getc(void) } /* + * Report the last key entered by the user. The 'mode' parameter controls + * the way it is separated from other results: + * -2 (no separator) + * -1 (separator after the key name) + * 0 (separator is optionally before the key name) + * 1 (same as -1) + */ +void +dlg_add_last_key(int mode) +{ + if (dialog_vars.last_key) { + if (mode >= 0) { + if (mode > 0) { + dlg_add_last_key(-1); + } else { + if (dlg_need_separator()) + dlg_add_separator(); + dlg_add_last_key(-2); + } + } else { + char temp[80]; + sprintf(temp, "%d", last_getc); + dlg_add_string(temp); + if (mode == -1) + dlg_add_separator(); + } + } +} + +/* * Check if the stream has been unexpectedly closed, returning false in that * case. */ diff --git a/contrib/dialog/util.c b/contrib/dialog/util.c index c26e238968..63c0ebe73c 100644 --- a/contrib/dialog/util.c +++ b/contrib/dialog/util.c @@ -1,9 +1,9 @@ /* - * $Id: util.c,v 1.253 2012/12/23 19:52:54 tom Exp $ + * $Id: util.c,v 1.260 2014/09/01 17:01:01 tom Exp $ * * util.c -- miscellaneous utilities for dialog * - * Copyright 2000-2011,2012 Thomas E. Dickey + * Copyright 2000-2013,2014 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -271,6 +271,18 @@ open_terminal(char **result, int mode) return open(device, mode); } +#ifdef NCURSES_VERSION +static int +my_putc(int ch) +{ + char buffer[2]; + int fd = fileno(dialog_state.screen_output); + + buffer[0] = (char) ch; + return (int) write(fd, buffer, (size_t) 1); +} +#endif + /* * Do some initialization for dialog. * @@ -377,19 +389,20 @@ init_dialog(FILE *input, FILE *output) * Cancel xterm's alternate-screen mode. */ if (!dialog_vars.keep_tite - && (dialog_state.screen_output != stdout + && (fileno(dialog_state.screen_output) != fileno(stdout) || isatty(fileno(dialog_state.screen_output))) && key_mouse != 0 /* xterm and kindred */ && isprivate(enter_ca_mode) && isprivate(exit_ca_mode)) { /* - * initscr() or newterm() already did putp(enter_ca_mode) as a side + * initscr() or newterm() already wrote enter_ca_mode as a side * effect of initializing the screen. It would be nice to not even * do that, but we do not really have access to the correct copy of * the terminfo description until those functions have been invoked. */ - (void) putp(exit_ca_mode); - (void) putp(clear_screen); + (void) refresh(); + (void) tputs(exit_ca_mode, 0, my_putc); + (void) tputs(clear_screen, 0, my_putc); /* * Prevent ncurses from switching "back" to the normal screen when * exiting from dialog. That would move the cursor to the original @@ -576,18 +589,21 @@ end_dialog(void) int dlg_count_real_columns(const char *text) { - int result = dlg_count_columns(text); - if (result && dialog_vars.colors) { - int hidden = 0; - while (*text) { - if (dialog_vars.colors && isOurEscape(text)) { - hidden += ESCAPE_LEN; - text += ESCAPE_LEN; - } else { - ++text; + int result = 0; + if (*text) { + result = dlg_count_columns(text); + if (result && dialog_vars.colors) { + int hidden = 0; + while (*text) { + if (dialog_vars.colors && isOurEscape(text)) { + hidden += ESCAPE_LEN; + text += ESCAPE_LEN; + } else { + ++text; + } } + result -= hidden; } - result -= hidden; } return result; } @@ -646,10 +662,13 @@ dlg_print_listitem(WINDOW *win, chtype attr = A_NORMAL; int limit; const int *cols; - const int *indx = dlg_index_wchars(text); chtype attrs[4]; + if (text == 0) + text = ""; + if (first) { + const int *indx = dlg_index_wchars(text); attrs[3] = tag_key_selected_attr; attrs[2] = tag_key_attr; attrs[1] = tag_selected_attr; @@ -908,6 +927,7 @@ dlg_print_line(WINDOW *win, test_ptr++; if (*test_ptr == '\n') test_ptr++; + dlg_finish_string(prompt); return (test_ptr); } @@ -1884,9 +1904,12 @@ dlg_strempty(void) char * dlg_strclone(const char *cprompt) { - char *prompt = dlg_malloc(char, strlen(cprompt) + 1); - assert_ptr(prompt, "dlg_strclone"); - strcpy(prompt, cprompt); + char *prompt = 0; + if (cprompt != 0) { + prompt = dlg_malloc(char, strlen(cprompt) + 1); + assert_ptr(prompt, "dlg_strclone"); + strcpy(prompt, cprompt); + } return prompt; } @@ -1973,6 +1996,7 @@ dlg_draw_title(WINDOW *win, const char *title) wmove(win, 0, x); dlg_print_text(win, title, getmaxx(win) - x, &attr); (void) wattrset(win, save); + dlg_finish_string(title); } } @@ -2489,7 +2513,7 @@ dlg_add_quoted(char *string) dlg_add_result(my_quote); while (*string != '\0') { temp[0] = *string++; - if (strchr(my_quote, *temp) || strchr(must_fix, *temp)) + if ((strchr) (my_quote, *temp) || (strchr) (must_fix, *temp)) dlg_add_result("\\"); dlg_add_result(temp); } @@ -2536,6 +2560,32 @@ dlg_add_separator(void) dlg_add_result(separator); } +#define HELP_PREFIX "HELP " + +void +dlg_add_help_listitem(int *result, char **tag, DIALOG_LISTITEM * item) +{ + dlg_add_result(HELP_PREFIX); + if (USE_ITEM_HELP(item->help)) { + *tag = dialog_vars.help_tags ? item->name : item->help; + *result = DLG_EXIT_ITEM_HELP; + } else { + *tag = item->name; + } +} + +void +dlg_add_help_formitem(int *result, char **tag, DIALOG_FORMITEM * item) +{ + dlg_add_result(HELP_PREFIX); + if (USE_ITEM_HELP(item->help)) { + *tag = dialog_vars.help_tags ? item->name : item->help; + *result = DLG_EXIT_ITEM_HELP; + } else { + *tag = item->name; + } +} + /* * Some widgets support only one value of a given variable - save/restore the * global dialog_vars so we can override it consistently. -- 2.11.4.GIT