on master help sign in
feat: Default theme palette using 16 terminal colors
commite40e6db2271b9568352b7477ed8b9f9895881cf9 authorGokul Soumya <gokulps15@gmail.com> dateThu 2 Sep 2021, 22:05 (5 years ago) parent95cd2c6
3 files changed+43−4
book/src/themes.md+21 helix-view/src/graphics.rs+3−3 helix-view/src/theme.rs+19−1
book/src/themes.md+21
@@ -123,3 +123,24 @@ black = "#000000"
123123
124124Remember that the `[palette]` table includes all keys after its header,
125125so you should define the palette after normal theme options.
126+
127+If there is no `[palette]` section, a default palette which uses the terminal's default 16 colors are used:
128+
129+| Color Name |
130+| --- |
131+| `black` |
132+| `red` |
133+| `green` |
134+| `yellow` |
135+| `blue` |
136+| `magenta` |
137+| `cyan` |
138+| `gray` |
139+| `light-red` |
140+| `light-green` |
141+| `light-yellow` |
142+| `light-blue` |
143+| `light-magenta` |
144+| `light-cyan` |
145+| `light-gray` |
146+| `white` |
helix-view/src/graphics.rs+3−3
@@ -224,13 +224,13 @@ pub enum Color {
224224 Magenta,
225225 Cyan,
226226 Gray,
227− DarkGray,
228227 LightRed,
229228 LightGreen,
230229 LightYellow,
231230 LightBlue,
232231 LightMagenta,
233232 LightCyan,
233+ LightGray,
234234 White,
235235 Rgb(u8, u8, u8),
236236 Indexed(u8),
@@ -250,14 +250,14 @@ impl From<Color> for crossterm::style::Color {
250250 Color::Blue => CColor::DarkBlue,
251251 Color::Magenta => CColor::DarkMagenta,
252252 Color::Cyan => CColor::DarkCyan,
253− Color::Gray => CColor::Grey,
254− Color::DarkGray => CColor::DarkGrey,
253+ Color::Gray => CColor::DarkGrey,
255254 Color::LightRed => CColor::Red,
256255 Color::LightGreen => CColor::Green,
257256 Color::LightBlue => CColor::Blue,
258257 Color::LightYellow => CColor::Yellow,
259258 Color::LightMagenta => CColor::Magenta,
260259 Color::LightCyan => CColor::Cyan,
260+ Color::LightGray => CColor::Grey,
261261 Color::White => CColor::White,
262262 Color::Indexed(i) => CColor::AnsiValue(i),
263263 Color::Rgb(r, g, b) => CColor::Rgb { r, g, b },
helix-view/src/theme.rs+19−1
@@ -5,6 +5,7 @@ use std::{
55};
66
77use anyhow::Context;
8+use helix_core::hashmap;
89use log::warn;
910use once_cell::sync::Lazy;
1011use serde::{Deserialize, Deserializer};
@@ -142,7 +143,24 @@ struct ThemePalette {
142143
143144impl Default for ThemePalette {
144145 fn default() -> Self {
145− Self::new(HashMap::new())
146+ Self::new(hashmap! {
147+ "black".to_string() => Color::Black,
148+ "red".to_string() => Color::Red,
149+ "green".to_string() => Color::Green,
150+ "yellow".to_string() => Color::Yellow,
151+ "blue".to_string() => Color::Blue,
152+ "magenta".to_string() => Color::Magenta,
153+ "cyan".to_string() => Color::Cyan,
154+ "gray".to_string() => Color::Gray,
155+ "light-red".to_string() => Color::LightRed,
156+ "light-green".to_string() => Color::LightGreen,
157+ "light-yellow".to_string() => Color::LightYellow,
158+ "light-blue".to_string() => Color::LightBlue,
159+ "light-magenta".to_string() => Color::LightMagenta,
160+ "light-cyan".to_string() => Color::LightCyan,
161+ "light-gray".to_string() => Color::LightGray,
162+ "white".to_string() => Color::White,
163+ })
146164 }
147165}
148166