From 42e5a053c480b0a57b0c4fcdb4e4f51ef474aca1 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Mon, 1 Sep 2025 09:27:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(shell):=20=E4=BF=AE=E5=A4=8D=E7=BB=88?= =?UTF-8?q?=E7=AB=AF=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 清除终端内容时保留顶部应用栏,并调整文本颜色为白色以提高可读性。同时修复了命令提示符的颜色显示问题。 --- data/computercraft/lua/rom/programs/shell.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/data/computercraft/lua/rom/programs/shell.lua b/data/computercraft/lua/rom/programs/shell.lua index ec84dcc..2eeba8e 100644 --- a/data/computercraft/lua/rom/programs/shell.lua +++ b/data/computercraft/lua/rom/programs/shell.lua @@ -81,8 +81,16 @@ end local history = {} while true do - term.setTextColor(colors.yellow) + -- 先清除控制台内容,但保留顶部应用栏 + local w, h = term.getSize() + term.setTextColor(colors.white) term.setBackgroundColor(colors.black) + for y=2, h do + term.at(1, y).clearLine() + end + term.at(1, 2) + + term.setTextColor(colors.yellow) rc.write("$ "..shell.dir().." >>> ") term.setTextColor(colors.white)