コード例 #1
0
        private void ComputeKeyBindings()
        {
            // This snapshot contains a list of active keys, and keys which are still conflicting. We will group all
            // bindings by the initial character, and will consider the entire group as being handled by VsVim as long
            // as one is being handled.
            _snapshot = GetCommandKeyBindingSnapshot();
            _keyBindingList.Clear();
            _advancedSet.Clear();

            var handledByVsVim = _snapshot.Removed.ToLookup(binding => binding.KeyBinding.FirstKeyStroke);
            var handledByVs    = _snapshot.Conflicting.ToLookup(binding => binding.KeyBinding.FirstKeyStroke);

            var allFirstKeys = handledByVsVim.Select(group => group.Key)
                               .Union(handledByVs.Select(group => group.Key));

            foreach (var firstKey in allFirstKeys)
            {
                var data = new KeyBindingData(handledByVsVim[firstKey].Union(handledByVs[firstKey]).ToReadOnlyCollection());
                data.HandledByVsVim = handledByVsVim.Contains(firstKey);
                _keyBindingList.Add(data);

                if (IsAdvanced(firstKey))
                {
                    _advancedSet.Add(data);
                }
            }
        }
コード例 #2
0
        public ConflictingKeyBindingDialog(CommandKeyBindingSnapshot snapshot)
        {
            InitializeComponent();

            _snapshot = snapshot;
            ComputeKeyBindings();

            BindingsListBox.ItemsSource = _keyBindingList;
            BindingsListBox.Items.SortDescriptions.Add(new SortDescription("KeyName", ListSortDirection.Ascending));
        }
コード例 #3
0
        public ConflictingKeyBindingDialog(CommandKeyBindingSnapshot snapshot)
        {
            InitializeComponent();

            _snapshot = snapshot;
            ComputeKeyBindings();

            BindingsListBox.ItemsSource = _keyBindingList;
            BindingsListBox.Items.SortDescriptions.Add(new SortDescription("KeyName", ListSortDirection.Ascending));
        }
コード例 #4
0
        public ConflictingKeyBindingDialog(CommandKeyBindingSnapshot snapshot, IVimApplicationSettings vimApplicationSettings, IProtectedOperations protectedOperations)
        {
            InitializeComponent();

            _snapshot = snapshot;
            _vimApplicationSettings = vimApplicationSettings;
            _protectedOperations = protectedOperations;
            ComputeKeyBindings();

            BindingsListBox.ItemsSource = _keyBindingList;
            BindingsListBox.Items.SortDescriptions.Add(new SortDescription("KeyName", ListSortDirection.Ascending));
        }
コード例 #5
0
        public KeyboardSettingsControl(CommandKeyBindingSnapshot snapshot, IVimApplicationSettings vimApplicationSettings, IProtectedOperations protectedOperations)
        {
            InitializeComponent();

            _snapshot = snapshot;
            _vimApplicationSettings = vimApplicationSettings;
            _protectedOperations    = protectedOperations;
            ComputeKeyBindings();

            BindingsListBox.ItemsSource = _keyBindingList;
            BindingsListBox.Items.SortDescriptions.Add(new SortDescription("KeyName", ListSortDirection.Ascending));
        }
コード例 #6
0
        public void ResolveAnyConflicts4()
        {
            Create("::ctrl+h");
            var snapshot = new CommandKeyBindingSnapshot(
                new CommandsSnapshot(_dte.Object),
                Enumerable.Empty <CommandKeyBinding>(),
                Enumerable.Empty <CommandKeyBinding>());

            _serviceRaw.UpdateConflictingState(ConflictingKeyBindingState.FoundConflicts, snapshot);
            _optionsDialogService.Setup(x => x.ShowConflictingKeyBindingsDialog(snapshot)).Returns(false).Verifiable();
            _serviceRaw.ResolveAnyConflicts();
            Assert.AreEqual(ConflictingKeyBindingState.FoundConflicts, _service.ConflictingKeyBindingState);
        }
コード例 #7
0
        internal void ResolveAnyConflicts()
        {
            if (_snapshot == null || _state != ConflictingKeyBindingState.FoundConflicts)
            {
                return;
            }

            if (_optionsDialogService.ShowConflictingKeyBindingsDialog(_snapshot))
            {
                ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved;
                _snapshot = null;
            }
        }
コード例 #8
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;
        }
コード例 #9
0
        public void RunConflictingKeyBindingStateCheck(IEnumerable <KeyInput> neededInputs, Action <ConflictingKeyBindingState, CommandKeyBindingSnapshot> onComplete)
        {
            if (_snapshot != null)
            {
                onComplete(_state, _snapshot);
                return;
            }

            var util = new KeyBindingUtil(_dte);
            var set  = new HashSet <KeyInput>(neededInputs);

            _snapshot = util.CreateCommandKeyBindingSnapshot(set);
            ConflictingKeyBindingState = _snapshot.Conflicting.Any()
                ? ConflictingKeyBindingState.FoundConflicts
                : ConflictingKeyBindingState.ConflictsIgnoredOrResolved;
        }
コード例 #10
0
        public static bool DoShow(CommandKeyBindingSnapshot snapshot)
        {
            var window = new ConflictingKeyBindingDialog();
            var removed = window.ConflictingKeyBindingControl.RemovedKeyBindingData;
            removed.AddRange(snapshot.Removed.Select(x => new KeyBindingData(x)));
            var current = window.ConflictingKeyBindingControl.ConflictingKeyBindingData;
            current.AddRange(snapshot.Conflicting.Select(x => new KeyBindingData(x)));
            var ret = window.ShowModal();
            if (ret.HasValue && ret.Value)
            {
                // Remove all of the removed bindings
                foreach (var cur in removed)
                {
                    var tuple = snapshot.TryGetCommand(cur.Name);
                    if ( tuple.Item1 )
                    {
                        tuple.Item2.SafeResetBindings();
                    }
                }

                // Restore all of the conflicting ones
                foreach (var cur in current)
                {
                    KeyBinding binding;
                    var tuple = snapshot.TryGetCommand(cur.Name);
                    if ( tuple.Item1 && KeyBinding.TryParse(cur.Keys, out binding))
                    {
                        tuple.Item2.SafeSetBindings(binding);
                    }
                }

                var settings = Settings.Settings.Default;
                settings.RemovedBindings =
                    removed
                    .Select(x => new Settings.CommandBindingSetting() { Name = x.Name, CommandString = x.Keys })
                    .ToArray();
                settings.HaveUpdatedKeyBindings = true;
                settings.Save();
            }

            return ret.HasValue && ret.Value;
        }
コード例 #11
0
ファイル: KeyBindingService.cs プロジェクト: rschatz/VsVim
 internal void ResetConflictingKeyBindingState()
 {
     ConflictingKeyBindingState = ConflictingKeyBindingState.HasNotChecked;
     _snapshot = null;
 }
コード例 #12
0
ファイル: KeyBindingService.cs プロジェクト: rschatz/VsVim
 internal void IgnoreAnyConflicts()
 {
     ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved;
     _snapshot = null;
 }
コード例 #13
0
ファイル: OptionsDialogService.cs プロジェクト: renjiec/VsVim
 public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot)
 {
     return(new ConflictingKeyBindingDialog(snapshot, _vimApplicationSettings).ShowDialog().Value);
 }
コード例 #14
0
 internal void ResetConflictingKeyBindingState()
 {
     ConflictingKeyBindingState = ConflictingKeyBindingState.HasNotChecked;
     _snapshot = null;
 }
コード例 #15
0
 internal void IgnoreAnyConflicts()
 {
     ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved;
     _snapshot = null;
 }
コード例 #16
0
ファイル: KeyBindingService.cs プロジェクト: rschatz/VsVim
 internal void UpdateConflictingState(ConflictingKeyBindingState state, CommandKeyBindingSnapshot snapshot)
 {
     _snapshot = snapshot;
     ConflictingKeyBindingState = state;
 }
