Ejemplo n.º 1
0
            public void Issue328()
            {
                var left  = KeyNotationUtil.StringToKeyInput("<S-SPACE>");
                var right = KeyInputUtil.ApplyKeyModifiersToChar(' ', VimKeyModifiers.Shift);

                Assert.Equal(left, right);
            }
Ejemplo n.º 2
0
 public void ShiftLeft_Normal()
 {
     Create("        hello");
     _vimBuffer.LocalSettings.ShiftWidth = 4;
     _vimBuffer.Process(KeyNotationUtil.StringToKeyInput("<C-D>"));
     Assert.Equal("    hello", _textBuffer.GetLine(0).GetText());
 }
Ejemplo n.º 3
0
 public void WordCompletion_Simple()
 {
     Create("c dog", "cat");
     _textView.MoveCaretTo(1);
     _vimBuffer.Process(KeyNotationUtil.StringToKeyInput("<C-N>"));
     Assert.Equal("cat dog", _textView.GetLine(0).GetText());
 }
Ejemplo n.º 4
0
            public void Nop()
            {
                var keyInput = KeyNotationUtil.StringToKeyInput("<nop>");

                Assert.Equal(VimKey.Nop, keyInput.Key);
                Assert.Equal(VimKeyModifiers.None, keyInput.KeyModifiers);
            }
Ejemplo n.º 5
0
        public void Single_HandleCommandKey()
        {
            var ki = KeyNotationUtil.StringToKeyInput("<D-a>");

            Assert.AreEqual(VimKey.LowerA, ki.Key);
            Assert.AreEqual(KeyModifiers.Command, ki.KeyModifiers);
        }
Ejemplo n.º 6
0
 public void CharLeft()
 {
     AssertMotion("h", Motion.CharLeft);
     AssertMotion(VimKey.Left, Motion.CharLeft);
     AssertMotion(VimKey.Back, Motion.CharLeft);
     AssertMotion(KeyNotationUtil.StringToKeyInput("<C-h>"), Motion.CharLeft);
 }
Ejemplo n.º 7
0
            public void EquivalentKeysToDecimal()
            {
                var list = new[]
                {
                    "Nul-0",
                    "Tab-9",
                    "NL-10",
                    "FF-12",
                    "CR-13",
                    "Return-13",
                    "Enter-13",
                    "Esc-27",
                    "Space-32",
                    "lt-60",
                    "Bslash-92",
                    "Bar-124"
                };

                foreach (var entry in list)
                {
                    var pair  = entry.Split('-');
                    var name  = String.Format("<{0}>", pair[0]);
                    var c     = (char)Int32.Parse(pair[1]);
                    var left  = KeyNotationUtil.StringToKeyInput(name);
                    var right = KeyInputUtil.CharToKeyInput(c);
                    Assert.Equal(left, right);
                }
            }
Ejemplo n.º 8
0
 public void Bind_ScrollPages_Down()
 {
     Create("");
     _commandUtil.SetupCommandNormal(NormalCommand.NewScrollPages(ScrollDirection.Down));
     _mode.Process(KeyNotationUtil.StringToKeyInput("<PageDown>"));
     _commandUtil.Verify();
 }
Ejemplo n.º 9
0
 public void Process_WordCompletion_CtrlP()
 {
     Create("hello world");
     SetupActiveWordCompletionSession();
     _activeWordCompletionSession.Setup(x => x.MovePrevious()).Returns(true).Verifiable();
     _mode.Process(KeyNotationUtil.StringToKeyInput("<C-p>"));
     _activeWordCompletionSession.Verify();
 }
Ejemplo n.º 10
0
            public void HandleCommandKey()
            {
                var ki = KeyNotationUtil.StringToKeyInput("<D-a>");

                Assert.Equal(VimKey.RawCharacter, ki.Key);
                Assert.Equal(VimKeyModifiers.Command, ki.KeyModifiers);
                Assert.Equal('a', ki.Char);
            }
Ejemplo n.º 11
0
 public void LineDown()
 {
     AssertMotion(KeyNotationUtil.StringToKeyInput("<c-j>"), Motion.LineDown);
     AssertMotion(KeyNotationUtil.StringToKeyInput("<c-n>"), Motion.LineDown);
     AssertMotion("j", Motion.LineDown);
     AssertMotion(VimKey.Down, Motion.LineDown);
     AssertMotion(VimKey.LineFeed, Motion.LineDown);
 }
Ejemplo n.º 12
0
 public void PageDown1()
 {
     Create("");
     _editorOperations.Setup(x => x.PageDown(false)).Verifiable();
     _tracker.Setup(x => x.UpdateSelection()).Verifiable();
     _mode.Process(KeyNotationUtil.StringToKeyInput("<PageDown>"));
     _factory.Verify();
 }
