From 3e3e35860c45019a1b51cad694a75d07182f4a8b Mon Sep 17 00:00:00 2001 From: WahPlus Date: Thu, 30 Oct 2025 15:02:52 +0200 Subject: [PATCH] Add text censoring to terminal.read() --- halyde/kernel/modules/terminal.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/halyde/kernel/modules/terminal.lua b/halyde/kernel/modules/terminal.lua index 204883c..42b8749 100644 --- a/halyde/kernel/modules/terminal.lua +++ b/halyde/kernel/modules/terminal.lua @@ -264,6 +264,7 @@ function module.init() checkOption("prefix", options.prefix, "string") checkOption("maxChars", options.maxChars, "number") checkOption("defaultText", options.defaultText, "string") + checkOption("censor", options.censor, "string") end options.maxChars = options.maxChars or math.huge @@ -297,8 +298,11 @@ function module.init() end return math.min(y,height) end - local function set(index, character, invertedColors) + local function set(index, character, invertedColors) -- HACK: Currently, this will uncensor all spaces in the inputted text. if character==nil or character=="" then return end + if options.censor then + character = character:gsub("[^ ]", options.censor) + end if invertedColors then gpu.setForeground(bg) gpu.setBackground(fg) @@ -400,6 +404,7 @@ function module.init() set(curPos(cur)," ",true) end + while true do local args = {event.pull("key_down", "clipboard", 0.5)} local ctrlDown = _PUBLIC.keyboard.getCtrlDown()