Esempio n. 1
0
        static void CompleteCommand()
        {
            int start = 1;

            if (key_lines[edit_line][start] == '\\' || key_lines[edit_line][start] == '/')
            {
                start++;
            }
            int end = start;

            while (key_lines[edit_line][end] != 0)
            {
                end++;
            }
            string s    = Encoding.ASCII.GetString(key_lines[edit_line], start, end - start);
            var    cmds = Cmd.CompleteCommand(s);
            var    vars = Cvar.CompleteVariable(s);
            int    c    = cmds.Count;
            int    v    = vars.Count;

            if ((c + v) > 1)
            {
                if (c > 0)
                {
                    PrintCompletions("\\nCommands:\\n", cmds);
                }
                if (v > 0)
                {
                    PrintCompletions("\\nVariables:\\n", vars);
                }
                return;
            }
            else if (c == 1)
            {
                s = (string)cmds[0];
            }
            else if (v == 1)
            {
                s = (string)vars[0];
            }
            else
            {
                return;
            }
            key_lines[edit_line][1] = (byte)'/';
            byte[] bytes = Lib.StringToBytes(s);
            System.Array.Copy(bytes, 0, key_lines[edit_line], 2, bytes.Length);
            key_linepos = bytes.Length + 2;
            key_lines[edit_line][key_linepos++] = Convert.ToByte(' ');
            key_lines[edit_line][key_linepos]   = 0;
            return;
        }