pub struct Syntax { /* private fields */ }Implementations§
Source§impl Syntax
impl Syntax
Sourcepub fn get_theme(name: &str) -> Box<dyn SyntaxTheme>
pub fn get_theme(name: &str) -> Box<dyn SyntaxTheme>
Sourcepub fn available_themes() -> Vec<&'static str>
pub fn available_themes() -> Vec<&'static str>
List available theme names.
Sourcepub fn available_languages() -> Vec<String>
pub fn available_languages() -> Vec<String>
List available language/lexer names.
Sourcepub fn with_theme(self, theme: impl AsRef<str>) -> Self
pub fn with_theme(self, theme: impl AsRef<str>) -> Self
Set the theme by name.
This overrides the Console’s theme for this renderable.
Sourcepub fn with_custom_theme(self, theme: Box<dyn SyntaxTheme>) -> Self
pub fn with_custom_theme(self, theme: Box<dyn SyntaxTheme>) -> Self
Set a custom theme.
This overrides the Console’s theme for this renderable.
Sourcepub fn with_dedent(self, dedent: bool) -> Self
pub fn with_dedent(self, dedent: bool) -> Self
Enable or disable code dedenting.
Sourcepub fn with_line_numbers(self, line_numbers: bool) -> Self
pub fn with_line_numbers(self, line_numbers: bool) -> Self
Enable or disable line numbers.
Sourcepub fn with_start_line(self, start_line: usize) -> Self
pub fn with_start_line(self, start_line: usize) -> Self
Set the starting line number.
Sourcepub fn with_line_range(self, start: Option<usize>, end: Option<usize>) -> Self
pub fn with_line_range(self, start: Option<usize>, end: Option<usize>) -> Self
Set the line range to display.
§Arguments
start- Optional start line (1-based, inclusive).end- Optional end line (1-based, inclusive).
Sourcepub fn with_highlight_lines(
self,
lines: impl IntoIterator<Item = usize>,
) -> Self
pub fn with_highlight_lines( self, lines: impl IntoIterator<Item = usize>, ) -> Self
Set lines to highlight.
Sourcepub fn with_code_width(self, width: usize) -> Self
pub fn with_code_width(self, width: usize) -> Self
Set a fixed code width.
Sourcepub fn with_tab_size(self, tab_size: usize) -> Self
pub fn with_tab_size(self, tab_size: usize) -> Self
Set the tab size.
Sourcepub fn with_word_wrap(self, word_wrap: bool) -> Self
pub fn with_word_wrap(self, word_wrap: bool) -> Self
Enable or disable word wrapping.
NOTE: Not yet implemented - option is stored for future use.
Sourcepub fn with_background_color(self, color: Color) -> Self
pub fn with_background_color(self, color: Color) -> Self
Set a background color override.
Sourcepub fn with_indent_guides(self, indent_guides: bool) -> Self
pub fn with_indent_guides(self, indent_guides: bool) -> Self
Enable or disable indent guides.
NOTE: Not yet implemented - option is stored for future use.
Sourcepub fn with_padding(self, padding: impl Into<PaddingDimensions>) -> Self
pub fn with_padding(self, padding: impl Into<PaddingDimensions>) -> Self
Set padding around the syntax block.
Sourcepub fn stylize_range(
&mut self,
style: Style,
start: (usize, usize),
end: (usize, usize),
)
pub fn stylize_range( &mut self, style: Style, start: (usize, usize), end: (usize, usize), )
Add a custom style range to apply on top of syntax highlighting.
Positions are (line, column) where line is 1-based and column is 0-based.
§Arguments
style- Style to apply to the range.start- Start position as (line, column).end- End position as (line, column).
Sourcepub fn with_highlight_range(
self,
style: Style,
start: (usize, usize),
end: (usize, usize),
) -> Self
pub fn with_highlight_range( self, style: Style, start: (usize, usize), end: (usize, usize), ) -> Self
Builder method to add a highlight range.
Positions are (line, column) where line is 1-based and column is 0-based.
Sourcepub fn line_numbers(&self) -> bool
pub fn line_numbers(&self) -> bool
Check if line numbers are enabled.