DIALOG(3)

NAME
dialog - widgets and utilities for the dialog program

SYNOPSIS
cc [ flag ... ] file ... -ldialog [ library ... ] #include <dialog.h>

Dialog is a program that will let you to present a variety of questions or display messages using dialog boxes from a shell script. It is built from the dialog library, which consists of several widgets as well as utility functions that are used by the widgets or the main program.

DESCRIPTION
This manpage documents the features from <dialog.h> which are likely to be important to developers using the widgets directly. Some hints are also given for developing new widgets.

  DEFINITIONS
Exit codes (passed back to the main program for its use) are defined with a "DLG_EXIT_ prefix. The defined constants can be mapped using environment variables as described in dialog(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 dialog(1)). The DIALOG_ATR(n) macro is used for defining the references to the combined color and attribute table dlg_color_table[].

The dialog 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 <dialog.h> are used for convenience in building the library or main program. These include definitions based on the generated <dlg_config.h> header.

  DATA STRUCTURES
All of the global data for the dialog 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 dialog library.

DIALOG_STATE.all_windows
    This 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.

DIALOG_STATE.aspect_ratio
    This 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.

DIALOG_STATE.getc_callbacks
    This is setup 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.

DIALOG_STATE.getc_redirect
    If 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.

DIALOG_STATE.output
    This is set in the dialog 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.

DIALOG_STATE.output_count
    This is incremented by dlg_does_output, which is called by each widget that writes text to the output. The dialog application uses that to decide if it should also write a separator, i.e., DIALOG_STATE.separate_str, between calls to each widget.

DIALOG_STATE.pipe_input
    This 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 dialog 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.

DIALOG_STATE.screen_initialized
    This 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.

DIALOG_STATE.screen_output
    This 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).

DIALOG_STATE.separate_str
    This corresponds to the command-line option "--separate-widget". The given string specifies a string that will separate the output on dialog'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.

DIALOG_STATE.tab_len
    This 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.

DIALOG_STATE.use_colors
    This is set in init_dialog if the curses implementation supports color.

DIALOG_STATE.use_shadow
    This 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.

The dialog application resets the dialog_vars data before accepting options to invoke each widget. Most of the DIALOG_VARS members are set directly from dialog's command-line options:

DIALOG_VARS.backtitle
    This 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.

DIALOG_VARS.beep_after_signal
    This corresponds to the command-line option "--beep-after". If true, beep after a user has completed a widget by pressing one of the buttons.

DIALOG_VARS.beep_signal
    This corresponds to the command-line option "--beep". It is obsolete.

DIALOG_VARS.begin_set
    This 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.

DIALOG_VARS.begin_x
    This corresponds to the x value from the command-line option "--begin y x" (second value).

DIALOG_VARS.begin_y
    This corresponds to the y value from the command-line option "--begin y x" (first value).

DIALOG_VARS.cancel_label
    This corresponds to the command-line option "--cancel-label string". The given string overrides the label used for "Cancel" buttons.

DIALOG_VARS.cant_kill
    This corresponds to the command-line option "--no-kill". If true, this tells dialog to put the tailboxbg box in the background, printing its process id to dialog's output. SIGHUP is disabled for the background process.

DIALOG_VARS.colors
    This corresponds to the command-line option "--colors". If true, interpret embedded "\Z" sequences in the dialog text by the following character, which tells dialog to set colors or video attributes: 0 through 7 are the ANSI used in curses: black, red, green, yellow, blue, magenta, cyan and 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 bright red. Restore normal settings with "\Zn".

DIALOG_VARS.cr_wrap
    This corresponds to the command-line option "--cr-wrap". If true, interpret embedded newlines in the dialog text as a newline on the screen. Otherwise, dialog will only wrap lines where needed to fit inside the text box. Even though you can control line breaks with this, dialog 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.

DIALOG_VARS.default_item
    This 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.

DIALOG_VARS.defaultno
    This corresponds to the command-line option "--defaultno". If true, make the default value of the yes/no box a No. Likewise, make the default button of widgets that provide "OK" and "Cancel" a Cancel. If --nocancel was given that option overrides this, making the default button always "Yes" (internally the same as "OK").

DIALOG_VARS.dlg_clear_screen
    This 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.

DIALOG_VARS.exit_label
    This corresponds to the command-line option "--exit-label string". The given string overrides the label used for "EXIT" buttons.

