diff --git a/CMLeonOS.csproj b/CMLeonOS.csproj
index 9fbd48c..1f48f88 100644
--- a/CMLeonOS.csproj
+++ b/CMLeonOS.csproj
@@ -27,8 +27,13 @@
true
None
1
+ 800x600x32
+
+
+
+
all
diff --git a/Wallpapers/wallpaper.bmp b/Wallpapers/wallpaper.bmp
new file mode 100644
index 0000000..6458b67
Binary files /dev/null and b/Wallpapers/wallpaper.bmp differ
diff --git a/shell/CommandList.cs b/shell/CommandList.cs
index 0d6dea6..d70dd1d 100644
--- a/shell/CommandList.cs
+++ b/shell/CommandList.cs
@@ -187,6 +187,12 @@ namespace CMLeonOS.shell
case "testgui":
shell.ProcessTestGui();
break;
+ case "alias":
+ shell.ProcessAlias(args);
+ break;
+ case "unalias":
+ shell.ProcessUnalias(args);
+ break;
default:
shell.ShowError($"Unknown command: {command}");
break;
diff --git a/shell/Commands/Help/Help.cs b/shell/Commands/Help/Help.cs
index 00313fa..22af828 100644
--- a/shell/Commands/Help/Help.cs
+++ b/shell/Commands/Help/Help.cs
@@ -66,6 +66,9 @@ namespace CMLeonOS.Commands
" whoami - Show current username",
" base64 encrypt - Encode text to Base64",
" base64 decrypt - Decode Base64 to text",
+ " alias - Create command alias",
+ " alias - List all aliases",
+ " unalias - Remove command alias",
" lua - Execute Lua script",
" version - Show OS version",
" about - Show about information",
diff --git a/shell/Commands/TestGuiCommand.cs b/shell/Commands/TestGuiCommand.cs
index 65f2be9..6fff355 100644
--- a/shell/Commands/TestGuiCommand.cs
+++ b/shell/Commands/TestGuiCommand.cs
@@ -1,43 +1,84 @@
using System;
+using System.Collections.Generic;
+using System.Text;
using Sys = Cosmos.System;
+using System.Drawing;
using Cosmos.System.Graphics;
+using Microsoft.VisualBasic;
+using Cosmos.System.Graphics.Fonts;
+using Cosmos.System;
+using Cosmos.HAL;
+using Cosmos.System.FileSystem.VFS;
+using Cosmos.System.FileSystem;
+using System.IO;
namespace CMLeonOS.Commands
{
public static class TestGuiCommand
{
+ public static Canvas Screen;
+ public static Bitmap Wallpaper;
+ public static Mode display;
+
+ public static void DrawCursor()
+ {
+ if ((int)MouseManager.X >= 0 && (int)MouseManager.Y >= 0 && (int)MouseManager.X < Screen.Mode.Width && (int)MouseManager.Y < Screen.Mode.Height)
+ {
+ MouseManager.ScreenWidth = Screen.Mode.Width;
+ MouseManager.ScreenHeight = Screen.Mode.Height;
+ Screen.DrawFilledCircle(Color.FromArgb(75, 255, 255, 255), (int)MouseManager.X, (int)MouseManager.Y, 10);
+ }
+ }
+
+ public static void DrawBackground()
+ {
+ Screen.Clear(Color.Indigo);
+ }
+
public static void RunTestGui()
{
- Canvas canvas;
-
- Console.WriteLine("Cosmos booted successfully. Let's go in Graphical Mode");
-
- canvas = FullScreenCanvas.GetFullScreenCanvas(new Mode(640, 480, ColorDepth.ColorDepth32));
-
- canvas.Clear(global::System.Drawing.Color.FromArgb(0, 0, 255));
-
try
{
- canvas.DrawPoint(global::System.Drawing.Color.FromArgb(255, 0, 0), 69, 69);
+ display = new Mode(1024, 768, ColorDepth.ColorDepth24);
+ Screen = FullScreenCanvas.GetFullScreenCanvas(display);
- canvas.DrawLine(global::System.Drawing.Color.FromArgb(173, 255, 47), 250, 100, 400, 100);
+ try
+ {
+ if (File.Exists(@"0:\system\wallpaper.bmp"))
+ {
+ Wallpaper = new Bitmap(File.ReadAllBytes(@"0:\system\wallpaper.bmp"));
+ }
+ else
+ {
+ Wallpaper = null;
+ }
+ }
+ catch
+ {
+ Wallpaper = null;
+ }
- canvas.DrawLine(global::System.Drawing.Color.FromArgb(205, 92, 92), 350, 150, 350, 250);
+ global::System.Console.WriteLine("Starting graphical mode...");
+ global::System.Console.WriteLine("Press ESC to return to shell.");
- canvas.DrawLine(global::System.Drawing.Color.FromArgb(245, 245, 220), 250, 150, 400, 250);
+ while (true)
+ {
+ Screen.Clear();
+ DrawBackground();
+ Screen.DrawString(DateTime.Now.ToString("H:mm") + ", Screen:" + Screen.Mode.Width + "x" + Screen.Mode.Height, PCScreenFont.Default, Color.White, 15, 10);
+ DrawCursor();
+ Screen.Display();
- canvas.DrawRectangle(global::System.Drawing.Color.FromArgb(219, 112, 147), 350, 350, 80, 60);
-
- canvas.DrawRectangle(global::System.Drawing.Color.FromArgb(50, 205, 50), 450, 450, 80, 60);
-
- canvas.Display();
-
- Console.WriteLine("Press any key to return to shell...");
- Console.ReadKey(true);
+ var key = global::System.Console.ReadKey(true);
+ if (key.Key == ConsoleKey.Escape)
+ {
+ break;
+ }
+ }
}
catch (Exception e)
{
- Console.WriteLine("Exception occurred: " + e.Message);
+ global::System.Console.WriteLine("Exception occurred: " + e.Message);
}
}
}
diff --git a/shell/Commands/Utility/AliasCommand.cs b/shell/Commands/Utility/AliasCommand.cs
new file mode 100644
index 0000000..2a1e87b
--- /dev/null
+++ b/shell/Commands/Utility/AliasCommand.cs
@@ -0,0 +1,158 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace CMLeonOS.Commands
+{
+ public static class AliasCommand
+ {
+ private static string aliasFilePath = @"0:\system\alias.dat";
+ private static Dictionary aliases = new Dictionary();
+
+ public static void LoadAliases()
+ {
+ aliases.Clear();
+
+ try
+ {
+ if (File.Exists(aliasFilePath))
+ {
+ string[] lines = File.ReadAllLines(aliasFilePath);
+ foreach (string line in lines)
+ {
+ if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#"))
+ {
+ int separatorIndex = line.IndexOf('=');
+ if (separatorIndex > 0)
+ {
+ string name = line.Substring(0, separatorIndex).Trim();
+ string value = line.Substring(separatorIndex + 1).Trim();
+ aliases[name] = value;
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine($"Error loading aliases: {e.Message}");
+ }
+ }
+
+ public static void SaveAliases()
+ {
+ try
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(aliasFilePath));
+
+ using (StreamWriter writer = new StreamWriter(aliasFilePath))
+ {
+ writer.WriteLine("# CMLeonOS Alias Configuration");
+ writer.WriteLine("# Format: alias_name=command");
+ writer.WriteLine();
+
+ var keys = new List(aliases.Keys);
+
+ for (int i = 0; i < keys.Count - 1; i++)
+ {
+ for (int j = i + 1; j < keys.Count; j++)
+ {
+ if (string.Compare(keys[i], keys[j]) > 0)
+ {
+ string temp = keys[i];
+ keys[i] = keys[j];
+ keys[j] = temp;
+ }
+ }
+ }
+
+ foreach (string key in keys)
+ {
+ writer.WriteLine($"{key}={aliases[key]}");
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine($"Error saving aliases: {e.Message}");
+ }
+ }
+
+ public static void AddAlias(string name, string command)
+ {
+ if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(command))
+ {
+ Console.WriteLine("Error: Alias name and command cannot be empty");
+ return;
+ }
+
+ aliases[name] = command;
+ SaveAliases();
+ Console.WriteLine($"Alias '{name}' added successfully");
+ }
+
+ public static void RemoveAlias(string name)
+ {
+ if (aliases.Remove(name))
+ {
+ SaveAliases();
+ Console.WriteLine($"Alias '{name}' removed successfully");
+ }
+ else
+ {
+ Console.WriteLine($"Error: Alias '{name}' not found");
+ }
+ }
+
+ public static void ListAliases()
+ {
+ if (aliases.Count == 0)
+ {
+ Console.WriteLine("No aliases defined");
+ return;
+ }
+
+ Console.WriteLine("Defined aliases:");
+ var keys = new List(aliases.Keys);
+
+ for (int i = 0; i < keys.Count - 1; i++)
+ {
+ for (int j = i + 1; j < keys.Count; j++)
+ {
+ if (string.Compare(keys[i], keys[j]) > 0)
+ {
+ string temp = keys[i];
+ keys[i] = keys[j];
+ keys[j] = temp;
+ }
+ }
+ }
+
+ foreach (string key in keys)
+ {
+ Console.WriteLine($" {key} => {aliases[key]}");
+ }
+ }
+
+ public static string GetAlias(string name)
+ {
+ if (aliases.TryGetValue(name, out string value))
+ {
+ return value;
+ }
+ return null;
+ }
+
+ public static bool AliasExists(string name)
+ {
+ return aliases.ContainsKey(name);
+ }
+
+ public static void ClearAliases()
+ {
+ aliases.Clear();
+ SaveAliases();
+ Console.WriteLine("All aliases cleared");
+ }
+ }
+}
diff --git a/shell/Shell.cs b/shell/Shell.cs
index 5e3924a..26f1a1d 100644
--- a/shell/Shell.cs
+++ b/shell/Shell.cs
@@ -57,6 +57,8 @@ namespace CMLeonOS
fileSystem = new FileSystem();
fixMode = Kernel.FixMode;
envManager = EnvironmentVariableManager.Instance;
+
+ Commands.AliasCommand.LoadAliases();
}
public void Run()
@@ -110,7 +112,28 @@ namespace CMLeonOS
private void ProcessCommand(string command, string args)
{
- shell.CommandList.ProcessCommand(this, command, args);
+ string expandedCommand = command;
+ string expandedArgs = args;
+
+ string aliasValue = Commands.AliasCommand.GetAlias(command);
+ if (aliasValue != null)
+ {
+ var aliasParts = aliasValue.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
+ if (aliasParts.Length > 0)
+ {
+ expandedCommand = aliasParts[0];
+ if (aliasParts.Length > 1)
+ {
+ expandedArgs = aliasParts[1] + (string.IsNullOrEmpty(args) ? "" : " " + args);
+ }
+ else
+ {
+ expandedArgs = args;
+ }
+ }
+ }
+
+ shell.CommandList.ProcessCommand(this, expandedCommand, expandedArgs);
}
public void ProcessEcho(string args)
@@ -1221,6 +1244,84 @@ namespace CMLeonOS
Commands.TestGuiCommand.RunTestGui();
}
+ public void ProcessAlias(string args)
+ {
+ if (string.IsNullOrWhiteSpace(args))
+ {
+ Commands.AliasCommand.ListAliases();
+ }
+ else
+ {
+ string name = "";
+ string command = "";
+
+ int i = 0;
+ while (i < args.Length && char.IsWhiteSpace(args[i]))
+ {
+ i++;
+ }
+
+ int nameStart = i;
+ while (i < args.Length && !char.IsWhiteSpace(args[i]))
+ {
+ i++;
+ }
+ name = args.Substring(nameStart, i - nameStart).Trim();
+
+ while (i < args.Length && char.IsWhiteSpace(args[i]))
+ {
+ i++;
+ }
+
+ if (i < args.Length && (args[i] == '\'' || args[i] == '"'))
+ {
+ char quoteChar = args[i];
+ i++;
+ int commandStart = i;
+ while (i < args.Length && args[i] != quoteChar)
+ {
+ i++;
+ }
+ if (i < args.Length)
+ {
+ command = args.Substring(commandStart, i - commandStart);
+ }
+ else
+ {
+ command = args.Substring(commandStart);
+ }
+ }
+ else
+ {
+ command = args.Substring(i).Trim();
+ }
+
+ if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(command))
+ {
+ ShowError("Usage: alias ");
+ ShowError("Example: alias ll 'ls -l'");
+ ShowError("Example: alias home \"cd /home\"");
+ ShowError("Example: alias cls clear");
+ return;
+ }
+
+ Commands.AliasCommand.AddAlias(name, command);
+ }
+ }
+
+ public void ProcessUnalias(string args)
+ {
+ if (string.IsNullOrWhiteSpace(args))
+ {
+ ShowError("Usage: unalias ");
+ ShowError("Example: unalias ll");
+ return;
+ }
+
+ string name = args.Trim();
+ Commands.AliasCommand.RemoveAlias(name);
+ }
+
public void SetDnsServer(string args)
{
if (string.IsNullOrWhiteSpace(args))