Skip to content

Commit 01d68f0

Browse files
committed
Fix Ansi outputting escape sequences when disabled, fixes #215
1 parent 3ba11e9 commit 01d68f0

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/main/java/org/fusesource/jansi/Ansi.java

+20
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,26 @@ public Ansi bgBright(Color color) {
249249
return this;
250250
}
251251

252+
@Override
253+
public Ansi fg(int color) {
254+
return this;
255+
}
256+
257+
@Override
258+
public Ansi fgRgb(int r, int g, int b) {
259+
return this;
260+
}
261+
262+
@Override
263+
public Ansi bg(int color) {
264+
return this;
265+
}
266+
267+
@Override
268+
public Ansi bgRgb(int r, int g, int b) {
269+
return this;
270+
}
271+
252272
@Override
253273
public Ansi a(Attribute attribute) {
254274
return this;

src/test/java/org/fusesource/jansi/AnsiTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ public void testCursorUpLine(int n, String expected) {
139139
assertAnsi(expected, new Ansi().cursorUpLine(n));
140140
}
141141

142+
@Test
143+
public void testColorDisabled() {
144+
Ansi.setEnabled(false);
145+
try {
146+
assertEquals("test", Ansi.ansi().fg(32).a("t").fgRgb(0).a("e").bg(24).a("s").bgRgb(100).a("t").toString());
147+
} finally {
148+
Ansi.setEnabled(true);
149+
}
150+
}
151+
142152
private static void assertAnsi(String expected, Ansi actual) {
143153
assertEquals(expected.replace("ESC", "\033"), actual.toString());
144154
}

0 commit comments

Comments
 (0)