diff --git a/cli/app.rs b/cli/app.rs index 1a063bbfb..0144a3653 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -200,7 +200,7 @@ macro_rules! query_internal { }}; } -static COLORS: &[Color] = &[Color::DarkRed, Color::DarkGreen, Color::DarkBlue]; +static COLORS: &[Color] = &[Color::Green, Color::Black, Color::Grey]; impl<'a> Limbo<'a> { pub fn new(rl: &'a mut rustyline::Editor) -> anyhow::Result { @@ -757,7 +757,7 @@ impl<'a> Limbo<'a> { let name = rows.get_column_name(i); Cell::new(name) .add_attribute(Attribute::Bold) - .fg(Color::AnsiValue(49)) // Green color for headers + .fg(Color::White) }) .collect::>(); table.set_header(header); diff --git a/cli/helper.rs b/cli/helper.rs index 37cd462b8..90549dd11 100644 --- a/cli/helper.rs +++ b/cli/helper.rs @@ -7,11 +7,6 @@ use rustyline::completion::{extract_word, Completer, Pair}; use rustyline::highlight::Highlighter; use rustyline::hint::HistoryHinter; use rustyline::{Completer, Helper, Hinter, Validator}; -use syntect::dumps::from_uncompressed_data; -use syntect::easy::HighlightLines; -use syntect::highlighting::ThemeSet; -use syntect::parsing::{Scope, SyntaxSet}; -use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings}; macro_rules! try_result { ($expr:expr, $err:expr) => { @@ -26,25 +21,14 @@ macro_rules! try_result { pub struct LimboHelper { #[rustyline(Completer)] completer: SqlCompleter, - syntax_set: SyntaxSet, - theme_set: ThemeSet, #[rustyline(Hinter)] hinter: HistoryHinter, } impl LimboHelper { pub fn new(conn: Rc, io: Arc) -> Self { - // Load only predefined syntax - let ps = from_uncompressed_data(include_bytes!(concat!( - env!("OUT_DIR"), - "/SQL_syntax_set_dump.packdump" - ))) - .unwrap(); - let ts = ThemeSet::load_defaults(); LimboHelper { completer: SqlCompleter::new(conn, io), - syntax_set: ps, - theme_set: ts, hinter: HistoryHinter::new(), } } @@ -53,25 +37,9 @@ impl LimboHelper { impl Highlighter for LimboHelper { fn highlight<'l>(&self, line: &'l str, pos: usize) -> std::borrow::Cow<'l, str> { let _ = pos; - // TODO use lifetimes to store highlight lines - let syntax = self - .syntax_set - .find_syntax_by_scope(Scope::new("source.sql").unwrap()) - .unwrap(); - let mut h = HighlightLines::new(syntax, &self.theme_set.themes["base16-ocean.dark"]); - let ranges = { - let mut ret_ranges = Vec::new(); - for new_line in LinesWithEndings::from(line) { - let ranges: Vec<(syntect::highlighting::Style, &str)> = - h.highlight_line(new_line, &self.syntax_set).unwrap(); - ret_ranges.extend(ranges); - } - ret_ranges - }; - let mut ret_line = as_24_bit_terminal_escaped(&ranges[..], false); - // Push this escape sequence to reset color modes at the end of the string - ret_line.push_str("\x1b[0m"); - std::borrow::Cow::Owned(ret_line) + let style = Style::new().fg(Color::White); // Standard shell text color + let styled_str = style.paint(line); + std::borrow::Cow::Owned(styled_str.to_string()) } fn highlight_prompt<'b, 's: 'b, 'p: 'b>( @@ -80,20 +48,16 @@ impl Highlighter for LimboHelper { default: bool, ) -> std::borrow::Cow<'b, str> { let _ = default; - // Make prompt bold - let style = Style::new().bold().fg(Color::Green); + // Dark emerald green for prompt + let style = Style::new().bold().fg(Color::Rgb(34u8, 197u8, 94u8)); let styled_str = style.paint(prompt); std::borrow::Cow::Owned(styled_str.to_string()) } fn highlight_hint<'h>(&self, hint: &'h str) -> std::borrow::Cow<'h, str> { - let style = Style::new() - .bold() - .dimmed() - .underline() - .fg(Color::Fixed(246)); + let style = Style::new().bold().fg(Color::Rgb(107u8, 114u8, 128u8)); // Brighter dark grey for hints let styled_str = style.paint(hint); - std::borrow::Cow::Owned(styled_str.to_string()) // Bold dim grey underline + std::borrow::Cow::Owned(styled_str.to_string()) } fn highlight_candidate<'c>( @@ -102,7 +66,7 @@ impl Highlighter for LimboHelper { completion: rustyline::CompletionType, ) -> std::borrow::Cow<'c, str> { let _ = completion; - let style = Style::new().fg(Color::Fixed(69)); + let style = Style::new().fg(Color::Green); let styled_str = style.paint(candidate); std::borrow::Cow::Owned(styled_str.to_string()) }