예제 #1
0
        private void DoAutoComplete()
        {
            String token = CommandBufferText();

            if (token.Length > 0)
            {
                suggestedCommands.Clear();
                commands.GetSuggested(token, suggestedCommands);

                if (suggestedCommands.Count == 1)
                {
                    CCommand command = suggestedCommands.First.Value;
                    SetCommandText('\\' + command.name, true);
                }
                else if (suggestedCommands.Count > 1)
                {
                    String suggestedText = GetSuggestedText(token, suggestedCommands);
                    SetCommandText('\\' + suggestedText, false);

                    Print(PROMPT_CMD_STRING + suggestedText);
                    foreach (CCommand cmd in suggestedCommands)
                    {
                        PrintIndent(cmd.name);
                    }
                }
            }
        }
예제 #2
0
        public bool UnregisterCommand(CCommand command)
        {
            LinkedList <CCommand> list = FindList(command);

            for (LinkedListNode <CCommand> node = list.First; node != null; node = node.Next)
            {
                if (command == node.Value)
                {
                    list.Remove(node);
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        private void TryExecuteCommand(String commandString, bool manual)
        {
            List <String> args = extractArgs(commandString);

            if (args.Count > 0)
            {
                String name = args[0];

                CCommand command = commands.FindCommand(name);
                if (command != null)
                {
                    command.console = this;
                    command.args    = args;
                    command.manual  = manual;

                    if (manual)
                    {
                        Print(PROMPT_CMD_STRING + commandString);
                    }

                    if (args.Count > 1)
                    {
                        command.Execute();
                    }
                    else
                    {
                        command.Execute();
                    }
                }
                else
                {
                    Append("Unknown command: '" + name + "'");
                }

                if (manual)
                {
                    PushHistory(commandString);
                }
            }
        }
예제 #4
0
        private bool AddCommand(LinkedList <CCommand> commandList, CCommand command)
        {
            String name = command.name;

            for (LinkedListNode <CCommand> node = commandList.First; node != null; node = node.Next)
            {
                CCommand other = node.Value;
                if (command == other)
                {
                    return(false); // no duplicates
                }

                String otherName = other.name;
                if (name.CompareTo(otherName) < 0)
                {
                    commandList.AddBefore(node, command);
                    return(true);
                }
            }

            commandList.AddLast(command);
            return(true);
        }
 public bool UnregisterCommands(CCommand[] commands)
 {
     for (int i = 0; i < commands.Length; ++i)
     {
         UnregisterCommand(commands[i]);
     }
     return true;
 }
 public bool UnregisterCommand(CCommand command)
 {
     return commands.UnregisterCommand(command);
 }
 public bool RegisterCommand(CCommand command)
 {
     return commands.RegisterCommand(command);
 }
 private int CompareCommands(CCommand a, CCommand b)
 {
     return a.name.CompareTo(b.name);
 }
예제 #9
0
 private LinkedList <CCommand> FindList(CCommand command)
 {
     return(FindList(command.name));
 }
예제 #10
0
        public bool RegisterCommand(CCommand command)
        {
            LinkedList <CCommand> commandList = FindList(command);

            return(AddCommand(commandList, command));
        }
 private LinkedList<CCommand> FindList(CCommand command)
 {
     return FindList(command.name);
 }
        private bool AddCommand(LinkedList<CCommand> commandList, CCommand command)
        {
            String name = command.name;
            for (LinkedListNode<CCommand> node = commandList.First; node != null; node = node.Next)
            {
                CCommand other = node.Value;
                if (command == other)
                {
                    return false; // no duplicates
                }

                String otherName = other.name;
                if (name.CompareTo(otherName) < 0)
                {
                    commandList.AddBefore(node, command);
                    return true;
                }
            }

            commandList.AddLast(command);
            return true;
        }
        public bool UnregisterCommand(CCommand command)
        {
            LinkedList<CCommand> list = FindList(command);
            for (LinkedListNode<CCommand> node = list.First; node != null; node = node.Next)
            {
                if (command == node.Value)
                {
                    list.Remove(node);
                    return true;
                }
            }

            return false;
        }
 public bool RegisterCommand(CCommand command)
 {
     LinkedList<CCommand> commandList = FindList(command);
     return AddCommand(commandList, command);
 }
예제 #15
0
 public bool RegisterCommand(CCommand command)
 {
     return(commands.RegisterCommand(command));
 }
예제 #16
0
 public bool UnregisterCommand(CCommand command)
 {
     return(commands.UnregisterCommand(command));
 }
예제 #17
0
 private int CompareCommands(CCommand a, CCommand b)
 {
     return(a.name.CompareTo(b.name));
 }