Package org.jnode.driver.input

Examples of org.jnode.driver.input.KeyboardEvent


     */
    private void sendKeyboardEvent(int keycode, boolean pressed) {
        final KeyboardHandler kbHandler = getToolkitImpl().getKeyboardHandler();
        final KeyboardAPI api = kbHandler.getKeyboardAPI();
        final KeyboardInterpreter kbInt = api.getKbInterpreter();
        final KeyboardEvent event = kbInt.interpretKeycode(keycode);
        if (event != null) {
            if (pressed)
                kbHandler.keyPressed(event);
            else
                kbHandler.keyReleased(event);
View Full Code Here


        if (keyboardDevice == null) {
            keyboardDriver = new MyKeyboardDriver();
            keyListener = new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    KeyboardEvent k = new KeyboardEvent(KeyEvent.KEY_PRESSED,
                        e.getWhen(), e.getModifiersEx(), e.getKeyCode(), e.getKeyChar());
                    keyboardDriver.dispatchEvent(k);

                }

                @Override
                public void keyReleased(KeyEvent e) {
                    KeyboardEvent k = new KeyboardEvent(KeyEvent.KEY_RELEASED,
                        e.getWhen(), e.getModifiersEx(), e.getKeyCode(), e.getKeyChar());
                    keyboardDriver.dispatchEvent(k);
                }
            };
            screen.addKeyListener(keyListener);
View Full Code Here

                            chr = (char) ch;
                    }

                    System.err.println("ch=" + ch);
                    long time = System.currentTimeMillis();
                    KeyboardEvent e = new KeyboardEvent(KeyEvent.KEY_PRESSED, time, 0, chr, chr);
                    System.err.println("event built");
                    postEvent(e);
                    System.err.println("event sent");
                } catch (IOException e) {
                    System.err.println("error : " + e.getMessage());
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
View Full Code Here

     *
     * @return true if the event should commit the characters in the
     *    input (line editing) buffer to the Reader's character stream.
     */
    private boolean processEvent() throws IOException {
        KeyboardEvent event = keyboardHandler.getEvent();
        if (!event.isConsumed()) {
            KeyboardReaderAction action = bindings.getKeyboardEventAction(event);
            boolean breakChar = false;
            boolean consume = true;
            switch (action) {
                case KR_DELETE_BEFORE:
                    // Delete character before cursor
                    if (currentLine.backspace()) {
                        refreshCurrentLine();
                    }
                    break;
                case KR_ENTER:
                    // Append event character to the line and commit.
                    currentLine.moveEnd();
                    refreshCurrentLine();
                    out.write('\n');
                    currentLine.appendChar(event.getKeyChar());
                    breakChar = true;
                    historyIndex = -1;
                    break;
                case KR_COMPLETE:
                    // Perform completion
                    if (completer != null) {
                        if (currentLine.complete(completer)) {
                            currentLine.start(true);
                        }
                        out.write(currentPrompt);
                        refreshCurrentLine();
                    }
                    break;
                case KR_HELP:
                    // Request incremental help
                    if (completer != null) {
                        if (currentLine.help(completer)) {
                            currentLine.start(true);
                        }
                        out.write(currentPrompt);
                        refreshCurrentLine();
                    }
                    break;
                case KR_SOFT_EOF:
                    // Set soft EOF status and commit
                    currentLine.moveEnd();
                    refreshCurrentLine();
                    out.write('\n');
                    eof = true;
                    breakChar = true;
                    break;
                case KR_KILL_LINE:
                    // Kill the current input line (and clear the screen)
                    this.console.clear();
                    this.console.setCursor(0, 0);
                    out.write(currentPrompt);
                    currentLine.start();
                    refreshCurrentLine();
                    break;
                case KR_INSERT:
                    // Insert event's character
                    currentLine.appendChar(event.getKeyChar());
                    refreshCurrentLine();
                    historyIndex = -1;
                    break;
                case KR_HISTORY_UP:
                    // Previous history item
                    if (completer != null) {
                        if (historyIndex == -1) {
                            historyIndex = completer.getInputHistory().size();
                            savedCurrentLine = currentLine.getContent();
                        }
                        historyIndex--;
                        updateCurrentLine();
                    }
                    break;
                case KR_HISTORY_DOWN:
                    // Next history item
                    if (completer != null) {
                        if (historyIndex == -1) {
                            savedCurrentLine = currentLine.getContent();
                        }
                        if (historyIndex == completer.getInputHistory().size() - 1) {
                            historyIndex = -2;
                        }
                        historyIndex++;
                        updateCurrentLine();
                    }
                    break;
                case KR_CURSOR_LEFT:
                    // Move the cursor left
                    if (currentLine.moveLeft()) {
                        refreshCurrentLine();
                    }
                    break;
                case KR_CURSOR_RIGHT:
                    // Move the cursor right
                    if (currentLine.moveRight()) {
                        refreshCurrentLine();
                    }
                    break;
                case KR_CURSOR_TO_START:
                    // Move the cursor to the start of the line
                    currentLine.moveBegin();
                    refreshCurrentLine();
                    break;
                case KR_CURSOR_TO_END:
                    // Move the cursor to the end of the line
                    currentLine.moveEnd();
                    refreshCurrentLine();
                    break;
                case KR_DELETE_AFTER:
                    // Delete the character after the cursor
                    currentLine.delete();
                    refreshCurrentLine();
                    break;
                case KR_CONSUME:
                    // Comsume (and ignore) the event
                    break;
                case KR_IGNORE:
                    // Leave the event unconsumed.
                    consume = false;
                    break;
            }
            if (consume) {
                event.consume();
            }
            return breakChar;
        } else {
            return false;
        }
View Full Code Here

TOP

Related Classes of org.jnode.driver.input.KeyboardEvent

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.