From ecaa76f72f346d90586b6ee1029399262f6addf6 Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Mon, 18 May 2015 17:07:05 +0400 Subject: [PATCH] =?UTF-8?q?IDEA-140342=20AltGr+=D0=B3=20in=20ukrainian=20l?= =?UTF-8?q?ayout=20does=20not=20working?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KeyboardSettingsExternalizable.java | 6 +++- .../src/com/intellij/ide/IdeEventQueue.java | 32 +++++++------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/keymap/KeyboardSettingsExternalizable.java b/platform/platform-api/src/com/intellij/openapi/keymap/KeyboardSettingsExternalizable.java index 8f4c6f6b4329..e96abb6fd18f 100644 --- a/platform/platform-api/src/com/intellij/openapi/keymap/KeyboardSettingsExternalizable.java +++ b/platform/platform-api/src/com/intellij/openapi/keymap/KeyboardSettingsExternalizable.java @@ -35,7 +35,7 @@ import java.util.Locale; ) public class KeyboardSettingsExternalizable implements PersistentStateComponent { - private static final String [] supportedNonEnglishLanguages = {"de", "fr", "it"}; + private static final String [] supportedNonEnglishLanguages = {"de", "fr", "it", "uk"}; public static boolean isSupportedKeyboardLayout(@NotNull Component component) { if (SystemInfo.isMac) return false; @@ -92,6 +92,10 @@ public class KeyboardSettingsExternalizable implements PersistentStateComponent< myOptions = state; } + public boolean isUkrainianKeyboard (Component c) { + return c!=null && "uk".equals(c.getInputContext().getLocale().getLanguage()); + } + public boolean isNonEnglishKeyboardSupportEnabled () { return myOptions.USE_NON_ENGLISH_KEYBOARD; } diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index f6a0b2d9e7fb..ad541c2675dc 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -416,20 +416,8 @@ public class IdeEventQueue extends EventQueue { if (e instanceof KeyEvent) { KeyEvent ke = (KeyEvent)e; - // Alt,keyChar=Undefined keyChar,modifiers=Ctrl+Alt,extModifiers=Ctrl+Alt+Button5,keyLocation=KEY_LOCATION_RIGHT - - //if (ke.getKeyCode() == KeyEvent.VK_ALT && ke.getID() == KeyEvent.KEY_PRESSED) { - // - // if (ke.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) { - // if ((ke.getModifiersEx() & (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) != (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) - // { - // altGrIsPressed = true; - // } - // } - // - //} else { - // altGrIsPressed = false; - //} + // Try to get it from editor + Component sourceComponent = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow(); if (ke.getID() == KeyEvent.KEY_PRESSED) { switch (ke.getKeyCode()) { @@ -459,8 +447,15 @@ public class IdeEventQueue extends EventQueue { } } - - + if (!leftAltIsPressed && KeyboardSettingsExternalizable.getInstance().isUkrainianKeyboard(sourceComponent) ) { + if ('ґ' == ke.getKeyChar() || ke.getKeyCode() == KeyEvent.VK_U) { + ke = new KeyEvent(ke.getComponent(), ke.getID(), ke.getWhen(), 0, + KeyEvent.VK_UNDEFINED, 'ґ', ke.getKeyLocation()); + ke.setKeyCode(KeyEvent.VK_U); + ke.setKeyChar('ґ'); + return ke; + } + } Integer keyCodeFromChar = CharToVKeyMap.get(ke.getKeyChar()); if (keyCodeFromChar != null) { @@ -469,15 +464,12 @@ public class IdeEventQueue extends EventQueue { ke.setKeyCode(keyCodeFromChar); } - // Try to get it from editor - Component sourceComponent = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow(); - //for (int i = 0; sourceComponent == null && i < WindowManagerEx.getInstanceEx().getAllProjectFrames().length; i++) { // sourceComponent = WindowManagerEx.getInstanceEx().getAllProjectFrames()[i].getComponent(); //} if (sourceComponent != null) { - if (sourceComponent.getInputContext().getLocale().getLanguage().equals("de")) { + if (KeyboardSettingsExternalizable.isSupportedKeyboardLayout(sourceComponent)) { if ((ke.getModifiersEx() & (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) != 0 /*&& ke.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT*/) { // On German keyboard layout on Windows we are getting on key press // ctrl + alt instead of AltGr