示例#1
0
  /**
   * InputMethod implementation For details read
   * http://docs.oracle.com/javase/7/docs/technotes/guides/imf/api-tutorial.html
   */
  @Override
  protected void processInputMethodEvent(InputMethodEvent e) {
    int commitCount = e.getCommittedCharacterCount();

    if (commitCount > 0) {
      myInputMethodUncommitedChars = null;
      AttributedCharacterIterator text = e.getText();
      if (text != null) {
        StringBuilder sb = new StringBuilder();

        //noinspection ForLoopThatDoesntUseLoopVariable
        for (char c = text.first(); commitCount > 0; c = text.next(), commitCount--) {
          if (c >= 0x20
              && c
                  != 0x7F) { // Hack just like in
                             // javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction
            sb.append(c);
          }
        }

        myTerminalStarter.sendString(sb.toString());
      }
    } else {
      myInputMethodUncommitedChars = uncommitedChars(e.getText());
    }
  }
示例#2
0
  protected void pasteSelection() {
    final String selection = getClipboardString();

    if (selection == null) {
      return;
    }

    try {
      myTerminalStarter.sendString(selection);
    } catch (RuntimeException e) {
      LOG.info(e);
    }
  }
示例#3
0
 private void processTerminalKeyTyped(KeyEvent e) {
   final char keychar = e.getKeyChar();
   if ((keychar & 0xff00) != 0) {
     final char[] foo;
     if (mySettingsProvider.altSendsEscape() && (e.getModifiers() & InputEvent.ALT_MASK) != 0) {
       foo = new char[] {Ascii.ESC, keychar};
     } else {
       foo = new char[] {keychar};
     }
     try {
       myTerminalStarter.sendString(new String(foo));
       if (mySettingsProvider.scrollToBottomOnTyping()) {
         scrollToBottom();
       }
     } catch (final RuntimeException ex) {
       LOG.error("Error sending key to emulator", ex);
     }
   }
 }