diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index bd9796f2..e7934c4c 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -130,6 +130,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) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/CommandHandler.java b/LauncherCore/src/main/java/pro/gravit/utils/command/CommandHandler.java index d52168e2..46bef058 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/CommandHandler.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/CommandHandler.java @@ -153,5 +153,5 @@ public List getCategories() { public abstract void bell() throws IOException; - public abstract void clear() throws IOException; + public abstract void clear() throws IOException, InterruptedException; } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java b/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java index c744be50..b32a8890 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java @@ -18,8 +18,19 @@ public void bell() { } @Override - public void clear() { - throw new UnsupportedOperationException("clear terminal"); + public void clear() throws IOException, InterruptedException { + //throw new UnsupportedOperationException("clear terminal"); + String os = System.getProperty("os.name"); + + if (os.contains("Windows")) + { + + new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); + } + else + { + Runtime.getRuntime().exec("clear"); + } } @Override