Package jline.console.history

Examples of jline.console.history.History


    @Option(name = "-c", aliases = { "--clear" }, description = "Clears the shell command history.", required = false, multiValued = false)
    private boolean clear;
   
    @Override
    protected Object doExecute() throws Exception {
        History history = (History) session.get(".jline.history");      

        if (history != null && clear) {
            history.clear();
        }
       
        for (History.Entry element : history) {
            System.out.println(
                    Ansi.ansi()
View Full Code Here


    @Option(name = "-c", aliases = { "--clear" }, description = "Clears the shell command history.", required = false, multiValued = false)
    private boolean clear;
   
     @Override
     protected Object doExecute() throws Exception {
        History history = (History) session.get(".jline.history");      
        if (history != null && clear) {
            history.clear();
        }

        for (History.Entry element : history) {
            System.out.println(
                    Ansi.ansi()
View Full Code Here

@Command(scope = "shell", name="history", description="Prints command history.")
public class HistoryAction extends AbstractAction {

    @Override
    protected Object doExecute() throws Exception {
        History history = (History) session.get(".jline.history");

        for (History.Entry element : history) {
            System.out.println(
                    Ansi.ansi()
                        .a("  ")
View Full Code Here

    @Option(name = "-c", aliases = { "--clear" }, description = "Clears the shell command history.", required = false, multiValued = false)
    private boolean clear;
   
     @Override
     protected Object doExecute() throws Exception {
        History history = (History) session.get(".jline.history");      
        if (history != null && clear) {
            history.clear();
        }

        for (History.Entry element : history) {
            System.out.println(
                    Ansi.ansi()
View Full Code Here

    cl = createMock(CommandLine.class);
    expect(cl.hasOption("c")).andReturn(false);
    expect(cl.hasOption("np")).andReturn(true);
    replay(cl);

    History history = new MemoryHistory();
    history.add("foo");
    history.add("bar");

    baos = new ByteArrayOutputStream();

    String input = String.format("!1%n"); // Construct a platform dependent new-line
    reader = new ConsoleReader(new ByteArrayInputStream(input.getBytes()), baos);
View Full Code Here

@Command(scope = "shell", name="history", description="Prints command history.")
public class HistoryAction extends AbstractAction {

    @Override
    protected Object doExecute() throws Exception {
        History history = (History) session.get(".jline.history");

        for (History.Entry element : history) {
            System.out.println(
                    Ansi.ansi()
                        .a("  ")
View Full Code Here

    }

    // reader.setDebug(new PrintWriter(new FileWriter("writer.debug", true)));

    openFileLogIfPossible();
    History history = this.reader.getHistory();
    if (history instanceof MemoryHistory) {
      ((MemoryHistory) history).setMaxSize(getHistorySize());
    }
    // Try to build previous command history from the project's log
    String[] filteredLogEntries = filterLogEntry();
View Full Code Here

        reader.setHistory(createSeededHistory());
        return reader;
    }

    private History createSeededHistory() {
        History history = new MemoryHistory();
        history.add("dir");
        history.add("cd c:\\");
        history.add("mkdir monkey");
        return history;
    }
View Full Code Here

    private void assertReadLine(String expected, ConsoleReader consoleReader) throws Exception {
        assertEquals(expected, consoleReader.readLine());
    }

    private void assertHistory(String expected, ConsoleReader consoleReader) {
        History history = consoleReader.getHistory();
        history.previous();
        assertEquals(expected, history.current());
    }
View Full Code Here

    @Test
    public void testSearch() throws Exception {
        /*
         * Tests the "/" forward search
         */
        History history = console.getHistory();
        history.clear();
        history.add("aaadef");
        history.add("bbbdef");
        history.add("cccdef");
       
        /*
         * An aborted search should leave you exactly on the
         * character you were on of the original term. First, I will
         * test aborting by deleting back over the search expression.
         */
        console.setKeyMap(KeyMap.VI_INSERT);
        Buffer b = (new Buffer("I like frogs"))
            .escape()
            .left(4)          // Cursor is on the "f"
            .append("/def")   // Start a search
            .back(4)          // Delete everything (aborts search)
            .append("ibig "// Insert mode, type "big "
            .enter();         // Done
        assertLine("I like big frogs", b, false);
       
        /*
         * Next, hit escape to abort. This technically isn't readline
         * behavior, but I added it because I find it useful.
         */
        console.setKeyMap(KeyMap.VI_INSERT);
        b = (new Buffer("I like frogs"))
            .escape()
            .left(4)          // Cursor is on the "f"
            .append("/def")   // Start a search
            .escape()         // Abort the search
            .append("ibig "// Insert mode, type "big "
            .enter();         // Done
        assertLine("I like big frogs", b, false);
       
        /*
         * Test a failed history match. This is like an abort, but it
         * should leave the cursor at the start of the line.
         */
        console.setKeyMap(KeyMap.VI_INSERT);
        b = (new Buffer("I like frogs"))
            .escape()
            .left(4)          // Cursor is on the "f"
            .append("/III")   // Search (no match)
            .enter()          // Kick it off.
            .append("iX")     // With cursor at start, insert an X
            .enter();
        assertLine("XI like frogs", b, false);
       
        /*
         * Test a valid search.
         */
        console.setKeyMap(KeyMap.VI_INSERT);
        b = (new Buffer("I like frogs"))
            .escape()
            .left(4)          // Cursor is on the "f"
            .append("/def")   // Search (no match)
            .enter()          // Kick it off.
            .append("nNiX")   // Move forward two, insert an X. Note I use
                              // use "n" and "N" to move.
            .enter();
        assertLine("Xcccdef", b, false);
       
        /*
         * The previous test messed with history.
         */
        history.clear();
        history.add("aaadef");
        history.add("bbbdef");
        history.add("cccdef");
       
        /*
         * Search backwards
         */
        console.setKeyMap(KeyMap.VI_INSERT);
View Full Code Here

TOP

Related Classes of jline.console.history.History

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.