Ejemplo n.º 1
0
 public void StandardCommand_ExtendSelectionRight()
 {
     Create("dog", "cat", "tree");
     _vsSimulation.SimulateStandardKeyMappings = true;
     _vsSimulation.Run(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Right, VimKeyModifiers.Shift));
     Assert.Equal(ModeKind.VisualCharacter, _vimBuffer.ModeKind);
 }
Ejemplo n.º 2
0
            public void DontPreserveModifiers()
            {
                var keyInput   = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.KeypadDivide, VimKeyModifiers.Control);
                var equivalent = KeyInputUtil.GetNonKeypadEquivalent(keyInput);

                Assert.Equal(KeyInputUtil.CharToKeyInput('/'), equivalent.Value);
            }
Ejemplo n.º 3
0
        internal bool TryProcess(VimKey vimKey, int clickCount = 1)
        {
            var keyInput = KeyInputUtil.ApplyKeyModifiersToKey(vimKey, _keyboardDevice.KeyModifiers);

            keyInput = KeyInputUtil.ApplyClickCount(keyInput, clickCount);

            // If the user has explicitly set the mouse to be <nop> then we don't want to report this as
            // handled.  Otherwise it will swallow the mouse event and as a consequence disable other
            // features that begin with a mouse click.
            //
            // There is really no other way for the user to opt out of mouse behavior besides mapping the
            // key to <nop> otherwise that would be done here.
            var keyInputSet = _vimBuffer.GetKeyInputMapping(keyInput).KeyInputSet;

            if (keyInputSet.Length > 0 && keyInputSet.KeyInputs[0].Key == VimKey.Nop)
            {
                return(false);
            }

            if (_vimBuffer.CanProcess(keyInput))
            {
                return(_vimBuffer.Process(keyInput).IsAnyHandled);
            }

            return(false);
        }
Ejemplo n.º 4
0
            public void AltGrAndEnter()
            {
                // Alt-Gr should not add any modifiers in combination with Enter, so the display name should remain <CR>
                // The #1008 and #1390 issues were caused by VsVim not handling this combination properly.
                var keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Enter, VimKeyModifiers.Alt | VimKeyModifiers.Control);

                Assert.Equal("<CR>", KeyNotationUtil.GetDisplayName(keyInput));
            }
Ejemplo n.º 5
0
            public void AlternateControAndShift()
            {
                var keyInputSet = KeyNotationUtil.StringToKeyInputSet(@"<CS-A><CS-Enter>");
                var list        = keyInputSet.KeyInputs.ToList();

                Assert.Equal(KeyInputUtil.CharWithControlToKeyInput('a'), list[0]);
                Assert.Equal(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Enter, VimKeyModifiers.Control | VimKeyModifiers.Shift), list[1]);
            }
Ejemplo n.º 6
0
 public void ShiftAndEnter()
 {
     Create("cat", "dog");
     _vimBuffer.Process(":inoremap <S-CR> <Esc>", enter: true);
     _vimBuffer.Process("i");
     _vsSimulation.Run(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Enter, VimKeyModifiers.Shift));
     Assert.Equal(ModeKind.Normal, _vimBuffer.ModeKind);
 }
Ejemplo n.º 7
0
 public void ShiftAndReturn()
 {
     Create("cat", "dog");
     _vimBuffer.Process(":map <S-RETURN> o<Esc>", enter: true);
     _vsSimulation.Run(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Enter, VimKeyModifiers.Shift));
     Assert.Equal(3, _textBuffer.CurrentSnapshot.LineCount);
     Assert.Equal("cat", _textBuffer.GetLine(0).GetText());
     Assert.Equal("", _textBuffer.GetLine(1).GetText());
     Assert.Equal("dog", _textBuffer.GetLine(2).GetText());
 }
Ejemplo n.º 8
0
 public void InsertPlusVisualWithIntellisenseInactive()
 {
     Create("blah");
     _vimBuffer.SwitchMode(ModeKind.Insert, ModeArgument.None);
     _vimBuffer.Process(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Right, VimKeyModifiers.Shift));
     _vimBuffer.SwitchMode(ModeKind.VisualCharacter, ModeArgument.None);
     _reSharperCommandTarget.IntellisenseDisplayed = false;
     _vsSimulation.Run(VimKey.Escape);
     Assert.Equal(ModeKind.Insert, _vimBuffer.ModeKind);
     Assert.Equal(0, _reSharperCommandTarget.ExecEscapeCount);
     Assert.Equal(1, _escapeKeyCount);
     Assert.False(_reSharperCommandTarget.IntellisenseDisplayed);
 }
