mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-19 04:21:06 +00:00
Do not export syntax_set and theme_set
This commit is contained in:
parent
fc1ca0875a
commit
62f2d0c100
@ -15,8 +15,8 @@ pub const BAT_THEME_DEFAULT: &str = "Monokai Extended";
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct HighlightingAssets {
|
pub struct HighlightingAssets {
|
||||||
pub syntax_set: SyntaxSet,
|
pub(crate) syntax_set: SyntaxSet,
|
||||||
pub theme_set: ThemeSet,
|
pub(crate) theme_set: ThemeSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HighlightingAssets {
|
impl HighlightingAssets {
|
||||||
@ -138,6 +138,14 @@ impl HighlightingAssets {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn syntaxes(&self) -> &[SyntaxReference] {
|
||||||
|
self.syntax_set.syntaxes()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn themes(&self) -> &BTreeMap<String, Theme> {
|
||||||
|
&self.theme_set.themes
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_theme(&self, theme: &str) -> &Theme {
|
pub fn get_theme(&self, theme: &str) -> &Theme {
|
||||||
match self.theme_set.themes.get(theme) {
|
match self.theme_set.themes.get(theme) {
|
||||||
Some(theme) => theme,
|
Some(theme) => theme,
|
||||||
|
@ -60,7 +60,6 @@ fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
|
|||||||
pub fn list_languages(config: &Config) -> Result<()> {
|
pub fn list_languages(config: &Config) -> Result<()> {
|
||||||
let assets = assets_from_cache_or_binary();
|
let assets = assets_from_cache_or_binary();
|
||||||
let mut languages = assets
|
let mut languages = assets
|
||||||
.syntax_set
|
|
||||||
.syntaxes()
|
.syntaxes()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|syntax| !syntax.hidden && !syntax.file_extensions.is_empty())
|
.filter(|syntax| !syntax.hidden && !syntax.file_extensions.is_empty())
|
||||||
@ -122,7 +121,7 @@ pub fn list_languages(config: &Config) -> Result<()> {
|
|||||||
|
|
||||||
pub fn list_themes(cfg: &Config) -> Result<()> {
|
pub fn list_themes(cfg: &Config) -> Result<()> {
|
||||||
let assets = assets_from_cache_or_binary();
|
let assets = assets_from_cache_or_binary();
|
||||||
let themes = &assets.theme_set.themes;
|
let themes = assets.themes();
|
||||||
let mut config = cfg.clone();
|
let mut config = cfg.clone();
|
||||||
let mut style = HashSet::new();
|
let mut style = HashSet::new();
|
||||||
style.insert(OutputComponent::Plain);
|
style.insert(OutputComponent::Plain);
|
||||||
|
@ -23,7 +23,7 @@ fn no_duplicate_extensions() {
|
|||||||
|
|
||||||
let mut extensions = HashSet::new();
|
let mut extensions = HashSet::new();
|
||||||
|
|
||||||
for syntax in assets.syntax_set.syntaxes() {
|
for syntax in assets.syntaxes() {
|
||||||
for extension in &syntax.file_extensions {
|
for extension in &syntax.file_extensions {
|
||||||
assert!(
|
assert!(
|
||||||
KNOWN_EXCEPTIONS.contains(&extension.as_str()) || extensions.insert(extension),
|
KNOWN_EXCEPTIONS.contains(&extension.as_str()) || extensions.insert(extension),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user