private void Create(KeyRemapMode countKeyRemapMode, params string[] lines) { _textView = CreateTextView(lines); _vimTextBuffer = Vim.CreateVimTextBuffer(_textView.TextBuffer); _registerMap = Vim.RegisterMap; var vimBufferData = CreateVimBufferData( _vimTextBuffer, _textView); _commandUtil = CreateCommandUtil(vimBufferData); var incrementalSearch = new IncrementalSearch( vimBufferData, CommonOperationsFactory.GetCommonOperations(vimBufferData)); var motionCapture = new MotionCapture(vimBufferData, incrementalSearch); _runnerRaw = new CommandRunner( _textView, _registerMap, motionCapture, vimBufferData.LocalSettings, _commandUtil, new StatusUtil(), VisualKind.Character, countKeyRemapMode); _runner = _runnerRaw; }
protected void AssertMapping(KeyInputSet lhs, string expected, KeyRemapMode mode = null) { mode = mode ?? KeyRemapMode.Normal; var ret = _map.GetKeyMappingResult(lhs, mode); Assert.True(ret.IsMapped); Assert.Equal(KeyInputSetUtil.OfString(expected), ret.GetMappedKeyInputs()); }
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()); }
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)); }
public void DefaultWithBang() { var modes = new KeyRemapMode[] { KeyRemapMode.Insert, KeyRemapMode.Command }; AssertMap("noremap! l h", "l", "h", modes); AssertMap("nore! l h", "l", "h", modes); AssertMap("no! l h", "l", "h", modes); }
public void Default() { var modes = new KeyRemapMode[] { KeyRemapMode.Normal, KeyRemapMode.Visual, KeyRemapMode.Select, KeyRemapMode.OperatorPending }; AssertMap("noremap l h", "l", "h", modes); AssertMap("nore l h", "l", "h", modes); AssertMap("no l h", "l", "h", modes); }
protected void AssertPartialMapping(KeyInputSet lhs, string expectedMapped, string expectedRemaining, KeyRemapMode mode = null) { mode = mode ?? KeyRemapMode.Normal; var ret = _map.GetKeyMappingResult(lhs, mode); Assert.True(ret.IsPartiallyMapped); var partiallyMapped = ret.AsPartiallyMapped(); Assert.Equal(KeyInputSetUtil.OfString(expectedMapped), partiallyMapped.Item1); Assert.Equal(KeyInputSetUtil.OfString(expectedRemaining), partiallyMapped.Item2); }
protected void AssertNoMapping(KeyInputSet lhs, KeyRemapMode mode = null) { Assert.False(_map.GetKeyMappingsForMode(mode).Any(keyMapping => keyMapping.Left == lhs)); mode = mode ?? KeyRemapMode.Normal; var result = _map.GetKeyMappingResult(lhs, mode); if (lhs.Length == 1) { Assert.True(result.IsMapped); } else { Assert.True(result.IsPartiallyMapped); Assert.Equal(lhs.FirstKeyInput.Value, result.AsPartiallyMapped().Item1.FirstKeyInput.Value); Assert.Equal(1, result.AsPartiallyMapped().Item1.Length); } Assert.Equal(lhs, result.GetMappedKeyInputs()); }
protected void AssertNoMapping(KeyInputSet lhs, KeyRemapMode mode = null) { mode = mode ?? KeyRemapMode.Normal; Assert.DoesNotContain(_map.GetKeyMappings(mode), keyMapping => keyMapping.Left == lhs); var result = _map.Map(lhs, mode); if (lhs.Length == 1) { Assert.True(result.IsMapped || result.IsUnmapped); } else { Assert.True(result.IsPartiallyMapped); Assert.Equal(lhs.FirstKeyInput.Value, result.AsPartiallyMapped().MappedKeyInputSet.FirstKeyInput.Value); Assert.Equal(1, result.AsPartiallyMapped().MappedKeyInputSet.Length); } Assert.Equal(lhs, result.GetMappedKeyInputs()); }
/// <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); } }
protected void AssertNoMapping(string lhs, KeyRemapMode mode = null) { AssertNoMapping(KeyNotationUtil.StringToKeyInputSet(lhs), mode); }
public static KeyMappingResult GetKeyMappingResult(this IKeyMap keyMap, string str, KeyRemapMode mode) { return(keyMap.GetKeyMapping(KeyNotationUtil.StringToKeyInputSet(str), mode)); }
public static KeyMappingResult GetKeyMappingResult(this IKeyMap keyMap, char c, KeyRemapMode mode) { return(GetKeyMappingResult(keyMap, KeyInputUtil.CharToKeyInput(c), mode)); }
public static KeyMappingResult GetKeyMappingResult(this IKeyMap keyMap, KeyInputSet set, KeyRemapMode mode) { return(keyMap.GetKeyMapping(set, mode)); }
public static KeyMappingResult GetKeyMappingResult(this IKeyMap keyMap, KeyInput ki, KeyRemapMode mode) { return(GetKeyMappingResult(keyMap, KeyInputSet.NewOneKeyInput(ki), mode)); }
public static IEnumerable <KeyInput> GetKeyMapping(this IKeyMap keyMap, KeyInputSet kiSet, KeyRemapMode mode) { return(keyMap.GetKeyMapping(kiSet, mode).AsMapped().Item.KeyInputs); }
public static IEnumerable <KeyInput> GetKeyMapping(this IKeyMap keyMap, KeyInput ki, KeyRemapMode mode) { return(GetKeyMapping(keyMap, KeyInputSet.NewOneKeyInput(ki), mode)); }
protected void AssertPartialMapping(string lhs, string expectedMapped, string expectedRemaining, KeyRemapMode mode = null) { AssertPartialMapping(KeyInputSetUtil.OfString(lhs), expectedMapped, expectedRemaining, mode); }
public static IEnumerable<KeyInput> GetKeyMapping(this IKeyMap keyMap, KeyInput ki, KeyRemapMode mode) { var set = KeyInputSet.NewOneKeyInput(ki); return keyMap.GetKeyMapping(set, mode).AsMapped().Item.KeyInputs; }
public void Remap_noremap() { Create(""); var modes = new KeyRemapMode[] { KeyRemapMode.Normal, KeyRemapMode.Visual, KeyRemapMode.Select, KeyRemapMode.OperatorPending }; TestNoRemap("noremap l h", "l", "h", modes); TestNoRemap("nore l h", "l", "h", modes); TestNoRemap("no l h", "l", "h", modes); }
protected void AssertMapping(string lhs, string expected, KeyRemapMode mode = null) { AssertMapping(KeyNotationUtil.StringToKeyInputSet(lhs), expected, mode); }
/// <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) { 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) { // No mapping. Use the original mapped = original; return true; } // Shouldn't get here because all cases of KeyMappingResult should be // handled abvoe Contract.Assert(false); mapped = null; return false; }
internal static BindData <T> CreateBindData <T>(Func <KeyInput, BindResult <T> > func = null, KeyRemapMode remapMode = null) { func = func ?? (x => BindResult <T> .Cancelled); return(new BindData <T>(FSharpOption.CreateForReference(remapMode), func.ToFSharpFunc())); }
public void Remap_noremap2() { Create(""); var modes = new KeyRemapMode[] { KeyRemapMode.Insert, KeyRemapMode.Command }; TestNoRemap("noremap! l h", "l", "h", modes); TestNoRemap("nore! l h", "l", "h", modes); TestNoRemap("no! l h", "l", "h", modes); }
public static IEnumerable <KeyInput> GetKeyMapping(this IKeyMap keyMap, char c, KeyRemapMode mode) { return(GetKeyMapping(keyMap, KeyInputUtil.CharToKeyInput(c), mode)); }
public static KeyMappingResult GetKeyMappingResult(this IKeyMap keyMap, KeyInput ki, KeyRemapMode mode) { var set = KeyInputSet.NewOneKeyInput(ki); return keyMap.GetKeyMapping(set, mode); }
public static IEnumerable <KeyInput> GetKeyMapping(this IKeyMap keyMap, string str, KeyRemapMode mode) { return(GetKeyMapping(keyMap, KeyNotationUtil.StringToKeyInputSet(str), mode)); }
/// <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; } }
internal static BindData <T> CreateBindData <T>(Func <KeyInput, BindResult <T> > func = null, KeyRemapMode remapMode = null) { func = func ?? (x => BindResult <T> .Cancelled); remapMode = remapMode ?? KeyRemapMode.None; return(new BindData <T>(remapMode, func.ToFSharpFunc())); }