mirror of https://github.com/zkat/miette.git
feat(graphical): simplify graphical header and remove a dep
This commit is contained in:
parent
dc2635e151
commit
9f36a4c253
|
|
@ -21,7 +21,6 @@ atty = { version = "0.2.14", optional = true }
|
|||
ci_info = { version = "0.14.2", optional = true }
|
||||
textwrap = { version = "0.14.2", optional = true }
|
||||
term_size = { version = "0.3.2", optional = true }
|
||||
unicode-width = { version = "0.1.8", optional = true }
|
||||
supports-hyperlinks = { version = "1.1.0", optional = true }
|
||||
supports-color = { version = "1.0.2", optional = true }
|
||||
supports-unicode = { version = "1.0.0", optional = true }
|
||||
|
|
@ -46,7 +45,6 @@ fancy = [
|
|||
"ci_info",
|
||||
"textwrap",
|
||||
"term_size",
|
||||
"unicode-width",
|
||||
"supports-hyperlinks",
|
||||
"supports-color",
|
||||
"supports-unicode",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use std::fmt::{self, Write};
|
|||
|
||||
use itertools::Itertools;
|
||||
use owo_colors::{OwoColorize, Style};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use crate::chain::Chain;
|
||||
use crate::handlers::theme::*;
|
||||
|
|
@ -126,13 +125,6 @@ impl GraphicalReportHandler {
|
|||
Some(Severity::Advice) => self.theme.styles.advice,
|
||||
};
|
||||
let mut header = String::new();
|
||||
let mut width = 0;
|
||||
write!(
|
||||
header,
|
||||
"{}",
|
||||
self.theme.characters.hbar.to_string().repeat(4)
|
||||
)?;
|
||||
width += 4;
|
||||
if self.linkify_code && diagnostic.url().is_some() && diagnostic.code().is_some() {
|
||||
let url = diagnostic.url().unwrap(); // safe
|
||||
let code = format!(
|
||||
|
|
@ -141,7 +133,6 @@ impl GraphicalReportHandler {
|
|||
.code()
|
||||
.expect("MIETTE BUG: already got checked for None")
|
||||
);
|
||||
width += code[..].width();
|
||||
let link = format!(
|
||||
"\u{1b}]8;;{}\u{1b}\\{}\u{1b}]8;;\u{1b}\\",
|
||||
url,
|
||||
|
|
@ -151,30 +142,14 @@ impl GraphicalReportHandler {
|
|||
"(link)".style(self.theme.styles.link)
|
||||
)
|
||||
);
|
||||
write!(header, "[{}]", link)?;
|
||||
width += "(link)".width() + 3
|
||||
write!(header, "{}", link)?;
|
||||
} else if let Some(code) = diagnostic.code() {
|
||||
write!(header, "[{}", code.style(severity_style),)?;
|
||||
width += &code.to_string()[..].width() + 1;
|
||||
|
||||
write!(header, "{}", code.style(severity_style),)?;
|
||||
if let Some(link) = diagnostic.url() {
|
||||
write!(header, " ({})]", link.style(self.theme.styles.link))?;
|
||||
width += &link.to_string()[..].width() + 4;
|
||||
} else {
|
||||
write!(header, "]")?;
|
||||
width += 1;
|
||||
write!(header, " ({})", link.style(self.theme.styles.link))?;
|
||||
}
|
||||
}
|
||||
writeln!(
|
||||
f,
|
||||
"{}{}",
|
||||
header,
|
||||
self.theme.characters.hbar.to_string().repeat(
|
||||
self.termwidth
|
||||
.saturating_sub(width)
|
||||
.saturating_sub("Error: ".width())
|
||||
)
|
||||
)?;
|
||||
writeln!(f, "{}", header)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue