mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Support setting custom background color for syntax highlighting (#12400)
Release Notes: - Added support for `background_color` in `syntax` map in `theme.json`. This adds support for setting a `background_color` for styles inside the `syntax` map for themes defined in `theme.json`. The field is optional so there should be no backwards compatibility issues. It is worth noting that the current behaviour for selecting text is that the background colours will mix/blend (I'm not sure the correct term here). Changing this behaviour, or making it configurable, looks to be a far more complex issue and I'm not sure I know how to do it.
This commit is contained in:
parent
fcb4abf18b
commit
7969a10643
@ -137,6 +137,10 @@ impl ThemeRegistry {
|
|||||||
.color
|
.color
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|color| try_parse_color(color).ok()),
|
.and_then(|color| try_parse_color(color).ok()),
|
||||||
|
background_color: highlight
|
||||||
|
.background_color
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|color| try_parse_color(color).ok()),
|
||||||
font_style: highlight.font_style.map(Into::into),
|
font_style: highlight.font_style.map(Into::into),
|
||||||
font_weight: highlight.font_weight.map(Into::into),
|
font_weight: highlight.font_weight.map(Into::into),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -117,6 +117,10 @@ impl ThemeStyleContent {
|
|||||||
.color
|
.color
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|color| try_parse_color(color).ok()),
|
.and_then(|color| try_parse_color(color).ok()),
|
||||||
|
background_color: style
|
||||||
|
.background_color
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|color| try_parse_color(color).ok()),
|
||||||
font_style: style
|
font_style: style
|
||||||
.font_style
|
.font_style
|
||||||
.map(|font_style| FontStyle::from(font_style)),
|
.map(|font_style| FontStyle::from(font_style)),
|
||||||
@ -1304,6 +1308,9 @@ impl From<FontWeightContent> for FontWeight {
|
|||||||
pub struct HighlightStyleContent {
|
pub struct HighlightStyleContent {
|
||||||
pub color: Option<String>,
|
pub color: Option<String>,
|
||||||
|
|
||||||
|
#[serde(deserialize_with = "treat_error_as_none")]
|
||||||
|
pub background_color: Option<String>,
|
||||||
|
|
||||||
#[serde(deserialize_with = "treat_error_as_none")]
|
#[serde(deserialize_with = "treat_error_as_none")]
|
||||||
pub font_style: Option<FontStyleContent>,
|
pub font_style: Option<FontStyleContent>,
|
||||||
|
|
||||||
@ -1313,7 +1320,10 @@ pub struct HighlightStyleContent {
|
|||||||
|
|
||||||
impl HighlightStyleContent {
|
impl HighlightStyleContent {
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.color.is_none() && self.font_style.is_none() && self.font_weight.is_none()
|
self.color.is_none()
|
||||||
|
&& self.background_color.is_none()
|
||||||
|
&& self.font_style.is_none()
|
||||||
|
&& self.font_weight.is_none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,6 +241,7 @@ impl VsCodeThemeConverter {
|
|||||||
|
|
||||||
let highlight_style = HighlightStyleContent {
|
let highlight_style = HighlightStyleContent {
|
||||||
color: token_color.settings.foreground.clone(),
|
color: token_color.settings.foreground.clone(),
|
||||||
|
background_color: token_color.settings.background.clone(),
|
||||||
font_style: token_color
|
font_style: token_color
|
||||||
.settings
|
.settings
|
||||||
.font_style
|
.font_style
|
||||||
|
Loading…
Reference in New Issue
Block a user