on master help sign in
Define text color (mostly) in theme.toml.
f071247Blaž Hrastnik
helix-term/src/ui/editor.rs+5−6
@@ -3,7 +3,7 @@ use crate::{
3 compositor::{Component, Compositor, Context, EventResult},
3 compositor::{Component, Compositor, Context, EventResult},
4 key,
4 key,
5 keymap::{self, Keymaps},
5 keymap::{self, Keymaps},
6− ui::{text_color, Completion},
6+ ui::Completion,
7};
7};
8
8
9use helix_core::{
9use helix_core::{
@@ -150,7 +150,7 @@ impl EditorView {
150 // first rule that matches (rule.all(|scope| scopes.contains(scope)))
150 // first rule that matches (rule.all(|scope| scopes.contains(scope)))
151 let style = match spans.first() {
151 let style = match spans.first() {
152 Some(span) => theme.get(theme.scopes()[span.0].as_str()),
152 Some(span) => theme.get(theme.scopes()[span.0].as_str()),
153− None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender
153+ None => theme.get("ui.text"),
154 };
154 };
155
155
156 // TODO: we could render the text to a surface, then cache that, that
156 // TODO: we could render the text to a surface, then cache that, that
@@ -409,11 +409,10 @@ impl EditorView {
409 Mode::Select => "SEL",
409 Mode::Select => "SEL",
410 Mode::Normal => "NOR",
410 Mode::Normal => "NOR",
411 };
411 };
412− // TODO: share text_color styles inside theme
413 let text_color = if is_focused {
412 let text_color = if is_focused {
414− Style::default().fg(Color::Rgb(219, 191, 239)) // lilac
413+ theme.get("ui.text.focus")
415 } else {
414 } else {
416− Style::default().fg(Color::Rgb(164, 160, 232)) // lavender
415+ theme.get("ui.text")
417 };
416 };
418 // statusline
417 // statusline
419 surface.set_style(
418 surface.set_style(
@@ -632,7 +631,7 @@ impl Component for EditorView {
632 let style = if *severity == Severity::Error {
631 let style = if *severity == Severity::Error {
633 cx.editor.theme.get("error")
632 cx.editor.theme.get("error")
634 } else {
633 } else {
635− Style::default().fg(Color::Rgb(164, 160, 232)) // lavender
634+ cx.editor.theme.get("ui.text")
636 };
635 };
637
636
638 surface.set_string(
637 surface.set_string(
helix-term/src/ui/markdown.rs+1−1
@@ -104,7 +104,7 @@ fn parse<'a>(contents: &'a str, theme: Option<&Theme>) -> tui::text::Text<'a> {
104 Some(span) => {
104 Some(span) => {
105 theme.get(theme.scopes()[span.0].as_str())
105 theme.get(theme.scopes()[span.0].as_str())
106 }
106 }
107− None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender
107+ None => text_style,
108 };
108 };
109
109
110 let mut slice = &text[start..end];
110 let mut slice = &text[start..end];
helix-term/src/ui/menu.rs+1−1
@@ -240,7 +240,7 @@ impl<T: 'static> Component for Menu<T> {
240 }
240 }
241
241
242 fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
242 fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
243− let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
243+ let style = cx.editor.theme.get("ui.text");
244 let selected = Style::default().fg(Color::Rgb(255, 255, 255));
244 let selected = Style::default().fg(Color::Rgb(255, 255, 255));
245
245
246 let scroll = self.scroll;
246 let scroll = self.scroll;
helix-term/src/ui/mod.rs−6
@@ -24,12 +24,6 @@ use helix_view::{Document, Editor, View};
24
24
25use std::path::{Path, PathBuf};
25use std::path::{Path, PathBuf};
26
26
27−// TODO: temp
28−#[inline(always)]
29−pub fn text_color() -> Style {
30− Style::default().fg(Color::Rgb(219, 191, 239)) // lilac
31−}
32−
33pub fn regex_prompt(
27pub fn regex_prompt(
34 cx: &mut crate::commands::Context,
28 cx: &mut crate::commands::Context,
35 prompt: String,
29 prompt: String,
helix-term/src/ui/picker.rs+1−1
@@ -245,7 +245,7 @@ impl<T: 'static> Component for Picker<T> {
245
245
246 // -- Render the contents:
246 // -- Render the contents:
247
247
248− let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
248+ let style = cx.editor.theme.get("ui.text");
249 let selected = Style::default().fg(Color::Rgb(255, 255, 255));
249 let selected = Style::default().fg(Color::Rgb(255, 255, 255));
250
250
251 let rows = inner.height - 2; // -1 for search bar
251 let rows = inner.height - 2; // -1 for search bar
helix-term/src/ui/prompt.rs+1−2
@@ -103,11 +103,10 @@ use tui::{
103};
103};
104
104
105const BASE_WIDTH: u16 = 30;
105const BASE_WIDTH: u16 = 30;
106−use crate::ui::text_color;
107
106
108impl Prompt {
107impl Prompt {
109 pub fn render_prompt(&self, area: Rect, surface: &mut Surface, theme: &Theme) {
108 pub fn render_prompt(&self, area: Rect, surface: &mut Surface, theme: &Theme) {
110− let text_color = text_color();
109+ let text_color = theme.get("ui.text.focus");
111 // completion
110 // completion
112 if !self.completion.is_empty() {
111 if !self.completion.is_empty() {
113 // TODO: find out better way of clearing individual lines of the screen
112 // TODO: find out better way of clearing individual lines of the screen
helix-term/src/ui/text.rs+1−1
@@ -25,7 +25,7 @@ impl Component for Text {
25 use tui::widgets::{Paragraph, Widget, Wrap};
25 use tui::widgets::{Paragraph, Widget, Wrap};
26 let contents = tui::text::Text::from(self.contents.clone());
26 let contents = tui::text::Text::from(self.contents.clone());
27
27
28− let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
28+ let style = cx.editor.theme.get("ui.text");
29
29
30 let par = Paragraph::new(contents).wrap(Wrap { trim: false });
30 let par = Paragraph::new(contents).wrap(Wrap { trim: false });
31 // .scroll(x, y) offsets
31 // .scroll(x, y) offsets
theme.toml+3
@@ -43,6 +43,9 @@
43"ui.popup" = { bg = "#281733" } # revolver
43"ui.popup" = { bg = "#281733" } # revolver
44"ui.window" = { bg = "#452859" } # bossa nova
44"ui.window" = { bg = "#452859" } # bossa nova
45
45
46+"ui.text" = { fg = "#a4a0e8"} # lavender
47+"ui.text.focus" = { fg = "#dbbfef"} # lilac
48+
46"warning" = "#ffcd1c"
49"warning" = "#ffcd1c"
47"error" = "#f47868"
50"error" = "#f47868"
48"info" = "#6F44F0"
51"info" = "#6F44F0"