pub struct ConfirmationStyle {
pub label_style: LabelStyle,
pub input_formatting: Formatting,
pub submitted_formatting: Formatting,
}Expand description
Style for the Confirmation prompt
Fields§
§label_style: LabelStyleStyle for the prompt itself
input_formatting: FormattingStyle for the user’s input
submitted_formatting: FormattingFormatting for the user’s input when the prompt is completed
Implementations§
Source§impl ConfirmationStyle
impl ConfirmationStyle
Sourcepub fn label_style(self, l: LabelStyle) -> Self
pub fn label_style(self, l: LabelStyle) -> Self
Examples found in repository?
examples/styling.rs (line 41)
17fn main() -> Result<()> {
18 let label_style = LabelStyle::default()
19 .prefix("*")
20 .prefix_formatting(Formatting::default().foreground_color(Color::Cyan))
21 .prompt_formatting(
22 Formatting::default()
23 .bold()
24 .underline()
25 .foreground_color(Color::Magenta),
26 );
27 let input_formatting = Formatting::default().foreground_color(Color::Cyan);
28 let submitted_formatting = Formatting::default().foreground_color(Color::DarkCyan);
29
30 let name = Input::new("Enter your name", name_validation)
31 .style(
32 InputStyle::default()
33 .label_style(label_style.clone())
34 .input_formatting(input_formatting.clone())
35 .submitted_formatting(submitted_formatting.clone()),
36 )
37 .display();
38 let coffee = Confirmation::new("Do you want a cup of coffee")
39 .style(
40 ConfirmationStyle::default()
41 .label_style(label_style.clone())
42 .input_formatting(input_formatting.clone())
43 .submitted_formatting(submitted_formatting.clone()),
44 )
45 .display();
46
47 println!("Name: {:?}", name);
48 println!("Coffee: {:?}", coffee);
49
50 Ok(())
51}Sourcepub fn input_formatting(self, f: Formatting) -> Self
pub fn input_formatting(self, f: Formatting) -> Self
Examples found in repository?
examples/styling.rs (line 42)
17fn main() -> Result<()> {
18 let label_style = LabelStyle::default()
19 .prefix("*")
20 .prefix_formatting(Formatting::default().foreground_color(Color::Cyan))
21 .prompt_formatting(
22 Formatting::default()
23 .bold()
24 .underline()
25 .foreground_color(Color::Magenta),
26 );
27 let input_formatting = Formatting::default().foreground_color(Color::Cyan);
28 let submitted_formatting = Formatting::default().foreground_color(Color::DarkCyan);
29
30 let name = Input::new("Enter your name", name_validation)
31 .style(
32 InputStyle::default()
33 .label_style(label_style.clone())
34 .input_formatting(input_formatting.clone())
35 .submitted_formatting(submitted_formatting.clone()),
36 )
37 .display();
38 let coffee = Confirmation::new("Do you want a cup of coffee")
39 .style(
40 ConfirmationStyle::default()
41 .label_style(label_style.clone())
42 .input_formatting(input_formatting.clone())
43 .submitted_formatting(submitted_formatting.clone()),
44 )
45 .display();
46
47 println!("Name: {:?}", name);
48 println!("Coffee: {:?}", coffee);
49
50 Ok(())
51}Sourcepub fn submitted_formatting(self, f: Formatting) -> Self
pub fn submitted_formatting(self, f: Formatting) -> Self
Examples found in repository?
examples/styling.rs (line 43)
17fn main() -> Result<()> {
18 let label_style = LabelStyle::default()
19 .prefix("*")
20 .prefix_formatting(Formatting::default().foreground_color(Color::Cyan))
21 .prompt_formatting(
22 Formatting::default()
23 .bold()
24 .underline()
25 .foreground_color(Color::Magenta),
26 );
27 let input_formatting = Formatting::default().foreground_color(Color::Cyan);
28 let submitted_formatting = Formatting::default().foreground_color(Color::DarkCyan);
29
30 let name = Input::new("Enter your name", name_validation)
31 .style(
32 InputStyle::default()
33 .label_style(label_style.clone())
34 .input_formatting(input_formatting.clone())
35 .submitted_formatting(submitted_formatting.clone()),
36 )
37 .display();
38 let coffee = Confirmation::new("Do you want a cup of coffee")
39 .style(
40 ConfirmationStyle::default()
41 .label_style(label_style.clone())
42 .input_formatting(input_formatting.clone())
43 .submitted_formatting(submitted_formatting.clone()),
44 )
45 .display();
46
47 println!("Name: {:?}", name);
48 println!("Coffee: {:?}", coffee);
49
50 Ok(())
51}Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConfirmationStyle
impl RefUnwindSafe for ConfirmationStyle
impl Send for ConfirmationStyle
impl Sync for ConfirmationStyle
impl Unpin for ConfirmationStyle
impl UnwindSafe for ConfirmationStyle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more