Package org.crsh.keyboard

Examples of org.crsh.keyboard.KeyHandler


    this.command = command;
  }

  @Override
  public void handle(KeyType type, int[] sequence) {
    KeyHandler keyHandler = process.getKeyHandler();
    if (keyHandler != null) {
      CRaSHConnector.log.fine("Processing key event " + type + " " + Arrays.toString(sequence));
      try {
        keyHandler.handle(type, sequence);
      }
      catch (Exception e) {
        CRaSHConnector.log.log(Level.SEVERE, "Processing key handler " + keyHandler + " threw an exception", e);
      }
    }
View Full Code Here


              if (s != null) {
                reader.line.add(s);
              }
            }
          } else {
            KeyHandler keyHandler = processHandler.process.getKeyHandler();
            if (keyHandler != null) {
              KeyType type = key.map();
              try {
                keyHandler.handle(type, key.sequence);
              }
              catch (Throwable t) {
                // Perhaps handle better this and treat error / exception differently
                log.log(Level.SEVERE, "Key handler " + keyHandler + " failure", t);
              }
View Full Code Here

    process.cancel();
    return this;
  }

  public BaseProcessContext on(KeyType type, int[] sequence) {
    KeyHandler handler = process.getKeyHandler();
    if (handler != null) {
      handler.handle(type, sequence);
    }
    return this;
  }
View Full Code Here

  }

  @Override
  public KeyHandler getKeyHandler() {
    for (CommandInvoker<?, ?> invoker : invokers) {
      KeyHandler handler = invoker.getKeyHandler();
      if (handler != null) {
        return handler;
      }
    }
    return null;
View Full Code Here

  public void testHandleKeyInProcess() {
    final ArrayBlockingQueue<Integer> keys = new ArrayBlockingQueue<Integer>(1);
    shell.addProcess(new SyncProcess() {
      @Override
      protected KeyHandler createKeyHandler() {
        return new KeyHandler() {
          @Override
          public void handle(KeyType type, int[] sequence) {
            for (int c : sequence) {
              keys.add(c);
            }
View Full Code Here

  public void testHandleKeyExceptionInProcess() {
    shell.addProcess(new SyncProcess() {
      @Override
      protected KeyHandler createKeyHandler() {
        return new KeyHandler() {
          @Override
          public void handle(KeyType type, int[] sequence) {
            throw new RuntimeException();
          }
        };
View Full Code Here

TOP

Related Classes of org.crsh.keyboard.KeyHandler

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.