Exemplo n.º 1
0
            public void Control_OpenBracket1()
            {
                var ki   = KeyInputUtil.CharWithControlToKeyInput('[');
                var name = KeyInputSet.NewOneKeyInput(ki);

                Assert.True(_mode.CommandNames.Contains(name));
            }
Exemplo n.º 2
0
        internal void RunConflictingKeyBindingStateCheck(IVimBuffer buffer, Action <ConflictingKeyBindingState, CommandKeyBindingSnapshot> onComplete)
        {
            var needed = buffer.AllModes.Select(x => x.CommandNames).SelectMany(x => x).ToList();

            needed.Add(KeyInputSet.NewOneKeyInput(buffer.LocalSettings.GlobalSettings.DisableAllCommand));
            RunConflictingKeyBindingStateCheck(needed.Select(x => x.KeyInputs.First()), onComplete);
        }
Exemplo n.º 3
0
        public void Add1()
        {
            var name1 = KeyInputSet.NewOneKeyInput(KeyInputUtil.CharToKeyInput('c'));
            var name2 = name1.Add(KeyInputUtil.CharToKeyInput('a'));

            Assert.AreEqual("ca", name2.Name);
        }
Exemplo n.º 4
0
        public void Compare_AlternateKeyInputShouldBeEqual()
        {
            var left  = KeyInputSet.NewOneKeyInput(KeyInputUtil.EnterKey);
            var right = KeyInputSet.NewOneKeyInput(KeyInputUtil.AlternateEnterKey);

            Assert.True(0 == left.CompareTo(right));
            Assert.True(0 == right.CompareTo(left));
        }
Exemplo n.º 5
0
            public void HandleCommandKey()
            {
                Map("<D-k>", "gk");
                var ki    = new KeyInput(VimKey.RawCharacter, KeyModifiers.Command, FSharpOption.Create('k'));
                var kiSet = KeyInputSet.NewOneKeyInput(ki);

                AssertPartialMapping(kiSet, "g", "k");
            }
Exemplo n.º 6
0
        public void Compare_AlternateKeyInputShouldBeEqualInMap()
        {
            var left   = KeyInputSet.NewOneKeyInput(KeyInputUtil.EnterKey);
            var right  = KeyInputSet.NewOneKeyInput(KeyInputUtil.AlternateEnterKey);
            var map    = MapModule.Empty <KeyInputSet, bool>().Add(left, true);
            var result = MapModule.TryFind(right, map);

            Assert.True(result.IsSome());

            map    = MapModule.Empty <KeyInputSet, bool>().Add(right, true);
            result = MapModule.TryFind(left, map);
            Assert.True(result.IsSome());
        }
Exemplo n.º 7
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")));
 }
Exemplo n.º 8
0
        public void MapWithRemap_HandleCommandKey()
        {
            Assert.IsTrue(_map.MapWithRemap("<D-k>", "gk", KeyRemapMode.Normal));
            var ki    = new KeyInput(VimKey.LowerK, KeyModifiers.Command, FSharpOption.Create('k'));
            var kiSet = KeyInputSet.NewOneKeyInput(ki);
            var ret   = _map.GetKeyMapping(kiSet, KeyRemapMode.Normal);

            Assert.IsTrue(ret.IsMapped);
            var all = ret.AsMapped().Item.KeyInputs.Select(x => x.Char).ToList();

            Assert.AreEqual('g', all[0]);
            Assert.AreEqual('k', all[1]);
        }
