Open sanmai-NL opened 6 years ago
Current styles:
pretty-assertions
uses the following (extracted from https://github.com/colin-kiegel/rust-pretty-assertions/blob/965f11b5b56a03a9c7d2d4844b5afdfc8a956f03/src/format_changeset.rs):
fn red(s: &str) -> ANSIString {
Colour::Red.paint(s)
}
fn on_red(s: &str) -> ANSIString {
Colour::Red.on(Colour::Fixed(52)).bold().paint(s)
}
fn green(s: &str) -> ANSIString {
Colour::Green.paint(s)
}
fn on_green(s: &str) -> ANSIString {
Colour::Green.on(Colour::Fixed(22)).bold().paint(s)
}
I'm not sure what the reason is, but, in my IDE's embedded terminal, I get the following output:
White.on(Red)
/White.on(Green)
:
Red.on(52)
/Green.on(22)
:
Thus why I likely chose this styling. For completeness, the difference example uses (the equivalent of) White.on(Green)
.
If I'm not mistaken, you're asking for the following styling, which is not what the current version of pretty-differences
uses:
fn red(s: &str) -> ANSIGenericString<str> {
Colour::Red.paint(s)
}
fn on_red(s: &str) -> ANSIGenericString<str> {
Colour::Red.bold().paint(s)
}
fn green(s: &str) -> ANSIGenericString<str> {
Colour::Green.paint(s)
}
fn on_green(s: &str) -> ANSIGenericString<str> {
Colour::Green.bold().paint(s)
}
which looks like this in my IDE terminal:
If ansi_term
uses the coming minimal const fn support of Rust to make manipulating Colour
/Style
const, I'll probably add a generic parameter to specify a styling set for a difference. Until then, I'm not sure what much I can do different to work ideally on more terminals.
pretty-assertions
presents differences between characters by also making differing characters boldface (1), whereascolored_diff::PrettyDifference
changes the background color behind those characters (2). The former is more readable and its readability is far less dependent on terminal color scheme.My proposal is to implement presentation 1 in
colored_diff::PrettyDifference
.