예제 #1
0
파일: Cmd.cs 프로젝트: optimus-code/Q2Sharp
            public override void Execute( )
            {
                cmdalias_t a = null;

                if (Cmd.Argc() == 1)
                {
                    Com.Printf("Current alias commands:\\n");
                    for (a = Globals.cmd_alias; a != null; a = a.next)
                    {
                        Com.Printf(a.name + " : " + a.value);
                    }

                    return;
                }

                var s = Cmd.Argv(1);

                if (s.Length > Defines.MAX_ALIAS_NAME)
                {
                    Com.Printf("Alias name is too long\\n");
                    return;
                }

                for (a = Globals.cmd_alias; a != null; a = a.next)
                {
                    if (s.EqualsIgnoreCase(a.name))
                    {
                        a.value = null;
                        break;
                    }
                }

                if (a == null)
                {
                    a                 = new cmdalias_t();
                    a.next            = Globals.cmd_alias;
                    Globals.cmd_alias = a;
                }

                a.name = s;
                var cmd = "";
                var c   = Cmd.Argc();

                for (var i = 2; i < c; i++)
                {
                    cmd = cmd + Cmd.Argv(i);
                    if (i != (c - 1))
                    {
                        cmd = cmd + " ";
                    }
                }

                cmd     = cmd + "\\n";
                a.value = cmd;
            }
예제 #2
0
파일: Cmd.cs 프로젝트: optimus-code/Q2Sharp
        public static ArrayList CompleteCommand(String partial)
        {
            ArrayList cmds = new ArrayList();

            for (cmd_function_t cmd = cmd_functions; cmd != null; cmd = cmd.next)
            {
                if (cmd.name.StartsWith(partial))
                {
                    cmds.Add(cmd.name);
                }
            }
            for (cmdalias_t a = Globals.cmd_alias; a != null; a = a.next)
            {
                if (a.name.StartsWith(partial))
                {
                    cmds.Add(a.name);
                }
            }
            return(cmds);
        }