Archived
0

Исправлены ошибк вывода ShellPrintStream

This commit is contained in:
2015-12-18 10:44:37 +03:00
parent 9820ea33a0
commit 1406f96fe4

View File

@@ -34,17 +34,12 @@ public class ShellPrintStream extends PrintStream {
this.formatter = formatter;
}
@Override
public void write(byte[] bytes, int off, int len) {
if (consoleReader != null) {
String s = new String(bytes);
private void _print(String s) {
writer.print(ConsoleReader.RESET_LINE);
if (formatter != null) {
writer.print(formatter.format(s));
} else {
writer.print(s);
if (formatter != null) { //TODO убрать проверку null
s = formatter.format(s);
}
writer.print(s);
cleanTrashLine(s);
writer.println();
try {
@@ -53,11 +48,36 @@ public class ShellPrintStream extends PrintStream {
// ignore
}
writer.flush();
}
@Override
public void write(byte[] bytes, int off, int len) {
if (consoleReader != null) {
if ((char)bytes[len-1] == '\n') len--; //TODO проверить в windows
_print(new String(bytes, off, len));
} else {
super.write(bytes, off, len);
}
}
@Override
public void print(String s) {
if (consoleReader != null) {
_print(s);
} else {
super.print(s);
}
}
@Override
public void println(String s) {
if (consoleReader != null) {
_print(s);
} else {
super.println(s);
}
}
/**
* Очистка печатной строки от мусора
*/