Skip to content

Commit

Permalink
Merge pull request #52 from hboutemy/master
Browse files Browse the repository at this point in the history
make ansi(int) and ansi(StringBuilder) static methods consistent with
  • Loading branch information
chirino authored Jun 15, 2016
2 parents a54d2b5 + affe709 commit 08fc17a
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 08fc17a

Please sign in to comment.