Skip to content

Commit

Permalink
refactor: update graphical
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Oct 27, 2024
1 parent c23ddaf commit f611cce
Show file tree
Hide file tree
Showing 6 changed files with 2,487 additions and 2,504 deletions.
36 changes: 0 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ regex = "1.11"
lazy_static = "1.5"

serde_json = "1.0.132"
strip-ansi-escapes = "0.2.0"
# strip-ansi-escapes = "0.2.0"

[features]
default = ["derive"]
Expand Down
42 changes: 21 additions & 21 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,30 +282,30 @@ impl MietteHandlerOpts {
} else {
ThemeStyles::none()
};
#[cfg(not(feature = "syntect-highlighter"))]
let highlighter = self.highlighter.unwrap_or_else(MietteHighlighter::nocolor);
#[cfg(feature = "syntect-highlighter")]
let highlighter = if self.color == Some(false) {
MietteHighlighter::nocolor()
} else if self.color == Some(true) || syscall::supports_color() {
match self.highlighter {
Some(highlighter) => highlighter,
None => match self.rgb_colors {
// Because the syntect highlighter currently only supports 24-bit truecolor,
// respect RgbColor::Never by disabling the highlighter.
// TODO: In the future, find a way to convert the RGB syntect theme
// into an ANSI color theme.
RgbColors::Never => MietteHighlighter::nocolor(),
_ => MietteHighlighter::syntect_truecolor(),
},
}
} else {
MietteHighlighter::nocolor()
};
// #[cfg(not(feature = "syntect-highlighter"))]
// let highlighter = self.highlighter.unwrap_or_else(MietteHighlighter::nocolor);
// #[cfg(feature = "syntect-highlighter")]
// let highlighter = if self.color == Some(false) {
// MietteHighlighter::nocolor()
// } else if self.color == Some(true) || syscall::supports_color() {
// match self.highlighter {
// Some(highlighter) => highlighter,
// None => match self.rgb_colors {
// // Because the syntect highlighter currently only supports 24-bit truecolor,
// // respect RgbColor::Never by disabling the highlighter.
// // TODO: In the future, find a way to convert the RGB syntect theme
// // into an ANSI color theme.
// RgbColors::Never => MietteHighlighter::nocolor(),
// _ => MietteHighlighter::syntect_truecolor(),
// },
// }
// } else {
// MietteHighlighter::nocolor()
// };
let theme = self.theme.unwrap_or(GraphicalTheme { characters, styles });
let mut handler =
GraphicalReportHandler::new_themed(theme).with_width(width).with_links(linkify);
handler.highlighter = highlighter;
// handler.highlighter = highlighter;
if let Some(with_cause_chain) = self.with_cause_chain {
if with_cause_chain {
handler = handler.with_cause_chain();
Expand Down
Loading

0 comments on commit f611cce

Please sign in to comment.