DIALOG_VARS.extra_button
    This corresponds to the command-line option "--extra-button". If true, some widgets show an extra button, between "OK" and "Cancel" buttons.

DIALOG_VARS.extra_label
    This 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".

DIALOG_VARS.help_button
    This 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. 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 dialog's output after the token "HELP". Otherwise, the return status will indicate that the Help button was pressed, and no message printed.

DIALOG_VARS.help_label
    This corresponds to the command-line option "--help-label string". The given string overrides the label used for "Help" buttons.

DIALOG_VARS.help_status
    This 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.

DIALOG_VARS.input_length
    This is nonzero if DIALOG_VARS.input_result is allocated, versus being a pointer to the user's local variables.

DIALOG_VARS.input_menu
    This flag is set to denote whether the menubox widget implements a menu versus a inputmenu widget.

DIALOG_VARS.input_result
    This is a dynamically-allocated buffer used by the widgets to return printable results to the calling application.

DIALOG_VARS.insecure
    This corresponds to the command-line option "--insecure". If true, make the password widget friendlier but less secure, by echoing asterisks for each character.

DIALOG_VARS.item_help
    This 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.

DIALOG_VARS.keep_window
    This 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.

DIALOG_VARS.max_input
    This corresponds to the command-line option "--max-input size". Limit input strings to the given size. If not specified, the limit is 2048.

DIALOG_VARS.no_label
    This corresponds to the command-line option "--no-label string". The given string overrides the label used for "No" buttons.

DIALOG_VARS.nocancel
    This 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.

DIALOG_VARS.nocollapse
    This corresponds to the command-line option "--no-collapse". Normally dialog 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 dialog will still wrap text, subject to the --cr-wrap option.

DIALOG_VARS.ok_label
    This corresponds to the command-line option "--ok-label string". The given string overrides the label used for "OK" buttons.

DIALOG_VARS.print_siz
    This corresponds to the command-line option "--print-size". If true, each widget prints its size to dialog's output when it is invoked.

DIALOG_VARS.separate_output
    This 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.

DIALOG_VARS.single_quoted
    This 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, dialog uses double quotes around each item. That requires occasional use of backslashes to make the output useful in shell scripts.

DIALOG_VARS.size_err
    This 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).

DIALOG_VARS.sleep_secs
    This 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.

DIALOG_VARS.tab_correct
    This 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.

DIALOG_VARS.timeout_secs
    This 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.

DIALOG_VARS.title
    This corresponds to the command-line option "--title title". Specifies a title string to be displayed at the top of the dialog box.

DIALOG_VARS.trim_whitespace
    This corresponds to the command-line option "--trim". If true, eliminate leading blanks, trim literal newlines and repeated blanks from message text.

DIALOG_VARS.visit_items
    This corresponds to the command-line option "--visit-items". Modify the tab-traversal of checklist, radiobox, menubox and inputmenu 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.

DIALOG_VARS.yes_label
    This corresponds to the command-line option "--yes-label string". The given string overrides the label used for "Yes" buttons.

  WIDGETS
Functions that implement major functionality for the command-line dialog program, e.g., widgets, have names beginning "dialog_". All dialog boxes have at least three parameters:

title
    the caption for the box, shown on its top border.

height
    the height of the dialog box.

width
    the width of the dialog box.

Other parameters depend on the box type.

dialog_calendar
    implements the "--calendar option.

    title
        is the title on the top of the widget.

    subtitle
        is the prompt text shown within the widget.

    height
        is the height excluding the fixed-height calendar grid.

    width
        is the overall width of the box, which is adjusted up to the calendar grid's minimum width if needed.

    day is the initial day of the week shown, counting zero as Sunday. If the value is negative, the current day of the week is used.

    month
        is the initial month of the year shown, counting one as January. If the value is negative, the current month of the year is used.

    year
        is the initial year shown. If the value is negative, the current year is used.

dialog_checklist
    implements the "--checklist and "--radiolist options depending on the flag parameter.

    title
        is the title on the top of the widget.

    cprompt
        is the prompt text shown within the widget.

    height
        is the desired height of the box. If zero, the height is adjusted to use the available screen size.

    width
        is the desired width of the box. If zero, the height is adjusted to use the available screen size.

    list_height
        is the minimum height to reserve for displaying the list. If zero, it is computed based on the given height and width.

    item_no
        is the number of rows in items.

    items
        is an array of strings which is viewed either as a list of rows
        tag item status

        or
        tag item status help

        depending on whether dialog_vars.item_help is set.

    flag
        is either FLAG_CHECK, for checklists, or FLAG_RADIO for radiolists.

