diff --git a/src/main/java/com/opencastsoftware/prettier4j/ansi/Attrs.java b/src/main/java/com/opencastsoftware/prettier4j/ansi/Attrs.java index d1cc338..b319fca 100644 --- a/src/main/java/com/opencastsoftware/prettier4j/ansi/Attrs.java +++ b/src/main/java/com/opencastsoftware/prettier4j/ansi/Attrs.java @@ -141,7 +141,7 @@ private Color color(ColorType colorType, long shiftValue) { case COLOR_16: return Color16.withCode(colorBits); case COLOR_256: - return new Color256(colorBits); + return new ColorXterm(colorBits); case COLOR_RGB: return ColorRgb.fromPacked(colorBits); } diff --git a/src/main/java/com/opencastsoftware/prettier4j/ansi/Color.java b/src/main/java/com/opencastsoftware/prettier4j/ansi/Color.java index b5c515b..1276767 100644 --- a/src/main/java/com/opencastsoftware/prettier4j/ansi/Color.java +++ b/src/main/java/com/opencastsoftware/prettier4j/ansi/Color.java @@ -78,8 +78,8 @@ static Color brightWhite() { return Color16.BRIGHT_WHITE; } - static Color xterm256(int color) { - return new Color256(color); + static Color xterm(int color) { + return new ColorXterm(color); } static Color rgb(int r, int g, int b) { diff --git a/src/main/java/com/opencastsoftware/prettier4j/ansi/Color256.java b/src/main/java/com/opencastsoftware/prettier4j/ansi/ColorXterm.java similarity index 84% rename from src/main/java/com/opencastsoftware/prettier4j/ansi/Color256.java rename to src/main/java/com/opencastsoftware/prettier4j/ansi/ColorXterm.java index 1e36123..ae46616 100644 --- a/src/main/java/com/opencastsoftware/prettier4j/ansi/Color256.java +++ b/src/main/java/com/opencastsoftware/prettier4j/ansi/ColorXterm.java @@ -6,10 +6,10 @@ import java.util.Objects; -class Color256 implements Color { +class ColorXterm implements Color { public final int color; - Color256(int color) { + ColorXterm(int color) { this.color = color & 0xFF; } @@ -36,8 +36,8 @@ public ColorType colorType() { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - Color256 color256 = (Color256) o; - return color == color256.color; + ColorXterm colorXterm = (ColorXterm) o; + return color == colorXterm.color; } @Override @@ -47,7 +47,7 @@ public int hashCode() { @Override public String toString() { - return "Color256 [" + + return "ColorXterm [" + "color=" + color + ']'; } diff --git a/src/main/java/com/opencastsoftware/prettier4j/ansi/Styles.java b/src/main/java/com/opencastsoftware/prettier4j/ansi/Styles.java index fce2492..c5a1362 100644 --- a/src/main/java/com/opencastsoftware/prettier4j/ansi/Styles.java +++ b/src/main/java/com/opencastsoftware/prettier4j/ansi/Styles.java @@ -78,8 +78,8 @@ private static long withColor(long attrs, Color color, long maskValue, long shif newColor = color16.code(); break; case COLOR_256: - Color256 color256 = (Color256) color; - newColor = color256.color(); + ColorXterm colorXterm = (ColorXterm) color; + newColor = colorXterm.color(); break; case COLOR_RGB: ColorRgb colorRgb = (ColorRgb) color; diff --git a/src/test/java/com/opencastsoftware/prettier4j/DocTest.java b/src/test/java/com/opencastsoftware/prettier4j/DocTest.java index 0314f03..722716a 100644 --- a/src/test/java/com/opencastsoftware/prettier4j/DocTest.java +++ b/src/test/java/com/opencastsoftware/prettier4j/DocTest.java @@ -564,7 +564,7 @@ void testNested16ColorFgStyleFlattening() { @Test void test256ColorFgStyle() { String expected = xtermFgCode(128) + "a" + Ansi.RESET; - String actual = text("a").styled(Styles.fg(Color.xterm256(128))).render(80); + String actual = text("a").styled(Styles.fg(Color.xterm(128))).render(80); char[] expectedChars = expected.toCharArray(); char[] actualChars = actual.toCharArray(); assertThat(actualChars, is(equalTo(expectedChars))); @@ -579,11 +579,11 @@ void testNested256ColorFgStyle() { xtermFgCode(37) + 'b' + xtermFgCode(255) + ')' + Ansi.RESET; - String actual = text("a").styled(Styles.fg(Color.xterm256(128))) + String actual = text("a").styled(Styles.fg(Color.xterm(128))) .append(text(",")) - .appendSpace(text("b").styled(Styles.fg(Color.xterm256(37)))) + .appendSpace(text("b").styled(Styles.fg(Color.xterm(37)))) .bracket(2, Doc.lineOrEmpty(), text("("), text(")")) - .styled(Styles.fg(Color.xterm256(255))) + .styled(Styles.fg(Color.xterm(255))) .render(6); char[] expectedChars = expected.toCharArray(); @@ -601,11 +601,11 @@ void testNested256ColorFgStyleFlattening() { ')' + Ansi.RESET; // expanded layout should still break over multiple lines - String actual = text("a").styled(Styles.fg(Color.xterm256(128))) + String actual = text("a").styled(Styles.fg(Color.xterm(128))) .append(text(",")) - .appendLineOrSpace(text("b").styled(Styles.fg(Color.xterm256(37)))) + .appendLineOrSpace(text("b").styled(Styles.fg(Color.xterm(37)))) .bracket(2, Doc.lineOrEmpty(), text("("), text(")")) - .styled(Styles.fg(Color.xterm256(255))) + .styled(Styles.fg(Color.xterm(255))) .render(1); char[] expectedChars = expected.toCharArray(); @@ -797,7 +797,7 @@ void testNested16ColorBgStyleFlattening() { @Test void test256ColorBgStyle() { String expected = xtermBgCode(128) + "a" + Ansi.RESET; - String actual = text("a").styled(Styles.bg(Color.xterm256(128))).render(80); + String actual = text("a").styled(Styles.bg(Color.xterm(128))).render(80); char[] expectedChars = expected.toCharArray(); char[] actualChars = actual.toCharArray(); assertThat(actualChars, is(equalTo(expectedChars))); @@ -812,11 +812,11 @@ void testNested256ColorBgStyle() { xtermBgCode(37) + 'b' + xtermBgCode(255) + ')' + Ansi.RESET; - String actual = text("a").styled(Styles.bg(Color.xterm256(128))) + String actual = text("a").styled(Styles.bg(Color.xterm(128))) .append(text(",")) - .appendSpace(text("b").styled(Styles.bg(Color.xterm256(37)))) + .appendSpace(text("b").styled(Styles.bg(Color.xterm(37)))) .bracket(2, Doc.lineOrEmpty(), text("("), text(")")) - .styled(Styles.bg(Color.xterm256(255))) + .styled(Styles.bg(Color.xterm(255))) .render(6); char[] expectedChars = expected.toCharArray(); @@ -834,11 +834,11 @@ void testNested256ColorBgStyleFlattening() { ')' + Ansi.RESET; // expanded layout should still break over multiple lines - String actual = text("a").styled(Styles.fg(Color.xterm256(128))) + String actual = text("a").styled(Styles.fg(Color.xterm(128))) .append(text(",")) - .appendLineOrSpace(text("b").styled(Styles.fg(Color.xterm256(37)))) + .appendLineOrSpace(text("b").styled(Styles.fg(Color.xterm(37)))) .bracket(2, Doc.lineOrEmpty(), text("("), text(")")) - .styled(Styles.fg(Color.xterm256(255))) + .styled(Styles.fg(Color.xterm(255))) .render(1); char[] expectedChars = expected.toCharArray(); diff --git a/src/test/java/com/opencastsoftware/prettier4j/ansi/AttrsTest.java b/src/test/java/com/opencastsoftware/prettier4j/ansi/AttrsTest.java index 25a3ece..0107351 100644 --- a/src/test/java/com/opencastsoftware/prettier4j/ansi/AttrsTest.java +++ b/src/test/java/com/opencastsoftware/prettier4j/ansi/AttrsTest.java @@ -155,7 +155,7 @@ Arbitrary colors() { Arbitraries.create(Color::brightWhite), Arbitraries.integers().between(0, 255) - .map(Color::xterm256), + .map(Color::xterm), Arbitraries.integers().between(0, 255) .tuple3().map(t -> Color.rgb(t.get1(), t.get2(), t.get3())) diff --git a/src/test/java/com/opencastsoftware/prettier4j/ansi/ColorTest.java b/src/test/java/com/opencastsoftware/prettier4j/ansi/ColorTest.java index aacdac9..f1836ca 100644 --- a/src/test/java/com/opencastsoftware/prettier4j/ansi/ColorTest.java +++ b/src/test/java/com/opencastsoftware/prettier4j/ansi/ColorTest.java @@ -22,13 +22,13 @@ public class ColorTest { void testEquals() { EqualsVerifier.forClasses( Color.class, Color16.class, - Color256.class, ColorRgb.class) + ColorXterm.class, ColorRgb.class) .usingGetClass().verify(); } @Test void testToString() { - ToStringVerifier.forClasses(Color16.class, Color256.class, ColorRgb.class).verify(); + ToStringVerifier.forClasses(Color16.class, ColorXterm.class, ColorRgb.class).verify(); } @Property