pub struct SyntaxHighlighter { /* private fields */ }Expand description
Syntax highlighter for TUI with ratatui support
Implementations§
Source§impl SyntaxHighlighter
impl SyntaxHighlighter
Sourcepub fn new() -> Result<Self, HighlightError>
pub fn new() -> Result<Self, HighlightError>
Load default syntax set and theme
Sourcepub fn with_theme(theme_name: &str) -> Result<Self, HighlightError>
pub fn with_theme(theme_name: &str) -> Result<Self, HighlightError>
Load with a custom theme from the built-in theme set
Sourcepub fn list_builtin_themes() -> Vec<&'static str>
pub fn list_builtin_themes() -> Vec<&'static str>
List available built-in themes
Sourcepub fn detect_language(&self, lang: &str) -> SyntaxReference
pub fn detect_language(&self, lang: &str) -> SyntaxReference
Detect and return syntax reference for a language identifier
Sourcepub fn highlight_to_spans(
&self,
code: &str,
lang: &str,
) -> Result<Vec<Vec<Span<'static>>>, HighlightError>
pub fn highlight_to_spans( &self, code: &str, lang: &str, ) -> Result<Vec<Vec<Span<'static>>>, HighlightError>
Highlight code and return spans for TUI rendering
Sourcepub fn theme_name(&self) -> &str
pub fn theme_name(&self) -> &str
Get theme name
Trait Implementations§
Source§impl Clone for SyntaxHighlighter
impl Clone for SyntaxHighlighter
Source§fn clone(&self) -> SyntaxHighlighter
fn clone(&self) -> SyntaxHighlighter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SyntaxHighlighter
impl Debug for SyntaxHighlighter
Auto Trait Implementations§
impl !Freeze for SyntaxHighlighter
impl RefUnwindSafe for SyntaxHighlighter
impl Send for SyntaxHighlighter
impl Sync for SyntaxHighlighter
impl Unpin for SyntaxHighlighter
impl UnsafeUnpin for SyntaxHighlighter
impl UnwindSafe for SyntaxHighlighter
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more