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