Hi,
In my two weeks away, I have added 3 things to SharpOS:
1) GetTimeString(), a function that returns a CString8* containing the time
2) WriteTimeString(), a function that simply writes the time using
TextMode.Write()
3) *Very *rudimentary command recall
I am aware that xfury has beaten me to the punch with the first two, but I
think that they may still be useful.
As for Command Recall, it's very rudimentary, here are a list of the
limitations:
1) It only saves the last ten commands
2) It doesn't save parameters
3) You can only recall upwards
I think that's it. Any suggestions would be welcome.
Signing off...
Liam (baddog144)
Index: ADC/X86/RTC.cs
===================================================================
--- ADC/X86/RTC.cs (revision 818)
+++ ADC/X86/RTC.cs (working copy)
@@ -70,6 +70,35 @@
}
#endregion
+
+ #region GetTimeString and WriteTimeString
+ public static void WriteTimeString()
+ {
+ byte Hours = CMOS.Read(CMOS.Address.Hour);
+ byte Minutes = CMOS.Read(CMOS.Address.Minutes);
+ byte Seconds = CMOS.Read(CMOS.Address.Seconds);
+ SharpOS.Kernel.ADC.TextMode.WriteByte(Hours);
+ SharpOS.Kernel.ADC.TextMode.Write(":");
+ SharpOS.Kernel.ADC.TextMode.WriteByte(Minutes);
+ SharpOS.Kernel.ADC.TextMode.Write(":");
+ SharpOS.Kernel.ADC.TextMode.WriteByte(Seconds);
+ }
+
+ public static Foundation.CString8* GetTimeString()
+ {
+ byte Hours = CMOS.Read(CMOS.Address.Hour);
+ byte Minutes = CMOS.Read(CMOS.Address.Minutes);
+ byte Seconds = CMOS.Read(CMOS.Address.Seconds);
+ Foundation.StringBuilder* sb = Foundation.StringBuilder.CREATE();
+ sb->AppendNumber(Hours, true);
+ sb->Append(":");
+ sb->AppendNumber(Minutes, true);
+ sb->Append(":");
+ sb->AppendNumber(Seconds, true);
+ Foundation.CString8* time = sb->buffer;
+ return time;
+ }
+ #endregion
}
}
Index: Console.cs
===================================================================
--- Console.cs (revision 818)
+++ Console.cs (working copy)
@@ -38,12 +38,228 @@
public const string CONSOLE_KEY_UP_HANDLER = "CONSOLE_KEY_UP_HANDLER";
public const string CONSOLE_KEY_DOWN_HANDLER = "CONSOLE_KEY_DOWN_HANDLER";
public const string CONSOLE_TIMER_HANDLER = "CONSOLE_TIMER_HANDLER";
-
+ public static string typedcommand1;
+ public static string typedcommand2;
+ public static string typedcommand3;
+ public static string typedcommand4;
+ public static string typedcommand5;
+ public static string typedcommand6;
+ public static string typedcommand7;
+ public static string typedcommand8;
+ public static string typedcommand9;
+ public static string typedcommand10;
+ public static int numberOfTypedCommands = 0;
+ public static int numberOfRecalledCommands = 0;
+ private static bool canrecall = true;
private static bool initialized = false;
private static bool overwrite = false;
private static StringBuilder* textBuffer;
+
+ /// <summary>
+ /// This function adds the name of the command that was just typed for recall later(no paramaters yet)
+ /// </summary>
+ /// <param name="name">This represents the name of the command typed</param>
+
+ public static void AddCommandToRecallList(string name)
+ {
+ switch (numberOfTypedCommands)
+ {
+ case 0:
+ typedcommand1 = name;
+ numberOfTypedCommands++;
+ numberOfRecalledCommands = 0;
+ break;
+ case 1:
+ typedcommand2 = name;
+ numberOfTypedCommands++;
+ numberOfRecalledCommands = 0;
+ break;
+ case 2:
+ typedcommand3 = name;
+ numberOfTypedCommands++;
+ numberOfRecalledCommands = 0;
+ break;
+ case 3:
+ typedcommand4 = name;
+ numberOfTypedCommands++;
+ numberOfRecalledCommands = 0;
+ break;
+ case 4:
+ typedcommand5 = name;
+ numberOfRecalledCommands = 0;
+ numberOfTypedCommands++;
+ break;
+ case 5:
+ typedcommand6 = name;
+ numberOfTypedCommands++;
+ numberOfRecalledCommands = 0;
+ break;
+ case 6:
+ typedcommand7 = name;
+ numberOfTypedCommands++;
+ numberOfRecalledCommands = 0;
+ break;
+ case 7:
+ typedcommand8 = name;
+ numberOfTypedCommands++;
+ numberOfRecalledCommands = 0;
+ break;
+ case 8:
+ typedcommand9 = name;
+ numberOfTypedCommands++;
+ numberOfRecalledCommands = 0;
+ break;
+ case 9:
+ typedcommand10 = name;
+ numberOfTypedCommands++;
+ numberOfRecalledCommands = 0;
+ break;
+ case 10:
+ typedcommand1 = name;
+ numberOfTypedCommands = 0;
+ numberOfRecalledCommands = 0;
+ break;
+ }
+ }
+
+ /// <summary>
+ /// This function recalls the commands in sequence
+ /// </summary>
+ public static void recallcommand()
+ {
+ int numberOfTimesToDelete;
+ switch (numberOfRecalledCommands)
+ {
+ case 0:
+ if (typedcommand1 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->RemoveAt(0, textBuffer->Length);
+ textBuffer->Append(typedcommand1);
+ TextMode.Write(typedcommand1);
+ numberOfRecalledCommands++;
+ break;
+ case 1:
+ if (typedcommand2 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->RemoveAt(0, textBuffer->Length);
+ textBuffer->Append(typedcommand2);
+ TextMode.Write(typedcommand2);
+ numberOfRecalledCommands++;
+ break;
+ case 2:
+ if (typedcommand3 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->Append(typedcommand3);
+ TextMode.Write(typedcommand3);
+ numberOfRecalledCommands++;
+ break;
+ case 3:
+ if (typedcommand4 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->Append(typedcommand4);
+ TextMode.Write(typedcommand4);
+ numberOfRecalledCommands++;
+ break;
+ case 4:
+ if (typedcommand5 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->Append(typedcommand5);
+ TextMode.Write(typedcommand5);
+ numberOfRecalledCommands++;
+ break;
+ case 5:
+ if (typedcommand6 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->Append(typedcommand6);
+ TextMode.Write(typedcommand6);
+ numberOfRecalledCommands++;
+ break;
+ case 6:
+ if (typedcommand7 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->Append(typedcommand7);
+ TextMode.Write(typedcommand7);
+ numberOfRecalledCommands++;
+ break;
+ case 7:
+ if (typedcommand8 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->Append(typedcommand8);
+ TextMode.Write(typedcommand8);
+ numberOfRecalledCommands++;
+ break;
+ case 8:
+ if (typedcommand9 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->Append(typedcommand9);
+ TextMode.Write(typedcommand9);
+ numberOfRecalledCommands++;
+ break;
+ case 9:
+ if (typedcommand10 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->Append(typedcommand10);
+ TextMode.Write(typedcommand10);
+ numberOfRecalledCommands++;
+ break;
+ case 10:
+ if (typedcommand1 == null)
+ return;
+ numberOfTimesToDelete = textBuffer->Length;
+ deleterange(numberOfTimesToDelete);
+ textBuffer->Append(typedcommand1);
+ TextMode.Write(typedcommand1);
+ numberOfRecalledCommands = 0;
+ break;
+ }
+ }
+ /// <summary>
+ /// This is pretty much an add-on to recallcommand(), it deletes a number of characters
+ /// </summary>
+ /// <param name="numberoftimes">This defines how many characters to delete</param>
+ private static void deleterange(int numberoftimes)
+ {
+ for (int i = 0; i < numberoftimes; i++)
+ {
+ Console.KeyDown((uint)Keys.Backspace);
+ }
+ }
+ /// <summary>
+ /// This disables recallcommand() for things like snake#
+ /// </summary>
+ public static void disablerecall()
+ {
+ canrecall = false;
+ }
+ /// <summary>
+ /// This enables recallcommand
+ /// </summary>
+ public static void enablerecall()
+ {
+ canrecall = true;
+ }
public static void Setup ()
{
textBuffer = StringBuilder.CREATE ((uint) 80);
@@ -185,7 +401,8 @@
TextMode.MoveTo(x, y);
TextMode.RefreshCursor();
#else
- //TODO: Beep?
+ if (canrecall)
+ recallcommand();
#endif
return;
}
Index: Shell/Commands/BuiltIn/Testcase.cs
===================================================================
--- Shell/Commands/BuiltIn/Testcase.cs (revision 818)
+++ Shell/Commands/BuiltIn/Testcase.cs (working copy)
@@ -114,6 +114,7 @@
}
MemoryManager.Free (source);
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/LS.cs
===================================================================
--- Shell/Commands/BuiltIn/LS.cs (revision 818)
+++ Shell/Commands/BuiltIn/LS.cs (working copy)
@@ -26,6 +26,7 @@
public static void Execute (CommandExecutionContext* context)
{
SharpOS.Kernel.FileSystem.Ext2FS.ListFile ();
+ Console.AddCommandToRecallList(name);
}
public static CommandTableEntry* CREATE ()
Index: Shell/Commands/BuiltIn/Show.cs
===================================================================
--- Shell/Commands/BuiltIn/Show.cs (revision 818)
+++ Shell/Commands/BuiltIn/Show.cs (working copy)
@@ -3,6 +3,7 @@
//
// Authors:
// Jonathan Dickinson <[EMAIL PROTECTED]>
+// Liam Dunn <[EMAIL PROTECTED]
//
// Licensed under the terms of the GNU GPL v3,
// with Classpath Linking Exception for Libraries
@@ -33,6 +34,7 @@
ShowDevelopers ();
else
GetHelp (context);
+ Console.AddCommandToRecallList(name);
}
public static void ShowWarranty ()
Index: Shell/Commands/BuiltIn/Cls.cs
===================================================================
--- Shell/Commands/BuiltIn/Cls.cs (revision 818)
+++ Shell/Commands/BuiltIn/Cls.cs (working copy)
@@ -26,6 +26,7 @@
public static void Execute (CommandExecutionContext* context)
{
ADC.TextMode.ClearScreen ();
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/Version.cs
===================================================================
--- Shell/Commands/BuiltIn/Version.cs (revision 818)
+++ Shell/Commands/BuiltIn/Version.cs (working copy)
@@ -28,6 +28,7 @@
TextMode.WriteLine ("SharpOS v0.0.1");
TextMode.WriteLine ("(C)opyright 2006-2007 SharpOS Development Team");
TextMode.WriteLine ("Licensed under the GNU GPL v3, with Classpath Linking Exception for Libraries");
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/Keymap.cs
===================================================================
--- Shell/Commands/BuiltIn/Keymap.cs (revision 818)
+++ Shell/Commands/BuiltIn/Keymap.cs (working copy)
@@ -58,6 +58,7 @@
} else {
TextMode.WriteLine ("Usage: keymap [--list|--set NAME]");
}
+ Console.AddCommandToRecallList(name);
}
public static void ListKeyMaps ()
Index: Shell/Commands/BuiltIn/Help.cs
===================================================================
--- Shell/Commands/BuiltIn/Help.cs (revision 818)
+++ Shell/Commands/BuiltIn/Help.cs (working copy)
@@ -46,6 +46,7 @@
if (result == CommandExecutionAttemptResult.BlankEntry) {
ADC.MemoryUtil.Call ((void*) Stubs.GetFunctionPointer (lblGetHelp), (void*) context);
}
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/Timezone.cs
===================================================================
--- Shell/Commands/BuiltIn/Timezone.cs (revision 818)
+++ Shell/Commands/BuiltIn/Timezone.cs (working copy)
@@ -40,6 +40,7 @@
TextMode.Write ("Current timezone: ");
TextMode.Write ((int)Clock.Timezone);
TextMode.WriteLine ();
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/Time.cs
===================================================================
--- Shell/Commands/BuiltIn/Time.cs (revision 818)
+++ Shell/Commands/BuiltIn/Time.cs (working copy)
@@ -34,6 +34,7 @@
time->ToString (pstr);
TextMode.WriteLine (pstr);
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/Commands.cs
===================================================================
--- Shell/Commands/BuiltIn/Commands.cs (revision 818)
+++ Shell/Commands/BuiltIn/Commands.cs (working copy)
@@ -26,6 +26,7 @@
public static void Execute (CommandExecutionContext* context)
{
Prompter.DisplayCommandList ();
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/Snake.cs
===================================================================
--- Shell/Commands/BuiltIn/Snake.cs (revision 818)
+++ Shell/Commands/BuiltIn/Snake.cs (working copy)
@@ -404,6 +404,7 @@
//Show the prompt. This and the backspacing above is just a hack to make it integrate more cleanly.
Prompter.WritePrompt ();
+ Console.enablerecall();
}
private static void WriteInfo ()
@@ -1202,6 +1203,8 @@
InitializeMap ();
SetupMap ();
+ Console.AddCommandToRecallList(name);
+ Console.disablerecall();
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/Egg.cs
===================================================================
--- Shell/Commands/BuiltIn/Egg.cs (revision 818)
+++ Shell/Commands/BuiltIn/Egg.cs (working copy)
@@ -41,6 +41,7 @@
TextMode.WriteLine ();
TextMode.WriteLine ("What is the egg?");
TextMode.WriteLine ("The egg has you.");
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/Stage.cs
===================================================================
--- Shell/Commands/BuiltIn/Stage.cs (revision 818)
+++ Shell/Commands/BuiltIn/Stage.cs (working copy)
@@ -60,6 +60,7 @@
TextMode.WriteLine ("(?) unknown");
break;
}
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/MemDump.cs
===================================================================
--- Shell/Commands/BuiltIn/MemDump.cs (revision 818)
+++ Shell/Commands/BuiltIn/MemDump.cs (working copy)
@@ -26,6 +26,7 @@
public static void Execute (CommandExecutionContext* context)
{
ADC.MemoryManager.Dump ();
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/CpuId.cs
===================================================================
--- Shell/Commands/BuiltIn/CpuId.cs (revision 818)
+++ Shell/Commands/BuiltIn/CpuId.cs (working copy)
@@ -95,6 +95,7 @@
TextMode.RestoreAttributes();
}
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/MemView.cs
===================================================================
--- Shell/Commands/BuiltIn/MemView.cs (revision 818)
+++ Shell/Commands/BuiltIn/MemView.cs (working copy)
@@ -65,6 +65,7 @@
}
TextMode.Write(Diagnostics.FormatDump ((byte*)offset, 256, 16));
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
Index: Shell/Commands/BuiltIn/LsPci.cs
===================================================================
--- Shell/Commands/BuiltIn/LsPci.cs (revision 818)
+++ Shell/Commands/BuiltIn/LsPci.cs (working copy)
@@ -62,6 +62,7 @@
MemoryManager.Free ((void*)sb->buffer);
MemoryManager.Free ((void*)sb);
+ Console.AddCommandToRecallList(name);
}
[Label (lblGetHelp)]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
SharpOS-Developers mailing list
SharpOS-Developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sharpos-developers