Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/prompt/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ use {
strum::EnumIter,
};

/// The default color for the prompt, indicator, and right prompt
pub static DEFAULT_PROMPT_COLOR: Color = Color::Green;
pub static DEFAULT_PROMPT_MULTILINE_COLOR: nu_ansi_term::Color = nu_ansi_term::Color::LightBlue;
pub static DEFAULT_INDICATOR_COLOR: Color = Color::Cyan;
pub static DEFAULT_PROMPT_RIGHT_COLOR: Color = Color::AnsiValue(5);
/// Terminal-default colors for prompt implementations that do not opt into
/// explicit styling.
pub static BASE_PROMPT_COLOR: Color = Color::Reset;
pub static BASE_PROMPT_MULTILINE_COLOR: nu_ansi_term::Color = nu_ansi_term::Color::Default;
pub static BASE_INDICATOR_COLOR: Color = Color::Reset;
pub static BASE_PROMPT_RIGHT_COLOR: Color = Color::Reset;

/// The current success/failure of the history search
pub enum PromptHistorySearchStatus {
Expand Down Expand Up @@ -98,21 +99,21 @@ pub trait Prompt: Send {
&self,
history_search: PromptHistorySearch,
) -> Cow<'_, str>;
/// Get the default prompt color
/// Get the base prompt color
fn get_prompt_color(&self) -> Color {
DEFAULT_PROMPT_COLOR
BASE_PROMPT_COLOR
}
/// Get the default multiline prompt color
/// Get the base multiline prompt color
fn get_prompt_multiline_color(&self) -> nu_ansi_term::Color {
DEFAULT_PROMPT_MULTILINE_COLOR
BASE_PROMPT_MULTILINE_COLOR
}
/// Get the default indicator color
/// Get the base indicator color
fn get_indicator_color(&self) -> Color {
DEFAULT_INDICATOR_COLOR
BASE_INDICATOR_COLOR
}
/// Get the default right prompt color
/// Get the base right prompt color
fn get_prompt_right_color(&self) -> Color {
DEFAULT_PROMPT_RIGHT_COLOR
BASE_PROMPT_RIGHT_COLOR
}

/// Whether to render right prompt on the last line
Expand Down
22 changes: 22 additions & 0 deletions src/prompt/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{Prompt, PromptEditMode, PromptHistorySearch, PromptHistorySearchStat

use {
chrono::Local,
crossterm::style::Color,
std::{borrow::Cow, env},
};

Expand All @@ -10,6 +11,11 @@ pub static DEFAULT_PROMPT_INDICATOR: &str = "〉";
pub static DEFAULT_VI_INSERT_PROMPT_INDICATOR: &str = ": ";
pub static DEFAULT_VI_NORMAL_PROMPT_INDICATOR: &str = "〉";
pub static DEFAULT_MULTILINE_INDICATOR: &str = "::: ";
/// The default prompt colors
pub static DEFAULT_PROMPT_COLOR: Color = Color::Green;
pub static DEFAULT_PROMPT_MULTILINE_COLOR: nu_ansi_term::Color = nu_ansi_term::Color::LightBlue;
pub static DEFAULT_INDICATOR_COLOR: Color = Color::Cyan;
pub static DEFAULT_PROMPT_RIGHT_COLOR: Color = Color::AnsiValue(5);

/// Simple [`Prompt`] displaying a configurable left and a right prompt.
/// For more fine-tuned configuration, implement the [`Prompt`] trait.
Expand Down Expand Up @@ -89,6 +95,22 @@ impl Prompt for DefaultPrompt {
prefix, history_search.term
))
}

fn get_prompt_color(&self) -> Color {
DEFAULT_PROMPT_COLOR
}

fn get_prompt_multiline_color(&self) -> nu_ansi_term::Color {
DEFAULT_PROMPT_MULTILINE_COLOR
}

fn get_indicator_color(&self) -> Color {
DEFAULT_INDICATOR_COLOR
}

fn get_prompt_right_color(&self) -> Color {
DEFAULT_PROMPT_RIGHT_COLOR
}
}

impl Default for DefaultPrompt {
Expand Down
Loading