dialog_form
    implements the "--form option.

    title
        is the title on the top of the widget.

    cprompt
        is the prompt text shown within the widget.

    height
        is the desired height of the box. If zero, the height is adjusted to use the available screen size.

    width
        is the desired width of the box. If zero, the height is adjusted to use the available screen size.

    form_height
        is the minimum height to reserve for displaying the list. If zero, it is computed based on the given height and width.

    item_no
        is the number of rows in items.

    items
        is an array of strings which is viewed either as a list of rows
        Name NameY NameX Text TextY TextX FLen ILen

        or
        Name NameY NameX Text TextY TextX FLen ILen Help

        depending on whether dialog_vars.item_help is set.

dialog_fselect
    implements the "--fselect option.

    title
        is the title on the top of the widget.

    path
        is the preselected value to show in the input-box, which is used also to set the directory- and file-windows.

    height
        is the height excluding the minimum needed to show the dialog box framework. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

dialog_gauge
    implements the "--gauge option.

    title
        is the title on the top of the widget.

    cprompt
        is the prompt text shown within the widget.

    height
        is the desired height of the box. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

    percent
        is the percentage to show in the progress bar.

dialog_inputbox
    implements the "--inputbox or "--password option, depending on the value of password.

    title
        is the title on the top of the widget.

    cprompt
        is the prompt text shown within the widget.

    height
        is the desired height of the box. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

    init
        is the initial value of the input box, whose length is taken into account when auto-sizing the width of the dialog box.

    password
        if true, causes typed input to be echoed as asterisks.

dialog_menu
    implements the "--menu or "--inputmenu option depending on whether dialog_vars.input_menu is set.

    title
        is the title on the top of the widget.

    cprompt
        is the prompt text shown within the widget.

    height
        is the desired height of the box. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

    menu_height
        is the minimum height to reserve for displaying the list. If zero, it is computed based on the given height and width.

    item_no
        is the number of rows in items.

    items
        is an array of strings which is viewed either as a list of rows
        tag item

        or
        tag item help

        depending on whether dialog_vars.item_help is set.

dialog_msgbox
    implements the "--msgbox or "--infobox option depending on whether pauseopt is set.

    title
        is the title on the top of the widget.

    cprompt
        is the prompt text shown within the widget.

    height
        is the desired height of the box. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

    pauseopt
        if true, an "OK" button will be shown, and the dialog will wait for it to complete. With an "OK" button, it is denoted a "msgbox", without an "OK" button, it is denoted an "infobox".

dialog_pause
    implements the "--pause option.

    title
        is the title on the top of the widget.

    height
        is the desired height of the box. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

    seconds
        is the timeout to use for the progress bar.

dialog_tailbox
    implements the "--tailbox or "--tailboxbg option depending on whether bg_task is set.

    title
        is the title on the top of the widget.

    file
        is the name of the file to display in the dialog.

    height
        is the desired height of the box. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

    bg_task
        if true, the window is added to the callback list in dialog_state, and the application will poll for the window to be updated. Otherwise an "OK" button is added to the window, and it will be closed when the button is activated.

dialog_textbox
    implements the "--textbox option.

    title
        is the title on the top of the widget.

    file
        is the name of the file to display in the dialog.

    height
        is the desired height of the box. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

dialog_timebox
    implements the "--timebox option.

    title
        is the title on the top of the widget.

    subtitle
        is the prompt text shown within the widget.

    height
        is the desired height of the box. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

    hour
        is the initial hour shown. If the value is negative, the current hour is used.

    minute
        is the initial minute shown. If the value is negative, the current minute is used.

    second
        is the initial second shown. If the value is negative, the current second is used.

dialog_yesno
    implements the "--yesno option.

    title
        is the title on the top of the widget.

    cprompt
        is the prompt text shown within the widget.

    height
        is the desired height of the box. If zero, the height is based on the screen size.

    width
        is the desired width of the box. If zero, the height is based on the screen size.

  UTILITY FUNCTIONS
Most functions that implement lower-level functionality for the command-line dialog 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.

AUTHOR
Thomas E. Dickey