diff --git a/src/prompts/fuzzy_select.rs b/src/prompts/fuzzy_select.rs index 59331b90..83535a96 100644 --- a/src/prompts/fuzzy_select.rs +++ b/src/prompts/fuzzy_select.rs @@ -89,7 +89,7 @@ impl FuzzySelect<'_> { self } - /// Sets the search text that a fuzzy search starts with. + /// Sets the search text that a fuzzy search starts with. pub fn with_initial_text>(&mut self, initial_text: S) -> &mut Self { self.initial_text = initial_text.into(); self @@ -164,7 +164,7 @@ impl FuzzySelect<'_> { /// Like `interact` but allows a specific terminal to be set. fn _interact_on(&self, term: &Term, allow_quit: bool) -> io::Result> { - // Place cursor at the end of the search term + // Place cursor at the end of the search term let mut position = self.initial_text.len(); let mut search_term = self.initial_text.to_owned(); diff --git a/src/prompts/input.rs b/src/prompts/input.rs index 72a71c77..eebed21f 100644 --- a/src/prompts/input.rs +++ b/src/prompts/input.rs @@ -46,6 +46,7 @@ pub struct Input<'a, T> { initial_text: Option, theme: &'a dyn Theme, permit_empty: bool, + #[allow(clippy::type_complexity)] validator: Option Option + 'a>>, #[cfg(feature = "history")] history: Option<&'a mut dyn History>, @@ -72,7 +73,10 @@ impl Input<'_, T> { } /// Changes the prompt text to the post completion text after input is complete - pub fn with_post_completion_text>(&mut self, post_completion_text: S) -> &mut Self { + pub fn with_post_completion_text>( + &mut self, + post_completion_text: S, + ) -> &mut Self { self.post_completion_text = Some(post_completion_text.into()); self } diff --git a/src/theme.rs b/src/theme.rs index 6f3404d7..a87cdbbe 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -318,30 +318,58 @@ pub struct ColorfulTheme { impl Default for ColorfulTheme { fn default() -> ColorfulTheme { - ColorfulTheme { - defaults_style: Style::new().for_stderr().cyan(), - prompt_style: Style::new().for_stderr().bold(), - prompt_prefix: style("?".to_string()).for_stderr().yellow(), - prompt_suffix: style("›".to_string()).for_stderr().black().bright(), - success_prefix: style("✔".to_string()).for_stderr().green(), - success_suffix: style("·".to_string()).for_stderr().black().bright(), - error_prefix: style("✘".to_string()).for_stderr().red(), - error_style: Style::new().for_stderr().red(), - hint_style: Style::new().for_stderr().black().bright(), - values_style: Style::new().for_stderr().green(), - active_item_style: Style::new().for_stderr().cyan(), - inactive_item_style: Style::new().for_stderr(), - active_item_prefix: style("❯".to_string()).for_stderr().green(), - inactive_item_prefix: style(" ".to_string()).for_stderr(), - checked_item_prefix: style("✔".to_string()).for_stderr().green(), - unchecked_item_prefix: style("✔".to_string()).for_stderr().black(), - picked_item_prefix: style("❯".to_string()).for_stderr().green(), - unpicked_item_prefix: style(" ".to_string()).for_stderr(), - #[cfg(feature = "fuzzy-select")] - fuzzy_cursor_style: Style::new().for_stderr().black().on_white(), - #[cfg(feature = "fuzzy-select")] - fuzzy_match_highlight_style: Style::new().for_stderr().bold(), - inline_selections: true, + if Term::stdout().features().wants_emoji() { + ColorfulTheme { + defaults_style: Style::new().for_stderr().cyan(), + prompt_style: Style::new().for_stderr().bold(), + prompt_prefix: style("?".to_string()).for_stderr().yellow(), + prompt_suffix: style("›".to_string()).for_stderr().black().bright(), + success_prefix: style("✔".to_string()).for_stderr().green(), + success_suffix: style("·".to_string()).for_stderr().black().bright(), + error_prefix: style("✘".to_string()).for_stderr().red(), + error_style: Style::new().for_stderr().red(), + hint_style: Style::new().for_stderr().black().bright(), + values_style: Style::new().for_stderr().green(), + active_item_style: Style::new().for_stderr().cyan(), + inactive_item_style: Style::new().for_stderr(), + active_item_prefix: style("❯".to_string()).for_stderr().green(), + inactive_item_prefix: style(" ".to_string()).for_stderr(), + checked_item_prefix: style("✔".to_string()).for_stderr().green(), + unchecked_item_prefix: style("✔".to_string()).for_stderr().black(), + picked_item_prefix: style("❯".to_string()).for_stderr().green(), + unpicked_item_prefix: style(" ".to_string()).for_stderr(), + #[cfg(feature = "fuzzy-select")] + fuzzy_cursor_style: Style::new().for_stderr().black().on_white(), + #[cfg(feature = "fuzzy-select")] + fuzzy_match_highlight_style: Style::new().for_stderr().bold(), + inline_selections: true, + } + } else { + ColorfulTheme { + defaults_style: Style::new().for_stderr().cyan(), + prompt_style: Style::new().for_stderr().bold(), + prompt_prefix: style("?".to_string()).for_stderr().yellow(), + prompt_suffix: style("›".to_string()).for_stderr().black().bright(), + success_prefix: style("√".to_string()).for_stderr().green(), + success_suffix: style("·".to_string()).for_stderr().black().bright(), + error_prefix: style("×".to_string()).for_stderr().red(), + error_style: Style::new().for_stderr().red(), + hint_style: Style::new().for_stderr().black().bright(), + values_style: Style::new().for_stderr().green(), + active_item_style: Style::new().for_stderr().cyan(), + inactive_item_style: Style::new().for_stderr(), + active_item_prefix: style(">".to_string()).for_stderr().green(), + inactive_item_prefix: style(" ".to_string()).for_stderr(), + checked_item_prefix: style("√".to_string()).for_stderr().green(), + unchecked_item_prefix: style("√".to_string()).for_stderr().black(), + picked_item_prefix: style(">".to_string()).for_stderr().green(), + unpicked_item_prefix: style(" ".to_string()).for_stderr(), + #[cfg(feature = "fuzzy-select")] + fuzzy_cursor_style: Style::new().for_stderr().black().on_white(), + #[cfg(feature = "fuzzy-select")] + fuzzy_match_highlight_style: Style::new().for_stderr().bold(), + inline_selections: true, + } } } }