Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ansi(int) and ansi(StringBuilder) static methods consistent with #52

Merged
merged 1 commit into from
Jun 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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