bat_impl::assets

Struct HighlightingAssets

Source
pub struct HighlightingAssets { /* private fields */ }

Implementations§

Source§

impl HighlightingAssets

Source

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.

Source

pub fn from_cache(cache_path: &Path) -> Result<Self>

Source

pub fn from_binary() -> Self

Source

pub fn set_fallback_theme(&mut self, theme: &'static str)

Source

pub fn get_syntax_set(&self) -> Result<&SyntaxSet>

Return the collection of syntect syntax definitions.

Source

pub fn syntaxes(&self) -> &[SyntaxReference]

👎Deprecated

Use Self::get_syntaxes instead

Source

pub fn get_syntaxes(&self) -> Result<&[SyntaxReference]>

Source

pub fn themes(&self) -> impl Iterator<Item = &str>

Source

pub fn syntax_for_file_name( &self, file_name: impl AsRef<Path>, mapping: &SyntaxMapping<'_>, ) -> Option<&SyntaxReference>

👎Deprecated
Source

pub fn get_syntax_for_path( &self, path: impl AsRef<Path>, mapping: &SyntaxMapping<'_>, ) -> Result<SyntaxReferenceInSet<'_>>

Detect the syntax based on, in order:

  1. Syntax mappings with MappingTarget::MapTo and MappingTarget::MapToUnknown (e.g. /etc/profile -> Bourne Again Shell (bash))
  2. The file name (e.g. Dockerfile)
  3. Syntax mappings with MappingTarget::MapExtensionToUnknown (e.g. *.conf)
  4. 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.

Source

pub fn get_theme(&self, theme: &str) -> &Theme

Look up a syntect theme by name.

Trait Implementations§

Source§

impl Debug for HighlightingAssets

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.