mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
Compare commits
4 Commits
01476795ff
...
9b783e057a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b783e057a | ||
|
|
14149aab9d | ||
|
|
e0e7da7ac2 | ||
|
|
0386511a00 |
@@ -1 +1 @@
|
|||||||
2026-02-19 17:19:17
|
2026-02-24 21:45:40
|
||||||
@@ -1 +1 @@
|
|||||||
8e60a49
|
14149aa
|
||||||
46
Kernel.cs
46
Kernel.cs
@@ -72,7 +72,7 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Console.WriteLine("Kernel load done!");
|
Console.WriteLine("Kernel load done!");
|
||||||
Console.WriteLine(@"-------------------------------------------------");
|
Console.WriteLine(@"----------------------------------------------------------");
|
||||||
Console.WriteLine(@" ____ __ __ _ ___ ____ ");
|
Console.WriteLine(@" ____ __ __ _ ___ ____ ");
|
||||||
Console.WriteLine(@" / ___| \/ | | ___ ___ _ __ / _ \/ ___| ");
|
Console.WriteLine(@" / ___| \/ | | ___ ___ _ __ / _ \/ ___| ");
|
||||||
Console.WriteLine(@" | | | |\/| | | / _ \/ _ \| '_ \| | | \___ \ ");
|
Console.WriteLine(@" | | | |\/| | | / _ \/ _ \| '_ \| | | \___ \ ");
|
||||||
@@ -80,8 +80,8 @@ namespace CMLeonOS
|
|||||||
Console.WriteLine(@" \____|_| |_|_____\___|\___/|_| |_|____/|____/ ");
|
Console.WriteLine(@" \____|_| |_|_____\___|\___/|_| |_|____/|____/ ");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("The CMLeonOS Project");
|
Console.WriteLine("The CMLeonOS Project");
|
||||||
Console.WriteLine("By LeonOS 2 Developement Team");
|
Console.WriteLine("(C) LeonOS 2 Developer Team 2025-2026. All rights reserved.");
|
||||||
Console.WriteLine(@"-------------------------------------------------");
|
Console.WriteLine(@"----------------------------------------------------------");
|
||||||
|
|
||||||
// 注册VFS
|
// 注册VFS
|
||||||
_logger.Info("Kernel", "Starting VFS initialization");
|
_logger.Info("Kernel", "Starting VFS initialization");
|
||||||
@@ -254,6 +254,8 @@ namespace CMLeonOS
|
|||||||
// 检查并执行启动脚本
|
// 检查并执行启动脚本
|
||||||
ExecuteStartupScript();
|
ExecuteStartupScript();
|
||||||
|
|
||||||
|
ExecuteStartupTest();
|
||||||
|
|
||||||
if (System.IO.File.Exists("0:\\system\\zen"))
|
if (System.IO.File.Exists("0:\\system\\zen"))
|
||||||
{
|
{
|
||||||
Console.WriteLine("=====================================");
|
Console.WriteLine("=====================================");
|
||||||
@@ -471,6 +473,44 @@ namespace CMLeonOS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ExecuteStartupTest()
|
||||||
|
{
|
||||||
|
Console.BackgroundColor = ConsoleColor.Red;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.Yellow;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.Green;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.Cyan;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.Blue;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.Magenta;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.White;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.DarkBlue;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.DarkCyan;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.DarkGreen;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.DarkYellow;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.DarkRed;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.Gray;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.DarkGray;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.DarkMagenta;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.BackgroundColor = ConsoleColor.Black;
|
||||||
|
Console.Write(" ");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.ResetColor();
|
||||||
|
}
|
||||||
|
|
||||||
private string FormatBytes(long bytes)
|
private string FormatBytes(long bytes)
|
||||||
{
|
{
|
||||||
string[] units = { "B", "KB", "MB", "GB", "TB" };
|
string[] units = { "B", "KB", "MB", "GB", "TB" };
|
||||||
|
|||||||
@@ -308,7 +308,11 @@ namespace CMLeonOS
|
|||||||
{
|
{
|
||||||
if (File.Exists(fullPath))
|
if (File.Exists(fullPath))
|
||||||
{
|
{
|
||||||
return File.ReadAllText(fullPath);
|
using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
|
||||||
|
using (StreamReader sr = new StreamReader(fs))
|
||||||
|
{
|
||||||
|
return sr.ReadToEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -389,15 +393,15 @@ namespace CMLeonOS
|
|||||||
return currentDirectory;
|
return currentDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*' };
|
//char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*' };
|
||||||
foreach (char c in invalidChars)
|
//foreach (char c in invalidChars)
|
||||||
{
|
//{
|
||||||
if (path.Contains(c.ToString()))
|
// if (path.Contains(c.ToString()))
|
||||||
{
|
// {
|
||||||
Console.WriteLine($"Error: Invalid character in path: '{c}'");
|
// Console.WriteLine($"Error: Invalid character in path: '{c}'");
|
||||||
return currentDirectory;
|
// return currentDirectory;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (path.Contains("//") || path.Contains("\\\\"))
|
if (path.Contains("//") || path.Contains("\\\\"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
private static bool ContainsInvalidChars(string input)
|
private static bool ContainsInvalidChars(string input)
|
||||||
{
|
{
|
||||||
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\' };
|
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\', ' ' };
|
||||||
foreach (char c in invalidChars)
|
foreach (char c in invalidChars)
|
||||||
{
|
{
|
||||||
if (input.Contains(c.ToString()))
|
if (input.Contains(c.ToString()))
|
||||||
@@ -405,7 +405,7 @@ namespace CMLeonOS
|
|||||||
{
|
{
|
||||||
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.Red, global::System.ConsoleColor.Black);
|
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.Red, global::System.ConsoleColor.Black);
|
||||||
global::System.Console.SetCursorPosition(7, 24);
|
global::System.Console.SetCursorPosition(7, 24);
|
||||||
global::System.Console.Write("Username contains invalid characters: < > : \" | ? / \\ ");
|
global::System.Console.Write("Username contains invalid characters: < > : \" | ? * / \\ space");
|
||||||
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.White, global::System.ConsoleColor.Black);
|
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.White, global::System.ConsoleColor.Black);
|
||||||
global::System.Console.SetCursorPosition(7, 7);
|
global::System.Console.SetCursorPosition(7, 7);
|
||||||
global::System.Console.Write("Username: ");
|
global::System.Console.Write("Username: ");
|
||||||
|
|||||||
126
editor/Nano.cs
126
editor/Nano.cs
@@ -47,15 +47,22 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
if (value != null && fileSystem != null)
|
if (value != null && fileSystem != null)
|
||||||
{
|
{
|
||||||
string fullPath = fileSystem.GetFullPath(value);
|
try
|
||||||
|
|
||||||
if (System.IO.File.Exists(fullPath))
|
|
||||||
{
|
{
|
||||||
|
string fullPath = fileSystem.GetFullPath(value);
|
||||||
string text = fileSystem.ReadFile(fullPath);
|
string text = fileSystem.ReadFile(fullPath);
|
||||||
text = text.Replace("\r\n", "\n");
|
|
||||||
lines.AddRange(text.Split('\n'));
|
if (!string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
text = text.Replace("\r\n", "\n");
|
||||||
|
lines.AddRange(text.Split('\n'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lines.Add(string.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch
|
||||||
{
|
{
|
||||||
lines.Add(string.Empty);
|
lines.Add(string.Empty);
|
||||||
}
|
}
|
||||||
@@ -90,7 +97,6 @@ namespace CMLeonOS
|
|||||||
{
|
{
|
||||||
int y = i - scrollY + TITLEBAR_HEIGHT;
|
int y = i - scrollY + TITLEBAR_HEIGHT;
|
||||||
if (y < TITLEBAR_HEIGHT || y >= consoleHeight - SHORTCUT_BAR_HEIGHT) continue;
|
if (y < TITLEBAR_HEIGHT || y >= consoleHeight - SHORTCUT_BAR_HEIGHT) continue;
|
||||||
|
|
||||||
Console.SetCursorPosition(0, y);
|
Console.SetCursorPosition(0, y);
|
||||||
|
|
||||||
if (i >= lines.Count || scrollX >= lines[i].Length)
|
if (i >= lines.Count || scrollX >= lines[i].Length)
|
||||||
@@ -100,7 +106,15 @@ namespace CMLeonOS
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string line = lines[i].Substring(scrollX, Math.Min(consoleWidth, lines[i].Length - scrollX));
|
string line = lines[i].Substring(scrollX, Math.Min(consoleWidth, lines[i].Length - scrollX));
|
||||||
Console.Write(line + new string(' ', Math.Max(0, consoleWidth - line.Length)));
|
|
||||||
|
if (IsLuaFile())
|
||||||
|
{
|
||||||
|
RenderLuaLine(line, consoleWidth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write(line + new string(' ', Math.Max(0, consoleWidth - line.Length)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +125,102 @@ namespace CMLeonOS
|
|||||||
Console.SetCursorPosition(linePos - scrollX, currentLine + TITLEBAR_HEIGHT - scrollY);
|
Console.SetCursorPosition(linePos - scrollX, currentLine + TITLEBAR_HEIGHT - scrollY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsLuaFile()
|
||||||
|
{
|
||||||
|
if (path != null)
|
||||||
|
{
|
||||||
|
string extension = System.IO.Path.GetExtension(path)?.ToLower();
|
||||||
|
return extension == ".lua";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RenderLuaLine(string line, int consoleWidth)
|
||||||
|
{
|
||||||
|
int pos = 0;
|
||||||
|
bool inString = false;
|
||||||
|
bool inComment = false;
|
||||||
|
|
||||||
|
while (pos < line.Length && pos < consoleWidth)
|
||||||
|
{
|
||||||
|
if (inComment)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.Write(line[pos]);
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
else if (line.Substring(pos).StartsWith("--"))
|
||||||
|
{
|
||||||
|
inComment = true;
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.Write(line.Substring(pos));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (inString)
|
||||||
|
{
|
||||||
|
if (line[pos] == '"' || line[pos] == '\'')
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
Console.Write(line[pos]);
|
||||||
|
inString = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
Console.Write(line[pos]);
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (line[pos] == '"' || line[pos] == '\'')
|
||||||
|
{
|
||||||
|
inString = true;
|
||||||
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
Console.Write(line[pos]);
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
else if (IsLuaKeyword(line, pos))
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||||
|
Console.Write(line[pos]);
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
Console.Write(line[pos]);
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos < consoleWidth)
|
||||||
|
{
|
||||||
|
Console.Write(new string(' ', consoleWidth - pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.ResetColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsLuaKeyword(string line, int pos)
|
||||||
|
{
|
||||||
|
string[] keywords = { "function", "end", "if", "then", "else", "elseif", "while", "do", "for", "return", "local", "true", "false", "nil", "and", "or", "not", "break", "repeat", "until" };
|
||||||
|
|
||||||
|
foreach (string keyword in keywords)
|
||||||
|
{
|
||||||
|
if (pos + keyword.Length <= line.Length && line.Substring(pos, keyword.Length) == keyword)
|
||||||
|
{
|
||||||
|
char nextChar = pos + keyword.Length < line.Length ? line[pos + keyword.Length] : ' ';
|
||||||
|
if (!char.IsLetterOrDigit(nextChar))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Insert a new line at the cursor.
|
// Insert a new line at the cursor.
|
||||||
private void InsertLine()
|
private void InsertLine()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user