From d44fca86a3aeeb65daae404cd369c6c10315a9b6 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Sat, 14 Mar 2026 21:52:47 +0800 Subject: [PATCH] =?UTF-8?q?Markit=E5=91=BD=E4=BB=A4+=E6=95=B4=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=91+=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BuildTime.txt | 2 +- CMLeonOS.csproj | 2 +- Examples/example.mi | 42 ++++++ GitCommit.txt | 2 +- Kernel.cs | 10 +- BootMenu.cs => System/BootMenu.cs | 0 UserManager.cs => System/UserManager.cs | 0 docs/cmleonos/docs/commands.md | 171 ++++++++++++++++++++++++ editor/Nano.cs | 106 ++++++++++++++- shell/CommandList.cs | 3 + shell/Commands/MarkitCommand.cs | 107 +++++++++++++++ shell/Shell.cs | 5 + LuaApps.cs => utils/LuaApps.cs | 0 Power.cs => utils/Power.cs | 0 14 files changed, 445 insertions(+), 5 deletions(-) create mode 100644 Examples/example.mi rename BootMenu.cs => System/BootMenu.cs (100%) rename UserManager.cs => System/UserManager.cs (100%) create mode 100644 shell/Commands/MarkitCommand.cs rename LuaApps.cs => utils/LuaApps.cs (100%) rename Power.cs => utils/Power.cs (100%) diff --git a/BuildTime.txt b/BuildTime.txt index a3ba124..18a4305 100644 --- a/BuildTime.txt +++ b/BuildTime.txt @@ -1 +1 @@ -2026-03-14 15:36:36 \ No newline at end of file +2026-03-14 21:51:05 \ No newline at end of file diff --git a/CMLeonOS.csproj b/CMLeonOS.csproj index 1621d77..dfbc0fb 100644 --- a/CMLeonOS.csproj +++ b/CMLeonOS.csproj @@ -1,4 +1,4 @@ - + net6.0 diff --git a/Examples/example.mi b/Examples/example.mi new file mode 100644 index 0000000..f6084d8 --- /dev/null +++ b/Examples/example.mi @@ -0,0 +1,42 @@ +欢迎使用Markit语言! + +{color:red}这是红色文字{/color} + +{bg:blue}这是蓝色背景{/bg} + +{color:green}{bg:yellow}绿色文字黄色背景{/bg}{/color} + +{color:magenta}{bg:cyan}洋红色文字青色背景{/bg}{/color} + +{color:white}{bg:black}白色文字黑色背景{/bg}{/color} + +{color:yellow}黄色文字{/color} + +{color:cyan}青色文字{/color} + +{color:darkred}深红色文字{/color} + +{color:darkgreen}深绿色文字{/color} + +{color:darkblue}深蓝色文字{/color} + +{color:darkmagenta}深洋红色文字{/color} + +{color:darkyellow}深黄色文字{/color} + +{color:darkgray}深灰色文字{/color} + +{color:gray}灰色文字{/color} + +{color:darkcyan}深青色文字{/color} + +{color:black}{bg:white}黑色文字白色背景{/bg}{/color} + +组合使用: +{color:red}{bg:yellow}警告:这是一个重要信息!{/bg}{/color} + +{color:green}{bg:black}成功:操作已完成!{/bg}{/color} + +{color:yellow}{bg:red}错误:发生了一个错误!{/bg}{/color} + +{color:cyan}{bg:blue}信息:这是一条普通信息{/bg}{/color} \ No newline at end of file diff --git a/GitCommit.txt b/GitCommit.txt index f8b018e..d9996bc 100644 --- a/GitCommit.txt +++ b/GitCommit.txt @@ -1 +1 @@ -3e196e7 \ No newline at end of file +fbb90da \ No newline at end of file diff --git a/Kernel.cs b/Kernel.cs index 74f7d2f..6690f2b 100644 --- a/Kernel.cs +++ b/Kernel.cs @@ -42,6 +42,14 @@ namespace CMLeonOS { public class Kernel : Sys.Kernel { + // fuck Windows + // fuck Linux + // fuck Unix + // fuck macOS + // fuck ALL!!! + + // a femboy's operating system :3 + private static CMLeonOS.Logger.Logger _logger = CMLeonOS.Logger.Logger.Instance; // 创建全局CosmosVFS实例 @@ -89,7 +97,7 @@ namespace CMLeonOS private void InitializeSystem() { // 修改光标样式等 - Console.CursorSize = 14; + Console.CursorSize = 100; // 注册VFS _logger.Info("Kernel", "Starting VFS initialization"); diff --git a/BootMenu.cs b/System/BootMenu.cs similarity index 100% rename from BootMenu.cs rename to System/BootMenu.cs diff --git a/UserManager.cs b/System/UserManager.cs similarity index 100% rename from UserManager.cs rename to System/UserManager.cs diff --git a/docs/cmleonos/docs/commands.md b/docs/cmleonos/docs/commands.md index 7683804..c6c9737 100644 --- a/docs/cmleonos/docs/commands.md +++ b/docs/cmleonos/docs/commands.md @@ -51,6 +51,26 @@ date uptime ``` +### ps +显示当前运行的进程列表。 + +**用法:** +```bash +ps +``` + +**输出信息:** +- ID:进程ID +- Name:进程名称 +- Type:进程类型 +- Parent:父进程ID +- Status:运行状态 + +**示例:** +```bash +ps +``` + ### whoami 显示当前登录的用户名。 @@ -72,6 +92,24 @@ sleep sleep 5 ``` +### kill +终止指定的进程。 + +**用法:** +```bash +kill +``` + +**示例:** +```bash +kill 123 +``` + +**说明:** +- process_id:要终止的进程ID +- 使用ps命令查看进程列表 +- 无法终止Shell进程(使用exit命令退出) + ## 文件系统命令 ### ls @@ -327,8 +365,24 @@ nano **示例:** ```bash nano myfile.txt +nano example.mi ``` +**说明:** +- 支持多种文件类型的语法高亮 +- 自动根据文件扩展名应用语法高亮 +- 支持的文件类型: + - Lua 文件:.lua, .los, .losb + - Ini 配置文件:.ini, .cfg, .conf, .config + - Json 文件:.json + - Markit 标记文件:.mi +- 支持智能缩进、自动补全括号和引号、智能删除 + +**语法高亮颜色方案:** +- Lua 文件:关键字(青色)、注释(绿色)、字符串(黄色)、数字(洋红色)、函数名(深洋红色) +- Ini 文件:节(青色)、键(黄色)、值(白色)、注释(绿色) +- Json 文件:字符串(绿色)、数字(洋红色)、布尔值(深洋红色)、null(深灰色)、键(黄色) +- Markit 文件:标签(青色)、颜色名称(黄色)、普通文本(白色) ### hex 使用16进制编辑器编辑二进制文件。 @@ -383,6 +437,62 @@ Controls: Q - Quit ``` +### markit +渲染并显示 Markit 标记语言文件(.mi)。 + +**用法:** +```bash +markit +``` + +**示例:** +```bash +markit example.mi +markit /path/to/file.mi +``` + +**说明:** +- Markit 是一种简单的标记语言,支持文字颜色和背景色 +- 文件扩展名:.mi +- 支持相对路径和绝对路径 +- 自动根据文件扩展名应用语法高亮 + +**Markit 语法:** +``` +{color:颜色名}文字{/color} +{bg:颜色名}文字{/bg} +{color:前景色}{bg:背景色}文字{/bg}{/color} +``` + +**支持的颜色:** +- 前景色和背景色:black, darkblue, darkgreen, darkcyan, darkred, darkmagenta, darkyellow, gray, darkgray, blue, green, cyan, red, magenta, yellow, white + +**语法示例:** +``` +{color:red}红色文字{/color} +{bg:blue}蓝色背景{/bg} +{color:green}{bg:yellow}绿色文字黄色背景{/bg}{/color} +{color:white}{bg:black}白色文字黑色背景{/bg}{/color} +``` + +**实际应用示例:** +``` +{color:green}{bg:black}✓ 成功:操作已完成!{/bg}{/color} +{color:red}{bg:yellow}⚠ 警告:这是一个重要信息!{/bg}{/color} +{color:white}{bg:blue}ℹ 信息:这是一条普通信息{/bg}{/color} +``` + +**控制键:** +- 无特殊控制键 +- 直接渲染文件内容到控制台 +- 支持所有颜色和背景色组合 + +**编辑器支持:** +- Nano 编辑器自动识别 .mi 文件并应用语法高亮 +- 标签显示为青色 +- 颜色名称显示为黄色 +- 普通文本显示为白色 + ## 用户管理命令 ### user @@ -630,6 +740,28 @@ calc 10*5 calc (3+5)*2 ``` +### calcgui +启动图形化计算器界面。 + +**用法:** +```bash +calcgui +``` + +**功能:** +- 图形化计算器界面 +- 支持基本运算:加、减、乘、除 +- 支持键盘和鼠标操作 +- 方向键导航按钮,Enter选择,Esc退出 + +**快捷键:** +- 数字键 0-9:输入数字 +- + - * /:选择运算符 +- Enter:计算结果 +- C:清除 +- Backspace:删除 +- Esc/Q:退出 + ### history 显示命令历史记录。 @@ -665,6 +797,24 @@ background 000000 background FF0000 ``` +### exportbackground +导出当前系统壁纸到指定路径。 + +**用法:** +```bash +exportbackground [output_path] +``` + +**示例:** +```bash +exportbackground +exportbackground 0:\mywallpaper.bmp +``` + +**说明:** +- 如果不指定输出路径,默认导出到 0:\background.bmp +- 导出的壁纸为BMP格式 + ### beep 播放系统提示音。 @@ -947,6 +1097,27 @@ env PATH env MYVAR hello ``` +### logs +显示系统日志。 + +**用法:** +```bash +logs +``` + +**说明:** +- 显示最近20条日志记录 +- 日志级别:DEBUG、INFO、WARN、ERROR、SUCCESS +- 不同级别使用不同颜色显示 +- 如果日志超过20条,会显示剩余数量 + +**日志级别颜色:** +- DEBUG:灰色 +- INFO:青色 +- WARN:黄色 +- ERROR:红色 +- SUCCESS:绿色 + ## 注意事项 1. 所有命令不区分大小写 diff --git a/editor/Nano.cs b/editor/Nano.cs index ae92ca0..9a9915f 100644 --- a/editor/Nano.cs +++ b/editor/Nano.cs @@ -200,6 +200,10 @@ namespace CMLeonOS { RenderJsonLine(line, consoleWidth); } + else if (IsMarkitFile() && settings.EnableSyntaxHighlight) + { + RenderMarkitLine(line, consoleWidth); + } else { Console.Write(line + new string(' ', Math.Max(0, consoleWidth - line.Length))); @@ -244,6 +248,16 @@ namespace CMLeonOS return false; } + private bool IsMarkitFile() + { + if (path != null) + { + string extension = System.IO.Path.GetExtension(path)?.ToLower(); + return extension == ".mi"; + } + return false; + } + private void RenderLuaLine(string line, int consoleWidth) { int pos = 0; @@ -615,6 +629,96 @@ namespace CMLeonOS Console.ResetColor(); } + private void RenderMarkitLine(string line, int consoleWidth) + { + int pos = 0; + bool inTag = false; + bool inColorTag = false; + bool inBgTag = false; + bool inCloseTag = false; + bool inColorName = false; + bool inBgName = false; + + while (pos < line.Length && pos < consoleWidth) + { + char c = line[pos]; + + if (inTag) + { + Console.ForegroundColor = ConsoleColor.Cyan; + Console.Write(c); + pos++; + + if (c == '}') + { + inTag = false; + inColorTag = false; + inBgTag = false; + inCloseTag = false; + inColorName = false; + inBgName = false; + } + else if (c == ':' && (inColorTag || inBgTag)) + { + inColorName = inColorTag; + inBgName = inBgTag; + } + else if (inColorName || inBgName) + { + Console.ForegroundColor = ConsoleColor.Yellow; + } + } + else if (c == '{') + { + if (pos + 1 < line.Length && line[pos + 1] == '/') + { + inTag = true; + inCloseTag = true; + Console.ForegroundColor = ConsoleColor.Cyan; + Console.Write(c); + pos++; + Console.Write(line[pos]); + pos++; + } + else if (pos + 6 < line.Length && line.Substring(pos, 7) == "{color:") + { + inTag = true; + inColorTag = true; + Console.ForegroundColor = ConsoleColor.Cyan; + Console.Write(c); + pos++; + } + else if (pos + 4 < line.Length && line.Substring(pos, 5) == "{bg:") + { + inTag = true; + inBgTag = true; + Console.ForegroundColor = ConsoleColor.Cyan; + Console.Write(c); + pos++; + } + else + { + Console.ForegroundColor = ConsoleColor.White; + Console.Write(c); + pos++; + } + } + else + { + Console.ForegroundColor = ConsoleColor.White; + Console.Write(c); + pos++; + } + } + + if (pos < consoleWidth) + { + Console.Write(new string(' ', consoleWidth - pos)); + } + + Console.ResetColor(); + } + private bool IsLuaNumber(string line, int pos) { if (pos >= line.Length) return false; @@ -1606,7 +1710,7 @@ namespace CMLeonOS "2. Auto Complete Brackets (All Files)", "3. Auto Complete Quotes (All Files)", "4. Smart Delete (All Files)", - "5. Syntax Highlight (Lua/Ini/Json)", + "5. Syntax Highlight (Lua/Ini/Json/Markit)", "6. Save and Exit" }; diff --git a/shell/CommandList.cs b/shell/CommandList.cs index 384f552..e18000b 100644 --- a/shell/CommandList.cs +++ b/shell/CommandList.cs @@ -233,6 +233,9 @@ namespace CMLeonOS.shell case "hex": shell.EditHexFile(args); break; + case "markit": + shell.ProcessMarkit(args); + break; case "alias": shell.ProcessAlias(args); break; diff --git a/shell/Commands/MarkitCommand.cs b/shell/Commands/MarkitCommand.cs new file mode 100644 index 0000000..d6ff3a7 --- /dev/null +++ b/shell/Commands/MarkitCommand.cs @@ -0,0 +1,107 @@ +using System; + +namespace CMLeonOS.Commands +{ + public static class MarkitCommand + { + public static void Execute(string args, Shell shell, CMLeonOS.FileSystem fileSystem) + { + if (string.IsNullOrWhiteSpace(args)) + { + Console.WriteLine("Usage: markit "); + Console.WriteLine("Markit syntax:"); + Console.WriteLine(" {color:red}Red text{/color}"); + Console.WriteLine(" {bg:blue}Blue background{/bg}"); + Console.WriteLine(" {color:green}{bg:yellow}Green text on yellow background{/bg}{/color}"); + return; + } + + string filePath = args.Trim(); + + try + { + string content = fileSystem.ReadFile(filePath); + if (content == null) + { + Console.WriteLine($"Error: File '{filePath}' not found."); + return; + } + RenderMarkit(content); + } + catch (Exception ex) + { + Console.WriteLine($"Error reading file: {ex.Message}"); + } + } + + private static void RenderMarkit(string content) + { + int i = 0; + while (i < content.Length) + { + if (content.Substring(i).StartsWith("{color:")) + { + int end = content.IndexOf('}', i); + if (end > i + 7) + { + string colorName = content.Substring(i + 7, end - i - 7).ToLower(); + ConsoleColor color = ParseColor(colorName); + Console.ForegroundColor = color; + i = end + 1; + continue; + } + } + else if (content.Substring(i).StartsWith("{bg:")) + { + int end = content.IndexOf('}', i); + if (end > i + 4) + { + string colorName = content.Substring(i + 4, end - i - 4).ToLower(); + ConsoleColor color = ParseColor(colorName); + Console.BackgroundColor = color; + i = end + 1; + continue; + } + } + else if (content.Substring(i).StartsWith("{/color}")) + { + Console.ForegroundColor = ConsoleColor.White; + i += 8; + continue; + } + else if (content.Substring(i).StartsWith("{/bg}")) + { + Console.BackgroundColor = ConsoleColor.Black; + i += 5; + continue; + } + + Console.Write(content[i]); + i++; + } + + Console.ResetColor(); + } + + private static ConsoleColor ParseColor(string colorName) + { + if (colorName == "black") return ConsoleColor.Black; + if (colorName == "darkblue") return ConsoleColor.DarkBlue; + if (colorName == "darkgreen") return ConsoleColor.DarkGreen; + if (colorName == "darkcyan") return ConsoleColor.DarkCyan; + if (colorName == "darkred") return ConsoleColor.DarkRed; + if (colorName == "darkmagenta") return ConsoleColor.DarkMagenta; + if (colorName == "darkyellow") return ConsoleColor.DarkYellow; + if (colorName == "gray") return ConsoleColor.Gray; + if (colorName == "darkgray") return ConsoleColor.DarkGray; + if (colorName == "blue") return ConsoleColor.Blue; + if (colorName == "green") return ConsoleColor.Green; + if (colorName == "cyan") return ConsoleColor.Cyan; + if (colorName == "red") return ConsoleColor.Red; + if (colorName == "magenta") return ConsoleColor.Magenta; + if (colorName == "yellow") return ConsoleColor.Yellow; + if (colorName == "white") return ConsoleColor.White; + return ConsoleColor.White; + } + } +} \ No newline at end of file diff --git a/shell/Shell.cs b/shell/Shell.cs index 8671eed..9897449 100644 --- a/shell/Shell.cs +++ b/shell/Shell.cs @@ -1087,6 +1087,11 @@ namespace CMLeonOS Commands.Utility.HexCommand.EditHexFile(args); } + public void ProcessMarkit(string args) + { + Commands.MarkitCommand.Execute(args, this, fileSystem); + } + public void CreateFTP() { Console.WriteLine("===================================="); diff --git a/LuaApps.cs b/utils/LuaApps.cs similarity index 100% rename from LuaApps.cs rename to utils/LuaApps.cs diff --git a/Power.cs b/utils/Power.cs similarity index 100% rename from Power.cs rename to utils/Power.cs