Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 internal static BindDataStorage <T> CreateBindDataStorage <T>(BindData <T> bindData = null)
 {
     bindData = bindData ?? CreateBindData <T>();
     return(BindDataStorage <T> .NewSimple(bindData));
 }