diff --git a/source/Cosmos/Cosmos.Kernel/TextScreen.cs b/source/Cosmos/Cosmos.Kernel/TextScreen.cs
index 772ac35ca..31c83bb7c 100644
--- a/source/Cosmos/Cosmos.Kernel/TextScreen.cs
+++ b/source/Cosmos/Cosmos.Kernel/TextScreen.cs
@@ -30,6 +30,8 @@ namespace Cosmos.Kernel {
public static void Clear() {
HW.Text.Clear();
+ CurrentChar = 0;
+ CurrentLine = 0;
}
public static void WriteChar(char aChar) {
diff --git a/source/Cosmos/Cosmos.Shell.Console/Commands/BaseCommand.cs b/source/Cosmos/Cosmos.Shell.Console/Commands/BaseCommand.cs
index 040ec3399..bfe2db751 100644
--- a/source/Cosmos/Cosmos.Shell.Console/Commands/BaseCommand.cs
+++ b/source/Cosmos/Cosmos.Shell.Console/Commands/BaseCommand.cs
@@ -10,10 +10,21 @@ namespace Cosmos.Shell.Console.Commands {
///
/// Gets the name of the command (must be lowercase).
///
- public abstract string Name {
- get;
- }
+ public abstract string Name
+ {
+ get;
+ }
+
+ ///
+ /// Gets the summary for the command.
+ ///
+ public abstract string Summary
+ {
+ get;
+ }
public abstract void Execute(string param);
+
+ public abstract void Help();
}
}
diff --git a/source/Cosmos/Cosmos.Shell.Console/Commands/ClsCommand.cs b/source/Cosmos/Cosmos.Shell.Console/Commands/ClsCommand.cs
new file mode 100644
index 000000000..272206bed
--- /dev/null
+++ b/source/Cosmos/Cosmos.Shell.Console/Commands/ClsCommand.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Cosmos.Shell.Console.Commands
+{
+ public class ClsCommand : CommandBase
+ {
+ public override string Name
+ {
+ get { return "cls"; }
+ }
+
+ public override string Summary
+ {
+ get { return "Clears the screen."; }
+ }
+
+ public override void Execute(string param)
+ {
+ System.Console.Clear();
+ }
+
+ public override void Help()
+ {
+ System.Console.WriteLine("cls");
+ System.Console.WriteLine(" Clears the screen.");
+ }
+ }
+}
diff --git a/source/Cosmos/Cosmos.Shell.Console/Commands/DirCommand.cs b/source/Cosmos/Cosmos.Shell.Console/Commands/DirCommand.cs
new file mode 100644
index 000000000..e6b6237ea
--- /dev/null
+++ b/source/Cosmos/Cosmos.Shell.Console/Commands/DirCommand.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Cosmos.Shell.Console.Commands
+{
+ public class DirCommand : CommandBase
+ {
+ public override string Name
+ {
+ get { return "dir"; }
+ }
+
+ public override string Summary
+ {
+ get { return "Lists the files in the current directory."; }
+ }
+
+ public override void Execute(string param)
+ {
+ Hardware.Storage.ATA xDrive = new Cosmos.Hardware.Storage.ATA(0, 0);
+ Cosmos.Kernel.FileSystem.Ext2 xExt2 = new Cosmos.Kernel.FileSystem.Ext2 (xDrive);
+ xExt2.Initialize();
+
+ string[] files = xExt2.GetDirectoryEntries(new string[0]);
+ for (int i = 0; i < files.Length; i++)
+ System.Console.WriteLine(files[i]);
+ }
+
+ public override void Help()
+ {
+ System.Console.WriteLine("dir");
+ System.Console.WriteLine(" Lists the files in the current directory.");
+ }
+ }
+}
diff --git a/source/Cosmos/Cosmos.Shell.Console/Commands/EchoCommand.cs b/source/Cosmos/Cosmos.Shell.Console/Commands/EchoCommand.cs
new file mode 100644
index 000000000..45daa15da
--- /dev/null
+++ b/source/Cosmos/Cosmos.Shell.Console/Commands/EchoCommand.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Cosmos.Shell.Console.Commands
+{
+ public class EchoCommand : CommandBase
+ {
+ public override string Name
+ {
+ get { return "echo"; }
+ }
+
+ public override string Summary
+ {
+ get { return "Duplicates text you enter to the console."; }
+ }
+
+ public override void Execute(string param)
+ {
+ System.Console.WriteLine(param);
+ System.Console.WriteLine();
+ }
+
+ public override void Help()
+ {
+ System.Console.WriteLine("echo [text]");
+ System.Console.WriteLine(" Duplicates text you enter to the console.");
+ System.Console.WriteLine(" [text]: The text to duplicate.");
+ }
+ }
+}
diff --git a/source/Cosmos/Cosmos.Shell.Console/Commands/ExitCommand.cs b/source/Cosmos/Cosmos.Shell.Console/Commands/ExitCommand.cs
new file mode 100644
index 000000000..3f9883366
--- /dev/null
+++ b/source/Cosmos/Cosmos.Shell.Console/Commands/ExitCommand.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Cosmos.Shell.Console.Commands
+{
+ public class ExitCommand : CommandBase
+ {
+ public override string Name
+ {
+ get { return "exit"; }
+ }
+
+ public override string Summary
+ {
+ get { return "Closes the console."; }
+ }
+
+ public delegate void SimpleDelegate();
+
+ private SimpleDelegate _exit;
+
+ public ExitCommand(SimpleDelegate exit)
+ {
+ _exit = exit;
+ }
+
+ public override void Execute(string param)
+ {
+ _exit();
+ }
+
+ public override void Help()
+ {
+ System.Console.WriteLine("exit");
+ System.Console.WriteLine(" Closes the console.");
+ }
+ }
+}
diff --git a/source/Cosmos/Cosmos.Shell.Console/Commands/HelpCommand.cs b/source/Cosmos/Cosmos.Shell.Console/Commands/HelpCommand.cs
new file mode 100644
index 000000000..f6732de0a
--- /dev/null
+++ b/source/Cosmos/Cosmos.Shell.Console/Commands/HelpCommand.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Cosmos.Shell.Console.Commands
+{
+ public class HelpCommand : CommandBase
+ {
+ public override string Name
+ {
+ get { return "help"; }
+ }
+
+ public HelpCommand(List commands)
+ {
+ _commands = commands;
+ }
+
+ private List _commands;
+
+ public override void Execute(string param)
+ {
+ if (param.CompareTo("") == 0)
+ DisplayCommands();
+ else
+ CommandHelp(param);
+ }
+
+ private void CommandHelp(string command)
+ {
+ bool found = false;
+ for (int i = 0; i < _commands.Count; i++)
+ {
+ if (_commands[i].Name.CompareTo(command) == 0)
+ {
+ found = true;
+ _commands[i].Help();
+ System.Console.WriteLine();
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ System.Console.ForegroundColor = ConsoleColor.Red;
+ System.Console.Write("The command ");
+ System.Console.Write(command);
+ System.Console.WriteLine(" is not supported. Please type help for more information.");
+ System.Console.ForegroundColor = ConsoleColor.White;
+ System.Console.WriteLine();
+ }
+ }
+
+ private void DisplayCommands()
+ {
+ System.Console.WriteLine("Supported Commands:");
+ for (int i = 0; i < _commands.Count; i++)
+ {
+ System.Console.ForegroundColor = ConsoleColor.Red;
+ System.Console.Write(" ");
+ System.Console.Write(_commands[i].Name);
+ System.Console.Write(": ");
+ System.Console.ForegroundColor = ConsoleColor.White;
+ System.Console.WriteLine(_commands[i].Summary);
+ }
+ System.Console.WriteLine("Please type help [command] for more information.");
+ System.Console.WriteLine();
+
+ }
+
+ public override void Help()
+ {
+ System.Console.WriteLine("help [command]");
+ System.Console.WriteLine(" Gets help on a specific command.");
+ System.Console.WriteLine(" [command]:The command to look up.");
+ }
+
+ public override string Summary
+ {
+ get { return "Gets help on a specific command."; }
+ }
+ }
+}
diff --git a/source/Cosmos/Cosmos.Shell.Console/Commands/TypeCommand.cs b/source/Cosmos/Cosmos.Shell.Console/Commands/TypeCommand.cs
index db9c3eec2..a02463a8a 100644
--- a/source/Cosmos/Cosmos.Shell.Console/Commands/TypeCommand.cs
+++ b/source/Cosmos/Cosmos.Shell.Console/Commands/TypeCommand.cs
@@ -40,5 +40,17 @@ namespace Cosmos.Shell.Console.Commands {
String s = new String(xChars);
System.Console.WriteLine(s);
}
- }
+
+ public override void Help()
+ {
+ System.Console.WriteLine("type [filename]");
+ System.Console.WriteLine(" Types the specified file out to the console window.");
+ System.Console.WriteLine(" [filename]: The name of the file.");
+ }
+
+ public override string Summary
+ {
+ get { return "Types the specified file out to the console window."; }
+ }
+ }
}
diff --git a/source/Cosmos/Cosmos.Shell.Console/Cosmos.Shell.Console.csproj b/source/Cosmos/Cosmos.Shell.Console/Cosmos.Shell.Console.csproj
index ed37bda72..48a0a8fd8 100644
--- a/source/Cosmos/Cosmos.Shell.Console/Cosmos.Shell.Console.csproj
+++ b/source/Cosmos/Cosmos.Shell.Console/Cosmos.Shell.Console.csproj
@@ -42,6 +42,11 @@
+
+
+
+
+
diff --git a/source/Cosmos/Cosmos.Shell.Console/Prompter.cs b/source/Cosmos/Cosmos.Shell.Console/Prompter.cs
index d7ba326e9..5a825bff5 100644
--- a/source/Cosmos/Cosmos.Shell.Console/Prompter.cs
+++ b/source/Cosmos/Cosmos.Shell.Console/Prompter.cs
@@ -25,7 +25,13 @@ namespace Cosmos.Shell.Console {
public override void Initialize() {
_commands = new List();
+ _commands.Add(new Commands.ClsCommand());
+ _commands.Add(new Commands.DirCommand());
+ _commands.Add(new Commands.EchoCommand());
+ _commands.Add(new Commands.ExitCommand(Stop));
+ _commands.Add(new Commands.HelpCommand(_commands));
_commands.Add(new Commands.TypeCommand());
+
while (running)
{
@@ -45,16 +51,26 @@ namespace Cosmos.Shell.Console {
param = line.Substring(index + 1);
}
+ bool found = false;
for (int i = 0; i < _commands.Count; i++)
{
-
if (_commands[i].Name.CompareTo(command) == 0)
{
+ found = true;
_commands[i].Execute(param);
break;
}
}
-
+
+ if (!found)
+ {
+ System.Console.ForegroundColor = ConsoleColor.Red;
+ System.Console.Write("The command ");
+ System.Console.Write(command);
+ System.Console.WriteLine(" is not supported. Please type help for more information.");
+ System.Console.ForegroundColor = ConsoleColor.White;
+ System.Console.WriteLine();
+ }
}
}