From 680670e834ff57cf6eb15c373870d1fd478f8edb Mon Sep 17 00:00:00 2001 From: sigoden Date: Tue, 31 Oct 2023 09:06:41 +0800 Subject: feat: support custom theme (#187) --- src/repl/highlighter.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/repl/highlighter.rs') diff --git a/src/repl/highlighter.rs b/src/repl/highlighter.rs index 103d198..cca6297 100644 --- a/src/repl/highlighter.rs +++ b/src/repl/highlighter.rs @@ -3,16 +3,13 @@ use crate::config::SharedConfig; use nu_ansi_term::{Color, Style}; use reedline::{Highlighter, StyledText}; -const MATCH_COLOR: Color = Color::Green; - pub struct ReplHighlighter { external_commands: Vec, config: SharedConfig, } impl ReplHighlighter { - /// Construct the default highlighter with a given set of extern commands/keywords to detect and highlight - pub fn new(config: SharedConfig, external_commands: Vec) -> Self { + pub fn new(external_commands: Vec, config: SharedConfig) -> Self { Self { external_commands, config, @@ -22,18 +19,15 @@ impl ReplHighlighter { impl Highlighter for ReplHighlighter { fn highlight(&self, line: &str, _cursor: usize) -> StyledText { - let mut styled_text = StyledText::new(); - let color = if self.config.read().light_theme { - Color::Black - } else { - Color::White - }; + let color = Color::Default; let match_color = if self.config.read().highlight { - MATCH_COLOR + Color::Green } else { color }; + let mut styled_text = StyledText::new(); + if self .external_commands .clone() -- cgit v1.2.3