etui/widgets/dialog
Types
Dialog configuration.
pub type Dialog {
Dialog(
message: String,
confirm_label: String,
cancel_label: String,
width: Int,
height: Int,
fg: style.Color,
bg: style.Color,
confirm_style: style.Style,
cancel_style: style.Style,
focused_style: style.Style,
border: block.Border,
)
}
Constructors
-
Dialog( message: String, confirm_label: String, cancel_label: String, width: Int, height: Int, fg: style.Color, bg: style.Color, confirm_style: style.Style, cancel_style: style.Style, focused_style: style.Style, border: block.Border, )Arguments
- width
-
Dialog box width (0 = auto: max of message width + 4 and 30).
- height
-
Total dialog height including border (0 = auto).
- focused_style
-
Style for the focused button.
Which button is currently focused.
pub type DialogButton {
Confirm
Cancel
}
Constructors
-
Confirm -
Cancel
Mutable dialog state.
pub type DialogState {
DialogState(focused: DialogButton)
}
Constructors
-
DialogState(focused: DialogButton)
Values
pub fn cancel(state: DialogState) -> DialogState
Convenience: focus Cancel (same as pressing Escape conceptually).
pub fn dialog_new(message: String) -> Dialog
Dialog with default labels (“OK” / “Cancel”) and a rounded border.
pub fn is_confirmed(state: DialogState) -> Bool
True if the Confirm button is focused.
pub fn render(
buf: buffer.Buffer,
area: geometry.Rect,
d: Dialog,
state: DialogState,
) -> buffer.Buffer
Render the dialog centered within area.
pub fn state_new() -> DialogState
pub fn toggle(state: DialogState) -> DialogState
Toggle focus between Confirm and Cancel.
pub fn with_border(d: Dialog, b: block.Border) -> Dialog
pub fn with_colors(
d: Dialog,
fg: style.Color,
bg: style.Color,
) -> Dialog
pub fn with_focused_style(d: Dialog, s: style.Style) -> Dialog
pub fn with_style(d: Dialog, s: style.Style) -> Dialog