pub struct Dialog { /* private fields */ }
Expand description
The dialog
backend.
This backend uses the external dialog
program (not to be confused with this crate also called
dialog
) to display text-based dialog boxes in the terminal.
Implementations§
Source§impl Dialog
impl Dialog
Sourcepub fn new() -> Dialog
pub fn new() -> Dialog
Creates a new Dialog
instance without configuration.
Examples found in repository?
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::Dialog::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_backtitle("Backtitle");
15 dialog::Message::new("This is a message.")
16 .title("And this is a title:")
17 .show_with(&backend)?;
18
19 backend.set_width(100);
20 backend.set_height(10);
21 dialog::Message::new("This is a message with a fixed size.")
22 .title("And this is a title:")
23 .show_with(&backend)
24}
Sourcepub fn set_backtitle(&mut self, backtitle: impl Into<String>)
pub fn set_backtitle(&mut self, backtitle: impl Into<String>)
Sets the backtitle for the dialog boxes.
The backtitle is displayed on the backdrop, at the top of the screen.
Examples found in repository?
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::Dialog::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_backtitle("Backtitle");
15 dialog::Message::new("This is a message.")
16 .title("And this is a title:")
17 .show_with(&backend)?;
18
19 backend.set_width(100);
20 backend.set_height(10);
21 dialog::Message::new("This is a message with a fixed size.")
22 .title("And this is a title:")
23 .show_with(&backend)
24}
Sourcepub fn set_height(&mut self, height: u32)
pub fn set_height(&mut self, height: u32)
Sets the height of the dialog boxes.
The height is given in characters. The actual height of the dialog box might be higher than the given height if the content would not fit otherwise. The default height is zero.
Examples found in repository?
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::Dialog::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_backtitle("Backtitle");
15 dialog::Message::new("This is a message.")
16 .title("And this is a title:")
17 .show_with(&backend)?;
18
19 backend.set_width(100);
20 backend.set_height(10);
21 dialog::Message::new("This is a message with a fixed size.")
22 .title("And this is a title:")
23 .show_with(&backend)
24}
Sourcepub fn set_width(&mut self, width: u32)
pub fn set_width(&mut self, width: u32)
Sets the width of the dialog boxes.
The width is given in characters. The actual width of the dialog box might be higher than the given width if the content would not fit otherwise. The default width is zero.
Examples found in repository?
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::Dialog::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_backtitle("Backtitle");
15 dialog::Message::new("This is a message.")
16 .title("And this is a title:")
17 .show_with(&backend)?;
18
19 backend.set_width(100);
20 backend.set_height(10);
21 dialog::Message::new("This is a message with a fixed size.")
22 .title("And this is a title:")
23 .show_with(&backend)
24}