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)); }
internal static CommandBinding CreateNormalBinding( string name = "default", CommandFlags flags = CommandFlags.None, NormalCommand command = null) { command = command ?? NormalCommand.NewPutAfterCaret(false); return(CommandBinding.NewNormalBinding(KeyNotationUtil.StringToKeyInputSet(name), flags, command)); }
internal static Command CreateNormalCommand( NormalCommand command = null, CommandData commandData = null) { command = command ?? NormalCommand.NewPutAfterCaret(false); commandData = commandData ?? new CommandData(FSharpOption <int> .None, FSharpOption <RegisterName> .None); return(Command.NewNormalCommand(command, commandData)); }
internal static CommandBinding CreateComplexNormalBinding( string name, Action <KeyInput> action, CommandFlags flags = CommandFlags.None) { Func <KeyInput, BindResult <NormalCommand> > func = keyInput => { action(keyInput); return(BindResult <NormalCommand> .NewComplete(NormalCommand.NewPutAfterCaret(false))); }; var bindData = new BindData <NormalCommand>( FSharpOption <KeyRemapMode> .None, func.ToFSharpFunc()); var bindDataStorage = BindDataStorage <NormalCommand> .NewSimple(bindData); return(CommandBinding.NewComplexNormalBinding( KeyNotationUtil.StringToKeyInputSet(name), flags, bindDataStorage)); }