Merge pull request #294 from leshasmlesha/dev

[FIX] Исправил clear в std
This commit is contained in:
Gravit 2019-06-19 10:45:12 +07:00 committed by GitHub
commit a707dc4f3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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