private static Terminal buildTerminal() { try { final Terminal terminal = TerminalBuilder.builder().system(true).build(); // Ignore ^C when not reading a line terminal.handle(Terminal.Signal.INT, Terminal.SignalHandler.SIG_IGN); return terminal; } catch (final IOException e) { throw new RuntimeException("JLineTerminal failed to start!", e); } } }
try (final Terminal terminal = TerminalBuilder.builder() .name(SHELL_NAME) .system(true)
terminal = TerminalBuilder.builder() .name(CliStrings.CLI_NAME) .build();
Terminal terminal = TerminalBuilder.builder().build(); LineReader reader = LineReaderBuilder.builder() .terminal(terminal)
@Bean(destroyMethod = "close") public Terminal terminal() { try { return TerminalBuilder.builder().build(); } catch (IOException e) { throw new BeanCreationException("Could not create Terminal: " + e.getMessage()); } }
/** * Returns the default system terminal. * Terminals should be closed properly using the {@link Terminal#close()} * method in order to restore the original terminal state. * * <p> * This call is equivalent to: * <code>builder().build()</code> * </p> * * @return the default system terminal * @throws IOException if an error occurs */ public static Terminal terminal() throws IOException { return builder().build(); }
private static void initializeTerminal() { if (!initialized) { initialized = true; boolean dumb = System.getProperty("java.class.path").contains("idea_rt.jar"); // TODO: Check if other IDEs also have virtual terminals with ANSI color support try { terminal = TerminalBuilder.builder().dumb(dumb).build(); } catch (IllegalStateException e) { LOGGER.warn("Not supported terminal"); LOGGER.debug(e); } catch (IOException e) { LOGGER.error("Failed to init, falling back to STDOUT"); LOGGER.debug(e); } } }
private Terminal buildTerminal (InputStream in, OutputStream out) throws IOException { TerminalBuilder builder = TerminalBuilder.builder(); builder.streams(in,out).system(System.in == in); Terminal t = builder.build(); Attributes attr = t.getAttributes(); attr.getOutputFlags().addAll( EnumSet.of(Attributes.OutputFlag.ONLCR, Attributes.OutputFlag.OPOST) ); t.setAttributes(attr); return t; }
private Terminal newTerminalInstance(String terminalType, InputStream is, OutputStream os) throws IOException { return TerminalBuilder.builder() .system(false) .type(terminalType) .streams(is, os) .build(); }
ProgressThread( ProgressState progress, ProgressBarStyle style, long updateInterval, PrintStream consoleStream, String unitName, long unitSize, boolean isSpeedShown ) { this.progress = progress; this.style = style; this.updateInterval = updateInterval; this.consoleStream = consoleStream; this.killed = false; this.unitName = unitName; this.unitSize = unitSize; this.isSpeedShown = isSpeedShown; try { // Issue #42 // Defaulting to a dumb terminal when a supported terminal can not be correctly created // see https://github.com/jline/jline3/issues/291 this.terminal = TerminalBuilder.builder().dumb(true).build(); } catch (IOException ignored) { } if (terminal.getWidth() >= 10) // Workaround for issue #23 under IntelliJ consoleWidth = terminal.getWidth(); }
ProgressThread( ProgressState progress, ProgressBarStyle style, long updateInterval, PrintStream consoleStream, String unitName, long unitSize, boolean isSpeedShown ) { this.progress = progress; this.style = style; this.updateInterval = updateInterval; this.consoleStream = consoleStream; this.killed = false; this.unitName = unitName; this.unitSize = unitSize; this.isSpeedShown = isSpeedShown; try { // Issue #42 // Defaulting to a dumb terminal when a supported terminal can not be correctly created // see https://github.com/jline/jline3/issues/291 this.terminal = TerminalBuilder.builder().dumb(true).build(); } catch (IOException ignored) { } if (terminal.getWidth() >= 10) // Workaround for issue #23 under IntelliJ consoleWidth = terminal.getWidth(); }
public void start() throws Exception { final Terminal terminal = TerminalBuilder.builder() .nativeSignals(true) .signalHandler(Terminal.SignalHandler.SIG_IGN)
public void start() throws Exception { final Terminal terminal = TerminalBuilder.builder() .nativeSignals(true) .signalHandler(Terminal.SignalHandler.SIG_IGN)
@Override public void run() { Terminal terminal; try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos, true, "utf-8")) { terminal = TerminalBuilder.builder().system(false).type(terminalType).streams(is, os).build(); DefaultResultHandler resultHandler = new DefaultResultHandler(); resultHandler.setTerminal(terminal); shellBanner.printBanner(environment, this.getClass(), ps); resultHandler.handleResult(new String(baos.toByteArray(), StandardCharsets.UTF_8)); resultHandler.handleResult("Please type `help` to see available commands"); LineReader reader = LineReaderBuilder.builder().terminal(terminal).completer(completerAdapter).build(); InputProvider inputProvider = new InteractiveShellApplicationRunner.JLineInputProvider(reader, promptProvider); THREAD_CONTEXT.set(new SshContext(terminal, ec, sshThread)); if (terminalDelegate instanceof SshShellTerminalDelegate) { ((SshShellTerminalDelegate) terminalDelegate).setDelegate(terminal); } shell.run(inputProvider); quit(0); } catch (IOException | RuntimeException e) { // log ex quit(1); } }
public static void main(String[] args) throws Exception { final Terminal terminal = TerminalBuilder.builder() .system(true) .build();
private static void runSqlConsole(Connection connection, Statement statement, boolean pretty) throws IOException { Terminal terminal = TerminalBuilder.builder() .system(true) .build(); LineReader reader = LineReaderBuilder.builder() .history(new DefaultHistory()) .terminal(terminal) .build(); String prompt = "herd: "; while (true) { String line = null; try { line = reader.readLine(prompt); if (line == null) { return; } executeStatement(true, true, false, false, line, statement, null, false, pretty); } catch (UserInterruptException | EndOfFileException e) { return; } catch (Exception e) { e.printStackTrace(); } } }
public JLineConsole(String defaultPath) throws IOException { super(defaultPath); DefaultParser parser = new DefaultParser(); //It will be applied from jline 3.9.1 //parser.setEscapeChars(null); this.terminal = TerminalBuilder.builder().encoding(encoding).build(); this.reader = LineReaderBuilder.builder() .appName(APP_NAME) .parser(parser) .terminal(terminal) .build(); this.commandReader = LineReaderBuilder.builder() .appName(APP_NAME) .completer(commandCompleter) .parser(parser) .terminal(terminal) .build(); }
terminal = TerminalBuilder.builder() .name(CliConstants.WINDOW_TITLE) .build();
return getLineReader(); TerminalBuilder terminalBuilder = TerminalBuilder.builder(); final Terminal terminal; if (inputStream != null) {
return getLineReader(); TerminalBuilder terminalBuilder = TerminalBuilder.builder(); final Terminal terminal; if (inputStream != null) {