reader.getHistory().addToHistory(logEntry);
protected void doExecute(ConsoleExecutionContext ctx, CommandLine cl) throws Exception { // print the history Iterator iter = ctx.getConsole().getReader().getHistory().getHistoryList().iterator(); int i=1; while (iter.hasNext()) { System.out.println(" " + i + " " + iter.next()); i++; } }
try { int historyIndex = Integer.valueOf(line.substring(1).trim()).intValue(); oldLine = (String) reader.getHistory().getHistoryList().get(historyIndex - 1); } catch (Exception e) { System.out.println(" " + line + ": event not found"); continue; reader.getHistory().addToHistory(oldLine); System.out.println("Executing '" + oldLine + "'"); line = oldLine;
private void initJline() throws Exception { // String osName = System.getProperty("os.name"); // if (osName.startsWith("Windows")) { // return; // } consoleReader = new ConsoleReader(); consoleReader.setBellEnabled(false); // consoleReader.setDebug(new java.io.PrintWriter("jline-debug.txt")); History history = consoleReader.getHistory(); if (history == null) { history = new History(); consoleReader.setHistory(history); } File historyFile = new File(System.getProperty("user.home"), ".gfshhistory"); history.setHistoryFile(historyFile); // reader.setDebug(new PrintWriter(new FileWriter("writer.debug", true))); List completors = new LinkedList(); completors.add(new SimpleCompletor(commands)); consoleReader.addCompletor(new ArgumentCompletor(completors)); }
reader.getHistory().setHistoryFile(file); session.put(".jline.history", reader.getHistory()); if (completer != null) { reader.addCompletor(
reader.getHistory().addToHistory(logEntry);
@JRubyMethod(name = "readline", module = true, visibility = Visibility.PRIVATE) public static IRubyObject s_readline(IRubyObject recv, IRubyObject prompt, IRubyObject add_to_hist) throws IOException { ConsoleHolder holder = getHolder(recv.getRuntime()); if (holder.readline == null) { initReadline(recv.getRuntime(), holder); // not overridden, let's go } IRubyObject line = recv.getRuntime().getNil(); holder.readline.getTerminal().disableEcho(); String v = holder.readline.readLine(prompt.toString()); holder.readline.getTerminal().enableEcho(); if (null != v) { if (add_to_hist.isTrue()) { holder.readline.getHistory().addToHistory(v); } line = recv.getRuntime().newString(v); } return line; }