diff --git a/README.md b/README.md index a970fa5..19a2447 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,29 @@ fn main() { } ``` +## Dialog + +Show a dialog with multiple buttons. +Run example with [`cargo run --example dialog`](./examples/dialog.rs). + +![Dialog](./assets/dialog.gif) + +```rust +use demand::{Dialog, DialogButton}; + +fn main() { + let ms = Dialog::new("Are you sure?") + .description("This will do a thing.") + .buttons(vec![ + DialogButton::new("Ok"), + DialogButton::new("Not sure"), + DialogButton::new("Cancel"), + ]) + .selected_button(1); + ms.run().expect("error running confirm"); +} +``` + ## Spinner Spinners are used to indicate that a process is running. diff --git a/assets/dialog.gif b/assets/dialog.gif new file mode 100644 index 0000000..d1563c9 Binary files /dev/null and b/assets/dialog.gif differ diff --git a/assets/dialog.tape b/assets/dialog.tape new file mode 100644 index 0000000..f2a3cdb --- /dev/null +++ b/assets/dialog.tape @@ -0,0 +1,77 @@ +# VHS documentation +# +# Output: +# Output .gif Create a GIF output at the given +# Output .mp4 Create an MP4 output at the given +# Output .webm Create a WebM output at the given +# +# Require: +# Require Ensure a program is on the $PATH to proceed +# +# Settings: +# Set FontSize Set the font size of the terminal +# Set FontFamily Set the font family of the terminal +# Set Height Set the height of the terminal +# Set Width Set the width of the terminal +# Set LetterSpacing Set the font letter spacing (tracking) +# Set LineHeight Set the font line height +# Set LoopOffset % Set the starting frame offset for the GIF loop +# Set Theme Set the theme of the terminal +# Set Padding Set the padding of the terminal +# Set Framerate Set the framerate of the recording +# Set PlaybackSpeed Set the playback speed of the recording +# Set MarginFill Set the file or color the margin will be filled with. +# Set Margin Set the size of the margin. Has no effect if MarginFill isn't set. +# Set BorderRadius Set terminal border radius, in pixels. +# Set WindowBar Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight) +# Set WindowBarSize Set window bar size, in pixels. Default is 40. +# Set TypingSpeed