mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-22 04:48:48 +00: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 directories::ProjectDirs;
|
||||||
use git2::{DiffOptions, IntoCString, Repository};
|
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::easy::HighlightFile;
|
||||||
use syntect::highlighting::{Theme, ThemeSet};
|
use syntect::highlighting::{Theme, ThemeSet};
|
||||||
use syntect::parsing::SyntaxSet;
|
use syntect::parsing::SyntaxSet;
|
||||||
@ -315,6 +315,17 @@ impl HighlightingAssets {
|
|||||||
theme_set,
|
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<()> {
|
fn run() -> Result<()> {
|
||||||
@ -357,7 +368,7 @@ fn run() -> Result<()> {
|
|||||||
true_color: is_truecolor_terminal(),
|
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(|| {
|
let theme = assets.theme_set.themes.get("Default").ok_or_else(|| {
|
||||||
io::Error::new(
|
io::Error::new(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user