Display a dialog, depending on input display warnings
Parameters:
- dialog: dialog name string identifier
- line4: identifier of message/warning to be displayed when the
dialog input cannot be accepted
wsdialog_${dialog}_msg
: prompt messagewsdialog_${dialog}_accept
: function called on^M
(accept), sets
wsdialog_mode to empty if accepted or to a name of a dialog mode
$wsdialog_text
holds the prompt input. Returns the selected mode in the
$wsdialog_l4mode
variable.
wsdialog_${dialog}_restore
: function called after accept/cancel/undo,
to restore the state after exiting the dialog
wsdialog_${dialog}_${line4}_msg
: prompt messagewsdialog_${dialog]_${line4}_funcs
: associative array of keybindings
to the functions that are bound to the keybindings, must be declared with
declare -A <funcs array>
wsdialog_${dialog}_mode
: name of the zle modewsdialog_${dialog}_${line4}_mode
: name of the zle mode
^M
is always bound to accept^U
is the default cancel key, for the dialog modes it removes the
dialog and restores the state before the dialog, and for line4 modes it
removes the line4 and returns to the prompt in order to restore the state
before ^M
was pressed.
These rules do not have to be followed strictly, for example if the state
was modified in such a way that it would be a problem to restore it.
The purpose of the dialogs is to get the string from the prompt, therefore
the user do not have to know whether it was exited through accept or cancel,
the most important thing is the string entered by the user.
- Declare the necessary variables
- Call wsdialog-add $dialog, where $dialog is the name of the dialog
- When in a line4 event function: define
$wsdialog_l4mode
in order to
tell what should be done after this event. The value can be either the name of another line4 mode, or a constant:
<accept>
: accepts the prompt value and exit dialog<cancel>
: exit dialog with empty result (same as^U
in dialog mode)
It also can be undefined, in which case the line4 is removed and the cursor is moved to the position where it was before entering line4 mode.
<message>: <enter text> *RETURN* done | *Backspace* or *^H* erase left *^U* cancel | *Del* or *^G* erase char <Line4>
The dialog as well as the messages defined by the user can contain
formatting defined by *bold text*
, #standout text#
, _underline text_
.