Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/renderer/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
Annotation, AnnotationKind, Element, Group, Message, Origin, Patch, Report, Snippet, Title,
};

const ANONYMIZED_LINE_NUM: &str = "LL";
pub(crate) const ANONYMIZED_LINE_NUM: &str = "LL";

pub(crate) fn render(renderer: &Renderer, groups: Report<'_>) -> String {
if renderer.short_message {
Expand Down Expand Up @@ -2295,7 +2295,7 @@ fn draw_line_separator(renderer: &Renderer, buffer: &mut StyledBuffer, line: usi
buffer.puts(line, column, dots, ElementStyle::LineNumber);
}

trait MessageOrTitle {
pub(crate) trait MessageOrTitle {
fn level(&self) -> &Level<'_>;
fn id(&self) -> Option<&Id<'_>>;
fn text(&self) -> &str;
Expand Down Expand Up @@ -2366,7 +2366,7 @@ fn num_decimal_digits(num: Option<usize>) -> usize {
MAX_DIGITS
}

fn str_width(s: &str) -> usize {
pub(crate) fn str_width(s: &str) -> usize {
s.chars().map(char_width).sum()
}

Expand Down Expand Up @@ -2629,13 +2629,13 @@ pub(crate) struct UnderlineParts {
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum TitleStyle {
pub(crate) enum TitleStyle {
Primary,
Secondary,
Message,
}

struct Hyperlink<D: fmt::Display> {
pub(crate) struct Hyperlink<D: fmt::Display> {
url: Option<D>,
}

Expand Down
14 changes: 13 additions & 1 deletion src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//! ```

pub(crate) mod graphics;
pub(crate) mod no_graphics;
pub(crate) mod source_map;
pub(crate) mod stylesheet;

Expand Down Expand Up @@ -114,6 +115,7 @@ pub struct Renderer {
stylesheet: Stylesheet,
hyperlink: bool,
short_message: bool,
no_graphics: bool,
}

impl Renderer {
Expand All @@ -127,6 +129,7 @@ impl Renderer {
stylesheet: Stylesheet::plain(),
hyperlink: false,
short_message: false,
no_graphics: false,
}
}

Expand Down Expand Up @@ -159,6 +162,11 @@ impl Renderer {
}
}

pub const fn no_graphics(mut self, no_graphics: bool) -> Self {
self.no_graphics = no_graphics;
self
}

/// Abbreviate the message
pub const fn short_message(mut self, short_message: bool) -> Self {
self.short_message = short_message;
Expand Down Expand Up @@ -229,7 +237,11 @@ impl Renderer {
impl Renderer {
/// Render a diagnostic [`Report`]
pub fn render(&self, groups: Report<'_>) -> String {
graphics::render(self, groups)
if self.no_graphics {
no_graphics::render_no_graphics(self, groups).unwrap()
} else {
graphics::render(self, groups)
}
}
}

Expand Down
Loading
Loading