Example #1
0
 public void RunNotation(string notation)
 {
     foreach (var keyInput in KeyNotationUtil.StringToKeyInputSet(notation).KeyInputs)
     {
         Run(keyInput);
     }
 }
Example #2
0
        internal static CommandBinding CreateComplexNormalBinding(
            string name,
            Func <KeyInput, bool> predicate,
            KeyRemapMode remapMode = null,
            CommandFlags flags     = CommandFlags.None)
        {
            var remapModeOption = FSharpOption.CreateForReference(remapMode);
            Func <KeyInput, BindResult <NormalCommand> > func = null;

            func = keyInput =>
            {
                if (predicate(keyInput))
                {
                    var data = new BindData <NormalCommand>(
                        remapModeOption,
                        func.ToFSharpFunc());
                    return(BindResult <NormalCommand> .NewNeedMoreInput(data));
                }

                return(BindResult <NormalCommand> .NewComplete(NormalCommand.NewPutAfterCaret(false)));
            };

            var bindData = new BindData <NormalCommand>(
                remapModeOption,
                func.ToFSharpFunc());
            var bindDataStorage = BindDataStorage <NormalCommand> .NewSimple(bindData);

            return(CommandBinding.NewComplexNormalBinding(
                       KeyNotationUtil.StringToKeyInputSet(name),
                       flags,
                       bindDataStorage));
        }
Example #3
0
        private KeyInput MapSingle(string lhs, KeyRemapMode mode = null)
        {
            mode = mode ?? KeyRemapMode.Normal;
            var result = _map.Map(KeyNotationUtil.StringToKeyInputSet(lhs), mode);

            return(result.AsMapped().KeyInputSet.KeyInputs.Single());
        }
Example #4
0
            public void EscapeLessThanSymbol()
            {
                Assert.True(_map.AddKeyMapping("a", @"\<Home>", allowRemap: false, KeyRemapMode.Normal));
                var result = _map.Map("a", KeyRemapMode.Normal);

                Assert.Equal(KeyNotationUtil.StringToKeyInputSet(@"\<Home>"), result.AsMapped().KeyInputSet);
            }
Example #5
0
 public void ProcessNotation(string notation)
 {
     foreach (var keyInput in KeyNotationUtil.StringToKeyInputSet(notation).KeyInputs)
     {
         Process(keyInput);
     }
 }
Example #6
0
            public void EscapeLessThanSymbol()
            {
                Assert.True(_map.MapWithNoRemap("a", @"\<Home>", KeyRemapMode.Normal));
                var result = _map.GetKeyMappingResult("a", KeyRemapMode.Normal);

                Assert.Equal(KeyNotationUtil.StringToKeyInputSet(@"\<Home>"), result.AsMapped().Item);
            }
Example #7
0
 internal static CommandBinding CreateMotionBinding(
     string name        = "default",
     CommandFlags flags = CommandFlags.None,
     Func <MotionData, NormalCommand> func = null)
 {
     func = func ?? NormalCommand.NewYank;
     return(CommandBinding.NewMotionBinding(KeyNotationUtil.StringToKeyInputSet(name), flags, func.ToFSharpFunc()));
 }
Example #8
0
 internal static CommandBinding CreateNormalBinding(
     string name           = "default",
     CommandFlags flags    = CommandFlags.None,
     NormalCommand command = null)
 {
     command = command ?? NormalCommand.NewPutAfterCaret(false);
     return(CommandBinding.NewNormalBinding(KeyNotationUtil.StringToKeyInputSet(name), flags, command));
 }
Example #9
0
            public void SplitIntoKeyNotationEntries4()
            {
                var keyInputSet = KeyNotationUtil.StringToKeyInputSet("<C-j><C-b>");

                Assert.Equal(
                    new[] { "<NL>", "<C-B>" },
                    keyInputSet.KeyInputs.Select(KeyNotationUtil.GetDisplayName));
            }
