Fixed terminal initialization/construction issues
This commit is contained in:
parent
a33e62b098
commit
8a4a462bda
@ -176,47 +176,52 @@ public class InputConsole {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Terminal t;
|
Class<? extends Terminal> t;
|
||||||
try {
|
try {
|
||||||
if (type.equals(TerminalType.UNIX)) {
|
if (type.equals(TerminalType.UNIX)) {
|
||||||
t = new UnixTerminal();
|
t = UnixTerminal.class;
|
||||||
} else if (type.equals(TerminalType.WIN) || type.equals(TerminalType.WINDOWS)) {
|
} else if (type.equals(TerminalType.WIN) || type.equals(TerminalType.WINDOWS)) {
|
||||||
t = new WindowsTerminal();
|
t = WindowsTerminal.class;
|
||||||
} else if (type.equals(TerminalType.NONE) || type.equals(TerminalType.OFF) || type.equals(TerminalType.FALSE)) {
|
} else if (type.equals(TerminalType.NONE) || type.equals(TerminalType.OFF) || type.equals(TerminalType.FALSE)) {
|
||||||
t = new UnsupportedTerminal();
|
t = UnsupportedTerminal.class;
|
||||||
} else {
|
} else {
|
||||||
if (isIDEAutoDetect()) {
|
if (isIDEAutoDetect()) {
|
||||||
logger.debug("Terminal is in UNSUPPORTED (best guess). Unable to support single key input. Only line input available.");
|
logger.debug("Terminal is in UNSUPPORTED (best guess). Unable to support single key input. Only line input available.");
|
||||||
t = new UnsupportedTerminal();
|
t = UnsupportedTerminal.class;
|
||||||
} else {
|
} else {
|
||||||
if (OS.isWindows()) {
|
if (OS.isWindows()) {
|
||||||
t = new WindowsTerminal();
|
t = WindowsTerminal.class;
|
||||||
} else {
|
} else {
|
||||||
t = new UnixTerminal();
|
t = UnixTerminal.class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Failed to construct terminal, falling back to unsupported");
|
logger.error("Failed to construct terminal, falling back to unsupported.");
|
||||||
t = new UnsupportedTerminal();
|
t = UnsupportedTerminal.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Terminal terminal = null;
|
||||||
try {
|
try {
|
||||||
t.init();
|
terminal = t.newInstance();
|
||||||
|
terminal.init();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Terminal initialization failed, falling back to unsupported");
|
logger.error("Terminal initialization failed for {}, falling back to unsupported.", t.getSimpleName());
|
||||||
t = new UnsupportedTerminal();
|
t = UnsupportedTerminal.class;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
t.init();
|
terminal = t.newInstance();
|
||||||
} catch (IOException e1) {
|
terminal.init();
|
||||||
|
} catch (Exception e1) {
|
||||||
// UnsupportedTerminal can't do this
|
// UnsupportedTerminal can't do this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.setEchoEnabled(true);
|
if (terminal != null) {
|
||||||
|
terminal.setEchoEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
this.terminal = t;
|
this.terminal = terminal;
|
||||||
this.enableBackspace = Boolean.parseBoolean(System.getProperty(TerminalType.ENABLE_BACKSPACE, "true"));
|
this.enableBackspace = Boolean.parseBoolean(System.getProperty(TerminalType.ENABLE_BACKSPACE, "true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user