try (final Terminal terminal = TerminalBuilder.builder() .name(SHELL_NAME) .system(true) .nativeSignals(true) .signalHandler(Terminal.SignalHandler.SIG_IGN) .build(); final PrintStream output = new PrintStream(terminal.output(), true)) {
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); } } }
public void start() throws Exception { final Terminal terminal = TerminalBuilder.builder() .nativeSignals(true) .signalHandler(Terminal.SignalHandler.SIG_IGN) .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); } } }
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(); }
public ProgressBar(long total) throws IOException { this.total = total; this.ctime = System.currentTimeMillis(); this.terminal = TerminalBuilder.terminal(); }
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; }
public void start() throws Exception { final Terminal terminal = TerminalBuilder.builder() .nativeSignals(true) .signalHandler(Terminal.SignalHandler.SIG_IGN) .build();
/** * 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 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(); } } }
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(); }
terminal = TerminalBuilder.terminal(); } catch (IOException e) { e.printStackTrace();
@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); } }
regs.add(context.registerService(Shell.class.getName(), shell, dict)); Terminal terminal = TerminalBuilder.builder() .name("gogo") .system(true) .nativeSignals(true) .signalHandler(Terminal.SignalHandler.SIG_IGN) .build(); CommandSession session = processor.createSession(terminal.input(), terminal.output(), terminal.output()); AtomicBoolean closing = new AtomicBoolean();
type = Terminal.TYPE_DUMB; try (Terminal terminal = TerminalBuilder.builder() .nativeSignals(true) .type(type) .signalHandler(Terminal.SignalHandler.SIG_IGN) .build()) { if (config.getCommand().length() > 0) { ChannelExec channel = session.createExecChannel(config.getCommand() + "\n");