Example #10
0
            public void UnmatchedLessThan()
            {
                var keyInputList = KeyNotationUtil.StringToKeyInputSet("<<s-a>");

                Assert.Equal(
                    new[] { '<', 'A' },
                    keyInputList.KeyInputs.Select(x => x.Char));
            }
Example #11
0
            public void SimpleTwoChars()
            {
                var keyInputSet = KeyNotationUtil.StringToKeyInputSet("ab");

                Assert.Equal(
                    new[] { "a", "b" },
                    keyInputSet.KeyInputs.Select(KeyNotationUtil.GetDisplayName));
            }
Example #12
0
            public void TagNotSpecialName()
            {
                var keyInputList = KeyNotationUtil.StringToKeyInputSet("<dest>");

                Assert.Equal(
                    new[] { '<', 'd', 'e', 's', 't', '>' },
                    keyInputList.KeyInputs.Select(x => x.Char));
            }
Example #13
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]);
            }
        private void ProcessNotation(string notation)
        {
            var keyInputSet = KeyNotationUtil.StringToKeyInputSet(notation);

            foreach (var keyInput in keyInputSet.KeyInputs)
            {
                _vimBuffer.Process(keyInput);
                DoEvents();
            }
        }
Example #15
0
 public void Equality()
 {
     EqualityUtil.RunAll(
         (left, right) => left == right,
         (left, right) => left != right,
         false,
         true,
         EqualityUnit.Create(CreateOne('a')).WithEqualValues(CreateOne('a')),
         EqualityUnit.Create(CreateOne('a')).WithNotEqualValues(CreateOne('b')),
         EqualityUnit.Create(CreateOne('a')).WithEqualValues(CreateMany('a')),
         EqualityUnit.Create(CreateOne('D')).WithEqualValues(KeyNotationUtil.StringToKeyInputSet("D")),
         EqualityUnit.Create(KeyInputSet.NewOneKeyInput(KeyInputUtil.CharToKeyInput('D'))).WithEqualValues(KeyNotationUtil.StringToKeyInputSet("D")));
 }
Example #16
0
 public void MacroSave()
 {
     _vim.RegisterMap.GetRegister('h').UpdateValue(
         KeyNotationUtil.StringToKeyInputSet("<Right><Left><Esc>").KeyInputs.ToArray());
     _vim.RegisterMap.GetRegister('i').UpdateValue(
         KeyNotationUtil.StringToKeyInputSet("abc<CR>").KeyInputs.ToArray());
     _vim.SaveSessionData();
     _vim.RegisterMap.Clear();
     _stream.Position = 0;
     _vim.LoadSessionData();
     AssertMacroRegister('h', "<Right><Left><Esc>");
     AssertMacroRegister('i', "abc<CR>");
 }
Example #17
0
        /// <summary>
        /// Process the full notation as a series of KeyInput values
        /// </summary>
        public static void ProcessNotation(this IVimBuffer vimBuffer, string notation, bool enter = false)
        {
            var keyInputSet = KeyNotationUtil.StringToKeyInputSet(notation);

            foreach (var keyInput in keyInputSet.KeyInputs)
            {
                vimBuffer.Process(keyInput);
            }

            if (enter)
            {
                vimBuffer.Process(KeyInputUtil.EnterKey);
            }
        }
