Define text color (mostly) in theme.toml.

This commit is contained in:
Blaž Hrastnik 2021-05-07 17:38:25 +09:00
parent f87dee926a
commit f0712479cb
8 changed files with 13 additions and 18 deletions

View file

@ -3,7 +3,7 @@ use crate::{
compositor::{Component, Compositor, Context, EventResult},
key,
keymap::{self, Keymaps},
ui::{text_color, Completion},
ui::Completion,
};
use helix_core::{
@ -150,7 +150,7 @@ impl EditorView {
// first rule that matches (rule.all(|scope| scopes.contains(scope)))
let style = match spans.first() {
Some(span) => theme.get(theme.scopes()[span.0].as_str()),
None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender
None => theme.get("ui.text"),
};
// TODO: we could render the text to a surface, then cache that, that
@ -409,11 +409,10 @@ impl EditorView {
Mode::Select => "SEL",
Mode::Normal => "NOR",
};
// TODO: share text_color styles inside theme
let text_color = if is_focused {
Style::default().fg(Color::Rgb(219, 191, 239)) // lilac
theme.get("ui.text.focus")
} else {
Style::default().fg(Color::Rgb(164, 160, 232)) // lavender
theme.get("ui.text")
};
// statusline
surface.set_style(
@ -632,7 +631,7 @@ impl Component for EditorView {
let style = if *severity == Severity::Error {
cx.editor.theme.get("error")
} else {
Style::default().fg(Color::Rgb(164, 160, 232)) // lavender
cx.editor.theme.get("ui.text")
};
surface.set_string(

View file

@ -104,7 +104,7 @@ fn parse<'a>(contents: &'a str, theme: Option<&Theme>) -> tui::text::Text<'a> {
Some(span) => {
theme.get(theme.scopes()[span.0].as_str())
}
None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender
None => text_style,
};
let mut slice = &text[start..end];

View file

@ -240,7 +240,7 @@ impl<T: 'static> Component for Menu<T> {
}
fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
let style = cx.editor.theme.get("ui.text");
let selected = Style::default().fg(Color::Rgb(255, 255, 255));
let scroll = self.scroll;

View file

@ -24,12 +24,6 @@ use helix_view::{Document, Editor, View};
use std::path::{Path, PathBuf};
// TODO: temp
#[inline(always)]
pub fn text_color() -> Style {
Style::default().fg(Color::Rgb(219, 191, 239)) // lilac
}
pub fn regex_prompt(
cx: &mut crate::commands::Context,
prompt: String,

View file

@ -245,7 +245,7 @@ impl<T: 'static> Component for Picker<T> {
// -- Render the contents:
let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
let style = cx.editor.theme.get("ui.text");
let selected = Style::default().fg(Color::Rgb(255, 255, 255));
let rows = inner.height - 2; // -1 for search bar

View file

@ -103,11 +103,10 @@ use tui::{
};
const BASE_WIDTH: u16 = 30;
use crate::ui::text_color;
impl Prompt {
pub fn render_prompt(&self, area: Rect, surface: &mut Surface, theme: &Theme) {
let text_color = text_color();
let text_color = theme.get("ui.text.focus");
// completion
if !self.completion.is_empty() {
// TODO: find out better way of clearing individual lines of the screen

View file

@ -25,7 +25,7 @@ impl Component for Text {
use tui::widgets::{Paragraph, Widget, Wrap};
let contents = tui::text::Text::from(self.contents.clone());
let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
let style = cx.editor.theme.get("ui.text");
let par = Paragraph::new(contents).wrap(Wrap { trim: false });
// .scroll(x, y) offsets

View file

@ -43,6 +43,9 @@
"ui.popup" = { bg = "#281733" } # revolver
"ui.window" = { bg = "#452859" } # bossa nova
"ui.text" = { fg = "#a4a0e8"} # lavender
"ui.text.focus" = { fg = "#dbbfef"} # lilac
"warning" = "#ffcd1c"
"error" = "#f47868"
"info" = "#6F44F0"