mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-15 07:10:43 +01:00
Use new default_theme
fn for --list-themes
This commit is contained in:
parent
06b645435a
commit
1b0a6da4be
@ -30,12 +30,12 @@ use directories::PROJECT_DIRS;
|
|||||||
use globset::GlobMatcher;
|
use globset::GlobMatcher;
|
||||||
|
|
||||||
use bat::{
|
use bat::{
|
||||||
assets::HighlightingAssets,
|
|
||||||
config::Config,
|
config::Config,
|
||||||
controller::Controller,
|
controller::Controller,
|
||||||
error::*,
|
error::*,
|
||||||
input::Input,
|
input::Input,
|
||||||
style::{StyleComponent, StyleComponents},
|
style::{StyleComponent, StyleComponents},
|
||||||
|
theme::{color_scheme, default_theme, ColorScheme, DetectColorScheme},
|
||||||
MappingTarget, PagingMode,
|
MappingTarget, PagingMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -200,10 +200,14 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
|
|||||||
let stdout = io::stdout();
|
let stdout = io::stdout();
|
||||||
let mut stdout = stdout.lock();
|
let mut stdout = stdout.lock();
|
||||||
|
|
||||||
let default_theme = HighlightingAssets::default_theme();
|
let default_theme_name = default_theme(color_scheme(DetectColorScheme::Auto));
|
||||||
for theme in assets.themes() {
|
for theme in assets.themes() {
|
||||||
let default_theme_info = if default_theme == theme {
|
let default_theme_info = if default_theme_name == theme {
|
||||||
" (default)"
|
" (default)"
|
||||||
|
} else if default_theme(ColorScheme::Dark) == theme {
|
||||||
|
" (default dark)"
|
||||||
|
} else if default_theme(ColorScheme::Light) == theme {
|
||||||
|
" (default light)"
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
};
|
};
|
||||||
|
@ -19,6 +19,11 @@ pub const fn default_theme(color_scheme: ColorScheme) -> &'static str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Detects the color scheme from the terminal.
|
||||||
|
pub fn color_scheme(when: DetectColorScheme) -> ColorScheme {
|
||||||
|
detect(when, &TerminalColorSchemeDetector).unwrap_or_default()
|
||||||
|
}
|
||||||
|
|
||||||
/// Options for configuring the theme used for syntax highlighting.
|
/// Options for configuring the theme used for syntax highlighting.
|
||||||
/// Used together with [`theme`].
|
/// Used together with [`theme`].
|
||||||
#[derive(Debug, Default, PartialEq, Eq)]
|
#[derive(Debug, Default, PartialEq, Eq)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user