This commit is contained in:
2026-02-09 23:08:36 +08:00
parent a02aab3b20
commit 350db3140d
6 changed files with 96 additions and 2 deletions

View File

@@ -1 +1 @@
a7bf977
a02aab3

View File

@@ -381,7 +381,6 @@ namespace CMLeonOS
// Console.WriteLine($"Error creating MBR and partition table: {exe.Message}");
// }
// Console.WriteLine("Done.");
}
}

View File

@@ -52,6 +52,9 @@ namespace CMLeonOS.shell
case "nano":
shell.NanoFile(args);
break;
case "matrix":
shell.ShowMatrix();
break;
case "diff":
shell.DiffFiles(args);
break;

View File

@@ -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 = "<filename>",

View File

@@ -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();
}
}
}

View File

@@ -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);