Merge pull request #2818 from pml68/feat/rehighlight-on-redraw
Rehighlight TextEditor when Theme changes
This commit is contained in:
commit
0bf00d0f83
2 changed files with 53 additions and 27 deletions
|
|
@ -168,31 +168,7 @@ impl Theme {
|
|||
|
||||
impl fmt::Display for Theme {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Light => write!(f, "Light"),
|
||||
Self::Dark => write!(f, "Dark"),
|
||||
Self::Dracula => write!(f, "Dracula"),
|
||||
Self::Nord => write!(f, "Nord"),
|
||||
Self::SolarizedLight => write!(f, "Solarized Light"),
|
||||
Self::SolarizedDark => write!(f, "Solarized Dark"),
|
||||
Self::GruvboxLight => write!(f, "Gruvbox Light"),
|
||||
Self::GruvboxDark => write!(f, "Gruvbox Dark"),
|
||||
Self::CatppuccinLatte => write!(f, "Catppuccin Latte"),
|
||||
Self::CatppuccinFrappe => write!(f, "Catppuccin Frappé"),
|
||||
Self::CatppuccinMacchiato => write!(f, "Catppuccin Macchiato"),
|
||||
Self::CatppuccinMocha => write!(f, "Catppuccin Mocha"),
|
||||
Self::TokyoNight => write!(f, "Tokyo Night"),
|
||||
Self::TokyoNightStorm => write!(f, "Tokyo Night Storm"),
|
||||
Self::TokyoNightLight => write!(f, "Tokyo Night Light"),
|
||||
Self::KanagawaWave => write!(f, "Kanagawa Wave"),
|
||||
Self::KanagawaDragon => write!(f, "Kanagawa Dragon"),
|
||||
Self::KanagawaLotus => write!(f, "Kanagawa Lotus"),
|
||||
Self::Moonfly => write!(f, "Moonfly"),
|
||||
Self::Nightfly => write!(f, "Nightfly"),
|
||||
Self::Oxocarbon => write!(f, "Oxocarbon"),
|
||||
Self::Ferra => write!(f, "Ferra"),
|
||||
Self::Custom(custom) => custom.fmt(f),
|
||||
}
|
||||
f.write_str(self.name())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -270,6 +246,12 @@ pub trait Base {
|
|||
/// debugging purposes; like displaying performance
|
||||
/// metrics or devtools.
|
||||
fn palette(&self) -> Option<Palette>;
|
||||
|
||||
/// Returns the unique name of the theme.
|
||||
///
|
||||
/// This name may be used to efficiently detect theme
|
||||
/// changes in some widgets.
|
||||
fn name(&self) -> &str;
|
||||
}
|
||||
|
||||
impl Base for Theme {
|
||||
|
|
@ -313,6 +295,34 @@ impl Base for Theme {
|
|||
fn palette(&self) -> Option<Palette> {
|
||||
Some(self.palette())
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
match self {
|
||||
Self::Light => "Light",
|
||||
Self::Dark => "Dark",
|
||||
Self::Dracula => "Dracula",
|
||||
Self::Nord => "Nord",
|
||||
Self::SolarizedLight => "Solarized Light",
|
||||
Self::SolarizedDark => "Solarized Dark",
|
||||
Self::GruvboxLight => "Gruvbox Light",
|
||||
Self::GruvboxDark => "Gruvbox Dark",
|
||||
Self::CatppuccinLatte => "Catppuccin Latte",
|
||||
Self::CatppuccinFrappe => "Catppuccin Frappé",
|
||||
Self::CatppuccinMacchiato => "Catppuccin Macchiato",
|
||||
Self::CatppuccinMocha => "Catppuccin Mocha",
|
||||
Self::TokyoNight => "Tokyo Night",
|
||||
Self::TokyoNightStorm => "Tokyo Night Storm",
|
||||
Self::TokyoNightLight => "Tokyo Night Light",
|
||||
Self::KanagawaWave => "Kanagawa Wave",
|
||||
Self::KanagawaDragon => "Kanagawa Dragon",
|
||||
Self::KanagawaLotus => "Kanagawa Lotus",
|
||||
Self::Moonfly => "Moonfly",
|
||||
Self::Nightfly => "Nightfly",
|
||||
Self::Oxocarbon => "Oxocarbon",
|
||||
Self::Ferra => "Ferra",
|
||||
Self::Custom(custom) => &custom.name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The default [`Style`] of a built-in [`Theme`].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue