diff --git a/GitCommit.txt b/GitCommit.txt index d0cf643..5ec3745 100644 --- a/GitCommit.txt +++ b/GitCommit.txt @@ -1 +1 @@ -a7bf977 \ No newline at end of file +a02aab3 \ No newline at end of file diff --git a/Kernel.cs b/Kernel.cs index 7581ed0..9691db6 100644 --- a/Kernel.cs +++ b/Kernel.cs @@ -381,7 +381,6 @@ namespace CMLeonOS // Console.WriteLine($"Error creating MBR and partition table: {exe.Message}"); // } // Console.WriteLine("Done."); - } } diff --git a/shell/CommandList.cs b/shell/CommandList.cs index 62a322c..f707506 100644 --- a/shell/CommandList.cs +++ b/shell/CommandList.cs @@ -52,6 +52,9 @@ namespace CMLeonOS.shell case "nano": shell.NanoFile(args); break; + case "matrix": + shell.ShowMatrix(); + break; case "diff": shell.DiffFiles(args); break; diff --git a/shell/Commands/Help/Help.cs b/shell/Commands/Help/Help.cs index aa8e178..78e9e0f 100644 --- a/shell/Commands/Help/Help.cs +++ b/shell/Commands/Help/Help.cs @@ -70,6 +70,12 @@ namespace CMLeonOS.Commands Description = "Simple calculator" }, new CommandInfo + { + Command = "calcgui", + Parameters = "", + Description = "TUI calculator" + }, + new CommandInfo { Command = "history", Parameters = "", @@ -248,6 +254,12 @@ namespace CMLeonOS.Commands Description = "Show system uptime" }, new CommandInfo + { + Command = "matrix", + Parameters = "", + Description = "Show Matrix effect (The Matrix movie)" + }, + new CommandInfo { Command = "branswe", Parameters = "", diff --git a/shell/Commands/Utility/MatrixCommand.cs b/shell/Commands/Utility/MatrixCommand.cs new file mode 100644 index 0000000..b03077c --- /dev/null +++ b/shell/Commands/Utility/MatrixCommand.cs @@ -0,0 +1,75 @@ +using System; +using System.Threading; + +namespace CMLeonOS.Commands.Utility +{ + public static class MatrixCommand + { + private static readonly string[] matrixChars = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "@", "#", "$", "%", "&", "*", "(", ")", "-", "_", "+", "=", "{", "}", "[", "]", "|", "\\", ":", ";", "\"", "'", "<", ">", ",", ".", "?", "/", "~", "`" }; + private static readonly ConsoleColor matrixColor = ConsoleColor.Green; + private static readonly ConsoleColor backgroundColor = ConsoleColor.Black; + private static Random random = new Random(); + private static bool running = true; + + public static void ShowMatrix() + { + Console.Clear(); + Console.BackgroundColor = backgroundColor; + Console.ForegroundColor = matrixColor; + Console.Clear(); + + running = true; + + Console.WriteLine("Press ESC or Q to exit..."); + Thread.Sleep(2000); + + int consoleWidth = 80; + int consoleHeight = 25; + + int[] columns = new int[consoleWidth]; + int[] columnSpeeds = new int[consoleWidth]; + + for (int i = 0; i < consoleWidth; i++) + { + columns[i] = random.Next(consoleHeight / 2); + columnSpeeds[i] = random.Next(1, 2); + } + + while (running) + { + if (Console.KeyAvailable) + { + var key = Console.ReadKey(true); + if (key.Key == ConsoleKey.Escape || key.Key == ConsoleKey.Q) + { + running = false; + break; + } + } + + for (int i = 0; i < consoleWidth; i++) + { + columns[i] += columnSpeeds[i]; + + if (columns[i] >= consoleHeight) + { + columns[i] = random.Next(consoleHeight / 2); + columnSpeeds[i] = random.Next(1, 2); + } + + if (columns[i] > 0 && columns[i] < consoleHeight) + { + int charIndex = random.Next(matrixChars.Length); + Console.SetCursorPosition(i, columns[i]); + Console.Write(matrixChars[charIndex] + " "); + } + } + + Thread.Sleep(100); + } + + Console.Clear(); + Console.ResetColor(); + } + } +} \ No newline at end of file diff --git a/shell/Shell.cs b/shell/Shell.cs index ae821b5..cdfd28f 100644 --- a/shell/Shell.cs +++ b/shell/Shell.cs @@ -566,6 +566,11 @@ namespace CMLeonOS Commands.Utility.CalcGUICommand.ShowCalculator(); } + public void ShowMatrix() + { + Commands.Utility.MatrixCommand.ShowMatrix(); + } + public void ShowHistory() { Commands.Utility.HistoryCommand.ShowHistory(commandHistory);