[FIX] Исправил clear в std

This commit is contained in:
Alex Dev Sm 2019-06-18 17:40:49 +03:00
parent 386f8d07bc
commit 3201be72cc
2 changed files with 19 additions and 3 deletions

View file

@ -136,6 +136,9 @@ function initConsoleScene() {
var appendFunction = function(line) javafx.application.Platform.runLater(function() output.appendText(line));
consoleMenu.lookup("#send").setOnAction(function(){
execCommand(text.getText());
if (text.getText() == "clear") {
output.setText("");
}
text.setText("");
});
FunctionalBridge.addPlainOutput(function(string) {

View file

@ -2,7 +2,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.IOHelper;
public class StdCommandHandler extends CommandHandler {
@ -18,8 +18,21 @@ public void bell() {
}
@Override
public void clear() {
throw new UnsupportedOperationException("clear terminal");
public void clear() throws IOException {
System.out.flush();
if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE)
{
try {
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
} catch (InterruptedException ex) {
throw new IOException(ex);
}
}
else
{
System.out.print("\033[H\033[2J");
System.out.flush();
}
}
@Override