|
NAMEcdialog - widgets and utilities for the cdialog programSYNOPSIScc [ flag ... ] file ... -lcdialog [ library ... ]or cc $(cdialog-config --cflags) file ... $(cdialog-config --libs) ] #include <cdialog.h> Cdialog 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 cdialog library, which consists of several widgets as well as utility functions that are used by the widgets or the main program. DESCRIPTIONThis manpage documents the features from <cdialog.h> which are likely to be important to developers using the widgets directly. Some hints are also given for developing new widgets.Here is a cdialog version of Hello World: int main(void) { int status; init_dialog(stdin, stdout); status = dialog_yesno( "Hello, in dialog-format", "Hello World!", 0, 0); end_dialog(); return status; } DEFINITIONSExit codes (passed back to the main program for its use) are defined with a "DLG_EXIT_ prefix. The efined constants can be mapped using environment variables as described in cdialog(1), e.g., DLG_EXIT_OK corresponds to $DIALOG_OK.Useful character constants which correspond to user input are named with the "CHR_" prefix, e.g., CHR_BACKSPACE. Colors and video attributes are categorized and associated with settings in the configuration file (see the discussion of $DIALOGRC in cdialog(1)). The DIALOG_ATR(n) macro is used for defining the references to the combined color and attribute table dlg_color_table[]. The cdialog application passes its command-line parameters 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 --item-help option is given, an extra column of data is expected. The USE_ITEM_HELP(), CHECKBOX_TAGS, MENUBOX_TAGS and FORMBOX_TAGS macros are used to hide this difference from the calling application. Most of the other definitions found in <cdialog.h> are used for convenience in building the library or main program. These include definitions based on the generated <dlg_config.h> header. DATA STRUCTURESAll of the global data for the cdialog library is stored in a few structures: DIALOG_STATE, DIALOG_VARS and DIALOG_COLORS. The corresponding dialog_state, dialog_vars and dlg_color_table global variables should be initialized to zeros, and then populated with the data to use. A few of these must be nonzero for the corresponding widgets to function. As as the case with function names, variables beginning with "dialog_" are designed for use by the calling application while variables beginning with "dlg_" are intended for lower levels, e.g., by the cdialog library.DIALOG_STATEThe state variables are cdialog's working variables. It initializes those, uses them to manage the widgets..all_subwindowsThis is a linked list of all subwindows created by the library. The dlg_del_window function uses this to free storage for subwindows when deleting a window..all_windowsThis is a linked list of all windows created by the library. The dlg_del_window function uses this to locate windows which may be redrawn after deleting a window..aspect_ratioThis corresponds to the command-line option "--aspect-ratio". The value gives the application some control over the box dimensions when using auto 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..finish_stringWhen set to true, this allows calls to dlg_finish_string to discard the corresponding data which is created to speed up layout computations for the given string parameter. The gauge widget uses this feature..getc_callbacksThis is set up in ui_getc.c to record windows which must be polled for input, e.g., to handle the background tailbox widget. One window is designated as the foreground or control window..getc_redirectIf the control window for DIALOG_STATE.getc_callbacks is closed, the list is transferred to this variable. Closing all windows causes the application to exit..had_resizeThis is set to TRUE in dlg_will_resize or dlg_result_key when KEY_RESIZE is read, to tell cdialog to ignore subsequent ERRs..no_mouseThis corresponds to the command-line option "--no-mouse". If true, cdialog will not initialize (and enable) the mouse in init_dialog..outputThis is set in the cdialog application to the stream on which the application and library functions may write text results. Normally that is the standard error, since the curses library prefers to write its data to the standard output. Some scripts, trading portability for convenience, prefer to write results to the standard output, e.g., by using the "--stdout" option..output_countThis is incremented by dlg_does_output, which is called by each widget that writes text to the output. The cdialog application uses that to decide if it should also write a separator, i.e., DIALOG_STATE.separate_str, between calls to each widget..pipe_inputThis is set in init_dialog to a stream which can be used by the gauge widget, which must be the application's standard input. The cdialog application calls init_dialog normally with input set to the standard input, but optionally based on the "--input-fd" option. Since the application cannot read from a pipe (standard input) and at the same time read the curses input from the standard input, it must allow for reopening the latter from either a specific file descriptor, or directly from the terminal. The adjusted pipe stream value is stored in this variable..screen_heightThe text-formatting functions use this for the number of rows used for formatting a string.It is used by cdialog for the command-line options "--print-text-size" and "--print-text-only". .screen_initializedThis is set in init_dialog and reset in end_dialog. It is used to check if curses has been initialized, and if the endwin function must be called on exit..screen_outputThis is set in init_dialog to the output stream used by the curses library. Normally that is the standard output, unless that happens to not be a terminal (and if init_dialog can successfully open the terminal directly)..screen_widthThe text-formatting functions use this for the number of columns used for formatting a string.It is used by cdialog for the command-line options "--print-text-size" and "--print-text-only". .separate_strThis corresponds to the command-line option "--separate-widget". The given string specifies a string that will separate the output on cdialog's output from each widget. This is used to simplify parsing the result of a dialog with several widgets. If this option is not given, the default separator string is a tab character..tab_lenThis corresponds to the command-line option "--tab-len number". Specify the number of spaces that a tab character occupies if the "--tab-correct" option is given. The default is 8..text_heightThe text-formatting functions set this to the number of lines used for formatting a string.It is used by cdialog for the command-line options "--print-text-size" and "--print-text-only". .text_onlyCdialog uses this in the command-line option "--print-text-only".The text-formatting functions (dlg_print_text, dlg_print_line, and dlg_print_autowrap) check this to decide whether to print the formatted text to cdialog's output or to the curses-display. Also, dlg_auto_size checks the flag, allowing it to be used before init_dialog is called. .text_widthThe text-formatting functions set this to the number of columns used for formatting a string.It is used by cdialog for the command-line options "--print-text-size" and "--print-text-only". .trace_outputThis corresponds to the command-line option "--trace file". It is the file pointer to which trace messages are written..use_colorsThis is set in init_dialog if the curses implementation supports color..use_scrollbarThis corresponds to the command-line option "--scrollbar". If true, draw a scrollbar to make windows holding scrolled data more readable..use_shadowThis corresponds to the command-line option "--no-shadow". This is set in init_dialog if the curses implementation supports color. If true, suppress shadows that would be drawn to the right and bottom of each dialog box..visit_itemsThis corresponds to the command-line option "--visit-items". Modify the tab-traversal of the list-oriented widgets (buildlist, checklist, radiobox, menubox, inputmenu, and treeview) to include the list of items as one of the states. This is useful as a visual aid, i.e., the cursor position helps some users.The cdialog application resets the dialog_vars data before accepting options to invoke each widget. Most of the DIALOG_VARS members are set directly from cdialog's command-line options: DIALOG_VARSIn contrast to DIALOG_STATE, the members of DIALOG_VARS are set by command-line options in cdialog..ascii_linesThis corresponds to the command-line option "--ascii-lines. It causes line-drawing to be done with ASCII characters, e.g., "+" and "-". See DIALOG_VARS.no_lines..backtitleThis corresponds to the command-line option "--backtitle backtitle". It specifies a backtitle string to be displayed on the backdrop, at the top of the screen..beep_after_signalThis corresponds to the command-line option "--beep-after". If true, beep after a user has completed a widget by pressing one of the buttons..beep_signalThis corresponds to the command-line option "--beep". It is obsolete..begin_setThis is true if the command-line option "--begin y x" was used. It specifies the position of the upper left corner of a dialog box on the screen..begin_xThis corresponds to the x value from the command-line option "--begin y x" (second value)..begin_yThis corresponds to the y value from the command-line option "--begin y x" (first value)..cancel_labelThis corresponds to the command-line option "--cancel-label string". The given string overrides the label used for “Cancel” buttons..cant_killThis corresponds to the command-line option "--no-kill". If true, this tells cdialog to put the tailboxbg box in the background, printing its process id to cdialog's output. SIGHUP is disabled for the background process..colorsThis corresponds to the command-line option "--colors". If true, interpret embedded "\Z" sequences in the dialog text by the following character, which tells cdialog to set colors or video attributes:
The settings are cumulative, e.g., "\Zb\Z1" makes the following text bright red. Restore normal settings with "\Zn". .column_separatorThis corresponds to the command-line option "--column-separator". Cdialog splits data for radio/checkboxes and menus on the occurrences of the given string, and aligns the split data into columns..cr_wrapThis corresponds to the command-line option "--cr-wrap". If true, interpret embedded newlines in the dialog text as a newline on the screen. Otherwise, cdialog will only wrap lines where needed to fit inside the text box. Even though you can control line breaks with this, cdialog will still wrap any lines that are too long for the width of the box. Without cr-wrap, the layout of your text may be formatted to look nice in the source code of your script without affecting the way it will look in the dialog..cursor_off_labelThis corresponds to the command-line option "--cursor-off-label". If true, place the terminal cursor at the end of a button instead of on the first character of the button label. This is useful to reduce visual confusion when the cursor coloration interacts poorly with the button-label text colors..date_formatThis corresponds to the command-line option "--date-format string". If the host provides strftime, and the value is nonnull, the calendar widget uses this to format its output..default_buttonThis is set by the command-line option "--default-button. It is used by dlg_default_button..default_itemThis corresponds to the command-line option "--default-item string". 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..defaultnoThis corresponds to the command-line option "--defaultno". If true, make the default value of the yes/no box a No. Likewise, treat the default button of widgets that provide “OK” and “Cancel” as a Cancel. If --no-cancel was given that option overrides this, making the default button always “Yes” (internally the same as “OK”)..dlg_clear_screenThis corresponds to the command-line option "--clear". This option is implemented in the main program, not the library. If true, the screen will be cleared on exit. This may be used alone, without other options..erase_on_exitThis corresponds to the command-line option "--erase-on-exit". If true, remove the dialog widget on program exit, erasing the entire screen to its native background color, and place the terminal cursor at the lower left corner of the screen.This is useful for making the window contents invisible at the end of a series of dialog boxes. It can also be used at earlier stages of a series of invocations of cdialog, if the series may be aborted before it is fully completed. .exit_labelThis corresponds to the command-line option "--exit-label string". The given string overrides the label used for “EXIT” buttons..extra_buttonThis corresponds to the command-line option "--extra-button". If true, some widgets show an extra button, between “OK” and “Cancel” buttons, or “Yes” and “No” buttons..extra_labelThis corresponds to the command-line option "--extra-label string". The given string overrides the label used for “Extra” buttons. Note: for inputmenu widgets, this defaults to “Rename”..formitem_typeThis is set by the command-line option "--passwordform" to tell the form widget that its text fields should be treated like password widgets..help_buttonThis corresponds to the command-line option "--help-button". If true, some widgets show a help-button after “OK” and “Cancel” buttons, i.e., in checklist, radiolist and menu boxes, or the “Yes” and “No” buttons for the yesno box.If --item-help 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 cdialog's output after the token “HELP”. Otherwise, the return status will indicate that the Help button was pressed, and no message printed. .help_fileThis corresponds to the command-line option "--hfile string". The given filename is passed to dialog_helpfile when the user presses F1..help_labelThis corresponds to the command-line option "--help-label string". The given string overrides the label used for “Help” buttons..help_lineThis corresponds to the command-line option "--hline string". The given string is displayed in the bottom of dialog windows, like a subtitle..help_statusThis corresponds to the command-line option "--help-status". If true, and the the help-button is selected, writes the checklist or radiolist information after the item-help “HELP” information. This can be used to reconstruct the state of a checklist after processing the help request..help_tagsThis corresponds to the command-line option "--help-tags". If true, dlg_add_help_formitem and dlg_add_help_listitem use the item's tag value consistently rather than using the tag's help-text value when DIALOG_VARS.item_help is set..input_lengthThis is nonzero if DIALOG_VARS.input_result is allocated, versus being a pointer to the user's local variables..input_menuThis flag is set to denote whether the menubox widget implements a menu versus a inputmenu widget..input_resultThis may be either a user-supplied buffer, or a buffer dynamically allocated by the library, depending on DIALOG_VARS.input_length:
Certain widgets copy a result to this buffer. If the pointer is NULL, or if the length is insufficient for the result, then the cdialog library allocates a buffer which is large enough, and sets DIALOG_VARS.input_length. Callers should check for this case if they have supplied their own buffer. .insecureThis corresponds to the command-line option "--insecure". If true, make the password widget friendlier but less secure, by echoing asterisks for each character..in_helpfileThis variable is used to prevent dialog_helpfile from showing anything, e.g., if F1 were pressed within a help-file display..iso_weekThis corresponds to the command-line option "--iso-week". It is used in the calendar widget to tell how to compute the starting week for the year:
.item_helpThis corresponds to the command-line option "--item-help". If true, interpret the tags data for checklist, radiolist and menu boxes adding a column whose text is displayed in the bottom line of the screen, for the currently selected item..keep_titeThis is set by the command-line option "--keep-tite" to tell cdialog to not attempt to cancel the terminal initialization (termcap ti/te) sequences which correspond to xterm's alternate-screen switching. Normally cdialog does this to avoid flickering when run several times in a script..keep_windowThis corresponds to the command-line option "--keep-window". If true, do not remove/repaint the window on exit. 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..last_keyThis corresponds to the command-line option "--last-key"..max_inputThis corresponds to the command-line option "--max-input size". Limit input strings to the given size. If not specified, the limit is 2048..no_hot_keyThis corresponds to the command-line option "--no-hot-list".Some widgets (buildlist, checklist, inputmenu, menu, radiolist, treeview) display a list for which the leading capital letter in each entry is accepted as a hot-key, to quickly move the focus to that entry. Setting this variable to TRUE disables the feature. .no_itemsThis corresponds to the command-line option "--no-items". Some widgets (checklist, inputmenu, radiolist, menu) display a list with two columns (a “tag” and “item”, i.e., “description”). This tells cdialog to read shorter rows from data, omitting the “list”..no_labelThis corresponds to the command-line option "--no-label string". The given string overrides the label used for “No” buttons..no_linesThis corresponds to the command-line option "--no-lines. It suppresses line-drawing. See DIALOG_VARS.ascii_lines..no_nl_expandThis corresponds to the command-line option "--no-nl-expand". If false, dlg_trim_string converts literal "\n" substrings in a message into newlines..no_tagsThis corresponds to the command-line option "--no-tags". Some widgets (checklist, inputmenu, radiolist, menu) display a list with two columns (a “tag” and “item”, also known as “description”). The tag is useful for scripting, but may not help the user. The --no-tags option (from Xdialog) may be used to suppress the column of tags from the display.Normally cdialog allows you to quickly move to entries on the displayed list, by matching a single character to the first character of the tag. When the --no-tags option is given, cdialog matches against the first character of the description. In either case, the matchable character is highlighted. Here is a table showing how the no_tags and no_items values interact:
.nocancelThis corresponds to the command-line option "--no-cancel". If true, suppress the “Cancel” button in checklist, inputbox and menu box modes. A script can still test if the user pressed the ESC key to cancel to quit..nocollapseThis corresponds to the command-line option "--no-collapse". Normally cdialog converts tabs to spaces and reduces multiple spaces to a single space for text which is displayed in a message boxes, etc. It true, that feature is disabled. Note that cdialog will still wrap text, subject to the --cr-wrap option..nookThis corresponds to the command-line option "--no-ok. Cdialog will suppress the “ok” (or “yes”) button from the widget..ok_labelThis corresponds to the command-line option "--ok-label string". The given string overrides the label used for “OK” buttons..pause_secsWhen set, force dlg_set_timeout to use 10 milliseconds rather than using the DIALOG_VARS.timeout_secs value..print_sizThis corresponds to the command-line option "--print-size". If true, each widget prints its size to cdialog's output when it is invoked..quotedThis corresponds to the command-line option "--quoted. Normally cdialog quotes the strings returned by checklist's as well as the item-help text. If true, cdialog will quote all string results..reorderThis corresponds to the command-line option "--reorder. By default, the buildlist widget uses the same order for the output (right) list as for the input (left). If true, cdialog will use the order in which a user adds selections to the output list..separate_outputThis corresponds to the command-line option "--separate-output". If true, checklist widgets output result one line at a time, with no quoting. This facilitates parsing by another program..single_quotedThis corresponds to the command-line option "--single-quoted". If true, 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, cdialog uses double quotes around each item. The latter requires occasional use of backslashes to make the output useful in shell scripts..size_errThis corresponds to the command-line option "--size-err". If true, check the resulting size of a dialog box before trying to use it, printing the resulting size if it is larger than the screen. (This option is obsolete, since all new-window calls are checked)..sleep_secsThis corresponds to the command-line option "--sleep secs". 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..tab_correctThis corresponds to the command-line option "--tab-correct". 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..time_formatThis corresponds to the command-line option "--time-format string". If the host provides strftime, and the value is nonnull, the timebox widget uses this to format its output..timeout_secsThis corresponds to the command-line option "--timeout secs". If nonzero, timeout input requests (exit with error code) if no user response within the given number of seconds..titleThis corresponds to the command-line option "--title title". Specifies a title string to be displayed at the top of the dialog box..trim_whitespaceThis corresponds to the command-line option "--trim". If true, eliminate leading blanks, trim literal newlines and repeated blanks from message text..week_startThis corresponds to the command-line option "--week-start". It is used in the calendar widget to set the starting day for the week. The string value can be
.yes_labelThis corresponds to the command-line option "--yes-label string". The given string overrides the label used for “Yes” buttons.WIDGETSFunctions that implement major functionality for the command-line cdialog program, e.g., widgets, have names beginning "dialog_".All dialog boxes have at least three parameters:
Other parameters depend on the box type. dialog_buildlistimplements the "--buildlist" option.
tag item status
tag item status help
dialog_calendarimplements the "--calendar" option.
dialog_checklistimplements the "--checklist" and "--radiolist" options depending on the flag parameter.
tag item status
tag item status help
dialog_dselectimplements the "--dselect" option.
dialog_editboximplements the "--editbox" option.
dialog_formimplements the "--form" option.
Name NameY NameX Text TextY TextX FLen ILen
Name NameY NameX Text TextY TextX FLen ILen
Help
dialog_fselectimplements the "--fselect" option.
dialog_gaugeimplements the "--gauge" option. Alternatively, a simpler or customized gauge widget can be set up using dlg_allocate_gauge, dlg_reallocate_gauge, dlg_update_gauge and dlg_free_gauge.
dialog_inputboximplements the "--inputbox" or "--password" option, depending on the value of password.
dialog_helpfileimplements the "--hfile" option.
dialog_menuimplements the "--menu" or "--inputmenu" option depending on whether dialog_vars.input_menu is set.
tag item
tag item help
dialog_mixedformimplements the "--mixedform" option.
Name NameY NameX Text TextY TextX FLen ILen
Ityp
Name NameY NameX Text TextY TextX FLen ILen Ityp
Help
dialog_mixedgaugeimplements the "--mixedgauge" option
dialog_msgboximplements the "--msgbox" or "--infobox" option depending on whether pauseopt is set.
dialog_pauseimplements the "--pause" option.
dialog_prgboximplements the "--prgbox" option.
dialog_progressboximplements the "--progressbox" option.
dialog_rangeboximplements the "--rangebox" option.
dialog_tailboximplements the "--tailbox" or "--tailboxbg" option depending on whether bg_task is set.
dialog_textboximplements the "--textbox" option.
dialog_timeboximplements the "--timebox" option. See dlg_auto_size for layout using height and width parameters.
dialog_treeviewimplements the "--treeview" option.
dialog_yesnoimplements the "--yesno" option.
UTILITY FUNCTIONSMost functions that implement lower-level functionality for the command-line cdialog program or widgets, have names beginning "dlg_". Bowing to longstanding usage, the functions that initialize the display and end it are named init_dialog and end_dialog.The only non-widget function whose name begins with "dialog_" is dialog_version, which returns the version number of the library as a string. A few functions are prefixed "_dlg_", because they are required for internal use, but not intended as part of the library application programming interface. Here is a brief summary of the utility functions and their parameters: dlg_add_callbackAdd a callback, used to allow polling input from multiple tailbox widgets.
dlg_add_callback_refLike dlg_add_callback, but passes a reference to the DIALOG_CALLBACK as well as a pointer to a cleanup function which will be called when the associated input ends.
dlg_add_help_formitemThis is a utility function used enforce consistent behavior for the DIALOG_VARS.help_tags and DIALOG_VARS.item_help variables.
dlg_add_help_listitemThis is a utility function used enforce consistent behavior for the DIALOG_VARS.help_tags and DIALOG_VARS.item_help variables.
dlg_add_last_keyReport the last key entered by the user. This implements the --last-key command-line option, using dialog_vars.last_key.
dlg_add_quotedAdd a quoted string to the result buffer (see dlg_add_result). If no quotes are necessary, none are used. If dialog_vars.single_quoted is set, single-quotes are used. Otherwise, double-quotes are used.
dlg_add_resultAdd a string to the result buffer dialog_vars.input_result.
dlg_add_separatorAdd an output-separator to the result buffer dialog_vars.input_result. If dialog_vars.output_separator is set, use that. Otherwise, if dialog_vars.separate_output is set, use newline. If neither is set, use a space.dlg_add_stringAdd a quoted or unquoted string to the result buffer (see dlg_add_quoted) and dlg_add_result), according to whether dialog_vars.quoted is true.
dlg_align_columnsCopy and reformat an array of pointers to strings, aligning according to the column separator dialog_vars.column_separator. If no column separator is set, the array will be unmodified; otherwise it is copied and reformatted.
dlg_allocate_gaugeAllocates a gauge widget. Use dlg_update_gauge to display the result.
dlg_asciiboxreturns its parameter transformed to the corresponding "+" or "-", etc., for the line-drawing characters used in cdialog. If the parameter is not a line-drawing or other special character such as ACS_DARROW, it returns 0.
dlg_attr_clearSet window to the given attribute.
dlg_auto_sizeCompute window size based on the size of the formatted prompt and minimum dimensions for a given widget.Cdialog sets dialog_state.text_height and dialog_state.text_width for the formatted prompt as a side-effect. Normally cdialog writes the formatted prompt to the curses window, but it will write the formatted prompt to the output stream if dialog_state.text_only is set.
dlg_auto_sizefileLike dlg_auto_size, but use a file contents to decide how large the widget should be.
dlg_beepingIf dialog_vars.beep_signal is nonzero, this calls beep once and sets dialog_vars.beep_signal to zero.dlg_boxcharreturns its chtype parameter transformed as follows:
dlg_box_x_ordinatereturns a suitable x-ordinate (column) for a new widget. If dialog_vars.begin_set is 1, use dialog_vars.begin_x; otherwise center the widget on the screen (using the width parameter).
dlg_box_y_ordinatereturns a suitable y-ordinate (row) for a new widget. If dialog_vars.begin_set is 1, use dialog_vars.begin_y; otherwise center the widget on the screen (using the height parameter).
dlg_buildlistThis is an alternate interface to the buildlist widget which allows the application to read the list item states back directly without putting them in the output buffer.
dlg_button_countCount the buttons in the list.
dlg_button_keyIf a key was bound to one of the button-codes in dlg_result_key, fake a button-value and an “Cancel” key to cause the calling widget to return the corresponding status.See dlg_ok_buttoncode, which maps settings for ok/extra/help and button number into exit-code. dlg_button_layoutMake sure there is enough space for the buttons by computing the width required for their labels, adding margins and limiting based on the screen size.
dlg_button_sizesCompute the size of the button array in columns.
dlg_button_to_charFind the first uppercase character in the label, which we may use for an abbreviation. If the label is empty, return -1. If no uppercase character is found, return 0. Otherwise return the uppercase character.Normally dlg_draw_buttons and dlg_char_to_button use the first uppercase character. However, they keep track of all of the labels and if the first has already been used in another label, they will continue looking for another uppercase character. This function does not have enough information to make that check.
dlg_button_x_stepCompute the step-size needed between elements of the button array.
dlg_calc_list_widthCalculate the minimum width for the list, assuming none of the items are truncated.
dlg_calc_listhCalculate new height and list_height values.
dlg_calc_listwThis function is obsolete, provided for library-compatibility. It is replaced by dlg_calc_list_width.
dlg_char_to_buttonGiven a list of button labels, and a character which may be the abbreviation for one, find it, if it exists. An abbreviation will be the first character which happens to be capitalized in the label. If the character is found, return its index within the list of labels. Otherwise, return DLG_EXIT_UNKNOWN.
dlg_checklistThis entrypoint provides the --checklist or --radiolist functionality without the limitations of cdialog's command-line syntax (compare to dialog_checklist).
dlg_check_scrolledgiven a function key (or other key that was mapped to a function key), check if it is one of the up/down scrolling functions:DLGK_PAGE_FIRST,
DLGK_PAGE_LAST, DLGK_GRID_UP, DLGK_GRID_DOWN, DLGK_PAGE_PREV or DLGK_PAGE_NEXT. Some widgets use these key bindings for scrolling the prompt-text up and down, to allow for display in very small windows. The function returns 0 (zero) if it finds one of these keys, and -1 if not.
dlg_clearSet window to the default cdialog screen attribute. This is set in the rc-file with screen_color.dlg_clr_resultFree storage used for the result buffer (dialog_vars.input_result). The corresponding pointer is set to NULL.dlg_color_countReturn the number of colors that can be configured in cdialog.dlg_color_setupInitialize the color pairs used in cdialog.dlg_count_argvCount the entries in an argument vector.
dlg_count_columnsReturns the number of columns used for a string. This is not necessarily the number of bytes in a string.
dlg_count_real_columnsReturns the number of columns used for a string, accounting for "\Z" sequences which can be used for coloring the text if dialog_vars.colors is set. This is not necessarily the number of bytes in a string.
dlg_count_wcharsReturns the number of wide-characters in the string.
dlg_create_rcCreate a configuration file, i.e., write internal tables to a file which can be read back by cdialog as an rc-file.
dlg_ctl_sizeIf dialog_vars.size_err is true, check if the given window size is too large to fit on the screen. If so, exit with an error reporting the size of the window.
dlg_default_buttonIf dialog_vars.default_button is positive, return the button-index for that button code, using dlg_ok_buttoncode to test indices starting with zero. Otherwise (or if no match was found for the button code), return zero.dlg_default_formitemIf dialog_vars.default_item is not null, find that name by matching the name field in the list of form items. If found, return the index of that item in the list. Otherwise, return zero.
dlg_default_itemThis function is obsolete, provided for library-compatibility. It is replaced by dlg_default_formitem and dlg_default_listitem.
dlg_defaultno_buttonIf dialog_vars.defaultno is true, and dialog_vars.nocancel is not, find the button-index for the “Cancel” button. Otherwise, return the index for “OK” (always zero).dlg_del_windowRemove a window, repainting everything else.
dlg_der_windowcreate a derived window, e.g., for an input area of a widget
dlg_does_outputThis is called each time a widget is invoked which may do output. It increments dialog_state.output_count, so the output function in cdialog can test this and add a separator.dlg_draw_arrowsDraw up/down arrows on a window, e.g., for scrollable lists. It calls dlg_draw_arrows2 using the menubox_color and menubox_border_color attributes.
dlg_draw_arrows2Draw up/down arrows on a window, e.g., for scrollable lists.
dlg_draw_bottom_boxDraw a partial box at the bottom of a window, e.g., to surround a row of buttons. It is designed to merge with an existing box around the whole window (see dlg_draw_box), so it uses tee-elements rather than corner-elements on the top corners of this box.
dlg_draw_bottom_box2Draw a partial box at the bottom of a window, e.g., to surround a row of buttons. It is designed to merge with an existing box around the whole window (see dlg_draw_box2), so it uses tee-elements rather than corner-elements on the top corners of this box.
dlg_draw_boxDraw a rectangular box with line drawing characters.
dlg_draw_box2Draw a rectangular box with line drawing characters.
dlg_draw_buttonsPrint a list of buttons at the given position.
dlg_draw_helplinedraw the text in dialog_vars.help_line at the bottom of the given window.
dlg_draw_scrollbarIf dialog_state.use_scrollbar is set, draw a scrollbar on the right margin of windows holding scrollable data. Also (whether or not the scrollbar is drawn), annotate the bottom margin of the window with the percentage of data by the bottom of that window, and call dlg_draw_arrows2 to put markers on the window showing when more data is available.
dlg_draw_shadowDraw shadows along the right and bottom edge of a window to give it a 3-dimensional look. (The height, etc., may not be the same as the window's actual values).
dlg_draw_titleDraw a title centered at the top of the window.
dlg_dummy_menutextThis is a utility function which supports the --inputmenu option of the cdialog program. If dialog_vars.input_menu is set, dialog_menu passes this pointer to dlg_menu as the rename_menutext parameter. Otherwise, it passes dlg_dummy_menutext.The function should only return DLG_EXIT_ERROR.
dlg_dump_keysWrite all user-defined key-bindings to the given stream, e.g., as part of dlg_create_rc.
dlg_dump_window_keysWrite all user-defined key-bindings to the given stream, e.g., as part of dlg_create_rc.
dlg_eat_argvRemove one or more items from an argument vector.
dlg_edit_offsetGiven the character-offset in the string, returns the display-offset where cdialog should position the cursor. In this context, “characters” may be multicolumn, since the string can be a multibyte character string.
dlg_edit_stringUpdates the string and character-offset, given various editing characters or literal characters which are inserted at the character-offset. Returns true if an editing change was made (and the display should be updated), and false if the key was something like KEY_ENTER, which is a non-editing action outside this function.
dlg_exitGiven an internal exit code, check if the corresponding environment variable is set. If so, remap the exit code to match the environment variable. Finally call exit with the resulting exit code.
The cdialog program uses this function to allow shell scripts to remap the exit codes so they can distinguish ESC from ERROR. dlg_exitcode2sReturns the name of an exit-code, e.g., “OK” for DLG_EXIT_OK.
dlg_exitname2nReturns an exit-code as the reverse of dlg_exitcode2n, e.g., 0 (DLG_EXIT_OK) for the “OK” string.
dlg_exit_buttoncodeMap the given button index for dlg_exit_label into cdialog's exit-code.
dlg_exit_labelReturn a list of button labels. If dialog_vars.extra_button is true, return the result of dlg_ok_labels. Otherwise, return a list with the “Exit” label and (if dialog_vars.help_button is set) the “Help” button as well.dlg_exiterrQuit program killing all tailboxbg widgets.
dlg_find_indexGiven the character-offset to find in the list, return the corresponding array index.
dlg_finish_stringIf DIALOG_STATE.finish_string is true, this function discards data used to speed up layout computations.
dlg_flush_getcCancel the local data saved by dlg_last_getc.dlg_editboxThis entrypoint provides the --editbox functionality without the limitations of cdialog's command-line syntax (compare to dialog_editbox).
dlg_formThis entrypoint provides the --form functionality without the limitations of cdialog's command-line syntax (compare to dialog_form).
dlg_free_columnsFree data allocated by dlg_align_columns.
dlg_free_formitemsFree memory owned by a list of DIALOG_FORMITEM's.
dlg_free_gaugeRemove the gauge widget from the screen and free its associated memory.
dlg_getcRead a character from the given window. Handle repainting here (to simplify things in the calling application). Also, if input-callback(s) are set up, poll the corresponding files and handle the updates, e.g., for displaying a tailbox. Returns the key-code.
dlg_getenv_numGet a number from the environment:
dlg_getenv_strGet a string from the environment, rejecting those which are entirely blank.
dlg_get_attrsextract the video attributes from the given window.
dlg_getc_callbackspasses the given key-code ch to the current window that has established a callback. If the callback returns zero, remove it and try the next window. If no more callbacks remain, return. If any callbacks were found, return true, otherwise false.
dlg_index_columnsBuild a list of the display-columns for the given multibyte string's characters.
dlg_index_wcharsBuild an index of the wide-characters in the string, so the caller can easily tell which byte-offset begins a given wide-character.
dlg_item_helpDraw the string for the dialog_vars.item_help feature.
dlg_keep_titeThis performs the check and modifications for the command-line option "--keep-tite", used in init_dialog as well as for the command-line option --erase-on-exit.
dlg_killall_bgIf cdialog has callbacks active, purge the list of all that are not marked to keep in the background. If any remain, run those in a background process.
dlg_last_getcreturns the most recent character that was read via dlg_getc.dlg_limit_columnsGiven a column limit, count the number of wide characters that can fit into that limit. The offset is used to skip over a leading character that was already written.
dlg_lookup_keyCheck for a key-binding. If there is no binding associated with the widget, it simply returns the given curses-key. Otherwise, it returns the result of the binding
dlg_max_inputLimit the parameter according to dialog_vars.max_input
dlg_match_charMatch a given character against the beginning of the string, ignoring case of the given character. The matching string must begin with an uppercase character.
dlg_menuThis entrypoint provides the --menu functionality without the limitations of cdialog's command-line syntax (compare to dialog_menu).
dlg_move_windowMoves/resizes the given window to the given position and size.
dlg_mouse_bigregionRetrieve the big-region under the pointer.
dlg_mouse_free_regionsFree the memory associated with mouse regions.dlg_mouse_mkbigregionCreates a region on which the mouse-clicks will return a specified code.
dlg_mouse_mkregion
dlg_mouse_regionRetrieve the frame under the mouse pointer
dlg_mouse_setbaseSets a base for subsequent calls to dlg_mouse_mkregion, so they can make regions relative to the start of a given window.
dlg_mouse_setcodeSets a value used internally by dlg_mouse_mkregion which is added to the code parameter. By providing different values, e.g., multiples of KEY_MAX, it is possible to support multiple “big” regions in a widget. The buildlist widget uses this feature to recognize mouse-clicks in the left/right panes.
dlg_mouse_wgetchis a wrapper for dlg_getc which additionally maps mouse-clicks (if the curses library supports those) into extended function-keys which encode the position according to the mode in dlg_mouse_mkbigregion. Returns the corresponding key-code.
dlg_mouse_wgetch_nowaitThis is a non-blocking variant of dlg_mouse_wgetch.
dlg_need_separatorCheck if an output-separator is needed. If dialog_vars.output_separator is set, return true. Otherwise, if dialog_vars.input_result is nonempty, return true. If neither, return false.dlg_new_modal_windowCreate a modal window, optionally with a shadow. The shadow is created if dialog_state.use_shadow is true.
dlg_new_windowCreate a window, optionally with a shadow. The shadow is created if dialog_state.use_shadow is true.
dlg_next_buttonReturn the next index in the list of labels.
dlg_next_ok_buttonindexAssuming that the caller is using dlg_ok_labels to list buttons, find the next index in the list of buttons.
dlg_ok_buttoncodeMap the given button index for dlg_ok_labels into cdialog's exit-code.
dlg_ok_button_keyCalls dlg_button_key with the “Cancel” button disabled, e.g., for the textbox widget.dlg_ok_labelReturns a list with the “Ok” label, and if dialog_vars.help_button is true, the “Help” label as well.dlg_ok_labelsReturn a list of button labels for the OK/Cancel group of widgets.dlg_ordinateDecode the string as an integer, decrement if greater than zero to make a curses-ordinate from a dialog-ordinate.dlg_parse_bindkeyParse the parameters of the “bindkeys” configuration-file entry. This expects widget name which may be "*", followed by curses key definition and then cdialog key definition.
dlg_parse_rcParse the configuration file and set up variables.dlg_popenOpen a pipe which ties the standard error and output together. The popen function captures only the standard output of a command.
dlg_prev_buttonReturn the previous index in the list of labels.
dlg_print_listitemThis is a helper function used for the various “list” widgets, e.g., checklist, menu, buildlist, treeview. Each list-widget has “tag” and “description” values for each item which can be displayed. If dialog_vars.no_tags is true, the “tag” value is not shown. The first character of the first value shown (tag or description) is highlighted to indicate that the widget will match it for quick navigation.
dlg_print_scrolledThis is a wrapper for dlg_print_autowrap which allows the user to scroll too-long prompt text up/down.See dlg_check_scrolled for a function which updates the offset variable used as a parameter here. It complements this function; you need both. If pauseopt is set, this function returns an updated last parameter, needed for dlg_check_scrolled calls.
dlg_print_linePrint one line of the prompt in the window within the limits of the specified right margin. The line will end on a word boundary and a pointer to the start of the next line is returned, or a NULL pointer if the end of *prompt is reached.
dlg_prev_ok_buttonindexFind the previous button index in the list from dlg_ok_labels.
dlg_print_autowrapPrint a string of text in a window, automatically wrap around to the next line if the string is too long to fit on one line. Note that the string may contain embedded newlines. The text is written starting at the top of the window.
dlg_print_sizeIf dialog_vars.print_siz is true, print the given height/width (from a widget) to dialog_state.output, e.g., Size: height, width.
dlg_print_textPrint up to cols columns from text, optionally rendering cdialog's escape sequences for attributes and color.
dlg_progressboximplements the "--prgbox" and "--progressbox" options.
dlg_put_backtitleDisplay the background title if dialog_vars.backtitle is non-null. The background title is shown at the top of the screen.dlg_reallocate_gaugeAllocates or reallocates a gauge widget (see dlg_allocate_gauge). Use dlg_update_gauge to display the result.
dlg_register_buttonsThe widget developer should call this function after dlg_register_window, for the list of button labels associated with the widget. One may bind a key to a button, e.g., “OK” for DLGK_OK,
dlg_register_windowFor a given named widget's window, associate a binding table.
dlg_remove_callbackRemove a callback.
dlg_renamed_menutextThis is a utility function which supports the --inputmenu option of the cdialog program. If dialog_vars.input_menu is set, dialog_menu passes this pointer to dlg_menu as the rename_menutext parameter. Otherwise, it passes dlg_dummy_menutext.The function should add “RENAMED” to dialog_vars.input_result , followed by the menu item's name and the newtext value (with a space separating the three items), and return DLG_EXIT_EXTRA.
dlg_reset_timeoutCalls wtimeout with the value saved for a window in the last call to dlg_set_timeout.dlg_restore_varsRestore cdialog's variables from the given variable (see dialog_save_vars).
The DIALOG_VARS.input_length and DIALOG_VARS.input_result members are treated specially, since these are used by a widget to pass data to the caller. They are not modified by this function. dlg_result_keyTest a cdialog internal keycode to see if it corresponds to one of the push buttons on the widget such as “OK”. This is only useful if there are user-defined key bindings, since there are no built-in bindings that map directly to DLGK_OK, etc. Return true if a mapping was done.
dlg_save_varsSave cdialog's variables into the given variable (see dlg_restore_vars).
dlg_set_focusSet focus on the given window, making it display above other windows on the screen.
dlg_set_resultSetup a fixed-buffer for the result in dialog_vars.input_result
dlg_set_timeoutCalls wtimeout to establish a preferred timeout for nonblocking reads, e.g., to allow the gauge widget to handle window-resizing events. The dlg_may_resize function temporarily overrides this value, to allow it to skip over the error codes returned while the ncurses library processes window-resizing events. It restores the value established in this call by calling dlg_restore_timeout.
dlg_show_stringDisplays the string, shifted as necessary, to fit within the box and show the current character-offset.
dlg_strcloneduplicate the string, like strdup.
dlg_strcmpcompare two strings, ignoring case.
dlg_string_to_argvConvert a string to an argument vector returning an index (which must be freed by the caller). The string is modified:
dlg_sub_windowcreate a subwindow, e.g., for an input area of a widget
dlg_tab_correct_strIf the dialog_vars.tab_correct is true, convert tabs to single spaces. Return the converted result. The caller is responsible for freeing the string.
dlg_traceIf the parameter is non-null, opens a trace file with that name and stores the file pointer in dialog_state.trace.dlg_trace_2nlogs a numeric value as a comment.
dlg_trace_2slogs a string value as a comment. If the value contains embedded newlines, the comment is continued with “#+” markers.
dlg_trace_chrIf dialog_state.trace is set, translate the parameters into a printable representation, log it on a “chr” line.
dlg_trace_msgWrite a formatted message to the trace file.
Use the DLG_TRACE macro for portability, in case the trace feature is not compiled into the library. It uses an extra level of parentheses to work with a variable number of parameters, e.g.,
DLG_TRACE(("this is dialog version %s\n", dialog_version()));
dlg_trace_va_msgWrite a formatted message to the trace file.
This is used in dlg_exiterr to capture error messages in the trace file: va_start(ap, fmt); dlg_trace_msg("## Error: "); dlg_trace_va_msg(fmt, ap); va_end(ap); Unlike dlg_trace_msg, an extra macro is not needed. dlg_ttysizeReturns the screensize without using curses. That allows the function to be used before initializing the screen.dlg_trace_winIf dialog_state.trace is set, log a printable picture of the given window.dlg_treeviewThis is an alternate interface to 'treeview' which allows the application to read the list item states back directly without putting them in the output buffer.
dlg_trim_stringThe cdialog 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 can be translated into a newline character).There are several optional features:
dlg_unregister_windowRemove the bindings for a given window.
dlg_update_gaugeUpdate a gauge widget to show a different percentage value.
dlg_will_resizeThis filters out bursts of KEY_RESIZE values. Call this after dlg_getc returns KEY_RESIZE, to improve performance.dlg_yes_buttoncodeMap the given button index for dlg_yes_labels into cdialog's exit-code.
dlg_yes_labelsReturn a list of buttons for Yes/No labels.end_dialogEnd use of cdialog functions.init_dialogDo some initialization for cdialog.
SEE ALSOcdialog (1).AUTHORThomas E. Dickey
Visit the GSP FreeBSD Man Page Interface. |