/// <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(KeyInput original, out KeyInput mapped) { var result = _vimBuffer.GetKeyInputMapping(original); if (result.IsNeedsMoreInput || result.IsRecursive || result.IsPartiallyMapped) { // No single mapping mapped = null; return(false); } if (result.IsMapped) { var set = ((KeyMappingResult.Mapped)result).Item; if (!set.IsOneKeyInput) { mapped = null; return(false); } mapped = set.FirstKeyInput.Value; return(true); } // Shouldn't get here because all cases of KeyMappingResult should be // handled above Contract.Assert(false); mapped = null; return(false); }
internal bool TryProcess(VimKey vimKey, int clickCount = 1) { var keyInput = KeyInputUtil.ApplyKeyModifiersToKey(vimKey, _keyboardDevice.KeyModifiers); keyInput = KeyInputUtil.ApplyClickCount(keyInput, clickCount); // If the user has explicitly set the mouse to be <nop> then we don't want to report this as // handled. Otherwise it will swallow the mouse event and as a consequence disable other // features that begin with a mouse click. // // There is really no other way for the user to opt out of mouse behavior besides mapping the // key to <nop> otherwise that would be done here. var keyInputSet = _vimBuffer.GetKeyInputMapping(keyInput).KeyInputSet; if (keyInputSet.Length > 0 && keyInputSet.KeyInputs[0].Key == VimKey.Nop) { return(false); } if (_vimBuffer.CanProcess(keyInput)) { return(_vimBuffer.Process(keyInput).IsAnyHandled); } return(false); }
/// <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(KeyInput original, out KeyInput mapped) { var result = _buffer.GetKeyInputMapping(original); if (result.IsNeedsMoreInput || result.IsRecursive) { // No single mapping mapped = null; return(false); } if (result.IsMapped) { var set = ((KeyMappingResult.Mapped)result).Item; if (!set.IsOneKeyInput) { mapped = null; return(false); } mapped = set.FirstKeyInput.Value; return(true); } if (result.IsNoMapping) { // If there is no mapping we still need to consider the case of buffered // KeyInput values. If there are any buffered KeyInput values then we // have > 1 input values: the current and whatever is mapped if (!_buffer.BufferedRemapKeyInputs.IsEmpty) { mapped = null; return(false); } // No mapping and no buffered input so it's just a simple normal KeyInput // value to be processed mapped = original; return(true); } // Shouldn't get here because all cases of KeyMappingResult should be // handled above Contract.Assert(false); mapped = null; return(false); }