Ejemplo n.º 9
0
            public void NonCharWithModifierShouldCarryModifier()
            {
                var ki = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Left, VimKeyModifiers.Shift);

                _mockVimBuffer.Setup(x => x.CanProcess(ki)).Returns(true).Verifiable();
                _mockVimBuffer.Setup(x => x.Process(ki)).Returns(ProcessResult.NewHandled(ModeSwitch.NoSwitch)).Verifiable();

                var arg = CreateKeyEventArgs(Key.Left, ModifierKeys.Shift);

                _processor.KeyDown(arg);
                Assert.True(arg.Handled);
                _mockVimBuffer.Verify();
            }
Ejemplo n.º 10
0
            public void ApplyModifiersControlToAllKeysNonAlpha()
            {
                foreach (var cur in Enum.GetValues(typeof(VimKey)).Cast <VimKey>())
                {
                    if (cur == VimKey.None || cur == VimKey.RawCharacter)
                    {
                        continue;
                    }

                    if (Char.IsLetter(KeyInputUtil.VimKeyToKeyInput(cur).Char))
                    {
                        continue;
                    }

                    var keyInput = KeyInputUtil.ApplyKeyModifiersToKey(cur, VimKeyModifiers.Control);
                    Assert.Equal(cur, keyInput.Key);
                    Assert.Equal(VimKeyModifiers.Control, keyInput.KeyModifiers & VimKeyModifiers.Control);
                }
            }
Ejemplo n.º 11
0
 static ReportDesignerUtil()
 {
     // The set of keys which are special handled are defined by the CodeWindow::ProcessKeyMessage inside
     // of Microsoft.ReportDesigner.dll
     SpecialHandledSet.Add(KeyInputUtil.EnterKey);
     SpecialHandledSet.Add(KeyInputUtil.TabKey);
     SpecialHandledSet.Add(KeyInputUtil.EscapeKey);
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.Delete));
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.Back));
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.PageUp));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.PageUp, VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.PageDown));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.PageDown, VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.End));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.End, VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.End, VimKeyModifiers.Control));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.End, VimKeyModifiers.Control | VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.Home));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Home, VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Home, VimKeyModifiers.Control));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Home, VimKeyModifiers.Control | VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.Left));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Left, VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Left, VimKeyModifiers.Control));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Left, VimKeyModifiers.Control | VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.Right));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Right, VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Right, VimKeyModifiers.Control));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Right, VimKeyModifiers.Control | VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.Up));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Up, VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.VimKeyToKeyInput(VimKey.Down));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Down, VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToChar('a', VimKeyModifiers.Control));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToChar('v', VimKeyModifiers.Control));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToChar('x', VimKeyModifiers.Control));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToChar('y', VimKeyModifiers.Control));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToChar('z', VimKeyModifiers.Control));
     SpecialHandledSet.Add(KeyInputUtil.ApplyKeyModifiersToChar('z', VimKeyModifiers.Control | VimKeyModifiers.Shift));
     SpecialHandledSet.Add(KeyInputUtil.CharToKeyInput('\b'));
 }
Ejemplo n.º 12
0
 public void NotationOfFunctionKey()
 {
     AssertSingle("<S-F11>", KeyInputUtil.ApplyKeyModifiersToKey(VimKey.F11, VimKeyModifiers.Shift));
     AssertSingle("<c-F11>", KeyInputUtil.ApplyKeyModifiersToKey(VimKey.F11, VimKeyModifiers.Control));
 }