コード例 #17
0
 public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot)
 {
     return(new UI.ConflictingKeyBindingDialog(snapshot, _legacySettings).ShowDialog().Value);
 }
コード例 #18
0
ファイル: OptionsDialogService.cs プロジェクト: rride/VsVim
 public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot)
 {
     return new UI.ConflictingKeyBindingDialog(snapshot).ShowDialog().Value;
 }
コード例 #19
0
ファイル: KeyBindingService.cs プロジェクト: ketiko/VsVim
        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;
        }
コード例 #20
0
ファイル: KeyBindingService.cs プロジェクト: praveennet/VsVim
        public void RunConflictingKeyBindingStateCheck(IEnumerable<KeyInput> neededInputs, Action<ConflictingKeyBindingState, CommandKeyBindingSnapshot> onComplete)
        {
            if (_snapshot != null)
            {
                onComplete(_state, _snapshot);
                return;
            }

            var util = new KeyBindingUtil(_dte);
            var set = new HashSet<KeyInput>(neededInputs);
            _snapshot = util.CreateCommandKeyBindingSnapshot(set);
            if (_snapshot.Conflicting.Any())
            {
                ConflictingKeyBindingState = ConflictingKeyBindingState.FoundConflicts;
            }
            else
            {
                ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved;
            }
        }
コード例 #21
0
ファイル: KeyBindingService.cs プロジェクト: rschatz/VsVim
        internal void ResolveAnyConflicts()
        {
            if (_snapshot == null || _state != ConflictingKeyBindingState.FoundConflicts)
            {
                return;
            }

            if (_optionsDialogService.ShowConflictingKeyBindingsDialog(_snapshot))
            {
                ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved;
                _snapshot = null;
            }
        }
コード例 #22
0
 public void ResolveAnyConflicts4()
 {
     Create("::ctrl+h");
     var snapshot = new CommandKeyBindingSnapshot(
         new CommandsSnapshot(_dte.Object),
         Enumerable.Empty<CommandKeyBinding>(),
         Enumerable.Empty<CommandKeyBinding>());
     _serviceRaw.UpdateConflictingState(ConflictingKeyBindingState.FoundConflicts, snapshot);
     _optionsDialogService.Setup(x => x.ShowConflictingKeyBindingsDialog(snapshot)).Returns(false).Verifiable();
     _serviceRaw.ResolveAnyConflicts();
     Assert.Equal(ConflictingKeyBindingState.FoundConflicts, _service.ConflictingKeyBindingState);
 }
コード例 #23
0
ファイル: KeyBindingService.cs プロジェクト: rschatz/VsVim
        internal void RunConflictingKeyBindingStateCheck(IEnumerable<KeyInput> neededInputs, Action<ConflictingKeyBindingState, CommandKeyBindingSnapshot> onComplete)
        {
            if (_snapshot != null)
            {
                onComplete(_state, _snapshot);
                return;
            }

            var util = new KeyBindingUtil(_dte, GetOrCreateImportantScopeSet());
            var set = new HashSet<KeyInput>(neededInputs);
            _snapshot = util.CreateCommandKeyBindingSnapshot(set);
            ConflictingKeyBindingState = _snapshot.Conflicting.Any()
                ? ConflictingKeyBindingState.FoundConflicts
                : ConflictingKeyBindingState.ConflictsIgnoredOrResolved;
        }
コード例 #24
0
 internal void UpdateConflictingState(ConflictingKeyBindingState state, CommandKeyBindingSnapshot snapshot)
 {
     _snapshot = snapshot;
     ConflictingKeyBindingState = state;
 }
コード例 #25
0
 public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot)
 {
     return new ConflictingKeyBindingDialog(snapshot, _legacySettings).ShowDialog().Value;
 }
コード例 #26
0
 public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot)
 {
     return new ConflictingKeyBindingDialog(snapshot, _vimApplicationSettings, _protectedOperations).ShowDialog().Value;
 }