Define text color (mostly) in theme.toml.
This commit is contained in:
parent
f87dee926a
commit
f0712479cb
8 changed files with 13 additions and 18 deletions
|
@ -3,7 +3,7 @@ use crate::{
|
||||||
compositor::{Component, Compositor, Context, EventResult},
|
compositor::{Component, Compositor, Context, EventResult},
|
||||||
key,
|
key,
|
||||||
keymap::{self, Keymaps},
|
keymap::{self, Keymaps},
|
||||||
ui::{text_color, Completion},
|
ui::Completion,
|
||||||
};
|
};
|
||||||
|
|
||||||
use helix_core::{
|
use helix_core::{
|
||||||
|
@ -150,7 +150,7 @@ impl EditorView {
|
||||||
// first rule that matches (rule.all(|scope| scopes.contains(scope)))
|
// first rule that matches (rule.all(|scope| scopes.contains(scope)))
|
||||||
let style = match spans.first() {
|
let style = match spans.first() {
|
||||||
Some(span) => theme.get(theme.scopes()[span.0].as_str()),
|
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
|
// TODO: we could render the text to a surface, then cache that, that
|
||||||
|
@ -409,11 +409,10 @@ impl EditorView {
|
||||||
Mode::Select => "SEL",
|
Mode::Select => "SEL",
|
||||||
Mode::Normal => "NOR",
|
Mode::Normal => "NOR",
|
||||||
};
|
};
|
||||||
// TODO: share text_color styles inside theme
|
|
||||||
let text_color = if is_focused {
|
let text_color = if is_focused {
|
||||||
Style::default().fg(Color::Rgb(219, 191, 239)) // lilac
|
theme.get("ui.text.focus")
|
||||||
} else {
|
} else {
|
||||||
Style::default().fg(Color::Rgb(164, 160, 232)) // lavender
|
theme.get("ui.text")
|
||||||
};
|
};
|
||||||
// statusline
|
// statusline
|
||||||
surface.set_style(
|
surface.set_style(
|
||||||
|
@ -632,7 +631,7 @@ impl Component for EditorView {
|
||||||
let style = if *severity == Severity::Error {
|
let style = if *severity == Severity::Error {
|
||||||
cx.editor.theme.get("error")
|
cx.editor.theme.get("error")
|
||||||
} else {
|
} else {
|
||||||
Style::default().fg(Color::Rgb(164, 160, 232)) // lavender
|
cx.editor.theme.get("ui.text")
|
||||||
};
|
};
|
||||||
|
|
||||||
surface.set_string(
|
surface.set_string(
|
||||||
|
|
|
@ -104,7 +104,7 @@ fn parse<'a>(contents: &'a str, theme: Option<&Theme>) -> tui::text::Text<'a> {
|
||||||
Some(span) => {
|
Some(span) => {
|
||||||
theme.get(theme.scopes()[span.0].as_str())
|
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];
|
let mut slice = &text[start..end];
|
||||||
|
|
|
@ -240,7 +240,7 @@ impl<T: 'static> Component for Menu<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
|
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 selected = Style::default().fg(Color::Rgb(255, 255, 255));
|
||||||
|
|
||||||
let scroll = self.scroll;
|
let scroll = self.scroll;
|
||||||
|
|
|
@ -24,12 +24,6 @@ use helix_view::{Document, Editor, View};
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
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(
|
pub fn regex_prompt(
|
||||||
cx: &mut crate::commands::Context,
|
cx: &mut crate::commands::Context,
|
||||||
prompt: String,
|
prompt: String,
|
||||||
|
|
|
@ -245,7 +245,7 @@ impl<T: 'static> Component for Picker<T> {
|
||||||
|
|
||||||
// -- Render the contents:
|
// -- 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 selected = Style::default().fg(Color::Rgb(255, 255, 255));
|
||||||
|
|
||||||
let rows = inner.height - 2; // -1 for search bar
|
let rows = inner.height - 2; // -1 for search bar
|
||||||
|
|
|
@ -103,11 +103,10 @@ use tui::{
|
||||||
};
|
};
|
||||||
|
|
||||||
const BASE_WIDTH: u16 = 30;
|
const BASE_WIDTH: u16 = 30;
|
||||||
use crate::ui::text_color;
|
|
||||||
|
|
||||||
impl Prompt {
|
impl Prompt {
|
||||||
pub fn render_prompt(&self, area: Rect, surface: &mut Surface, theme: &Theme) {
|
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
|
// completion
|
||||||
if !self.completion.is_empty() {
|
if !self.completion.is_empty() {
|
||||||
// TODO: find out better way of clearing individual lines of the screen
|
// TODO: find out better way of clearing individual lines of the screen
|
||||||
|
|
|
@ -25,7 +25,7 @@ impl Component for Text {
|
||||||
use tui::widgets::{Paragraph, Widget, Wrap};
|
use tui::widgets::{Paragraph, Widget, Wrap};
|
||||||
let contents = tui::text::Text::from(self.contents.clone());
|
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 });
|
let par = Paragraph::new(contents).wrap(Wrap { trim: false });
|
||||||
// .scroll(x, y) offsets
|
// .scroll(x, y) offsets
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
"ui.popup" = { bg = "#281733" } # revolver
|
"ui.popup" = { bg = "#281733" } # revolver
|
||||||
"ui.window" = { bg = "#452859" } # bossa nova
|
"ui.window" = { bg = "#452859" } # bossa nova
|
||||||
|
|
||||||
|
"ui.text" = { fg = "#a4a0e8"} # lavender
|
||||||
|
"ui.text.focus" = { fg = "#dbbfef"} # lilac
|
||||||
|
|
||||||
"warning" = "#ffcd1c"
|
"warning" = "#ffcd1c"
|
||||||
"error" = "#f47868"
|
"error" = "#f47868"
|
||||||
"info" = "#6F44F0"
|
"info" = "#6F44F0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue