From 119f43b7cc63a748363674883cb1aed20b17dd12 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Tue, 2 Sep 2025 16:29:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(installer):=20=E6=9B=B4=E6=96=B0=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E7=A8=8B=E5=BA=8F=E7=89=88=E6=9C=AC=E8=87=B30.3.7=20B?= =?UTF-8?q?eta=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit docs(help): 更新about.hlp中的网站链接至新域名 refactor(help): 优化pkg_download_en.hlp的代码块显示格式 feat(imageview): 添加图像加载错误提示和注释说明 style(time): 修复帮助文档格式错误 feat(shell): 添加欢迎界面图形显示 test: 新增imageview和help文档的测试程序 --- data/computercraft/lua/rom/help/about.hlp | 2 +- .../lua/rom/help/pkg_download_en.hlp | 44 +++++++++---------- .../lua/rom/programs/imageview.lua | 3 ++ data/computercraft/lua/rom/programs/shell.lua | 16 ++++++- .../lua/rom/programs/test_help_format.lua | 44 +++++++++++++++++++ .../lua/rom/programs/test_imageview.lua | 34 ++++++++++++++ data/computercraft/lua/rom/programs/time.lua | 11 ++--- installer.lua | 2 +- 8 files changed, 126 insertions(+), 30 deletions(-) create mode 100644 data/computercraft/lua/rom/programs/test_help_format.lua create mode 100644 data/computercraft/lua/rom/programs/test_imageview.lua diff --git a/data/computercraft/lua/rom/help/about.hlp b/data/computercraft/lua/rom/help/about.hlp index 2b66b74..1d0feda 100644 --- a/data/computercraft/lua/rom/help/about.hlp +++ b/data/computercraft/lua/rom/help/about.hlp @@ -3,4 +3,4 @@ This help document is not complete. LeonOS's website: >>color blue -wget run https://gh.catmak.name/https://raw.githubusercontent.com/Leonmmcoset/LeonOS/refs/heads/main/installer.lua +https://leonkingdom.netlify.app/leonos/ diff --git a/data/computercraft/lua/rom/help/pkg_download_en.hlp b/data/computercraft/lua/rom/help/pkg_download_en.hlp index 99b90d5..c88b27d 100644 --- a/data/computercraft/lua/rom/help/pkg_download_en.hlp +++ b/data/computercraft/lua/rom/help/pkg_download_en.hlp @@ -5,9 +5,9 @@ In LeonOS, you can use the `pkg` command to download and install software packag == Basic Usage == Download and install a package: -``` +>>color yellow pkg install -``` +>>color white == Command Options == @@ -20,60 +20,60 @@ The `pkg install` command supports the following options: == Usage Examples == 1. Install a package: -``` +>>color yellow pkg install example-package -``` +>>color white 2. Force install a package: -``` +>>color yellow pkg install --force example-package -``` +>>color white 3. Install a package with detailed information: -``` +>>color yellow pkg install -v example-package -``` +>>color white 4. View help for `pkg install` command: -``` +>>color yellow pkg install --help -``` +>>color white == Search for Packages == Before installing a package, you can search for available packages: -``` +>>color yellow pkg search -``` +>>color white Example: -``` +>>color yellow pkg search editor -``` +>>color white == View Package Information == Before installing a package, you can view detailed information about it: -``` +>>color yellow pkg info -``` +>>color white Example: -``` +>>color yellow pkg info example-package -``` +>>color white == Update Packages == You can update installed packages using the following command: -``` +>>color yellow pkg update -``` +>>color white If you don't specify a package name, all installed packages will be updated: -``` +>>color yellow pkg update -``` +>>color white == Frequently Asked Questions == diff --git a/data/computercraft/lua/rom/programs/imageview.lua b/data/computercraft/lua/rom/programs/imageview.lua index 97468fd..2cd2d0f 100644 --- a/data/computercraft/lua/rom/programs/imageview.lua +++ b/data/computercraft/lua/rom/programs/imageview.lua @@ -1,4 +1,6 @@ -- imageview.lua: Image viewer that loads from URL +-- This program uses paintutils library for image handling (CC Tweaked standard) +-- There is no 'image' API; we use paintutils.loadImage and paintutils.drawImage local http = require("http") local paintutils = require("paintutils") local term = require("term") @@ -59,6 +61,7 @@ local function main(args) if not success then print("Error loading image: " .. image) + print("Make sure the URL points to a valid image file compatible with CC Tweaked.") return end diff --git a/data/computercraft/lua/rom/programs/shell.lua b/data/computercraft/lua/rom/programs/shell.lua index 91fc58b..f5978fa 100644 --- a/data/computercraft/lua/rom/programs/shell.lua +++ b/data/computercraft/lua/rom/programs/shell.lua @@ -27,10 +27,24 @@ local textutils = require("textutils") if os.version then textutils.coloredPrint(colors.yellow, os.version(), colors.white) + local image = paintutils.parseImage([[ + f f + +f f + ffff + ]]) + paintutils.drawImage(image, term.getCursorPos()) else textutils.coloredPrint(colors.yellow, rc.version(), colors.white) + local image = paintutils.parseImage([[ + f f + +f f + ffff + ]]) + paintutils.drawImage(image, term.getCursorPos()) end --- textutils.coloredPrint(colors.yellow, "Welcome using the beta version of LeonOS!"colors.white) +textutils.coloredPrint(colors.yellow, "Welcome using the beta version of LeonOS!", colors.white) thread.vars().parentShell = thread.id() shell.init(_ENV) diff --git a/data/computercraft/lua/rom/programs/test_help_format.lua b/data/computercraft/lua/rom/programs/test_help_format.lua new file mode 100644 index 0000000..3144f99 --- /dev/null +++ b/data/computercraft/lua/rom/programs/test_help_format.lua @@ -0,0 +1,44 @@ +-- test_help_format.lua: Test the formatted pkg_download_en help document +local help = require("rom/programs/help") +local term = require("term") + +print("=== Testing pkg_download_en Help Document Formatting ===") +print("This test will display the pkg_download_en help document") +print("to verify that code blocks are properly formatted with colors.") +print("\n3...") +os.sleep(1) +print("2...") +os.sleep(1) +print("1...") +os.sleep(1) + +-- Clear screen and display help document +term.clear() +term.setCursorPos(1, 1) + +local success, content = pcall(function() + return help.loadTopic("pkg_download_en") +end) + +if success and content then + -- Process the content to simulate how help system would display it + print("=== pkg_download_en Help Document ===") + for line in content:gmatch("[^ +]+") do + -- Handle color commands + if line:match("^>>color yellow") then + term.setTextColor(0xFFFF00) + elseif line:match("^>>color white") then + term.setTextColor(0xFFFFFF) + else + print(line) + end + end + term.setTextColor(0xFFFFFF) -- Reset to white + print("\n=== End of Help Document ===") +else + print("Error: Could not load pkg_download_en help document.") +end + +print("\nTest finished. Press any key to return.") +os.pullEvent("key") \ No newline at end of file diff --git a/data/computercraft/lua/rom/programs/test_imageview.lua b/data/computercraft/lua/rom/programs/test_imageview.lua new file mode 100644 index 0000000..7268b7c --- /dev/null +++ b/data/computercraft/lua/rom/programs/test_imageview.lua @@ -0,0 +1,34 @@ +-- test_imageview.lua: Test the imageview command +local shell = require("shell") + +print("=== Image Viewer Test ===") +print("Note: This program uses the paintutils library for image handling,") +print(" not an 'image' API. CC Tweaked doesn't have an 'image' API.") +print("") +print("Testing imageview command with a sample image...") +print("This will attempt to load a test image from the internet.") +print("Press Ctrl+T to stop the test if needed.") +print("\nNote: You need an internet connection for this test.") +print("\n3...") +os.sleep(1) +print("2...") +os.sleep(1) +print("1...") +os.sleep(1) + +-- Use a sample image URL that's known to work +local testImageUrl = "http://time.syiban.com/img/xcx.png" + +-- Execute the imageview command with the test URL +local success, errorMsg = shell.execute("imageview " .. testImageUrl) + +if success then + print("\nTest completed successfully.") + print("The image viewer is working correctly with paintutils.") +else + print("\nTest failed: " .. errorMsg) + print("Make sure you have internet access and the URL is valid.") +end + +print("\nTest finished. Press any key to return.") +os.pullEvent("key") \ No newline at end of file diff --git a/data/computercraft/lua/rom/programs/time.lua b/data/computercraft/lua/rom/programs/time.lua index 2fa3598..e524533 100644 --- a/data/computercraft/lua/rom/programs/time.lua +++ b/data/computercraft/lua/rom/programs/time.lua @@ -18,11 +18,12 @@ Formats for --format option: ]]) print(" %A: Full weekday name") print(" %B: Full month name") - print(" -Examples:") - print(" time # Show current time in default format") - print(" time --format '%Y-%m-%d %H:%M:%S' # Show time as YYYY-MM-DD HH:MM:SS") - print(" time -f '%A, %B %d, %Y' # Show time as 'Monday, January 01, 2023'") + print([[ +Examples: + time # Show current time in default format + time --format '%Y-%m-%d %H:%M:%S' # Show time as YYYY-MM-DD HH:MM:SS + time -f '%A, %B %d, %Y' # Show time as 'Monday, January 01, 2023' +]]) end -- 主函数 diff --git a/installer.lua b/installer.lua index 107f311..e3c0ad5 100644 --- a/installer.lua +++ b/installer.lua @@ -1,5 +1,5 @@ -- LeonOS installer -local INSTALLER_VERSION = "0.3.7 Beta 8" +local INSTALLER_VERSION = "0.3.7 Beta 9" local DEFAULT_ROM_DIR = "/leonos" print("Start loading LeonOS installer ("..INSTALLER_VERSION..")...")