示例#1
0
        private bool TryGetKeyInput(Key key, ModifierKeys modifierKeys, out VimKeyData vimKeyData)
        {
            // First just check and see if there is a direct mapping
            var keyState = new KeyState(key, modifierKeys);

            if (_keyStateToVimKeyDataMap.TryGetValue(keyState, out vimKeyData))
            {
                return(true);
            }

            // Next consider only the shift key part of the requested modifier.  We can
            // re-apply the original modifiers later
            keyState = new KeyState(key, modifierKeys & ModifierKeys.Shift);
            if (_keyStateToVimKeyDataMap.TryGetValue(keyState, out vimKeyData) &&
                vimKeyData.KeyInputOptional != null)
            {
                // Reapply the modifiers
                var keyInput = KeyInputUtil.ApplyModifiers(vimKeyData.KeyInputOptional, ConvertToKeyModifiers(modifierKeys));
                vimKeyData = new VimKeyData(keyInput, vimKeyData.TextOptional);
                return(true);
            }

            // Last consider it without any modifiers and reapply
            keyState = new KeyState(key, ModifierKeys.None);
            if (_keyStateToVimKeyDataMap.TryGetValue(keyState, out vimKeyData) &&
                vimKeyData.KeyInputOptional != null)
            {
                // Reapply the modifiers
                var keyInput = KeyInputUtil.ApplyModifiers(vimKeyData.KeyInputOptional, ConvertToKeyModifiers(modifierKeys));
                vimKeyData = new VimKeyData(keyInput, vimKeyData.TextOptional);
                return(true);
            }

            return(false);
        }
示例#2
0
            /// <summary>
            /// Build up the information about the known set of vim key input
            /// </summary>
            private void BuildKeyInputData()
            {
                foreach (var current in KeyInputUtil.VimKeyInputList)
                {
                    uint         virtualKey;
                    ModifierKeys modKeys;
                    if (!TryGetVirtualKeyAndModifiers(current, out virtualKey, out modKeys))
                    {
                        continue;
                    }

                    // Only processing items which can map to actual keys
                    var key = KeyInterop.KeyFromVirtualKey((int)virtualKey);
                    if (Key.None == key)
                    {
                        continue;
                    }

                    string text;
                    if (!TryGetText(virtualKey, ModifierKeys.None, out text))
                    {
                        text = "";
                    }

                    var keyState = new KeyState(key, modKeys);
                    _keyStateToVimKeyDataMap[keyState] = new VimKeyData(current, text);
                    _keyInputToWpfKeyDataMap[current]  = keyState;
                }
            }
示例#3
0
        private bool TryGetKeyInput(Key key, ModifierKeys modifierKeys, out VimKeyData vimKeyData)
        {
            // First just check and see if there is a direct mapping
            var keyState = new KeyState(key, modifierKeys);
            if (_keyStateToVimKeyDataMap.TryGetValue(keyState, out vimKeyData))
            {
                return true;
            }

            // Next consider only the shift key part of the requested modifier.  We can
            // re-apply the original modifiers later
            keyState = new KeyState(key, modifierKeys & ModifierKeys.Shift);
            if (_keyStateToVimKeyDataMap.TryGetValue(keyState, out vimKeyData) &&
                vimKeyData.KeyInputOptional != null)
            {
                // Reapply the modifiers
                var keyInput = KeyInputUtil.ApplyModifiers(vimKeyData.KeyInputOptional, ConvertToKeyModifiers(modifierKeys));
                vimKeyData = new VimKeyData(keyInput, vimKeyData.TextOptional);
                return true;
            }

            // Last consider it without any modifiers and reapply
            keyState = new KeyState(key, ModifierKeys.None);
            if (_keyStateToVimKeyDataMap.TryGetValue(keyState, out vimKeyData) &&
                vimKeyData.KeyInputOptional != null)
            {
                // Reapply the modifiers
                var keyInput = KeyInputUtil.ApplyModifiers(vimKeyData.KeyInputOptional, ConvertToKeyModifiers(modifierKeys));
                vimKeyData = new VimKeyData(keyInput, vimKeyData.TextOptional);
                return true;
            }

            return false;
        }
示例#4
0
            /// <summary>
            /// Build up the information about the known set of vim key input
            /// </summary>
            private void BuildKeyInputData()
            {
                foreach (var current in KeyInputUtil.VimKeyInputList)
                {
                    uint virtualKey;
                    ModifierKeys modKeys;
                    if (!TryGetVirtualKeyAndModifiers(current, out virtualKey, out modKeys))
                    {
                        continue;
                    }

                    // Only processing items which can map to actual keys
                    var key = KeyInterop.KeyFromVirtualKey((int)virtualKey);
                    if (Key.None == key)
                    {
                        continue;
                    }

                    string text;
                    if (!TryGetText(virtualKey, ModifierKeys.None, out text))
                    {
                        text = "";
                    }

                    var keyState = new KeyState(key, modKeys);
                    _keyStateToVimKeyDataMap[keyState] = new VimKeyData(current, text);
                    _keyInputToWpfKeyDataMap[current] = keyState;
                }
            }