Adding TTY setting in the emulator

This commit is contained in:
duckietm 2021-12-09 07:41:10 +00:00
parent 92636bbdc5
commit f167c6b6cd

View File

@ -175,26 +175,30 @@ public final class Emulator {
Runtime.getRuntime().availableProcessors() * 2); Runtime.getRuntime().availableProcessors() * 2);
} }
Emulator.getThreading().run(() -> { Emulator.getThreading().run(() -> {
}, 1500); }, 1500);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); // Check if console mode is true or false, default is true
if (Emulator.getConfig().getBoolean("console.mode", true)) {
while (!isShuttingDown && isReady) { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
String line = reader.readLine();
if (line != null) { while (!isShuttingDown && isReady) {
ConsoleCommand.handle(line); try {
} String line = reader.readLine();
System.out.println("Waiting for command: ");
} catch (Exception e) { if (line != null) {
if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) { ConsoleCommand.handle(line);
LOGGER.error("Error while reading command", e); }
System.out.println("Waiting for command: ");
} catch (Exception e) {
if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) {
LOGGER.error("Error while reading command", e);
}
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }