Add text censoring to terminal.read()
This commit is contained in:
@@ -264,6 +264,7 @@ function module.init()
|
|||||||
checkOption("prefix", options.prefix, "string")
|
checkOption("prefix", options.prefix, "string")
|
||||||
checkOption("maxChars", options.maxChars, "number")
|
checkOption("maxChars", options.maxChars, "number")
|
||||||
checkOption("defaultText", options.defaultText, "string")
|
checkOption("defaultText", options.defaultText, "string")
|
||||||
|
checkOption("censor", options.censor, "string")
|
||||||
end
|
end
|
||||||
|
|
||||||
options.maxChars = options.maxChars or math.huge
|
options.maxChars = options.maxChars or math.huge
|
||||||
@@ -297,8 +298,11 @@ function module.init()
|
|||||||
end
|
end
|
||||||
return math.min(y,height)
|
return math.min(y,height)
|
||||||
end
|
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 character==nil or character=="" then return end
|
||||||
|
if options.censor then
|
||||||
|
character = character:gsub("[^ ]", options.censor)
|
||||||
|
end
|
||||||
if invertedColors then
|
if invertedColors then
|
||||||
gpu.setForeground(bg)
|
gpu.setForeground(bg)
|
||||||
gpu.setBackground(fg)
|
gpu.setBackground(fg)
|
||||||
@@ -400,6 +404,7 @@ function module.init()
|
|||||||
set(curPos(cur)," ",true)
|
set(curPos(cur)," ",true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local args = {event.pull("key_down", "clipboard", 0.5)}
|
local args = {event.pull("key_down", "clipboard", 0.5)}
|
||||||
local ctrlDown = _PUBLIC.keyboard.getCtrlDown()
|
local ctrlDown = _PUBLIC.keyboard.getCtrlDown()
|
||||||
|
|||||||
Reference in New Issue
Block a user