Package jline.console

Examples of jline.console.KeyMap


            // Maintain persistent history in ~/.sqlcmd_history.
            historyFile = new FileHistory(new File(System.getProperty("user.home"), ".sqlcmd_history"));
            lineInputReader.setHistory(historyFile);

            // Make Ctrl-D (EOF) exit if on an empty line, otherwise delete the next character.
            KeyMap keyMap = lineInputReader.getKeys();
            keyMap.bind(new Character(KeyMap.CTRL_D).toString(), new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e)
                {
                    CursorBuffer cursorBuffer = lineInputReader.getCursorBuffer();
                    if (cursorBuffer.length() == 0) {
View Full Code Here


                terminal.setEchoEnabled(false);
                terminal.addSignalListener(this, Signal.WINCH);
                try {
                    window = terminal.getHeight() - 1;
                    halfWindow = window / 2;
                    keys = new KeyMap("less", false);
                    bindKeys(keys);
                    consoleInput = new NonBlockingInputStream(session.getKeyboard(), true);
                    consoleReader = new InputStreamReader(consoleInput);

                    // Use alternate buffer
View Full Code Here

public class KeyMapTest {

    @Test
    public void testBound() throws Exception {

        KeyMap map = KeyMap.emacs();

        assertEquals( Operation.COMPLETE, map.getBound("\u001B" + KeyMap.CTRL_OB) );
        assertEquals( Operation.BACKWARD_WORD, map.getBound(KeyMap.ESCAPE + "b") );

        map.bindIfNotBound("\033[0A", Operation.PREVIOUS_HISTORY);
        assertEquals( Operation.PREVIOUS_HISTORY, map.getBound("\033[0A") );


        map.bind( "\033[0AB", Operation.NEXT_HISTORY );
        assertTrue( map.getBound("\033[0A") instanceof KeyMap );
        assertEquals( Operation.NEXT_HISTORY , map.getBound("\033[0AB") );
    }
View Full Code Here

        assertBuffer("XXXtest line 4", b = b.op(ACCEPT_LINE).op(PREVIOUS_HISTORY));
    }

    @Test
    public void testHistorySearchBackwardAndForward() throws Exception {
        KeyMap map = console.getKeys();

        // Map in HISTORY_SEARCH_BACKWARD.
        map.bind("\033[0A", HISTORY_SEARCH_BACKWARD);
        map.bind("\033[0B", HISTORY_SEARCH_FORWARD);

        Buffer b = new Buffer().
            append("toes").op(ACCEPT_LINE).
            append("the quick brown").op(ACCEPT_LINE).
            append("fox jumps").op(ACCEPT_LINE).
View Full Code Here

TOP

Related Classes of jline.console.KeyMap

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.