diff options
| author | sigoden <sigoden@gmail.com> | 2023-10-31 09:06:41 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-31 09:06:41 +0800 |
| commit | 680670e834ff57cf6eb15c373870d1fd478f8edb (patch) | |
| tree | 5b3ef0436532560c35da9959d3e603397a1d8c0d /src/repl/highlighter.rs | |
| parent | 84004fd5767abc94a5360b742e7fd0c8a79c6c55 (diff) | |
| download | aichat-680670e834ff57cf6eb15c373870d1fd478f8edb.tar.gz | |
feat: support custom theme (#187)
Diffstat (limited to 'src/repl/highlighter.rs')
| -rw-r--r-- | src/repl/highlighter.rs | 16 |
1 files changed, 5 insertions, 11 deletions
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<String>, 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<String>) -> Self { + pub fn new(external_commands: Vec<String>, 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() |
