on master help sign in
Define text color (mostly) in theme.toml.
commitf0712479cbdff239347049461be1901e13950044 authorBlaž Hrastnik <blaz@mxxn.io> dateFri 7 May 2021, 17:38 (5 years ago) parentf87dee9
8 files changed+13−18
helix-term/src/ui/editor.rs+5−6 helix-term/src/ui/markdown.rs+1−1 helix-term/src/ui/menu.rs+1−1 helix-term/src/ui/mod.rs−6 helix-term/src/ui/picker.rs+1−1 helix-term/src/ui/prompt.rs+1−2 helix-term/src/ui/text.rs+1−1 theme.toml+3
helix-term/src/ui/editor.rs+5−6
@@ -3,7 +3,7 @@ use crate::{
33 compositor::{Component, Compositor, Context, EventResult},
44 key,
55 keymap::{self, Keymaps},
6− ui::{text_color, Completion},
6+ ui::Completion,
77};
88
99use helix_core::{
@@ -150,7 +150,7 @@ impl EditorView {
150150 // first rule that matches (rule.all(|scope| scopes.contains(scope)))
151151 let style = match spans.first() {
152152 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"),
154154 };
155155
156156 // TODO: we could render the text to a surface, then cache that, that
@@ -409,11 +409,10 @@ impl EditorView {
409409 Mode::Select => "SEL",
410410 Mode::Normal => "NOR",
411411 };
412− // TODO: share text_color styles inside theme
413412 let text_color = if is_focused {
414− Style::default().fg(Color::Rgb(219, 191, 239)) // lilac
413+ theme.get("ui.text.focus")
415414 } else {
416− Style::default().fg(Color::Rgb(164, 160, 232)) // lavender
415+ theme.get("ui.text")
417416 };
418417 // statusline
419418 surface.set_style(
@@ -632,7 +631,7 @@ impl Component for EditorView {
632631 let style = if *severity == Severity::Error {
633632 cx.editor.theme.get("error")
634633 } else {
635− Style::default().fg(Color::Rgb(164, 160, 232)) // lavender
634+ cx.editor.theme.get("ui.text")
636635 };
637636
638637 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> {
104104 Some(span) => {
105105 theme.get(theme.scopes()[span.0].as_str())
106106 }
107− None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender
107+ None => text_style,
108108 };
109109
110110 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> {
240240 }
241241
242242 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");
244244 let selected = Style::default().fg(Color::Rgb(255, 255, 255));
245245
246246 let scroll = self.scroll;
helix-term/src/ui/mod.rs−6
@@ -24,12 +24,6 @@ use helix_view::{Document, Editor, View};
2424
2525use std::path::{Path, PathBuf};
2626
27−// TODO: temp
28−#[inline(always)]
29−pub fn text_color() -> Style {
30− Style::default().fg(Color::Rgb(219, 191, 239)) // lilac
31−}
32−
3327pub fn regex_prompt(
3428 cx: &mut crate::commands::Context,
3529 prompt: String,
helix-term/src/ui/picker.rs+1−1
@@ -245,7 +245,7 @@ impl<T: 'static> Component for Picker<T> {
245245
246246 // -- Render the contents:
247247
248− let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
248+ let style = cx.editor.theme.get("ui.text");
249249 let selected = Style::default().fg(Color::Rgb(255, 255, 255));
250250
251251 let rows = inner.height - 2; // -1 for search bar
helix-term/src/ui/prompt.rs+1−2
@@ -103,11 +103,10 @@ use tui::{
103103};
104104
105105const BASE_WIDTH: u16 = 30;
106−use crate::ui::text_color;
107106
108107impl Prompt {
109108 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");
111110 // completion
112111 if !self.completion.is_empty() {
113112 // 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 {
2525 use tui::widgets::{Paragraph, Widget, Wrap};
2626 let contents = tui::text::Text::from(self.contents.clone());
2727
28− let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
28+ let style = cx.editor.theme.get("ui.text");
2929
3030 let par = Paragraph::new(contents).wrap(Wrap { trim: false });
3131 // .scroll(x, y) offsets
theme.toml+3
@@ -43,6 +43,9 @@
4343"ui.popup" = { bg = "#281733" } # revolver
4444"ui.window" = { bg = "#452859" } # bossa nova
4545
46+"ui.text" = { fg = "#a4a0e8"} # lavender
47+"ui.text.focus" = { fg = "#dbbfef"} # lilac
48+
4649"warning" = "#ffcd1c"
4750"error" = "#f47868"
4851"info" = "#6F44F0"