diff --git a/jansi/src/main/java/org/fusesource/jansi/Ansi.java b/jansi/src/main/java/org/fusesource/jansi/Ansi.java index 317aa455..1b900123 100644 --- a/jansi/src/main/java/org/fusesource/jansi/Ansi.java +++ b/jansi/src/main/java/org/fusesource/jansi/Ansi.java @@ -187,8 +187,36 @@ public static Ansi ansi() { } } + public static Ansi ansi(StringBuilder builder) { + if (isEnabled()) { + return new Ansi(builder); + } else { + return new NoAnsi(builder); + } + } + + public static Ansi ansi(int size) { + if (isEnabled()) { + return new Ansi(size); + } else { + return new NoAnsi(size); + } + } + private static class NoAnsi extends Ansi { + public NoAnsi() { + super(); + } + + public NoAnsi(int size) { + super(size); + } + + public NoAnsi(StringBuilder builder) { + super(builder); + } + @Override public Ansi fg(Color color) { return this; @@ -336,14 +364,6 @@ public Ansi(StringBuilder builder) { this.builder = builder; } - public static Ansi ansi(StringBuilder builder) { - return new Ansi(builder); - } - - public static Ansi ansi(int size) { - return new Ansi(size); - } - public Ansi fg(Color color) { attributeOptions.add(color.fg()); return this;