diff --git a/CMLeonOS.csproj b/CMLeonOS.csproj index fde6c18..6f913d3 100644 --- a/CMLeonOS.csproj +++ b/CMLeonOS.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -6,7 +6,7 @@ cosmos false True - AnyCPU;x64 + AnyCPU;x64;ARM64 Debug;Release;Fixed_Release diff --git a/GitCommit.txt b/GitCommit.txt index f832675..6885200 100644 --- a/GitCommit.txt +++ b/GitCommit.txt @@ -1 +1 @@ -350db31 \ No newline at end of file +22c896e \ No newline at end of file diff --git a/Kernel.cs b/Kernel.cs index 9691db6..f4145b6 100644 --- a/Kernel.cs +++ b/Kernel.cs @@ -63,8 +63,8 @@ namespace CMLeonOS // { // 我不认,我试着转换成Base64 // 我认了 - PCScreenFont defaultFont = PCScreenFont.Default; - VGAScreen.SetFont(defaultFont.CreateVGAFont(), defaultFont.Height); + // PCScreenFont defaultFont = PCScreenFont.Default; + // VGAScreen.SetFont(defaultFont.CreateVGAFont(), defaultFont.Height); // Console.WriteLine($"{defaultFont.Height}"); // Console.WriteLine($"{defaultFont.Width}"); // VGAScreen.SetGraphicsMode(VGADriver.ScreenSize.Size720x480, ColorDepth.ColorDepth32); diff --git a/LuaApps.cs b/LuaApps.cs index 8c05051..266bfe6 100644 --- a/LuaApps.cs +++ b/LuaApps.cs @@ -9,5 +9,8 @@ namespace CMLeonOS [ManifestResourceStream(ResourceName = "CMLeonOS.LuaApps.testspeed.lua")] public static readonly byte[] testspeed; + + [ManifestResourceStream(ResourceName = "CMLeonOS.LuaApps.calculator.lua")] + public static readonly byte[] calculator; } } \ No newline at end of file diff --git a/LuaApps/calculator.lua b/LuaApps/calculator.lua new file mode 100644 index 0000000..da4481d --- /dev/null +++ b/LuaApps/calculator.lua @@ -0,0 +1,98 @@ +print("====================================") +print(" Lua Calculator") +print("====================================") +print("Type 'exit' or 'quit' to exit") +print("Type 'clear' to clear the result") +print() + +local result = nil +local operator = nil +local lastResult = nil + +while true do + io.write("calc> ") + local input = io.read() + + if input == nil or input == "" then + goto continue + end + + input = input:lower() + + if input == "exit" or input == "quit" then + print("Exiting calculator...") + break + elseif input == "clear" then + result = nil + operator = nil + lastResult = nil + print("Calculator cleared.") + goto continue + elseif input == "help" then + print("Available commands:") + print(" + : Addition") + print(" - : Subtraction") + print(" * : Multiplication") + print(" / : Division") + print(" ^ : Power") + print(" % : Modulo") + print(" clear : Clear calculator") + print(" exit : Exit calculator") + goto continue + end + + local num = tonumber(input) + + if num ~= nil then + if operator == nil then + result = num + lastResult = num + print("Result: " .. result) + else + local calcResult = nil + if operator == "+" then + calcResult = result + num + elseif operator == "-" then + calcResult = result - num + elseif operator == "*" then + calcResult = result * num + elseif operator == "/" then + if num == 0 then + print("Error: Division by zero!") + else + calcResult = result / num + end + elseif operator == "^" then + calcResult = result ^ num + elseif operator == "%" then + if num == 0 then + print("Error: Modulo by zero!") + else + calcResult = result % num + end + end + + if calcResult ~= nil then + result = calcResult + lastResult = calcResult + print("Result: " .. result) + end + + operator = nil + end + else + if input == "+" or input == "-" or input == "*" or input == "/" or input == "^" or input == "%" then + operator = input + print("Operator: " .. operator) + else + print("Invalid input: " .. input) + print("Type 'help' for available commands") + end + end + + ::continue:: +end + +print() +print("Final result: " .. (lastResult or "No calculation")) +print("Goodbye!") \ No newline at end of file diff --git a/shell/Commands/Utility/AppManagerCommand.cs b/shell/Commands/Utility/AppManagerCommand.cs index 3adfe95..fe6e001 100644 --- a/shell/Commands/Utility/AppManagerCommand.cs +++ b/shell/Commands/Utility/AppManagerCommand.cs @@ -29,6 +29,11 @@ namespace CMLeonOS.Commands.Utility { embeddedApps["testspeed.lua"] = LuaApps.testspeed; } + + if (LuaApps.calculator != null && LuaApps.calculator.Length > 0) + { + embeddedApps["calculator.lua"] = LuaApps.calculator; + } } catch (Exception ex) {