diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index f1e11f91..631d3744 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -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) { 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..3d817c7b 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/StdCommandHandler.java @@ -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