Struct codespan_reporting::term::renderer::Renderer
source · pub struct Renderer<'writer, 'config> {
writer: &'writer mut dyn WriteColor,
config: &'config Config,
}
Expand description
A renderer of display list entries.
The following diagram gives an overview of each of the parts of the renderer’s output:
┌ outer gutter
│ ┌ left border
│ │ ┌ inner gutter
│ │ │ ┌─────────────────────────── source ─────────────────────────────┐
│ │ │ │ │
┌────────────────────────────────────────────────────────────────────────────
header ── │ error[0001]: oh noes, a cupcake has occurred!
snippet start ── │ ┌─ test:9:0
snippet empty ── │ │
snippet line ── │ 9 │ ╭ Cupcake ipsum dolor. Sit amet marshmallow topping cheesecake
snippet line ── │ 10 │ │ muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly
│ │ ╭─│─────────^
snippet break ── │ · │ │
snippet line ── │ 33 │ │ │ Muffin danish chocolate soufflé pastry icing bonbon oat cake.
snippet line ── │ 34 │ │ │ Powder cake jujubes oat cake. Lemon drops tootsie roll marshmallow
│ │ │ ╰─────────────────────────────^ blah blah
snippet break ── │ · │
snippet line ── │ 38 │ │ Brownie lemon drops chocolate jelly-o candy canes. Danish marzipan
snippet line ── │ 39 │ │ jujubes soufflé carrot cake marshmallow tiramisu caramels candy canes.
│ │ │ ^^^^^^^^^^^^^^^^^^^ -------------------- blah blah
│ │ │ │
│ │ │ blah blah
│ │ │ note: this is a note
snippet line ── │ 40 │ │ Fruitcake jelly-o danish toffee. Tootsie roll pastry cheesecake
snippet line ── │ 41 │ │ soufflé marzipan. Chocolate bar oat cake jujubes lollipop pastry
snippet line ── │ 42 │ │ cupcake. Candy canes cupcake toffee gingerbread candy canes muffin
│ │ │ ^^^^^^^^^^^^^^^^^^ blah blah
│ │ ╰──────────^ blah blah
snippet break ── │ ·
snippet line ── │ 82 │ gingerbread toffee chupa chups chupa chups jelly-o cotton candy.
│ │ ^^^^^^ ------- blah blah
snippet empty ── │ │
snippet note ── │ = blah blah
snippet note ── │ = blah blah blah
│ blah blah
snippet note ── │ = blah blah blah
│ blah blah
empty ── │
Filler text from http://www.cupcakeipsum.com
Fields§
§writer: &'writer mut dyn WriteColor
§config: &'config Config
Implementations§
source§impl<'writer, 'config> Renderer<'writer, 'config>
impl<'writer, 'config> Renderer<'writer, 'config>
sourcepub fn new(
writer: &'writer mut dyn WriteColor,
config: &'config Config,
) -> Renderer<'writer, 'config> ⓘ
pub fn new( writer: &'writer mut dyn WriteColor, config: &'config Config, ) -> Renderer<'writer, 'config> ⓘ
Construct a renderer from the given writer and config.
fn chars(&self) -> &'config Chars
fn styles(&self) -> &'config Styles
sourcepub fn render_header(
&mut self,
locus: Option<&Locus>,
severity: Severity,
code: Option<&str>,
message: &str,
) -> Result<(), Error>
pub fn render_header( &mut self, locus: Option<&Locus>, severity: Severity, code: Option<&str>, message: &str, ) -> Result<(), Error>
Diagnostic header, with severity, code, and message.
error[E0001]: unexpected type in `+` application
sourcepub fn render_empty(&mut self) -> Result<(), Error>
pub fn render_empty(&mut self) -> Result<(), Error>
Empty line.
sourcepub fn render_snippet_start(
&mut self,
outer_padding: usize,
locus: &Locus,
) -> Result<(), Error>
pub fn render_snippet_start( &mut self, outer_padding: usize, locus: &Locus, ) -> Result<(), Error>
Top left border and locus.
┌─ test:2:9
sourcepub fn render_snippet_source(
&mut self,
outer_padding: usize,
line_number: usize,
source: &str,
severity: Severity,
single_labels: &[(LabelStyle, Range<usize>, &'_ str)],
num_multi_labels: usize,
multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)],
) -> Result<(), Error>
pub fn render_snippet_source( &mut self, outer_padding: usize, line_number: usize, source: &str, severity: Severity, single_labels: &[(LabelStyle, Range<usize>, &'_ str)], num_multi_labels: usize, multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)], ) -> Result<(), Error>
A line of source code.
10 │ │ muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly
│ ╭─│─────────^
sourcepub fn render_snippet_empty(
&mut self,
outer_padding: usize,
severity: Severity,
num_multi_labels: usize,
multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)],
) -> Result<(), Error>
pub fn render_snippet_empty( &mut self, outer_padding: usize, severity: Severity, num_multi_labels: usize, multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)], ) -> Result<(), Error>
An empty source line, for providing additional whitespace to source snippets.
│ │ │
sourcepub fn render_snippet_break(
&mut self,
outer_padding: usize,
severity: Severity,
num_multi_labels: usize,
multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)],
) -> Result<(), Error>
pub fn render_snippet_break( &mut self, outer_padding: usize, severity: Severity, num_multi_labels: usize, multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)], ) -> Result<(), Error>
A broken source line, for labeling skipped sections of source.
· │ │
sourcepub fn render_snippet_note(
&mut self,
outer_padding: usize,
message: &str,
) -> Result<(), Error>
pub fn render_snippet_note( &mut self, outer_padding: usize, message: &str, ) -> Result<(), Error>
Additional notes.
= expected type `Int`
found type `String`
sourcefn char_metrics(
&self,
char_indices: impl Iterator<Item = (usize, char)>,
) -> impl Iterator<Item = (Metrics, char)>
fn char_metrics( &self, char_indices: impl Iterator<Item = (usize, char)>, ) -> impl Iterator<Item = (Metrics, char)>
Adds tab-stop aware unicode-width computations to an iterator over character indices. Assumes that the character indices begin at the start of the line.
sourcefn outer_gutter(&mut self, outer_padding: usize) -> Result<(), Error>
fn outer_gutter(&mut self, outer_padding: usize) -> Result<(), Error>
The outer gutter of a source line.
sourcefn outer_gutter_number(
&mut self,
line_number: usize,
outer_padding: usize,
) -> Result<(), Error>
fn outer_gutter_number( &mut self, line_number: usize, outer_padding: usize, ) -> Result<(), Error>
The outer gutter of a source line, with line number.
sourcefn border_left(&mut self) -> Result<(), Error>
fn border_left(&mut self) -> Result<(), Error>
The left-hand border of a source line.
sourcefn border_left_break(&mut self) -> Result<(), Error>
fn border_left_break(&mut self) -> Result<(), Error>
The broken left-hand border of a source line.
sourcefn caret_pointers(
&mut self,
severity: Severity,
max_label_start: usize,
single_labels: &[(LabelStyle, Range<usize>, &'_ str)],
trailing_label: Option<(usize, &(LabelStyle, Range<usize>, &'_ str))>,
char_indices: impl Iterator<Item = (usize, char)>,
) -> Result<(), Error>
fn caret_pointers( &mut self, severity: Severity, max_label_start: usize, single_labels: &[(LabelStyle, Range<usize>, &'_ str)], trailing_label: Option<(usize, &(LabelStyle, Range<usize>, &'_ str))>, char_indices: impl Iterator<Item = (usize, char)>, ) -> Result<(), Error>
Write vertical lines pointing to carets.
sourcefn label_multi_left(
&mut self,
severity: Severity,
label_style: LabelStyle,
underline: Option<LabelStyle>,
) -> Result<(), Error>
fn label_multi_left( &mut self, severity: Severity, label_style: LabelStyle, underline: Option<LabelStyle>, ) -> Result<(), Error>
The left of a multi-line label.
│
sourcefn label_multi_top_left(
&mut self,
severity: Severity,
label_style: LabelStyle,
) -> Result<(), Error>
fn label_multi_top_left( &mut self, severity: Severity, label_style: LabelStyle, ) -> Result<(), Error>
The top-left of a multi-line label.
╭
sourcefn label_multi_bottom_left(
&mut self,
severity: Severity,
label_style: LabelStyle,
) -> Result<(), Error>
fn label_multi_bottom_left( &mut self, severity: Severity, label_style: LabelStyle, ) -> Result<(), Error>
The bottom left of a multi-line label.
╰
sourcefn label_multi_top_caret(
&mut self,
severity: Severity,
label_style: LabelStyle,
source: &str,
start: usize,
) -> Result<(), Error>
fn label_multi_top_caret( &mut self, severity: Severity, label_style: LabelStyle, source: &str, start: usize, ) -> Result<(), Error>
Multi-line label top.
─────────────^
sourcefn label_multi_bottom_caret(
&mut self,
severity: Severity,
label_style: LabelStyle,
source: &str,
start: usize,
message: &str,
) -> Result<(), Error>
fn label_multi_bottom_caret( &mut self, severity: Severity, label_style: LabelStyle, source: &str, start: usize, message: &str, ) -> Result<(), Error>
Multi-line label bottom, with a message.
─────────────^ expected `Int` but found `String`
sourcefn inner_gutter_column(
&mut self,
severity: Severity,
underline: Option<(LabelStyle, VerticalBound)>,
) -> Result<(), Error>
fn inner_gutter_column( &mut self, severity: Severity, underline: Option<(LabelStyle, VerticalBound)>, ) -> Result<(), Error>
Writes an empty gutter space, or continues an underline horizontally.
sourcefn inner_gutter_space(&mut self) -> Result<(), Error>
fn inner_gutter_space(&mut self) -> Result<(), Error>
Writes an empty gutter space.
sourcefn inner_gutter(
&mut self,
severity: Severity,
num_multi_labels: usize,
multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)],
) -> Result<(), Error>
fn inner_gutter( &mut self, severity: Severity, num_multi_labels: usize, multi_labels: &[(usize, LabelStyle, MultiLabel<'_>)], ) -> Result<(), Error>
Writes an inner gutter, with the left lines if necessary.
Trait Implementations§
source§impl<'writer, 'config> Write for Renderer<'writer, 'config>
impl<'writer, 'config> Write for Renderer<'writer, 'config>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)source§impl<'writer, 'config> WriteColor for Renderer<'writer, 'config>
impl<'writer, 'config> WriteColor for Renderer<'writer, 'config>
source§fn supports_color(&self) -> bool
fn supports_color(&self) -> bool
source§fn set_color(&mut self, spec: &ColorSpec) -> Result<()>
fn set_color(&mut self, spec: &ColorSpec) -> Result<()>
source§fn reset(&mut self) -> Result<()>
fn reset(&mut self) -> Result<()>
source§fn is_synchronous(&self) -> bool
fn is_synchronous(&self) -> bool
false
. Read more