Пример #1
0
        private void AddMapping(KeyState keyState, KeyInput keyInput, string text)
        {
            _keyStateToVimKeyDataMap[keyState] = new VimKeyData(keyInput, text);

            FrugalList <KeyState> list;

            if (!_keyInputToWpfKeyDataMap.TryGetValue(keyInput, out list))
            {
                _keyInputToWpfKeyDataMap[keyInput] = new FrugalList <KeyState>(keyState);
            }
            else
            {
                list.Add(keyState);
            }
        }
Пример #2
0
        private bool TryGetKeyInput(Key key, ModifierKeys modifierKeys, out VimKeyData vimKeyData)
        {
            var virtualKeyModifiers = KeyState.GetVirtualKeyModifiers(modifierKeys);

            if (_virtualKeyboard.UsesExtendedModifiers)
            {
                virtualKeyModifiers |= _virtualKeyboard.VirtualKeyModifiersExtended;
            }

            if (_virtualKeyboard.IsCapsLockToggled)
            {
                virtualKeyModifiers |= VirtualKeyModifiers.CapsLock;
            }

            // First just check and see if there is a direct mapping
            var keyState = new KeyState(key, virtualKeyModifiers);

            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, virtualKeyModifiers & VirtualKeyModifiers.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, VirtualKeyModifiers.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);
        }
Пример #3
0
        private bool TryGetKeyInput(Key key, ModifierKeys modifierKeys, out VimKeyData vimKeyData)
        {
            var virtualKeyModifiers = KeyState.GetVirtualKeyModifiers(modifierKeys);
            if (_virtualKeyboard.UsesExtendedModifiers)
            {
                virtualKeyModifiers |= _virtualKeyboard.VirtualKeyModifiersExtended;
            }

            if (_virtualKeyboard.IsCapsLockToggled)
            {
                virtualKeyModifiers |= VirtualKeyModifiers.CapsLock;
            }

            // First just check and see if there is a direct mapping
            var keyState = new KeyState(key, virtualKeyModifiers);
            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, virtualKeyModifiers & VirtualKeyModifiers.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, VirtualKeyModifiers.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
        private void AddMapping(KeyState keyState, KeyInput keyInput, string text)
        {
            _keyStateToVimKeyDataMap[keyState] = new VimKeyData(keyInput, text);

            FrugalList<KeyState> list;
            if (!_keyInputToWpfKeyDataMap.TryGetValue(keyInput, out list))
            {
                _keyInputToWpfKeyDataMap[keyInput] = new FrugalList<KeyState>(keyState);
            }
            else
            {
                list.Add(keyState);
            }
        }