consoleReader.setHistory(this.history); } else { consoleReader.setHistoryEnabled(false);
public GreysConsole(InetSocketAddress address) throws IOException { this.console = initConsoleReader(); this.history = initHistory(); this.out = console.getOutput(); this.history.moveToEnd(); this.console.setHistoryEnabled(true); this.console.setHistory(history); this.console.setExpandEvents(false); this.socket = connect(address); // 关闭会话静默 disableSilentOfSession(); // 初始化自动补全 initCompleter(); this.isRunning = true; activeConsoleReader(); socketWriter.write("version\n"); socketWriter.flush(); loopForWriter(); }
private static void configureHistory(ConsoleReader reader) throws IOException { String homeFolder = System.getProperty("user.home"); File historyFile = new File(homeFolder, ".iclojure_history"); reader.setHistory(new FileHistory(historyFile)); reader.setHistoryEnabled(true); }
public PrompterImpl() throws IOException { this.console = new ConsoleReader(); console.setHistoryEnabled(false); console.setExpandEvents(false); }
public PrompterImpl(InputStream in, OutputStream out) throws IOException { this.console = new ConsoleReader(in, out); console.setHistoryEnabled(false); console.setExpandEvents(false); }
/** * Displays the message and reads the input. * @param session The {@link CommandSession} to use. * @param msg The message to display. * @param hidden Flag to hide the user input. * @return * @throws IOException */ public static String readLine(CommandSession session, String msg, boolean hidden) throws IOException { Object obj = session.get(".jline.reader"); if (obj instanceof ConsoleReader) { ConsoleReader reader = (ConsoleReader) obj; try { reader.setHistoryEnabled(false); if (hidden) { return reader.readLine(msg, ConsoleReader.NULL_MASK); } else { return reader.readLine(msg); } } finally { reader.setHistoryEnabled(true); } } return null; }
/** * Displays the message and reads the input. * @param session The {@link CommandSession} to use. * @param msg The message to display. * @param hidden Flag to hide the user input. * @return * @throws IOException */ public static String readLine(CommandSession session, String msg, boolean hidden) throws IOException { Object obj = session.get(".jline.reader"); if (obj instanceof ConsoleReader) { ConsoleReader reader = (ConsoleReader) obj; try { reader.setHistoryEnabled(false); if (hidden) { return reader.readLine(msg, ConsoleReader.NULL_MASK); } else { return reader.readLine(msg); } } finally { reader.setHistoryEnabled(true); } } return null; }
@Override public Optional<String> getSparql() throws IOException { final ConsoleReader reader = getReader(); reader.setCopyPasteDetection(true); // disable tab completion from activating reader.setHistoryEnabled(false); // don't store SPARQL fragments in the command history try { reader.println("Enter a SPARQL Query."); reader.println("Type '" + EXECUTE_COMMAND + "' to execute the current query."); reader.println("Type '" + CLEAR_COMMAND + "' to clear the current query."); reader.flush(); final StringBuilder sb = new StringBuilder(); String line = reader.readLine("SPARQL> "); while (!line.endsWith(CLEAR_COMMAND) && !line.endsWith(EXECUTE_COMMAND)) { sb.append(line).append("\n"); line = reader.readLine(" -> "); } if (line.endsWith(EXECUTE_COMMAND)) { sb.append(line.substring(0, line.length() - EXECUTE_COMMAND.length())); return Optional.of(sb.toString()); } return Optional.absent(); } finally { reader.setHistoryEnabled(true); // restore the ConsoleReader's settings reader.setCopyPasteDetection(false); // restore tab completion } }
@Override public Optional<String> getSparqlWithResults() throws IOException { final ConsoleReader reader = getReader(); reader.setCopyPasteDetection(true); // disable tab completion from activating reader.setHistoryEnabled(false); // don't store SPARQL fragments in the command history try { reader.println("To see more results press [Enter]."); reader.println("Type '" + STOP_COMMAND + "' to stop showing results."); reader.flush(); final String line = reader.readLine("> "); if(line.endsWith(STOP_COMMAND)) { return Optional.of(STOP_COMMAND); } return Optional.absent(); } finally { reader.setHistoryEnabled(true); // restore the ConsoleReader's settings reader.setCopyPasteDetection(false); // restore tab completion } } }
static void initReader() throws IOException { reader = new ConsoleReader(); reader.setBellEnabled(false); reader.setAutoprintThreshold(10); reader.setHistoryEnabled(true); }
@Inject public JLine2Console(History history) throws Exception { super(); TerminalFactory.configure(Type.AUTO); terminal = TerminalFactory.get(); terminal.init(); consoleReader = new ConsoleReader(System.in, System.out, terminal); consoleReader.setHistory(history); consoleReader.setHistoryEnabled(true); }
System.getProperty("user.home") + "/.annis/shellhistory.txt")); console.setHistory(history); console.setHistoryEnabled(true); console.setBellEnabled(true); console.setExpandEvents(false);
@Override public boolean config(String... args) throws IOException { // If configuring the shell failed, fail quickly if (!super.config(args)) { return false; } // Update the ConsoleReader with the input and output "redirected" try { this.reader = new ConsoleReader(in, out); } catch (Exception e) { printException(e); return false; } // Don't need this for testing purposes this.reader.setHistoryEnabled(false); this.reader.setPaginationEnabled(false); // Make the parsing from the client easier; this.verbose = false; return true; }
this.console = new ConsoleReader(appName, input, output, terminal, encoding); this.console.setBellEnabled(true); this.console.setHistoryEnabled(true); this.console.setHandleUserInterrupt(true); this.console.setExpandEvents(false);
private void initializeConsoleReader() { this.consoleReader.setHistoryEnabled(true); this.consoleReader.setBellEnabled(false); this.consoleReader.setExpandEvents(false); this.consoleReader.addCompleter(new CommandCompleter(this.consoleReader, this.argumentDelimiter, this.commandRunner)); this.consoleReader.setCompletionHandler(new CandidateListCompletionHandler()); }
private void initializeConsoleReader() { this.consoleReader.setHistoryEnabled(true); this.consoleReader.setBellEnabled(false); this.consoleReader.setExpandEvents(false); this.consoleReader.addCompleter(new CommandCompleter(this.consoleReader, this.argumentDelimiter, this.commandRunner)); this.consoleReader.setCompletionHandler(new CandidateListCompletionHandler()); }
@Override public String readLine(String prompt) throws IOException { boolean oldHistoryEnabled = reader.isHistoryEnabled(); History oldHistory = reader.getHistory(); Collection<Completer> oldCompleters = new ArrayList<>(reader.getCompleters()); String oldPrompt = reader.getPrompt(); try { reader.setHistoryEnabled(false); reader.setHistory(new MemoryHistory()); for (Completer c : oldCompleters) { reader.removeCompleter(c); } String result = reader.readLine(prompt); return result; } finally { for (Completer c : oldCompleters) { reader.addCompleter(c); } reader.setPrompt(oldPrompt); reader.setHistory(oldHistory); reader.setHistoryEnabled(oldHistoryEnabled); } } }
@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); }
history.setMaxSize(config.getInt("console.hisory.size", 100)); console.setHistory(history); console.setHistoryEnabled(true); console.setKeyMap(KeyMap.EMACS); out = new ConsoleWriter(console);