Struct bat_impl::assets::HighlightingAssets
source · [−]pub struct HighlightingAssets { /* private fields */ }
Implementations
sourceimpl HighlightingAssets
impl HighlightingAssets
sourcepub fn default_theme() -> &'static str
pub fn default_theme() -> &'static str
The default theme.
Windows and Linux
Windows and most Linux distributions has a dark terminal theme by default. On these platforms, this function always returns a theme that looks good on a dark background.
macOS
On macOS the default terminal background is light, but it is common that Dark Mode is active, which makes the terminal background dark. On this platform, the default theme depends on
defaults read -globalDomain AppleInterfaceStyle
To avoid the overhead of the check on macOS, simply specify a theme
explicitly via --theme
, BAT_THEME
, or ~/.config/bat
.
See https://github.com/sharkdp/bat/issues/1746 and https://github.com/sharkdp/bat/issues/1928 for more context.
pub fn from_cache(cache_path: &Path) -> Result<Self>
pub fn from_binary() -> Self
pub fn set_fallback_theme(&mut self, theme: &'static str)
sourcepub fn get_syntax_set(&self) -> Result<&SyntaxSet>
pub fn get_syntax_set(&self) -> Result<&SyntaxSet>
Return the collection of syntect syntax definitions.
sourcepub fn syntaxes(&self) -> &[SyntaxReference]
👎 Deprecated
pub fn syntaxes(&self) -> &[SyntaxReference]
Use Self::get_syntaxes instead
pub fn get_syntaxes(&self) -> Result<&[SyntaxReference]>
pub fn themes(&self) -> impl Iterator<Item = &str>
sourcepub fn syntax_for_file_name(
&self,
file_name: impl AsRef<Path>,
mapping: &SyntaxMapping<'_>
) -> Option<&SyntaxReference>
👎 Deprecated
pub fn syntax_for_file_name(
&self,
file_name: impl AsRef<Path>,
mapping: &SyntaxMapping<'_>
) -> Option<&SyntaxReference>
Use Self::get_syntax_for_path instead
sourcepub fn get_syntax_for_path(
&self,
path: impl AsRef<Path>,
mapping: &SyntaxMapping<'_>
) -> Result<SyntaxReferenceInSet<'_>>
pub fn get_syntax_for_path(
&self,
path: impl AsRef<Path>,
mapping: &SyntaxMapping<'_>
) -> Result<SyntaxReferenceInSet<'_>>
Detect the syntax based on, in order:
- Syntax mappings with MappingTarget::MapTo and MappingTarget::MapToUnknown
(e.g.
/etc/profile
->Bourne Again Shell (bash)
) - The file name (e.g.
Dockerfile
) - Syntax mappings with MappingTarget::MapExtensionToUnknown
(e.g.
*.conf
) - The file name extension (e.g.
.rs
)
When detecting syntax based on syntax mappings, the full path is taken into account. When detecting syntax based on file name, no regard is taken to the path of the file. Only the file name itself matters. When detecting syntax based on file name extension, only the file name extension itself matters.
Returns Error::UndetectedSyntax if it was not possible detect syntax based on path/file name/extension (or if the path was mapped to MappingTarget::MapToUnknown or MappingTarget::MapExtensionToUnknown). In this case it is appropriate to fall back to other methods to detect syntax. Such as using the contents of the first line of the file.
Returns Error::UnknownSyntax if a syntax mapping exist, but the mapped syntax does not exist.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for HighlightingAssets
impl Send for HighlightingAssets
impl !Sync for HighlightingAssets
impl Unpin for HighlightingAssets
impl UnwindSafe for HighlightingAssets
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more