diff options
author | Gokul Soumya | 2021-09-02 16:35:33 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-09-05 03:42:03 +0000 |
commit | e40e6db2271b9568352b7477ed8b9f9895881cf9 (patch) | |
tree | 3a45d4704d4c01b50fdac8191a045aa1ca4b8480 | |
parent | 95cd2c645b853b8b31792a5f97a144676198927f (diff) |
feat: Default theme palette using 16 terminal colors
-rw-r--r-- | book/src/themes.md | 21 | ||||
-rw-r--r-- | helix-view/src/graphics.rs | 6 | ||||
-rw-r--r-- | helix-view/src/theme.rs | 20 |
3 files changed, 43 insertions, 4 deletions
diff --git a/book/src/themes.md b/book/src/themes.md index 0a4d58ad..8642e659 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -123,3 +123,24 @@ black = "#000000" Remember that the `[palette]` table includes all keys after its header, so you should define the palette after normal theme options. + +If there is no `[palette]` section, a default palette which uses the terminal's default 16 colors are used: + +| Color Name | +| --- | +| `black` | +| `red` | +| `green` | +| `yellow` | +| `blue` | +| `magenta` | +| `cyan` | +| `gray` | +| `light-red` | +| `light-green` | +| `light-yellow` | +| `light-blue` | +| `light-magenta` | +| `light-cyan` | +| `light-gray` | +| `white` | diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index 66013ee5..0bfca04a 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -224,13 +224,13 @@ pub enum Color { Magenta,
Cyan,
Gray,
- DarkGray,
LightRed,
LightGreen,
LightYellow,
LightBlue,
LightMagenta,
LightCyan,
+ LightGray,
White,
Rgb(u8, u8, u8),
Indexed(u8),
@@ -250,14 +250,14 @@ impl From<Color> for crossterm::style::Color { Color::Blue => CColor::DarkBlue,
Color::Magenta => CColor::DarkMagenta,
Color::Cyan => CColor::DarkCyan,
- Color::Gray => CColor::Grey,
- Color::DarkGray => CColor::DarkGrey,
+ Color::Gray => CColor::DarkGrey,
Color::LightRed => CColor::Red,
Color::LightGreen => CColor::Green,
Color::LightBlue => CColor::Blue,
Color::LightYellow => CColor::Yellow,
Color::LightMagenta => CColor::Magenta,
Color::LightCyan => CColor::Cyan,
+ Color::LightGray => CColor::Grey,
Color::White => CColor::White,
Color::Indexed(i) => CColor::AnsiValue(i),
Color::Rgb(r, g, b) => CColor::Rgb { r, g, b },
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 74b817d0..9f768505 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -5,6 +5,7 @@ use std::{ }; use anyhow::Context; +use helix_core::hashmap; use log::warn; use once_cell::sync::Lazy; use serde::{Deserialize, Deserializer}; @@ -142,7 +143,24 @@ struct ThemePalette { impl Default for ThemePalette { fn default() -> Self { - Self::new(HashMap::new()) + Self::new(hashmap! { + "black".to_string() => Color::Black, + "red".to_string() => Color::Red, + "green".to_string() => Color::Green, + "yellow".to_string() => Color::Yellow, + "blue".to_string() => Color::Blue, + "magenta".to_string() => Color::Magenta, + "cyan".to_string() => Color::Cyan, + "gray".to_string() => Color::Gray, + "light-red".to_string() => Color::LightRed, + "light-green".to_string() => Color::LightGreen, + "light-yellow".to_string() => Color::LightYellow, + "light-blue".to_string() => Color::LightBlue, + "light-magenta".to_string() => Color::LightMagenta, + "light-cyan".to_string() => Color::LightCyan, + "light-gray".to_string() => Color::LightGray, + "white".to_string() => Color::White, + }) } } |