Exemple #1
0
        public void TestUnbind()
        {
            Execute("bind a test-1");
            Execute("bind b test-2");
            Execute("bind c test-3");

            IList <CBinding> list = CBindings.List();

            AssertList(list,
                       "bind a test-1",
                       "bind b test-2",
                       "bind c test-3"
                       );

            Execute("unbind a");
            list = CBindings.List();
            AssertList(list,
                       "bind b test-2",
                       "bind c test-3"
                       );

            Execute("unbind c");
            list = CBindings.List();
            AssertList(list,
                       "bind b test-2"
                       );

            Execute("unbind b");
            list = CBindings.List();
            AssertList(list);

            Execute("unbind b");
            list = CBindings.List();
            AssertList(list);
        }
Exemple #2
0
        public void TestListBindings()
        {
            Execute("bind mouse0 test-1");
            Execute("bind mouse1 test-2");
            Execute("bind m test-3");

            IList <CBinding> list = CBindings.List("m");

            AssertList(list,
                       "bind mouse0 test-1",
                       "bind mouse1 test-2",
                       "bind m test-3"
                       );

            list = CBindings.List("mo");
            AssertList(list,
                       "bind mouse0 test-1",
                       "bind mouse1 test-2"
                       );

            list = CBindings.List("mouse0");
            AssertList(list,
                       "bind mouse0 test-1"
                       );

            list = CBindings.List("mouse2");
            AssertList(list);

            list = CBindings.List("foo");
            AssertList(list);
        }
Exemple #3
0
        public void TestSingleBindWithInnerArgsAndSingleQuotes()
        {
            Execute("bind t 'test arg1 \"arg2 arg3\" arg4'");

            IList <CBinding> list = CBindings.List();

            AssertList(list, "bind t \"test arg1 \\\"arg2 arg3\\\" arg4\"");
        }
Exemple #4
0
        public void TestSingleBindWithArgSingleQuotes()
        {
            Execute("bind t 'test arg'");

            IList <CBinding> list = CBindings.List();

            AssertList(list, "bind t \"test arg\"");
        }
Exemple #5
0
        public void TestSingleBind()
        {
            Execute("bind t test");

            IList <CBinding> list = CBindings.List();

            AssertList(list, "bind t test");
        }
Exemple #6
0
 void Execute()
 {
     if (CBindings.Count > 0)
     {
         CBindings.Clear();
         PostNotification();
     }
 }
Exemple #7
0
        void Execute(string prefix = null)
        {
            IList <CBinding> bindings = CBindings.List(prefix);

            foreach (CBinding b in bindings)
            {
                PrintIndent("bind {0} {1}", b.shortCut.ToString(), StringUtils.Arg(b.cmdKeyDown));
            }
        }
Exemple #8
0
        protected virtual void Clear(bool deleteConfigs = true)
        {
            CBindings.Clear();
            CRegistery.Clear();

            if (deleteConfigs)
            {
                CConfigHelper.DeleteConfigs();
            }
        }
Exemple #9
0
        //////////////////////////////////////////////////////////////////////////////

        #region Scene key handling

        private bool SceneKeyDownHandler(KeyCode key, CModifiers modifiers)
        {
            CBinding  binding;
            CShortCut shortCut = new CShortCut(key, modifiers);

            if (CBindings.FindBinding(shortCut, out binding))
            {
                return(ExecCommand(binding.cmdKeyDown));
            }

            return(false);
        }
Exemple #10
0
        private static IList <string> ListBindings()
        {
            IList <CBinding> bindings = CBindings.List();

            IList <string> entries = new List <string>(bindings.Count);

            foreach (CBinding binding in bindings)
            {
                entries.Add(string.Format("bind {0} {1}", binding.shortCut.ToString(), StringUtils.Arg(binding.cmdKeyDown)));
            }

            return(entries);
        }
Exemple #11
0
        void Execute(string prefix)
        {
            if (CBindings.Count > 0)
            {
                IList <CBinding> bindings = CBindings.List(prefix);
                if (bindings.Count > 0)
                {
                    foreach (CBinding binding in bindings)
                    {
                        CBindings.Unbind(binding.shortCut);
                    }

                    PostNotification();
                }
            }
        }
Exemple #12
0
        public void TestBindReplaceItem()
        {
            Execute("bind a test-1");
            Execute("bind b test-2");
            Execute("bind c test-3");
            Execute("bind d test-4");

            Execute("bind d test-5");
            Execute("bind a test-6");
            Execute("bind c test-7");
            Execute("bind b test-8");

            IList <CBinding> list = CBindings.List();

            AssertList(list,
                       "bind a test-6",
                       "bind b test-8",
                       "bind c test-7",
                       "bind d test-5"
                       );
        }
Exemple #13
0
        bool Execute(string key)
        {
            string token = key.ToLower();

            CShortCut shortCut;

            if (!CShortCut.TryParse(token, out shortCut))
            {
                PrintError("Invalid shortcut: {0}", token);
                return(false);
            }

            CBindings.Unbind(shortCut); // TODO: unbind 'operation' commands

            PostNotification(
                CCommandNotifications.CBindingsChanged,
                CCommandNotifications.KeyManualMode, this.IsManualMode
                );

            return(true);
        }
Exemple #14
0
 internal static IList <string> AutoCompleteArgs(string token)
 {
     return(CBindings.ListShortCuts(token));
 }
Exemple #15
0
        bool Execute(string stroke, string command = null) // TODO: refactor me!
        {
            string name = stroke.ToLower();

            if (!string.IsNullOrEmpty(command))
            {
                CShortCut shortCut;
                if (!CShortCut.TryParse(stroke, out shortCut))
                {
                    PrintError("Invalid shortcut: {0}", name);
                    return(false);
                }

                string keyUpCommand = null;

                char keyDownOp = command[0];
                if (keyDownOp == '+' || keyDownOp == '-')
                {
                    if (command.Length == 1)
                    {
                        PrintError("Identifier expected!");
                        return(false);
                    }

                    string identifier = command.Substring(1);

                    // register operation command
                    CCommand keyDownCmd = CRegistery.FindCommand(command);
                    if (keyDownCmd == null)
                    {
                        keyDownCmd = new COperationCommand(keyDownOp, identifier);
                        CRegistery.Register(keyDownCmd);
                        keyDownCmd.SetFlag(CCommandFlags.System, true);
                    }

                    // register opposite operation command
                    char keyUpOp = OppositeOperation(keyDownOp);
                    keyUpCommand = keyUpOp + identifier;
                    CCommand keyUpCmd = CRegistery.FindCommand(keyUpCommand);
                    if (keyUpCmd == null)
                    {
                        keyUpCmd = new COperationCommand(keyUpOp, identifier);
                        CRegistery.Register(keyUpCmd);
                        keyUpCmd.SetFlag(CCommandFlags.System, true);
                    }
                }

                CBindings.Bind(shortCut, StringUtils.UnArg(command), keyUpCommand != null ? StringUtils.UnArg(keyUpCommand) : null);

                PostNotification(
                    CCommandNotifications.CBindingsChanged,
                    CCommandNotifications.KeyManualMode, this.IsManualMode
                    );

                return(true);
            }

            IList <CBinding> bindings = CBindings.List(name);

            if (bindings.Count > 0)
            {
                foreach (CBinding b in bindings)
                {
                    PrintIndent(ToString(b));
                }
            }
            else
            {
                PrintIndent("No bindings");
            }

            return(true);
        }