reader.setHandleUserInterrupt(true);
private ConsoleReader setupConsoleReader(@Nonnull Logger logger, @Nonnull InputStream inputStream) throws IOException { ConsoleReader reader = new ConsoleReader(inputStream, logger.getOutputStream()); // Disable expansion of bangs: ! reader.setExpandEvents(false); // Ensure Reader does not handle user input for ctrl+C behaviour reader.setHandleUserInterrupt(false); return reader; }
private void initConsoleReader() { try { this.consoleReader = new ConsoleReader("IzPack", new FileInputStream(FileDescriptor.in), System.out, null); this.consoleReader.setHandleUserInterrupt(true); Terminal terminal = consoleReader.getTerminal(); if (terminal == null || terminal instanceof UnsupportedTerminal) { consoleReader.shutdown(); throw new Throwable("Terminal not initialized"); } fileNameCompleter = new FileNameCompleter(); } catch (Throwable t) { logger.log(Level.WARNING, "Cannot initialize the console reader. Falling back to default console.", t); } }
private static ConsoleReader createInteractiveConsoleReader() throws IOException { ConsoleReader reader; if(Strings.nullToEmpty(System.getProperty("os.name")).startsWith("Windows")) { // AnsiWindowsTerminal does not work properly in WIndows 7 // so disabling across the board for now reader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal()); } else { reader = new ConsoleReader(); } reader.setExpandEvents(false); // disable events triggered by "!", which is a valid R token reader.setHandleUserInterrupt(true); return reader; }
/** * @param prompt * to display to the user * @param mask * single character to display instead of what the user is typing, use null if text is not secret * @return the text which was entered * @throws Exception * in case of errors */ @Nonnull private String promptForText(@Nonnull String prompt, @Nullable Character mask) throws Exception { String line; ConsoleReader consoleReader = new ConsoleReader(in, out); // Disable expansion of bangs: ! consoleReader.setExpandEvents(false); // Ensure Reader does not handle user input for ctrl+C behaviour consoleReader.setHandleUserInterrupt(false); line = consoleReader.readLine(prompt + ": ", mask); consoleReader.close(); if (line == null) { throw new CommandException("No text could be read, exiting..."); } return line; } }
reader.removeCompleter(c); reader.setHandleUserInterrupt(true); String optionLine; try { optionLine = reader.readLine("Choose application: "); } finally { reader.setHandleUserInterrupt(false); reader.setHistoryEnabled(useHistory); reader.setHistory(previousHistory);
reader.setHandleUserInterrupt(true);
this.console.setBellEnabled(true); this.console.setHistoryEnabled(true); this.console.setHandleUserInterrupt(true); this.console.setExpandEvents(false); final PrintWriter writer = new PrintWriter(console.getOutput(), true);
if (args == null || args.length == 0) { final ConsoleReader reader = new ConsoleReader(mainEnvironment.getInput(), mainEnvironment.getOutput()); reader.setHandleUserInterrupt(true);
private void init() throws ODPSConsoleException { if (ODPSConsoleUtils.isWindows()) { isWindows = true; scanner = new Scanner(System.in); } else { try { consoleReader = new ConsoleReader(); } catch (IOException e) { throw new ODPSConsoleException(e); } consoleReader.setExpandEvents(false); // disable jline event consoleReader.setHandleUserInterrupt(true); setSignal(); setHistory(); setCommandCompleter(); } } }
console.setHandleUserInterrupt(true);
@Override public void start(Environment environment) throws IOException { errorPrintStream = new PrintStream(errorStream, true); String user = environment.getEnv().get(Environment.ENV_USER); if (Strings.isNullOrEmpty(user)) { user = "unknown"; } try { // Use our RemoteTerminal which does not depends on the platform. terminal = new RemoteTerminal(true); terminal.init(); } catch (Exception e) { LOGGER.warn("Error during terminal detection, falling back to unsupported terminal"); LOGGER.debug(DETAILS_MESSAGE, e); terminal = new UnsupportedTerminal(); } consoleReader = new ConsoleReader(inputStream, outputStream, terminal); // Disable jline shutdownhook to avoid exception at application shutdown jline.internal.Configuration.getString("jline.shutdownhook", "false"); consoleReader.addCompleter(new StringsCompleter(commandRegistry.getCommandList())); consoleReader.setCompletionHandler(new CandidateListCompletionHandler()); consoleReader.setPrompt(user + "@" + application.getId() + "$ "); consoleReader.setHandleUserInterrupt(false); consoleReader.setHistoryEnabled(true); ses = new SubjectAwareExecutorService(Executors.newSingleThreadExecutor()); ses.submit(this); }
@Override public void start(Environment environment) throws IOException { errorPrintStream = new PrintStream(errorStream, true); String user = environment.getEnv().get(Environment.ENV_USER); if (Strings.isNullOrEmpty(user)) { user = "unknown"; } try { // Use our RemoteTerminal which does not depends on the platform. terminal = new RemoteTerminal(true); terminal.init(); } catch (Exception e) { LOGGER.warn("Error during terminal detection, falling back to unsupported terminal"); LOGGER.debug(DETAILS_MESSAGE, e); terminal = new UnsupportedTerminal(); } consoleReader = new ConsoleReader(inputStream, outputStream, terminal); // Disable jline shutdownhook to avoid exception at application shutdown jline.internal.Configuration.getString("jline.shutdownhook", "false"); consoleReader.addCompleter(new StringsCompleter(commandRegistry.getCommandList())); consoleReader.setCompletionHandler(new CandidateListCompletionHandler()); consoleReader.setPrompt(user + "@" + application.getId() + "$ "); consoleReader.setHandleUserInterrupt(false); consoleReader.setHistoryEnabled(true); ses = new SubjectAwareExecutorService(Executors.newSingleThreadExecutor()); ses.submit(this); }
reader.removeCompleter(c); reader.setHandleUserInterrupt(true); String optionLine; try { optionLine = reader.readLine("Choose application: "); } finally { reader.setHandleUserInterrupt(false); reader.setHistoryEnabled(useHistory); reader.setHistory(previousHistory);
console.setHandleUserInterrupt(true); File file = new File(historyStore); file.createNewFile();
public int readEvalPrint() throws IOException { ConsoleReader console = new ConsoleReader(in, out); console.setHandleUserInterrupt(true); console.setExpandEvents(false); console.setCopyPasteDetection(true);
((CandidateListCompletionHandler)reader.getCompletionHandler()).setPrintSpaceAfterFullCompletion(printSpaceAfterFullCompletion()); reader.setHandleUserInterrupt(true);
public JLineTextTerminal(ConsoleReader reader) { if(reader == null) throw new IllegalArgumentException("reader is null"); reader.setHandleUserInterrupt(true); this.reader = reader; TerminalProperties<JLineTextTerminal> props = getProperties(); props.addStringListener(PROP_PROMPT_COLOR, null, (term, newVal) -> setPromptColor(newVal)); props.addStringListener(PROP_PROMPT_BGCOLOR, null, (term, newVal) -> setPromptBackgroundColor(newVal)); props.addBooleanListener(PROP_PROMPT_BOLD, false, (term, newVal) -> setPromptBold(newVal)); props.addBooleanListener(PROP_PROMPT_ITALIC, false, (term, newVal) -> setPromptItalic(newVal)); props.addBooleanListener(PROP_PROMPT_UNDERLINE, false, (term, newVal) -> setPromptUnderline(newVal)); props.addStringListener(PROP_INPUT_COLOR, null, (term, newVal) -> setInputColor(newVal)); props.addStringListener(PROP_INPUT_BGCOLOR, null, (term, newVal) -> setInputBackgroundColor(newVal)); props.addBooleanListener(PROP_INPUT_BOLD, false, (term, newVal) -> setInputBold(newVal)); props.addBooleanListener(PROP_INPUT_ITALIC, false, (term, newVal) -> setInputItalic(newVal)); props.addBooleanListener(PROP_INPUT_UNDERLINE, false, (term, newVal) -> setInputUnderline(newVal)); props.addStringListener(PROP_ANSI_COLOR_MODE, AnsiColorMode.STANDARD.toString(), (term, newVal) -> setAnsiColorMode(newVal)); }