Ejemplo n.º 13
0
            public void ControlHAndBackspace()
            {
                var left  = KeyInputUtil.CharWithControlToKeyInput('h');
                var right = KeyNotationUtil.StringToKeyInput("<BS>");

                Assert.Equal("<C-H>", KeyNotationUtil.GetDisplayName(left));
                Assert.Equal("<BS>", KeyNotationUtil.GetDisplayName(right));
            }
Ejemplo n.º 14
0
 public void ShiftRight1()
 {
     SetUp();
     _textView.SetText("hello world");
     _operations.Setup(x => x.ShiftLineRangeRight(_textView.GetLineRange(0, 0), 1)).Verifiable();
     _mode.Process(KeyNotationUtil.StringToKeyInput("<C-T>"));
     _factory.Verify();
 }
Ejemplo n.º 15
0
 public void Command_ShiftRight()
 {
     Create(insertMode: true, lines: "");
     _textView.SetText("hello world");
     _insertUtil.Setup(x => x.RunInsertCommand(InsertCommand.ShiftLineRight)).Returns(CommandResult.NewCompleted(ModeSwitch.NoSwitch)).Verifiable();
     _mode.Process(KeyNotationUtil.StringToKeyInput("<C-T>"));
     _factory.Verify();
 }
Ejemplo n.º 16
0
 public void WordCompletion_NoMatches()
 {
     Create("c dog");
     _textView.MoveCaretTo(1);
     _vimBuffer.Process(KeyNotationUtil.StringToKeyInput("<C-N>"));
     Assert.Equal("c dog", _textView.GetLine(0).GetText());
     Assert.Equal(ModeKind.Insert, _vimBuffer.ModeKind);
     Assert.True(_vimBuffer.InsertMode.ActiveWordCompletionSession.IsNone());
 }
Ejemplo n.º 17
0
 public void WordCompletion_Down()
 {
     Create("c dog", "cat copter");
     _vimBuffer.SwitchMode(ModeKind.Insert, ModeArgument.None);
     _textView.MoveCaretTo(1);
     _vsSimulation.Run(KeyNotationUtil.StringToKeyInput("<C-n>"));
     _vsSimulation.Run(KeyNotationUtil.StringToKeyInput("<Down>"));
     Assert.Equal("copter dog", _textView.GetLine(0).GetText());
 }
Ejemplo n.º 18
0
 public void WordCompletion_Escape()
 {
     Create("c dog", "cat");
     _textView.MoveCaretTo(1);
     _vimBuffer.Process(KeyNotationUtil.StringToKeyInput("<C-N>"));
     _vimBuffer.Process(KeyNotationUtil.StringToKeyInput("<Esc>"));
     Assert.Equal(ModeKind.Normal, _vimBuffer.ModeKind);
     Assert.Equal(2, _textView.GetCaretPoint().Position);
 }
Ejemplo n.º 19
0
 public void WordCompletion_TypeChar()
 {
     Create("c dog", "cat");
     _vimBuffer.SwitchMode(ModeKind.Insert, ModeArgument.None);
     _textView.MoveCaretTo(1);
     _vsSimulation.Run(KeyNotationUtil.StringToKeyInput("<C-n>"));
     _vsSimulation.Run('s');
     Assert.Equal("cats dog", _textView.GetLine(0).GetText());
     Assert.True(_vimBuffer.InsertMode.ActiveWordCompletionSession.IsNone());
 }
Ejemplo n.º 20
0
            public void CaseShouldntMatter()
            {
                var ki  = KeyInputUtil.EscapeKey;
                var all = new string[] { "<ESC>", "<esc>", "<Esc>" };

                foreach (var cur in all)
                {
                    Assert.Equal(ki, KeyNotationUtil.StringToKeyInput(cur));
                }
            }
Ejemplo n.º 21
0
 public void WordCompletionWithNoCompletion()
 {
     Create("z ");
     _textView.MoveCaretTo(1);
     TestRegister.UpdateValue(
         KeyNotationUtil.StringToKeyInput("i"),
         KeyNotationUtil.StringToKeyInput("<C-n>"),
         KeyNotationUtil.StringToKeyInput("s"));
     _vimBuffer.Process("@c");
     Assert.Equal("zs ", _textView.GetLine(0).GetText());
 }
Ejemplo n.º 22
0
            public void StringToKeyInput8()
            {
                var ki = KeyInputUtil.CharToKeyInput(' ');

                ki = KeyInputUtil.ChangeKeyModifiersDangerous(ki, VimKeyModifiers.Shift);
                var all = new string[] { "<S-space>", "<S-SPACE>" };

                foreach (var cur in all)
                {
                    Assert.Equal(ki, KeyNotationUtil.StringToKeyInput(cur));
                }
            }
