pub struct Syntax {
pub code: String,
pub language: String,
pub theme: String,
pub start_line: usize,
pub line_numbers: bool,
pub highlight: bool,
pub background_color: Option<Color>,
pub tab_size: usize,
}Expand description
A syntax-highlighted source code renderable.
Fields§
§code: StringThe source code.
language: StringThe language name (e.g. “rust”, “python”, “javascript”).
theme: StringOptional theme name.
start_line: usizeStarting line number (for line numbers).
line_numbers: boolIf true, show line numbers.
highlight: boolIf true, highlight the code.
background_color: Option<Color>Optional background color.
tab_size: usizeTab size.
Implementations§
Source§impl Syntax
impl Syntax
Sourcepub fn new(code: impl Into<String>, language: impl Into<String>) -> Self
pub fn new(code: impl Into<String>, language: impl Into<String>) -> Self
Create a new Syntax renderable for the given code and language.
Sourcepub fn line_numbers(self) -> Self
pub fn line_numbers(self) -> Self
Builder: show line numbers.
Sourcepub fn start_line(self, n: usize) -> Self
pub fn start_line(self, n: usize) -> Self
Builder: set start line.
Sourcepub fn background(self, color: Color) -> Self
pub fn background(self, color: Color) -> Self
Builder: set background color.
Trait Implementations§
Source§impl Renderable for Syntax
impl Renderable for Syntax
fn render(&self, _options: &ConsoleOptions) -> RenderResult
Source§fn measure(&self, _options: &ConsoleOptions) -> Option<Measurement>
fn measure(&self, _options: &ConsoleOptions) -> Option<Measurement>
Optional width-measurement hook (equivalent to
__rich_measure__).
Override to provide min/max width constraints for layout.Auto Trait Implementations§
impl Freeze for Syntax
impl RefUnwindSafe for Syntax
impl Send for Syntax
impl Sync for Syntax
impl Unpin for Syntax
impl UnsafeUnpin for Syntax
impl UnwindSafe for Syntax
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