public void Ctor1() { var binding = KeyBinding.Parse("Global::Ctrl+Left Arrow"); var command = new CommandKeyBinding(new CommandId(), "Foo", binding); var data = new KeyBindingData(new ReadOnlyCollection<CommandKeyBinding>(new CommandKeyBinding[] { command })); Assert.Equal("Ctrl+Left Arrow", data.KeyName); Assert.False(data.HandledByVsVim); }
public void Ctor1() { var binding = KeyBinding.Parse("Global::Ctrl+Left Arrow"); var command = new CommandKeyBinding(new CommandId(), "Foo", binding); var data = new KeyBindingData(new ReadOnlyCollection <CommandKeyBinding>(new CommandKeyBinding[] { command })); Assert.Equal("Ctrl+Left Arrow", data.KeyName); Assert.False(data.HandledByVsVim); }
public void Ctor1() { var binding = KeyBinding.Parse("Global::Ctrl+Left Arrow"); var command = new CommandKeyBinding("Foo", binding); var data = new KeyBindingData(new CommandKeyBinding[] { command }); Assert.AreEqual("Ctrl+Left Arrow", data.KeyName); Assert.IsFalse(data.HandledByVsVim); }
/// <summary> /// Is the specified command active with the given binding /// </summary> public bool IsActive(CommandKeyBinding commandKeyBinding) { CommandData commandData; if (!_commandMap.TryGetValue(commandKeyBinding.Id, out commandData)) { return false; } return commandData.CommandKeyBindings.Contains(commandKeyBinding); }
/// <summary> /// True if the binding is applicable to a text view /// </summary> private bool IsTextViewBinding(CommandKeyBinding binding) { switch (_scopeData.GetScopeKind(binding.KeyBinding.Scope)) { case ScopeKind.TextEditor: case ScopeKind.Global: return(true); default: return(false); } }
static MiscTest() { var list = new List <CommandKeyBinding>(); var commandId = new CommandId(Guid.NewGuid(), 42); var name = "Name"; foreach (var bindingText in KeyBindingTest.SampleCommands) { var keyBinding = KeyBinding.Parse(bindingText); var commandKeyBinding = new CommandKeyBinding(commandId, name, keyBinding); list.Add(commandKeyBinding); } CommandKeyBindings = list; }
/// <summary> /// Should this be skipped when removing conflicting bindings? /// </summary> internal bool ShouldSkip(CommandKeyBinding binding) { var scope = binding.KeyBinding.Scope; var importantScopeSet = _importantScopeSet.Value; if (!importantScopeSet.Contains(scope)) { return(true); } if (!binding.KeyBinding.KeyStrokes.Any()) { return(true); } var first = binding.KeyBinding.FirstKeyStroke; // We don't want to remove any mappings which don't include a modifier key // because it removes too many mappings. Without this check we would for // example remove Delete in insert mode, arrow keys for intellisense and // general navigation, space bar for completion, etc ... // // One exception is function keys. They are only bound in Vim to key // mappings and should win over VS commands since users explicitly // want them to occur if (first.KeyModifiers == KeyModifiers.None && !first.KeyInput.IsFunctionKey) { return(true); } // In Vim ctlr+shift+f is exactly the same command as ctrl+f. Vim simply ignores the // shift key when processing a control command with an alpha character. Visual Studio // though does differentiate. Ctrl+f is differente than Ctrl+Shift+F. So don't // process any alpha commands which have both Ctrl and Shift as Vim wouldn't // ever hit them if (Char.IsLetter(first.Char) && first.KeyModifiers == (KeyModifiers.Shift | KeyModifiers.Control)) { return(true); } return(false); }
private ReadOnlyCollection<CommandKeyBinding> FindRemovedBindings() { var nameToIdMap = GetCommandNameToIdMap(); var list = new List<CommandKeyBinding>(); foreach (var commandSetting in _legacySettings.RemovedBindings) { List<CommandId> idList; KeyBinding keyBinding; if (nameToIdMap.TryGetValue(commandSetting.Name, out idList) && KeyBinding.TryParse(commandSetting.CommandString, out keyBinding)) { foreach (var id in idList) { var binding = new CommandKeyBinding(id, commandSetting.Name, keyBinding); list.Add(binding); } } } return list.ToReadOnlyCollectionShallow(); }
private ReadOnlyCollection <CommandKeyBinding> FindRemovedBindings() { var nameToIdMap = GetCommandNameToIdMap(); var list = new List <CommandKeyBinding>(); foreach (var commandSetting in _legacySettings.RemovedBindings) { List <CommandId> idList; KeyBinding keyBinding; if (nameToIdMap.TryGetValue(commandSetting.Name, out idList) && KeyBinding.TryParse(commandSetting.CommandString, out keyBinding)) { foreach (var id in idList) { var binding = new CommandKeyBinding(id, commandSetting.Name, keyBinding); list.Add(binding); } } } return(list.ToReadOnlyCollectionShallow()); }
/// <summary> /// Should this be skipped when removing conflicting bindings? /// </summary> internal bool ShouldSkip(CommandKeyBinding binding) { var scope = binding.KeyBinding.Scope; if (!_scopeData.IsImportantScope(scope)) { return true; } if (!binding.KeyBinding.KeyStrokes.Any()) { return true; } var first = binding.KeyBinding.FirstKeyStroke; // We don't want to remove any mappings which don't include a modifier key // because it removes too many mappings. Without this check we would for // example remove Delete in insert mode, arrow keys for intellisense and // general navigation, space bar for completion, etc ... // // One exception is function keys. They are only bound in Vim to key // mappings and should win over VS commands since users explicitly // want them to occur if (first.KeyModifiers == KeyModifiers.None && !first.KeyInput.IsFunctionKey) { return true; } // In Vim Ctrl+Shift+f is exactly the same command as ctrl+f. Vim simply ignores the // shift key when processing a control command with an alpha character. Visual Studio // though does differentiate. Ctrl+f is different than Ctrl+Shift+F. So don't // process any alpha commands which have both Ctrl and Shift as Vim wouldn't // ever hit them if (Char.IsLetter(first.Char) && first.KeyModifiers == (KeyModifiers.Shift | KeyModifiers.Control)) { return true; } return false; }
static MiscTest() { var list = new List<CommandKeyBinding>(); var commandId = new CommandId(Guid.NewGuid(), 42); var name = "Name"; foreach (var bindingText in KeyBindingTest.SampleCommands) { var keyBinding = KeyBinding.Parse(bindingText); var commandKeyBinding = new CommandKeyBinding(commandId, name, keyBinding); list.Add(commandKeyBinding); } s_commandKeyBindings = list; }
private void ExpectEqual(CommandKeyBinding left, CommandKeyBinding right) { Assert.Equal(left.Id, right.Id); Assert.Equal(left.Name, right.Name); Assert.Equal(left.KeyBinding, right.KeyBinding); }
/// <summary> /// True if the binding is applicable to a text view /// </summary> private bool IsTextViewBinding(CommandKeyBinding binding) { switch (_scopeData.GetScopeKind(binding.KeyBinding.Scope)) { case ScopeKind.TextEditor: case ScopeKind.Global: return true; default: return false; } }
public KeyBindingData(CommandKeyBinding binding) { Scope = binding.KeyBinding.Scope; Name = binding.Name; Keys = binding.KeyBinding.CommandString; }
/// <summary> /// Should this be skipped when removing conflicting bindings? /// </summary> internal bool ShouldSkip(CommandKeyBinding binding) { var scope = binding.KeyBinding.Scope; var importantScopeSet = _importantScopeSet.Value; if (!importantScopeSet.Contains(scope)) { return true; } if (!binding.KeyBinding.KeyStrokes.Any()) { return true; } var first = binding.KeyBinding.FirstKeyStroke; // We don't want to remove any mappings which don't include a modifier key // because it removes too many mappings. Without this check we would for // example remove Delete in insert mode, arrow keys for intellisense and // general navigation, space bar for completion, etc ... // // One exception is function keys. They are only bound in Vim to key // mappings and should win over VS commands since users explicitly // want them to occur if (first.KeyModifiers == KeyModifiers.None && !first.KeyInput.IsFunctionKey) { return true; } return false; }