Skip to content

Commit

Permalink
Harcode the reset code to avoid having the AnsiOutputStream depending…
Browse files Browse the repository at this point in the history
… on Ansi, fix typo
  • Loading branch information
gnodet committed Apr 26, 2017
1 parent 228563e commit 97750d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static OutputStream wrapOutputStream(final OutputStream stream, int filen
return new FilterOutputStream(stream) {
@Override
public void close() throws IOException {
write(AnsiOutputStream.REST_CODE);
write(AnsiOutputStream.RESET_CODE);
flush();
super.close();
}
Expand Down
15 changes: 5 additions & 10 deletions jansi/src/main/java/org/fusesource/jansi/AnsiOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
*/
public class AnsiOutputStream extends FilterOutputStream {

public static final byte[] REST_CODE = resetCode();
public static final byte[] RESET_CODE = "\033[0m".getBytes();

@Deprecated
public static final byte[] REST_CODE = RESET_CODE;

public AnsiOutputStream(OutputStream os) {
super(os);
Expand Down Expand Up @@ -568,17 +571,9 @@ private int optionInt(ArrayList<Object> options, int index, int defaultValue) {

@Override
public void close() throws IOException {
write(REST_CODE);
write(RESET_CODE);
flush();
super.close();
}

static private byte[] resetCode() {
try {
return new Ansi().reset().toString().getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}

}

0 comments on commit 97750d6

Please sign in to comment.