pub struct Renderer { /* private fields */ }Expand description
The caller is expected to detect any relevant terminal features and configure the renderer, including
- ANSI Escape code support (always outputted with
Renderer::styled) - Terminal width (
Renderer::term_width) - Unicode support (
Renderer::decor_style)
§Example
let report = // ...
let renderer = Renderer::styled();
let output = renderer.render(report);
anstream::println!("{output}");Implementations§
Source§impl Renderer
impl Renderer
Sourcepub const fn styled() -> Self
pub const fn styled() -> Self
Default terminal styling
If ANSI escape codes are not supported, either
- Call
Renderer::plaininstead - Strip them after the fact, like with
anstream
§Note
When testing styled terminal output, see the testing-colors feature
Sourcepub const fn short_message(self, short_message: bool) -> Self
pub const fn short_message(self, short_message: bool) -> Self
Abbreviate the message
Sourcepub const fn term_width(self, term_width: usize) -> Self
pub const fn term_width(self, term_width: usize) -> Self
Set the width to render within
Affects the rendering of Snippets
Sourcepub const fn decor_style(self, decor_style: DecorStyle) -> Self
pub const fn decor_style(self, decor_style: DecorStyle) -> Self
Set the character set used for rendering decor
Sourcepub const fn anonymized_line_numbers(
self,
anonymized_line_numbers: bool,
) -> Self
pub const fn anonymized_line_numbers( self, anonymized_line_numbers: bool, ) -> Self
Anonymize line numbers
When enabled, line numbers are replaced with LL which is useful for tests.
§Example
--> $DIR/whitespace-trimming.rs:4:193
|
LL | ... let _: () = 42;
| ^^ expected (), found integer
|Source§impl Renderer
Customize Renderer::styled
impl Renderer
Customize Renderer::styled
Sourcepub const fn line_num(self, style: Style) -> Self
pub const fn line_num(self, style: Style) -> Self
Override the output style for line numbers in the Snippet gutter
Sourcepub const fn emphasis(self, style: Style) -> Self
pub const fn emphasis(self, style: Style) -> Self
Override the output style for emphasis for the
primary_title
Sourcepub const fn context(self, style: Style) -> Self
pub const fn context(self, style: Style) -> Self
Override the output style for AnnotationKind::Context
Sourcepub const fn addition(self, style: Style) -> Self
pub const fn addition(self, style: Style) -> Self
Override the output style for Patch additions
pub const fn hyperlink(self, hyperlink: bool) -> Self
Sourcepub const fn cut_indicator(self, cut: &'static str) -> Self
pub const fn cut_indicator(self, cut: &'static str) -> Self
Set the string used for when a long line is cut.
The default for DecorStyle::Ascii is ... (three U+002E characters).