Struct Dialog

Source
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

Source

pub fn new() -> Dialog

Creates a new Dialog instance without configuration.

Examples found in repository?
examples/backend-dialog.rs (line 8)
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}
Source

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?
examples/backend-dialog.rs (line 14)
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}
Source

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?
examples/backend-dialog.rs (line 20)
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}
Source

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?
examples/backend-dialog.rs (line 19)
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}

Trait Implementations§

Source§

impl AsRef<Dialog> for Dialog

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Backend for Dialog

Source§

fn show_input(&self, input: &Input) -> Result<Option<String>>

Shows the given input dialog and returns the input.
Source§

fn show_message(&self, message: &Message) -> Result<()>

Shows the given message dialog.
Source§

fn show_password(&self, password: &Password) -> Result<Option<String>>

Shows the given password dialog and returns the password.
Source§

fn show_question(&self, question: &Question) -> Result<Choice>

Shows the given question dialog and returns the choice.
Source§

fn show_file_selection( &self, file_selection: &FileSelection, ) -> Result<Option<String>>

Shows the given file selection dialog and returns the file name.
Source§

impl Debug for Dialog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Dialog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Dialog

§

impl RefUnwindSafe for Dialog

§

impl Send for Dialog

§

impl Sync for Dialog

§

impl Unpin for Dialog

§

impl UnwindSafe for Dialog

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.