Пример #1
0
 @Override
 public boolean handleKey(KeyStroke stroke) {
   boolean incsearch = editorAdaptor.getConfiguration().get(Options.INCREMENTAL_SEARCH);
   if (incsearch
       && (stroke.equals(AbstractCommandParser.KEY_RETURN)
           || stroke.equals(AbstractCommandParser.KEY_ESCAPE))) {
     resetIncSearch();
   }
   super.handleKey(stroke);
   if (incsearch && isEnabled) {
     // isEnabled == false indicates that super method ran a search and went to normal mode.
     doIncSearch();
   }
   return true;
 }
Пример #2
0
 public Transition<KeyMapInfo> press(KeyStroke key) {
   char c = key.getCharacter();
   if ('0' <= c && c <= '9') {
     return new SimpleTransition<KeyMapInfo>(value, this);
   }
   return state.press(key);
 }
Пример #3
0
  /**
   * Tries to work around AltGr madness if we detect that AltGr was pressed. If you did press Ctrl +
   * Alt or Alt and hit this function, then check the state provider. This function should be called
   * as a fallback when remaps and default bindings failed to find a match.
   *
   * <p>Examples for different Operating Systems when AltGr + Q is pressed (@ key on German
   * keybord):
   *
   * <ul>
   *   <li>Windows SWT sends Ctrl + Alt + @.
   *   <li>Mac OSX SWT sends Alt + @.
   *   <li>Linux SWT passes just @.
   * </ul>
   *
   * @return Either a {@link KeyStroke} without modifiers or <tt>null</tt> if not applicable.
   */
  public static KeyStroke fixAltGrKey(KeyStroke key) {
    // Most-common case, bail as fast as possible
    if (!key.withAltKey()) {
      return null;
    }

    // Turn off control and alt key bits.
    if (key.getSpecialKey() == null) {
      return new SimpleKeyStroke(key.getCharacter(), key.withShiftKey(), false, false);
    } else {
      return new SimpleKeyStroke(key.getSpecialKey(), key.withShiftKey(), false, false);
    }
  }
Пример #4
0
 private void assertGetCharReturns(char expected, KeyStroke key) {
   assertEquals(expected, key.getCharacter());
 }