mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-22 07:43:39 +01:00
Load assets from the binary
This commit is contained in:
parent
ced6801740
commit
59fabd8ca5
15
src/main.rs
15
src/main.rs
@ -34,7 +34,7 @@ use console::Term;
|
||||
use directories::ProjectDirs;
|
||||
use git2::{DiffOptions, IntoCString, Repository};
|
||||
|
||||
use syntect::dumps::{dump_to_file, from_reader};
|
||||
use syntect::dumps::{dump_to_file, from_binary, from_reader};
|
||||
use syntect::easy::HighlightFile;
|
||||
use syntect::highlighting::{Theme, ThemeSet};
|
||||
use syntect::parsing::SyntaxSet;
|
||||
@ -315,6 +315,17 @@ impl HighlightingAssets {
|
||||
theme_set,
|
||||
})
|
||||
}
|
||||
|
||||
fn from_binary() -> Self {
|
||||
let mut syntax_set: SyntaxSet = from_binary(include_bytes!("../assets/syntax_set"));
|
||||
syntax_set.link_syntaxes();
|
||||
let theme_set: ThemeSet = from_binary(include_bytes!("../assets/theme_set"));
|
||||
|
||||
HighlightingAssets {
|
||||
syntax_set,
|
||||
theme_set,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run() -> Result<()> {
|
||||
@ -357,7 +368,7 @@ fn run() -> Result<()> {
|
||||
true_color: is_truecolor_terminal(),
|
||||
};
|
||||
|
||||
let assets = HighlightingAssets::from_cache()?;
|
||||
let assets = HighlightingAssets::from_binary();
|
||||
|
||||
let theme = assets.theme_set.themes.get("Default").ok_or_else(|| {
|
||||
io::Error::new(
|
||||
|
Loading…
Reference in New Issue
Block a user