sunnycase hace 6 años
padre
commit
ad17da81f7

+ 64 - 11
src/Chino.Kernel/Program.cs

@@ -8,17 +8,70 @@ namespace Chino.Kernel
     {
         static void Main()
         {
-            //var sb = new StringBuilder();
-            //sb.AppendLine("Hello Chino OS!");
-            //sb.AppendLine("Baka xiahuan!");
-
-            //Action action = () => Debug.WriteLine(sb.ToString());
-            //action();
-            //Debug.WriteLine(sb.ToString());
-            //byte i = 225;
-            Debug.WriteLine("Hello Chino OS!");
-            Debug.WriteLine("Used: " + Memory.MemoryManager.GetUsedMemorySize() + " Bytes");
-            Debug.WriteLine("Free: " + Memory.MemoryManager.GetFreeMemorySize() + " Bytes");
+            var terminal = new Terminal();
+
+            terminal.Foreground(TerminalColor.White)
+                .WriteLine("Hello Chino OS!");
+
+            terminal.Foreground(TerminalColor.White)
+                .Write("Used: ").Foreground(TerminalColor.Green).Write(Memory.MemoryManager.GetUsedMemorySize().ToString())
+                .Foreground(TerminalColor.White).WriteLine(" Bytes");
+            terminal.Foreground(TerminalColor.White)
+                .Write("Free: ").Foreground(TerminalColor.Green).Write(Memory.MemoryManager.GetFreeMemorySize().ToString())
+                .Foreground(TerminalColor.White).WriteLine(" Bytes");
+            terminal.WriteLine(string.Empty).Reset();
+
+            terminal.Ready();
+        }
+    }
+
+    enum TerminalColor
+    {
+        Black,
+        Red,
+        Green,
+        White
+    }
+
+    class Terminal
+    {
+        public Terminal Write(string message)
+        {
+            Debug.Write(message);
+            return this;
+        }
+
+        public Terminal WriteLine(string message)
+        {
+            Debug.WriteLine(message);
+            return this;
+        }
+
+        public Terminal Reset()
+        {
+            Debug.Write("\u001b[0m");
+            return this;
+        }
+
+        public Terminal Foreground(TerminalColor color)
+        {
+            string seq = color switch
+            {
+                TerminalColor.Black => "\u001b[30m",
+                TerminalColor.Red => "\u001b[31m",
+                TerminalColor.Green => "\u001b[32m",
+                TerminalColor.White => "\u001b[37m",
+                _ => string.Empty
+            };
+
+            Debug.Write(seq);
+            return this;
+        }
+
+        public Terminal Ready()
+        {
+            Debug.Write("$ ");
+            return this;
         }
     }
 }

+ 3 - 0
src/Native/main.cpp

@@ -6,6 +6,9 @@ void InitializeHeap() noexcept;
 
 int main()
 {
+#ifdef WIN32
+    system(" ");
+#endif
     InitializeHeap();
     Program::_s_Main();
     return 0;

+ 7 - 7
src/Natsu.Compiler/Program.cs

@@ -15,13 +15,13 @@ namespace Natsu.Compiler
         private static readonly string[] _modulePaths = new[]
         {
             @"..\..\..\..\..\out\bin\netcoreapp3.0\Chino.Kernel.dll",
-            @"..\..\..\..\..\out\bin\netcoreapp3.0\Chino.Core.dll",
-            @"..\..\..\..\..\out\bin\netcoreapp3.0\Chino.Chip.K210.dll",
-            @"..\..\..\..\..\out\bin\netcoreapp3.0\System.Private.CorLib.dll",
-            @"..\..\..\..\..\out\bin\netcoreapp3.0\System.Runtime.dll",
-            @"..\..\..\..\..\out\bin\netcoreapp3.0\System.Diagnostics.Debug.dll",
-            @"..\..\..\..\..\out\bin\netcoreapp3.0\System.Runtime.InteropServices.dll",
-            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @".nuget\packages\bitfields\0.1.0\lib\netstandard1.0\BitFields.dll")
+            //@"..\..\..\..\..\out\bin\netcoreapp3.0\Chino.Core.dll",
+            //@"..\..\..\..\..\out\bin\netcoreapp3.0\Chino.Chip.K210.dll",
+            //@"..\..\..\..\..\out\bin\netcoreapp3.0\System.Private.CorLib.dll",
+            //@"..\..\..\..\..\out\bin\netcoreapp3.0\System.Runtime.dll",
+            //@"..\..\..\..\..\out\bin\netcoreapp3.0\System.Diagnostics.Debug.dll",
+            //@"..\..\..\..\..\out\bin\netcoreapp3.0\System.Runtime.InteropServices.dll",
+            //Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @".nuget\packages\bitfields\0.1.0\lib\netstandard1.0\BitFields.dll")
         };
 
         static void Main(string[] args)

+ 1 - 1
src/System.Private.CorLib/System/String.cs

@@ -26,7 +26,7 @@ namespace System
         // We need to call the String constructor so that the compiler doesn't mark this as a literal.
         // Marking this as a literal would mean that it doesn't show up as a field which we can access 
         // from native.
-        public static readonly string Empty;
+        public static readonly string Empty = "";
 
         // Gets the character at a specified position.
         //