use of jline.Terminal in project es6draft by anba.
the class JLineConsole method newConsoleReader.
private static ConsoleReader newConsoleReader(String programName) throws IOException {
final boolean isWindows = isWindows();
final String type = System.getProperty(TerminalFactory.JLINE_TERMINAL);
if (isWindows && type == null) {
TerminalFactory.registerFlavor(TerminalFactory.Flavor.WINDOWS, UnsupportedTerminal.class);
} else if (isWindows && type.equalsIgnoreCase(TerminalFactory.UNIX)) {
TerminalFactory.registerFlavor(TerminalFactory.Flavor.UNIX, CygwinTerminal.class);
}
FileInputStream in = new FileInputStream(FileDescriptor.in);
Terminal terminal = TerminalFactory.get();
ConsoleReader consoleReader = new ConsoleReader(programName, in, System.out, terminal, getDefaultEncoding());
consoleReader.setExpandEvents(false);
return consoleReader;
}
use of jline.Terminal in project GeoGig by boundlessgeo.
the class GeogigConsole method run.
private void run(final InputStream in, final OutputStream out) throws IOException {
final Terminal terminal;
if (interactive) {
terminal = null;
/* let jline select an appropriate one */
} else {
// no colors in output
terminal = new UnsupportedTerminal();
}
ConsoleReader consoleReader = new ConsoleReader(in, out, terminal);
consoleReader.setAutoprintThreshold(20);
consoleReader.setPaginationEnabled(interactive);
consoleReader.setHistoryEnabled(interactive);
// needed for CTRL+C not to let the console broken
consoleReader.getTerminal().setEchoEnabled(interactive);
final GeogigCLI cli = new GeogigCLI(consoleReader);
if (interactive) {
addCommandCompleter(consoleReader, cli);
} else {
// no progress percent in output
cli.disableProgressListener();
}
GeogigCLI.addShutdownHook(cli);
setPrompt(cli);
cli.close();
try {
runInternal(cli);
} finally {
try {
cli.close();
} finally {
try {
if (terminal != null) {
terminal.restore();
}
consoleReader.shutdown();
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
}
}
Aggregations