Open skuzzle opened 2 years ago
First test did not prove so effective.
Usage of
<dependency>
<groupId>com.diogonunes</groupId>
<artifactId>JColor</artifactId>
<version>5.2.0</version>
</dependency>
Is as simple as:
public String getDisplayDiff(Diff diff) {
if (isFailureDifference(diff)) {
switch (diff.operation) {
case DELETE:
return Ansi.colorize("-" + einklammern(diff.text), Attribute.BOLD(), Attribute.BLACK_TEXT(),
Attribute.YELLOW_BACK());
case INSERT:
return Ansi.colorize("+" + einklammern(diff.text), Attribute.BOLD(), Attribute.BLACK_TEXT(),
Attribute.YELLOW_BACK());
default:
throw new IllegalStateException();
}
} else {
return diff.text;
}
}
Coming back to this after a while, this might still be a nice feature to have. Now that diff creation and rendering has been extracted into its own module we could provide some configuration options for colorized diff rendering
We could use ANSI color codes to improve dispaly of the unified diff in console windows