Exemplo n.º 9
0
        internal void RunConflictingKeyBindingStateCheck(IVimBuffer buffer)
        {
            // Create the set of KeyInput values which are handled by VsVim
            var needed = buffer.AllModes.Select(x => x.CommandNames).SelectMany(x => x).ToList();

            needed.Add(KeyInputSet.NewOneKeyInput(buffer.LocalSettings.GlobalSettings.DisableAllCommand));
            var set = new HashSet <KeyInput>(needed.Select(x => x.KeyInputs.First()));

            // Take a snapshot based on the current state of the DTE commands and store it
            // and the conflicting state
            _snapshot = CreateCommandKeyBindingSnapshot(set);
            ConflictingKeyBindingState = _snapshot.Conflicting.Any()
                ? ConflictingKeyBindingState.FoundConflicts
                : ConflictingKeyBindingState.ConflictsIgnoredOrResolved;
        }
Exemplo n.º 10
0
        public void Commands1()
        {
            Create("foo");
            var list = new KeyInput[] {
                KeyInputUtil.CharToKeyInput('h'),
                KeyInputUtil.CharToKeyInput('j'),
                KeyInputUtil.CharToKeyInput('k'),
                KeyInputUtil.CharToKeyInput('l'),
                KeyInputUtil.VimKeyToKeyInput(VimKey.Left),
                KeyInputUtil.VimKeyToKeyInput(VimKey.Right),
                KeyInputUtil.VimKeyToKeyInput(VimKey.Up),
                KeyInputUtil.VimKeyToKeyInput(VimKey.Down),
                KeyInputUtil.VimKeyToKeyInput(VimKey.Back)
            };
            var commands = _mode.CommandNames.ToList();

            foreach (var item in list)
            {
                var name = KeyInputSet.NewOneKeyInput(item);
                Assert.Contains(name, commands);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Try and map a KeyInput to a single KeyInput value.  This will only succeed for KeyInput
        /// values which have no mapping or map to a single KeyInput value
        /// </summary>
        private bool TryGetSingleMapping(KeyRemapMode mode, KeyInput original, out KeyInput mapped)
        {
            // If we're currently in the middle of a key mapping sequence we won't provide a KeyInput
            if (!_buffer.BufferedRemapKeyInputs.IsEmpty)
            {
                mapped = null;
                return(false);
            }

            var result = _buffer.Vim.KeyMap.GetKeyMapping(
                KeyInputSet.NewOneKeyInput(original),
                mode);

            mapped = null;
            if (result.IsMappingNeedsMoreInput || result.IsRecursiveMapping)
            {
                // No single mapping
                return(false);
            }
            else if (result.IsMapped)
            {
                var set = ((KeyMappingResult.Mapped)result).Item;
                if (!set.IsOneKeyInput)
                {
                    return(false);
                }

                mapped = set.FirstKeyInput.Value;
                return(true);
            }
            else
            {
                // No mapping.  Use the original
                mapped = original;
                return(true);
            }
        }
Exemplo n.º 12
0
 public void CommandMapSupportsAlternateKeys()
 {
     Assert.True(MapModule.TryFind(KeyInputSet.NewOneKeyInput(KeyInputUtil.EnterKey), _captureRaw.MotionBindingsMap).IsSome());
 }
Exemplo n.º 13
0
 public static KeyMappingResult GetKeyMappingResult(this IKeyMap keyMap, KeyInput ki, KeyRemapMode mode)
 {
     return(GetKeyMappingResult(keyMap, KeyInputSet.NewOneKeyInput(ki), mode));
 }
Exemplo n.º 14
0
 public static IEnumerable <KeyInput> GetKeyMapping(this IKeyMap keyMap, KeyInput ki, KeyRemapMode mode)
 {
     return(GetKeyMapping(keyMap, KeyInputSet.NewOneKeyInput(ki), mode));
 }
Exemplo n.º 15
0
        public void Name1()
        {
            var name1 = KeyInputSet.NewOneKeyInput(KeyInputUtil.CharToKeyInput('c'));

            Assert.AreEqual("c", name1.Name);
        }
Exemplo n.º 16
0
 private KeyInputSet CreateOne(char c)
 {
     return(KeyInputSet.NewOneKeyInput(KeyInputUtil.CharToKeyInput(c)));
 }