jdx / demand

prompt library for rust
https://docs.rs/demand
MIT License
52 stars 3 forks source link

custom theme support #15

Closed jdx closed 7 months ago

roele commented 7 months ago

What do you have in mind here?

By exposing some helper methods for the colors, a custom theme could already be achieved with something like

let theme = Theme {
    cursor: Theme::color_rgb(166, 227, 161),
    selected_prefix: String::from("(*)"),
    unselected_prefix: String::from("( )"),
    ..Default::default()
};
jdx commented 7 months ago

perhaps just documenting how to do it

roele commented 7 months ago

One thing i find a bit cumbersome is the fact that a theme needs to be cloned when used with multiple inputs. Not sure if thats expensive or generally an accepted pattern in Rust.

let mut theme = Theme::new();

let i = Input::new("What's your e-mail?")
    .description("Please enter your e-mail address.")
    .placeholder("john.doe@acme.com")
    .theme(theme.clone());
i.run().expect("error running input");

let c = Confirm::new("Confirm privacy policy")
    .description("Do you accept the privacy policy?")
    .affirmative("Yes")
    .negative("No")
    .theme(theme.clone());
c.run().expect("error running confirm");
jdx commented 7 months ago

created #22 to address that