Ejemplo n.º 23
0
 public void NumberedList()
 {
     Create("1. Heading");
     _vimBuffer.Process("qaYp");
     _vimBuffer.Process(KeyNotationUtil.StringToKeyInput("<C-a>"));
     _vimBuffer.Process("q3@a");
     for (var i = 0; i < 5; i++)
     {
         var line = String.Format("{0}. Heading", i + 1);
         Assert.Equal(line, _textView.GetLine(i).GetText());
     }
 }
Ejemplo n.º 24
0
            public void Letters()
            {
                var baseCase = (int)'a';

                for (var i = 0; i < 26; i++)
                {
                    var msg      = string.Format("<Char-{0}>", baseCase + i);
                    var keyInput = KeyNotationUtil.StringToKeyInput(msg);

                    var target = (char)(baseCase + i);
                    Assert.Equal(target, keyInput.Char);
                }
            }
Ejemplo n.º 25
0
            public void AlternateShiftAndControlWithNonPrintable()
            {
                void assert(string name, VimKey vimKey)
                {
                    var notation = $"<CS-{name}>";
                    var keyInput = KeyNotationUtil.StringToKeyInput(notation);

                    Assert.Equal(vimKey, keyInput.Key);
                    Assert.Equal(VimKeyModifiers.Shift | VimKeyModifiers.Control, keyInput.KeyModifiers);
                }

                assert("Enter", VimKey.Enter);
                assert("F2", VimKey.F2);
            }
Ejemplo n.º 26
0
            public void AlternateShiftAndControlWithNonPrintable()
            {
                Action <string, VimKey> assert =
                    (name, vimKey) =>
                {
                    var notation = string.Format("<CS-{0}>", name);
                    var keyInput = KeyNotationUtil.StringToKeyInput(notation);
                    Assert.Equal(vimKey, keyInput.Key);
                    Assert.Equal(VimKeyModifiers.Shift | VimKeyModifiers.Control, keyInput.KeyModifiers);
                };

                assert("Enter", VimKey.Enter);
                assert("F2", VimKey.F2);
            }
Ejemplo n.º 27
0
            public void Keypad()
            {
                Action <VimKey, string> func = (vimKey, name) =>
                {
                    var keyInput = KeyNotationUtil.StringToKeyInput(name);
                    Assert.Equal(vimKey, keyInput.Key);
                };

                func(VimKey.KeypadEnter, "<kEnter>");
                func(VimKey.KeypadDecimal, "<kPoint>");
                func(VimKey.KeypadDivide, "<kDivide>");
                func(VimKey.KeypadMinus, "<kMinus>");
                func(VimKey.KeypadMultiply, "<kMultiply>");
                func(VimKey.KeypadPlus, "<kPlus>");
            }
Ejemplo n.º 28
0
        protected static void AssertSingle(string input, KeyInput expected = null)
        {
            var opt = KeyNotationUtil.TryStringToKeyInput(input);

            if (expected != null)
            {
                Assert.True(opt.IsSome());
                Assert.Equal(expected, opt.Value);
                Assert.Equal(expected, KeyNotationUtil.StringToKeyInput(input));
            }
            else
            {
                Assert.True(opt.IsNone());
            }
        }
Ejemplo n.º 29
0
            public void Mouse()
            {
                Action <VimKey, string> func = (vimKey, name) =>
                {
                    var keyInput = KeyNotationUtil.StringToKeyInput(name);
                    Assert.Equal(vimKey, keyInput.Key);
                };

                func(VimKey.LeftMouse, "<LeftMouse>");
                func(VimKey.LeftDrag, "<LeftDrag>");
                func(VimKey.LeftRelease, "<LeftRelease>");
                func(VimKey.MiddleMouse, "<MiddleMouse>");
                func(VimKey.MiddleDrag, "<MiddleDrag>");
                func(VimKey.MiddleRelease, "<MiddleRelease>");
                func(VimKey.RightMouse, "<RightMouse>");
                func(VimKey.RightDrag, "<RightDrag>");
                func(VimKey.RightRelease, "<RightRelease>");
            }
Ejemplo n.º 30
0
 public void AllAlternatesShouldEqualTheirTarget()
 {
     foreach (var current in AlternateArray)
     {
         var all   = current.Split('&');
         var left  = KeyNotationUtil.StringToKeyInput(all[0]);
         var right = KeyNotationUtil.StringToKeyInput(all[1]);
         Assert.Equal(left, right);
         if (!String.IsNullOrEmpty(all[2]))
         {
             var number = Int32.Parse(all[2]);
             var c      = (char)number;
             var third  = KeyInputUtil.CharToKeyInput(c);
             Assert.Equal(left, third);
             Assert.Equal(right, third);
         }
     }
 }