Ejemplo n.º 13
0
 private void AssertMap(Key key, VimKey vimKey)
 {
     AssertMap(key, ModifierKeys.Control, KeyInputUtil.ApplyKeyModifiersToKey(vimKey, VimKeyModifiers.Control));
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Try and convert a Visual Studio 2000 style command into the associated KeyInput and EditCommand items
        /// </summary>
        internal static bool TryConvert(VSConstants.VSStd2KCmdID cmdId, IntPtr variantIn, out KeyInput keyInput, out EditCommandKind kind, out bool isRawText)
        {
            isRawText = false;
            switch (cmdId)
            {
            case VSConstants.VSStd2KCmdID.TYPECHAR:
                if (variantIn == IntPtr.Zero)
                {
                    keyInput = KeyInputUtil.CharToKeyInput(char.MinValue);
                }
                else
                {
                    var obj = Marshal.GetObjectForNativeVariant(variantIn);
                    var c   = (char)(ushort)obj;
                    keyInput = KeyInputUtil.CharToKeyInput(c);
                }
                kind      = EditCommandKind.UserInput;
                isRawText = true;
                break;

            case VSConstants.VSStd2KCmdID.RETURN:
                keyInput = KeyInputUtil.EnterKey;
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.CANCEL:
                keyInput = KeyInputUtil.EscapeKey;
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.DELETE:
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.Delete);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.BACKSPACE:
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.Back);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.LEFT:
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.Left);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.LEFT_EXT:
            case VSConstants.VSStd2KCmdID.LEFT_EXT_COL:
                keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Left, VimKeyModifiers.Shift);
                kind     = EditCommandKind.VisualStudioCommand;
                break;

            case VSConstants.VSStd2KCmdID.RIGHT:
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.Right);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.RIGHT_EXT:
            case VSConstants.VSStd2KCmdID.RIGHT_EXT_COL:
                keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Right, VimKeyModifiers.Shift);
                kind     = EditCommandKind.VisualStudioCommand;
                break;

            case VSConstants.VSStd2KCmdID.UP:
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.Up);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.UP_EXT:
            case VSConstants.VSStd2KCmdID.UP_EXT_COL:
                keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Up, VimKeyModifiers.Shift);
                kind     = EditCommandKind.VisualStudioCommand;
                break;

            case VSConstants.VSStd2KCmdID.DOWN:
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.Down);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.DOWN_EXT:
            case VSConstants.VSStd2KCmdID.DOWN_EXT_COL:
                keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Down, VimKeyModifiers.Shift);
                kind     = EditCommandKind.VisualStudioCommand;
                break;

            case VSConstants.VSStd2KCmdID.TAB:
                keyInput = KeyInputUtil.TabKey;
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.BACKTAB:
                keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Tab, VimKeyModifiers.Shift);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.PAGEDN:
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.PageDown);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.PAGEDN_EXT:
                keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.PageDown, VimKeyModifiers.Shift);
                kind     = EditCommandKind.VisualStudioCommand;
                break;

            case VSConstants.VSStd2KCmdID.PAGEUP:
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.PageUp);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.PAGEUP_EXT:
                keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.PageUp, VimKeyModifiers.Shift);
                kind     = EditCommandKind.VisualStudioCommand;
                break;

            case VSConstants.VSStd2KCmdID.UNDO:
            case VSConstants.VSStd2KCmdID.UNDONOMOVE:
                // Visual Studio was asked to undo.  This happens when either the undo button
                // was hit or the visual studio key combination bound to the undo command
                // was executed
                keyInput = KeyInput.DefaultValue;
                kind     = EditCommandKind.Undo;
                break;

            case VSConstants.VSStd2KCmdID.REDO:
            case VSConstants.VSStd2KCmdID.REDONOMOVE:
                // Visual Studio was asked to redo.  This happens when either the redo button
                // was hit or the visual studio key combination bound to the redo command
                // was executed
                keyInput = KeyInput.DefaultValue;
                kind     = EditCommandKind.Redo;
                break;

            case VSConstants.VSStd2KCmdID.BOL:
                // Even though there as a HOME value defined, Visual Studio apparently maps the
                // Home key to BOL
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.Home);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.BOL_EXT:
            case VSConstants.VSStd2KCmdID.BOL_EXT_COL:
                keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Home, VimKeyModifiers.Shift);
                kind     = EditCommandKind.VisualStudioCommand;
                break;

            case VSConstants.VSStd2KCmdID.EOL:
                // Even though there as a END value defined, Visual Studio apparently maps the
                // Home key to EOL
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.End);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.EOL_EXT:
            case VSConstants.VSStd2KCmdID.EOL_EXT_COL:
                keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.End, VimKeyModifiers.Shift);
                kind     = EditCommandKind.VisualStudioCommand;
                break;

            case VSConstants.VSStd2KCmdID.TOGGLE_OVERTYPE_MODE:
                // The <Insert> key is expressed in the toggle overtype mode flag.  In general
                // over write mode is referred to as overtype in the code / documentation
                keyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.Insert);
                kind     = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd2KCmdID.PASTE:
                keyInput = KeyInput.DefaultValue;
                kind     = EditCommandKind.Paste;
                break;

            case VSConstants.VSStd2KCmdID.COMMENT_BLOCK:
            case VSConstants.VSStd2KCmdID.COMMENTBLOCK:
                keyInput = KeyInput.DefaultValue;
                kind     = EditCommandKind.Comment;
                break;

            case VSConstants.VSStd2KCmdID.UNCOMMENT_BLOCK:
            case VSConstants.VSStd2KCmdID.UNCOMMENTBLOCK:
                keyInput = KeyInput.DefaultValue;
                kind     = EditCommandKind.Uncomment;
                break;

            default:
                keyInput = null;
                kind     = EditCommandKind.UserInput;
                break;
            }

            return(keyInput != null);
        }
            private void VerifySpecial(VimKey vimKey, VimKeyModifiers keyModifiers = VimKeyModifiers.None)
            {
                var keyInput = KeyInputUtil.ApplyKeyModifiersToKey(vimKey, keyModifiers);

                Assert.True(_reportDesignerUtil.IsSpecialHandled(keyInput));
            }
Ejemplo n.º 16
0
            public void AltGrAndEnter()
            {
                var keyInput = KeyInputUtil.ApplyKeyModifiersToKey(VimKey.Enter, VimKeyModifiers.Alt | VimKeyModifiers.Control);

                Assert.Equal("<C-A-CR>", KeyNotationUtil.GetDisplayName(keyInput));
            }