DIALOG(3) DIALOG(3)
NAME
dialog(1,3,n) - widgets and utilities for the dialog(1,3,n) program
SYNOPSIS
cc [ flag ... ] file(1,n) ... -ldialog [ library ... ]
#include <dialog.h>
Dialog is a program that will let you to present a variety of questions
or display messages using dialog(1,3,n) boxes from a shell script. It is
built from the dialog(1,3,n) library, which consists of several widgets as
well as utility functions that are used by the widgets or the main pro-
gram.
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(1,8) dialog(1,3,n)(1), e.g., DLG_EXIT_OK cor-
responds to $DIALOG_OK.
Useful character constants which correspond to user input are named(5,8)
with the "CHR_" prefix, e.g., CHR_BACKSPACE.
Colors and video attributes are categorized and associated with set-
tings in(1,8) the configuration file(1,n) (see the discussion of $DIALOGRC in(1,8)
dialog(1,3,n)(1)). The DIALOG_ATR(n) macro is used for defining the refer-
ences to the combined color and attribute table dlg_color_table[].
The dialog(1,3,n) application passes its command-line parameters to the widget
functions. Some of those parameters are single values, but some of the
widgets accept(2,8) data as an array of values. Those include check-
list/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(1,8) <dialog.h> are used for conve-
nience in(1,8) building the library or main program. These include defini-
tions based on the generated <dlg_config.h> header.
DATA STRUCTURES
All of the global data for the dialog(1,3,n) library is stored in(1,8) a few struc-
tures: 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 begin-
ning with "dlg_" are intended for lower levels, e.g., by the dialog(1,3,n)
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 dimen-
sions when using auto(5,8) 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(2,8) in(1,8) 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(7,n,1 builtins) in(1,8) the dialog(1,3,n) application to the stream on which the
application and library functions may write(1,2) text results. Nor-
mally that is the standard error(8,n), since the curses library
prefers to write(1,2) its data to the standard output. Some scripts,
trading portability for convenience, prefer to write(1,2) 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(1,3,n) application
uses that to decide if(3,n) it should also write(1,2) a separator, i.e.,
DIALOG_STATE.separate_str, between calls to each widget.
DIALOG_STATE.pipe_input
This is set(7,n,1 builtins) in(1,8) init_dialog to a stream which can be used by the
gauge widget, which must be the application's standard input.
The dialog(1,3,n) application calls init_dialog normally with input set(7,n,1 builtins)
to the standard input, but optionally based on the "--input-fd"
option. Since the application cannot read(2,n,1 builtins) from a pipe(2,8) (standard
input) and at the same time(1,2,n) read(2,n,1 builtins) the curses input from the stan-
dard input, it must allow for reopening the latter from either a
specific file(1,n) descriptor, or directly from the terminal. The
adjusted pipe(2,8) stream value is stored in(1,8) this variable.
DIALOG_STATE.screen_initialized
This is set(7,n,1 builtins) in(1,8) init_dialog and reset(1,7,1 tput) in(1,8) end_dialog. It is used
to check if(3,n) curses has been initialized, and if(3,n) the endwin func-
tion must be called on exit.
DIALOG_STATE.screen_output
This is set(7,n,1 builtins) in(1,8) 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(3,n) init_dialog can suc-
cessfully open(2,3,n) the terminal directly).
DIALOG_STATE.separate_str
This corresponds to the command-line option "--separate-widget".
The given string(3,n) specifies a string(3,n) that will separate the out-
put on dialog(1,3,n)'s output from each widget. This is used to sim-
plify parsing the result of a dialog(1,3,n) with several widgets. If
this option is not given, the default separator string(3,n) 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(3,n)
the "--tab-correct" option is given. The default is 8.
DIALOG_STATE.use_colors
This is set(7,n,1 builtins) in(1,8) init_dialog if(3,n) the curses implementation supports
color.
DIALOG_STATE.use_shadow
This corresponds to the command-line option "--no-shadow". This
is set(7,n,1 builtins) in(1,8) init_dialog if(3,n) the curses implementation supports
color. If true, suppress shadows that would be drawn to the
right and bottom of each dialog(1,3,n) box.
The dialog(1,3,n) application resets the dialog_vars data before accepting
options to invoke each widget. Most of the DIALOG_VARS members are set(7,n,1 builtins)
directly from dialog(1,3,n)'s command-line options:
DIALOG_VARS.backtitle
This corresponds to the command-line option "--backtitle backti-
tle". It specifies a backtitle string(3,n) 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(1,3x,3x curs_beep) if(3,n) input is interrupted, e.g., by a control/C.
DIALOG_VARS.beep_signal
This corresponds to the command-line option "--beep". If true,
sound the audible alarm(1,2) each time(1,2,n) the screen is refreshed.
DIALOG_VARS.begin_set
This is true if(3,n) the command-line option "--begin y x" was used.
It specifies the position of the upper left corner of a dialog(1,3,n)
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(3,n)". The given string(3,n) 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(1,3,n) to put the tailboxbg box in(1,8) the back-
ground, printing its process id to dialog(1,3,n)'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(1,8) the dialog(1,3,n) text by
the following character, which tells dialog(1,3,n) to set(7,n,1 builtins) colors or
video attributes: 0 through 7 are the ANSI used in(1,8) curses:
black, red, green, yellow, blue, magenta, cyan and white respec-
tively. Bold is set(7,n,1 builtins) by 'b', reset(1,7,1 tput) by 'B'. Reverse is set(7,n,1 builtins) by
'r', reset(1,7,1 tput) by 'R'. Underline is set(7,n,1 builtins) by 'u', reset(1,7,1 tput) 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(1,8) the dialog(1,3,n) text as a new-
line on the screen. Otherwise, dialog(1,3,n) will only wrap lines
where needed to fit inside the text box. Even though you can
control line breaks with this, dialog(1,3,n) 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(1,8,3 Search::Dict) nice(1,2) in(1,8) the
source code of your script without affecting the way it will
look(1,8,3 Search::Dict) in(1,8) the dialog.
DIALOG_VARS.default_item
This corresponds to the command-line option "--default-item
string(3,n)". The given string(3,n) is used as the default item in(1,8) a
checklist, form or menu(3x,n,n tk_menuSetFocus) box. Normally the first item in(1,8) 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 "Can-
cel" 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(1,8) 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(3,n)". The given string(3,n) 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(3,n)". The given string(3,n) 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(1,8) checklist, radiolist and menu(3x,n,n tk_menuSetFocus) boxes. If
--item-help is also given, on exit(3,n,1 builtins) the return status will be the
same as for the "OK" button, and the item-help text will be
written to dialog(1,3,n)'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(3,n)". The given string(3,n) 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(3,n) DIALOG_VARS.input_result is allocated, versus
being a pointer to the user's local variables.
DIALOG_VARS.input_menu
This flag is set(7,n,1 builtins) to denote whether the menubox widget implements
a menu(3x,n,n tk_menuSetFocus) 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(1,3) 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(3x,n,n tk_menuSetFocus)
boxes adding a column whose text is displayed in(1,8) 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(1,8) the same process. Note that curses will clear(1,3x,3x clrtobot) 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(3,n)".
The given string(3,n) 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(1,8) checklist, inputbox and
menu(3x,n,n tk_menuSetFocus) box modes. A script can still test if(3,n) the user pressed the
ESC key to cancel to quit.
DIALOG_VARS.nocollapse
This corresponds to the command-line option "--no-collapse".
Normally dialog(1,3,n) converts tabs to spaces and reduces multiple
spaces to a single space for text which is displayed in(1,8) a mes-
sage boxes, etc. It true, that feature is disabled. Note that
dialog(1,3,n) will still wrap text, subject to the --cr-wrap option.
DIALOG_VARS.ok_label
This corresponds to the command-line option "--ok-label string(3,n)".
The given string(3,n) 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(1,3,n)'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(1,2,n),
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(3,n)
unneeded) for the output of checklist's as well as the item-help
text. If this option is not set(7,n,1 builtins), dialog(1,3,n) uses double quotes
around each item. That requires occasional use of backslashes
to make the output useful in(1,8) shell scripts.
DIALOG_VARS.size_err
This corresponds to the command-line option "--size-err". If
true, check the resulting size of a dialog(1,3,n) box before trying to
use it, printing the resulting size if(3,n) 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(1,8) the main program, not the library.
If nonzero, this is the number of seconds after to delay after
processing a dialog(1,3,n) 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 spa-
ces. 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(1,3x,3x cbreak) input requests (exit(3,n,1 builtins) with error(8,n) code) if(3,n) 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(3,n) to be displayed at the top of the dia-
log 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(3,n)". The given string(3,n) overrides the label used for "Yes"
buttons.
WIDGETS
Functions that implement major functionality for the command-line dia-
log program, e.g., widgets, have names beginning "dialog_".
All dialog(1,3,n) boxes have at least three parameters:
title
the caption for the box, shown on its top border.
height
the height of the dialog(1,3,n) box.
width
the width of the dialog(1,3,n) 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(3,n) 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(1,8) 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(1,8) 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(1,8) the input-box, which
is used also to set(7,n,1 builtins) the directory- and file-windows.
height is the height excluding the minimum needed to show the
dialog(1,3,n) 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(1,8) 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 dia-
log box.
password
if(3,n) 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(1,8) 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(3,n) true, an "OK" button will be shown, and the dialog(1,3,n)
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_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(1,n) is the name of the file(1,n) to display in(1,8) 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(3,n) true, the window is added to the callback list in(1,8) dia-
log_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 acti-
vated.
dialog_textbox
implements the "--textbox option.
title is the title on the top of the widget.
file(1,n) is the name of the file(1,n) to display in(1,8) 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 com-
mand-line dialog(1,3,n) program or widgets, have names beginning "dlg_". Bow-
ing to longstanding usage, the functions that initialize the display
and end it are named(5,8) init_dialog and end_dialog.
The only non-widget function whose name begins with "dialog_" is dia-
log_version, which returns the version(1,3,5) number of the library as a
string.
AUTHOR
Thomas E. Dickey
$Date: 2004/06/06 01:07:58 $ DIALOG(3)