pub struct HighlightResource<'theme> { /* private fields */ }Expand description
Highlight Resource
§Create new instance
use hlight::HighlightResource;
use hlight::theme::names::monokai;
let res = HighlightResource::default();
assert_eq!(res.get_theme_name(), monokai());§Enable or disable background
use hlight::HighlightResource;
let res = HighlightResource::default().with_background(false);
assert!(!res.get_background())Implementations§
Source§impl<'theme> HighlightResource<'theme>
 
impl<'theme> HighlightResource<'theme>
pub fn get_theme_name(&self) -> &CmString
pub fn get_theme_set(&self) -> &HlightThemeSet<'theme>
pub fn get_syntax_set(&self) -> &Cow<'theme, SyntaxSet>
pub fn get_background(&self) -> &bool
Source§impl<'theme> HighlightResource<'theme>
 
impl<'theme> HighlightResource<'theme>
pub fn with_theme_name(self, val: CmString) -> Self
Sourcepub fn with_theme(self, val: OnceLock<Theme>) -> Self
 
pub fn with_theme(self, val: OnceLock<Theme>) -> Self
- get or init: Self::get_or_init_theme
pub fn with_theme_set(self, val: HlightThemeSet<'theme>) -> Self
pub fn with_syntax_set(self, val: Cow<'theme, SyntaxSet>) -> Self
pub fn with_background(self, val: bool) -> Self
Source§impl HighlightResource<'_>
 
impl HighlightResource<'_>
Sourcepub fn static_syntax_set() -> &'static SyntaxSet
 
pub fn static_syntax_set() -> &'static SyntaxSet
This is the default syntax set.
§Example
use hlight::HighlightResource;
let set = HighlightResource::static_syntax_set();
set.syntaxes()
    .iter()
    .map(|x| (&x.name, &x.file_extensions))
    .for_each(|(name, ext)| {
        println!(
        "name: {name}\n\
        ext:{ext:?}\n---"
        )
    });Source§impl HighlightResource<'_>
 
impl HighlightResource<'_>
Sourcepub fn get_or_init_theme(&self) -> &Theme
 
pub fn get_or_init_theme(&self) -> &Theme
Gets the theme or initialize it if it is not already set.
Sourcepub fn static_theme_set() -> &'static ThemeSet
 
pub fn static_theme_set() -> &'static ThemeSet
This is the default theme set.
§Example
use hlight::HighlightResource;
let set = HighlightResource::static_theme_set();
let themes = &set.themes;
for t in themes.keys() {
    println!("{t}")
}Trait Implementations§
Source§impl<'theme> Clone for HighlightResource<'theme>
 
impl<'theme> Clone for HighlightResource<'theme>
Source§fn clone(&self) -> HighlightResource<'theme>
 
fn clone(&self) -> HighlightResource<'theme>
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
 
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moreSource§impl<'theme> Debug for HighlightResource<'theme>
 
impl<'theme> Debug for HighlightResource<'theme>
Auto Trait Implementations§
impl<'theme> !Freeze for HighlightResource<'theme>
impl<'theme> RefUnwindSafe for HighlightResource<'theme>
impl<'theme> Send for HighlightResource<'theme>
impl<'theme> Sync for HighlightResource<'theme>
impl<'theme> Unpin for HighlightResource<'theme>
impl<'theme> UnwindSafe for HighlightResource<'theme>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> Pipe for Twhere
    T: ?Sized,
 
impl<T> Pipe for Twhere
    T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
    Self: Sized,
 
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
    Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
    R: 'a,
 
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
    R: 'a,
Borrows 
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
    R: 'a,
 
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
    R: 'a,
Mutably borrows 
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
 
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
    &'a mut self,
    func: impl FnOnce(&'a mut B) -> R,
) -> R
 
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
 
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows 
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
 
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows 
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
 
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows 
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
 
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
 
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the 
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
 
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the 
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
 
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the 
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
 
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the 
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
 
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the 
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
 
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the 
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
 
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls 
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
 
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls 
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
 
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls 
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
 
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls 
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
 
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls 
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
 
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls 
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
 
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls 
.tap_deref() only in debug builds, and is erased in release
builds.