on master help sign in
feat: Default theme palette using 16 terminal colors
e40e6dbGokul Soumya
book/src/themes.md+21
@@ -123,3 +123,24 @@ black = "#000000"
123
123
124Remember that the `[palette]` table includes all keys after its header,
124Remember that the `[palette]` table includes all keys after its header,
125so you should define the palette after normal theme options.
125so 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 {
224 Magenta,
224 Magenta,
225 Cyan,
225 Cyan,
226 Gray,
226 Gray,
227− DarkGray,
228 LightRed,
227 LightRed,
229 LightGreen,
228 LightGreen,
230 LightYellow,
229 LightYellow,
231 LightBlue,
230 LightBlue,
232 LightMagenta,
231 LightMagenta,
233 LightCyan,
232 LightCyan,
233+ LightGray,
234 White,
234 White,
235 Rgb(u8, u8, u8),
235 Rgb(u8, u8, u8),
236 Indexed(u8),
236 Indexed(u8),
@@ -250,14 +250,14 @@ impl From<Color> for crossterm::style::Color {
250 Color::Blue => CColor::DarkBlue,
250 Color::Blue => CColor::DarkBlue,
251 Color::Magenta => CColor::DarkMagenta,
251 Color::Magenta => CColor::DarkMagenta,
252 Color::Cyan => CColor::DarkCyan,
252 Color::Cyan => CColor::DarkCyan,
253− Color::Gray => CColor::Grey,
253+ Color::Gray => CColor::DarkGrey,
254− Color::DarkGray => CColor::DarkGrey,
255 Color::LightRed => CColor::Red,
254 Color::LightRed => CColor::Red,
256 Color::LightGreen => CColor::Green,
255 Color::LightGreen => CColor::Green,
257 Color::LightBlue => CColor::Blue,
256 Color::LightBlue => CColor::Blue,
258 Color::LightYellow => CColor::Yellow,
257 Color::LightYellow => CColor::Yellow,
259 Color::LightMagenta => CColor::Magenta,
258 Color::LightMagenta => CColor::Magenta,
260 Color::LightCyan => CColor::Cyan,
259 Color::LightCyan => CColor::Cyan,
260+ Color::LightGray => CColor::Grey,
261 Color::White => CColor::White,
261 Color::White => CColor::White,
262 Color::Indexed(i) => CColor::AnsiValue(i),
262 Color::Indexed(i) => CColor::AnsiValue(i),
263 Color::Rgb(r, g, b) => CColor::Rgb { r, g, b },
263 Color::Rgb(r, g, b) => CColor::Rgb { r, g, b },
helix-view/src/theme.rs+19−1
@@ -5,6 +5,7 @@ use std::{
5};
5};
6
6
7use anyhow::Context;
7use anyhow::Context;
8+use helix_core::hashmap;
8use log::warn;
9use log::warn;
9use once_cell::sync::Lazy;
10use once_cell::sync::Lazy;
10use serde::{Deserialize, Deserializer};
11use serde::{Deserialize, Deserializer};
@@ -142,7 +143,24 @@ struct ThemePalette {
142
143
143impl Default for ThemePalette {
144impl Default for ThemePalette {
144 fn default() -> Self {
145 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+ })
146 }
164 }
147}
165}
148
166