use std::borrow::Cow;
use reedline::{
Color, PromptEditMode, PromptHistorySearch, PromptHistorySearchStatus, PromptViMode,
};
#[derive(Default, Clone)]
pub struct Prompt;
impl reedline::Prompt for Prompt {
fn render_prompt_left(&self) -> Cow<str> {
Cow::Owned("".to_string())
}
fn render_prompt_right(&self) -> Cow<str> {
Cow::Owned("".to_string())
}
fn render_prompt_indicator(&self, edit_mode: PromptEditMode) -> Cow<str> {
match edit_mode {
PromptEditMode::Default | PromptEditMode::Emacs => "> ".into(),
PromptEditMode::Vi(vi_mode) => match vi_mode {
PromptViMode::Normal => "n]".into(),
PromptViMode::Insert => "i]".into(),
},
PromptEditMode::Custom(str) => format!("({})", str).into(),
}
}
fn render_prompt_multiline_indicator(&self) -> Cow<str> {
Cow::Borrowed(": ")
}
fn render_prompt_history_search_indicator(
&self,
history_search: PromptHistorySearch,
) -> Cow<str> {
let prefix = match history_search.status {
PromptHistorySearchStatus::Passing => "",
PromptHistorySearchStatus::Failing => "failing ",
};
Cow::Owned(format!(
"({}reverse-search: {}) ",
prefix, history_search.term
))
}
fn get_prompt_color(&self) -> Color {
Color::White
}
fn get_indicator_color(&self) -> Color {
Color::White
}
fn get_prompt_right_color(&self) -> Color {
Color::White
}
fn get_prompt_multiline_color(&self) -> nu_ansi_term::Color {
nu_ansi_term::Color::LightGray
}
}