From a106be94f140918fa392bea660a87197b66390f0 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sat, 12 Sep 2020 17:44:57 +0900 Subject: Refactor a little bit. --- helix-term/src/theme.rs | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'helix-term/src/theme.rs') diff --git a/helix-term/src/theme.rs b/helix-term/src/theme.rs index 0353f0e6..5b6eb7de 100644 --- a/helix-term/src/theme.rs +++ b/helix-term/src/theme.rs @@ -3,9 +3,38 @@ use tui::style::{Color, Style}; /// Color theme for syntax highlighting. pub struct Theme { + scopes: Vec, mapping: HashMap<&'static str, Style>, } +// let highlight_names: Vec = [ +// "attribute", +// "constant.builtin", +// "constant", +// "function.builtin", +// "function.macro", +// "function", +// "keyword", +// "operator", +// "property", +// "punctuation", +// "comment", +// "escape", +// "label", +// // "punctuation.bracket", +// "punctuation.delimiter", +// "string", +// "string.special", +// "tag", +// "type", +// "type.builtin", +// "constructor", +// "variable", +// "variable.builtin", +// "variable.parameter", +// "path", +// ]; + impl Default for Theme { fn default() -> Self { let mapping = hashmap! { @@ -45,7 +74,9 @@ impl Default for Theme { "function.builtin" => Style::default().fg(Color::Rgb(255, 0, 0)), // white }; - Self { mapping } + let scopes = mapping.keys().map(ToString::to_string).collect(); + + Self { mapping, scopes } } } @@ -56,4 +87,8 @@ impl Theme { .copied() .unwrap_or_else(|| Style::default().fg(Color::Rgb(0, 0, 255))) } + + pub fn scopes(&self) -> &[String] { + &self.scopes + } } -- cgit v1.2.3-70-g09d2