mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-24 16:53:55 +01:00
Use default_theme()
function from theme module
This commit is contained in:
parent
de796392cf
commit
cda363a3f7
@ -13,6 +13,7 @@ use crate::error::*;
|
|||||||
use crate::input::{InputReader, OpenedInput};
|
use crate::input::{InputReader, OpenedInput};
|
||||||
use crate::syntax_mapping::ignored_suffixes::IgnoredSuffixes;
|
use crate::syntax_mapping::ignored_suffixes::IgnoredSuffixes;
|
||||||
use crate::syntax_mapping::MappingTarget;
|
use crate::syntax_mapping::MappingTarget;
|
||||||
|
use crate::theme::{default_theme, ColorScheme};
|
||||||
use crate::{bat_warning, SyntaxMapping};
|
use crate::{bat_warning, SyntaxMapping};
|
||||||
|
|
||||||
use lazy_theme_set::LazyThemeSet;
|
use lazy_theme_set::LazyThemeSet;
|
||||||
@ -94,33 +95,18 @@ impl HighlightingAssets {
|
|||||||
pub fn default_theme() -> &'static str {
|
pub fn default_theme() -> &'static str {
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
{
|
{
|
||||||
Self::default_dark_theme()
|
default_theme(ColorScheme::Dark)
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
if macos_dark_mode_active() {
|
if macos_dark_mode_active() {
|
||||||
Self::default_dark_theme()
|
default_theme(ColorScheme::Dark)
|
||||||
} else {
|
} else {
|
||||||
Self::default_light_theme()
|
default_theme(ColorScheme::Light)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The default theme that looks good on a dark background.
|
|
||||||
*/
|
|
||||||
fn default_dark_theme() -> &'static str {
|
|
||||||
"Monokai Extended"
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default theme that looks good on a light background.
|
|
||||||
*/
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
fn default_light_theme() -> &'static str {
|
|
||||||
"Monokai Extended Light"
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_cache(cache_path: &Path) -> Result<Self> {
|
pub fn from_cache(cache_path: &Path) -> Result<Self> {
|
||||||
Ok(HighlightingAssets::new(
|
Ok(HighlightingAssets::new(
|
||||||
SerializedSyntaxSet::FromFile(cache_path.join("syntaxes.bin")),
|
SerializedSyntaxSet::FromFile(cache_path.join("syntaxes.bin")),
|
||||||
@ -249,7 +235,10 @@ impl HighlightingAssets {
|
|||||||
bat_warning!("Unknown theme '{}', using default.", theme)
|
bat_warning!("Unknown theme '{}', using default.", theme)
|
||||||
}
|
}
|
||||||
self.get_theme_set()
|
self.get_theme_set()
|
||||||
.get(self.fallback_theme.unwrap_or_else(Self::default_theme))
|
.get(
|
||||||
|
self.fallback_theme
|
||||||
|
.unwrap_or_else(|| default_theme(ColorScheme::Dark)),
|
||||||
|
)
|
||||||
.expect("something is very wrong if the default theme is missing")
|
.expect("something is very wrong if the default theme is missing")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ fn detect(when: DetectColorScheme, detector: &dyn ColorSchemeDetector) -> Option
|
|||||||
should_detect.then(|| detector.detect()).flatten()
|
should_detect.then(|| detector.detect()).flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn default_theme(color_scheme: ColorScheme) -> &'static str {
|
pub(crate) const fn default_theme(color_scheme: ColorScheme) -> &'static str {
|
||||||
match color_scheme {
|
match color_scheme {
|
||||||
ColorScheme::Dark => "Monokai Extended",
|
ColorScheme::Dark => "Monokai Extended",
|
||||||
ColorScheme::Light => "Monokai Extended Light",
|
ColorScheme::Light => "Monokai Extended Light",
|
||||||
|
Loading…
Reference in New Issue
Block a user