Skip to content

Commit

Permalink
make ansi(int) and ansi(StringBuilder) static methods consistent with
Browse files Browse the repository at this point in the history
ansi(), ie support NoAnsi
  • Loading branch information
hboutemy committed Jun 6, 2016
1 parent 03e7a2a commit affe709
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions jansi/src/main/java/org/fusesource/jansi/Ansi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit affe709

Please sign in to comment.