コード例 #1
0
ファイル: SCI.cs プロジェクト: ChrisJamesSadler/Kernel
        public new void Main()
        {
            AddCommand("clear", CMD_Clear, "Clears the display");
            AddCommand("help", CMD_Help, "List all commands");
            AddCommand("halt", CMD_Shutdown, "Power down the computer");
            AddCommand("reboot", CMD_Reboot, "Restart the computer");
            AddCommand("ps", CMD_ListProcesses, "List the running processes");
            AddCommand("lshw", CMD_ListHardware, "List the installed hardware");
            AddCommand("lsmod", CMD_ListDrivers, "List all running drivers");
            AddCommand("echo", CMD_Echo, "Echo the user input");
            AddCommand("gui", CMD_GUI, "Start the graphical interface");
            stream = new AudioStream(400);
            for (int i = 0; i < 1; i++)
            {
                stream.AddSample(207, 400);
                stream.AddSample(277, 300);
                stream.AddSample(329, 200);
                Thread.Sleep(500);
            }
            while (true)
            {
                Console.Write("CMD>>");
                content = Console.ReadLine();

                int length = 0;
                var ptr    = content;
                while (*ptr != 0)
                {
                    ptr++;
                    length++;
                }

                bool found = false;
                foreach (var cmd in Commands)
                {
                    if (Utils.Compare(content, cmd.trigger))
                    {
                        found = true;
                        cmd.Invoke(content);
                    }
                }
                if (!found)
                {
                    foreach (var cmd in Commands)
                    {
                        if (Utils.StartsWith(content, cmd.trigger))
                        {
                            found = true;
                            cmd.Invoke(content);
                        }
                    }
                }
                if (!found && length > 0)
                {
                    Console.Write("Unknown Command ");
                    Console.WriteLine(content);
                }

                Heap.free(content);
                if (Console.X != 0)
                {
                    Console.NewLine();
                }
            }
        }