Ansi ansi = AnsiDecorator.newAnsi(console.getTerminal().isAnsiSupported());
Set<Entry<PropertyDescriptor, AttributeDiff>> entries = diffs.entrySet();
Iterator<Entry<PropertyDescriptor, AttributeDiff>> iter = entries.iterator();
while (iter.hasNext()) {
Entry<PropertyDescriptor, AttributeDiff> entry = iter.next();
PropertyDescriptor pd = entry.getKey();
AttributeDiff ad = entry.getValue();
if (ad instanceof GeometryAttributeDiff
&& ad.getType() == org.locationtech.geogig.api.plumbing.diff.AttributeDiff.TYPE.MODIFIED
&& !noGeom) {
GeometryAttributeDiff gd = (GeometryAttributeDiff) ad;
ansi.fg(YELLOW);
ansi.a(pd.getName()).a(": ");
ansi.reset();
String text = gd.getDiff().getDiffCoordsString();
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '(') {
ansi.fg(GREEN);
ansi.a(text.charAt(i));
} else if (text.charAt(i) == '[') {
ansi.fg(RED);
ansi.a(text.charAt(i));
} else if (text.charAt(i) == ']' || text.charAt(i) == ')') {
ansi.a(text.charAt(i));
ansi.reset();
} else if (text.charAt(i) == LCSGeometryDiffImpl.INNER_RING_SEPARATOR
.charAt(0)
|| text.charAt(i) == LCSGeometryDiffImpl.SUBGEOM_SEPARATOR
.charAt(0)) {
ansi.fg(BLUE);
ansi.a(text.charAt(i));
ansi.reset();
} else {
ansi.a(text.charAt(i));
}
}
ansi.reset();
ansi.newline();
} else {
ansi.fg(ad.getType() == org.locationtech.geogig.api.plumbing.diff.AttributeDiff.TYPE.ADDED ? GREEN
: (ad.getType() == org.locationtech.geogig.api.plumbing.diff.AttributeDiff.TYPE.REMOVED ? RED
: YELLOW));
ansi.a(pd.getName()).a(": ").a(ad.toString());
ansi.reset();
ansi.newline();
}
}
console.println(ansi.toString());