Example #18
0
        /// <summary>
        /// This will process the provided string as key notation.  This method is different than
        /// IVimBuffer::ProcessNotation because it will attempt to take into account the focus
        /// of the CommandMarginControl instance.  It will route the provided key into a WPF key
        /// event when it has focus and give it directly to that control
        /// </summary>
        private void ProcessNotation(string notation)
        {
            var keyInputList = KeyNotationUtil.StringToKeyInputSet(notation).KeyInputs.ToList();

            for (var i = 0; i < keyInputList.Count; i++)
            {
                var keyInput = keyInputList[i];
                if (_marginControl.IsEditEnabled)
                {
                    _keyboardDevice.SendKeyStroke(_marginControl.CommandLineTextBox, keyInput);
                }
                else
                {
                    _vimBuffer.Process(keyInput);
                }
            }
        }
        private void AssertPrintMap(string input, string output)
        {
            var keyInputSet = KeyNotationUtil.StringToKeyInputSet(input);

            _keyMap
            .Setup(x => x.GetKeyMappingsForMode(KeyRemapMode.Normal))
            .Returns(new[] { Tuple.Create(keyInputSet, keyInputSet) })
            .Verifiable();

            var expected = String.Format("n    {0} {0}", output);

            _statusUtil
            .Setup(x => x.OnStatusLong(It.IsAny <IEnumerable <string> >()))
            .Callback <IEnumerable <string> >(x => Assert.AreEqual(expected, x.Single()))
            .Verifiable();
            _operations.PrintKeyMap((new[] { KeyRemapMode.Normal }).ToFSharpList());
            _factory.Verify();
        }
Example #20
0
        internal BindResult <Motion> Process(string input, bool enter = false)
        {
            var keyInputSet = KeyNotationUtil.StringToKeyInputSet(input);
            var res         = _capture.GetMotionAndCount(keyInputSet.FirstKeyInput.Value);

            foreach (var keyInput in keyInputSet.Rest.KeyInputs)
            {
                Assert.True(res.IsNeedMoreInput);
                var needMore = res.AsNeedMoreInput();
                res = needMore.BindData.BindFunction.Invoke(keyInput);
            }

            if (enter)
            {
                var needMore = res.AsNeedMoreInput();
                res = needMore.BindData.BindFunction.Invoke(KeyInputUtil.EnterKey);
            }

            return(res.Convert(x => x.Item1));
        }
Example #21
0
        internal static CommandBinding CreateComplexNormalBinding(
            string name,
            Action <KeyInput> action,
            CommandFlags flags = CommandFlags.None)
        {
            Func <KeyInput, BindResult <NormalCommand> > func = keyInput =>
            {
                action(keyInput);
                return(BindResult <NormalCommand> .NewComplete(NormalCommand.NewPutAfterCaret(false)));
            };

            var bindData = new BindData <NormalCommand>(
                FSharpOption <KeyRemapMode> .None,
                func.ToFSharpFunc());
            var bindDataStorage = BindDataStorage <NormalCommand> .NewSimple(bindData);

            return(CommandBinding.NewComplexNormalBinding(
                       KeyNotationUtil.StringToKeyInputSet(name),
                       flags,
                       bindDataStorage));
        }
Example #22
0
 public static IEnumerable <KeyInput> GetKeyMapping(this IKeyMap keyMap, string str, KeyRemapMode mode)
 {
     return(GetKeyMapping(keyMap, KeyNotationUtil.StringToKeyInputSet(str), mode));
 }
Example #23
0
 public void Remove2()
 {
     Create(string.Empty);
     _runner.Remove(KeyNotationUtil.StringToKeyInputSet("foo"));
     Assert.Empty(_runner.Commands);
 }
Example #24
0
 protected void AssertMapping(string lhs, string expected, KeyRemapMode mode = null)
 {
     AssertMapping(KeyNotationUtil.StringToKeyInputSet(lhs), expected, mode);
 }
Example #25
0
            public void FormFeed()
            {
                var keyInputSet = KeyNotationUtil.StringToKeyInputSet("<C-l>");

                Assert.Equal("<C-L>", KeyNotationUtil.GetDisplayName(keyInputSet.FirstKeyInput.Value));
            }
Example #26
0
 public static KeyMappingResult GetKeyMappingResult(this IKeyMap keyMap, string str, KeyRemapMode mode)
 {
     return(keyMap.GetKeyMapping(KeyNotationUtil.StringToKeyInputSet(str), mode));
 }
Example #27
0
 public void Remove2()
 {
     Create(String.Empty);
     _runner.Remove(KeyNotationUtil.StringToKeyInputSet("foo"));
     Assert.Equal(0, _runner.Commands.Count());
 }