Merge branch 'master' of https://github.com/magik6k/OpenComputers into master-MC1.7.10

This commit is contained in:
Florian Nücke 2015-01-15 16:41:19 +01:00
commit 17a4394ba4

View File

@ -108,10 +108,11 @@ function term.isAvailable()
return component.isAvailable("gpu") and component.isAvailable("screen") return component.isAvailable("gpu") and component.isAvailable("screen")
end end
function term.read(history, dobreak, hint, pwchar) function term.read(history, dobreak, hint, pwchar, match)
checkArg(1, history, "table", "nil") checkArg(1, history, "table", "nil")
checkArg(3, hint, "function", "table", "nil") checkArg(3, hint, "function", "table", "nil")
checkArg(4, pwchar, "string", "nil") checkArg(4, pwchar, "string", "nil")
checkArg(5, match, "string", "function", "nil")
history = history or {} history = history or {}
table.insert(history, "") table.insert(history, "")
local offset = term.getCursor() - 1 local offset = term.getCursor() - 1
@ -327,12 +328,16 @@ function term.read(history, dobreak, hint, pwchar)
elseif code == keyboard.keys.tab and hint then elseif code == keyboard.keys.tab and hint then
tab(keyboard.isShiftDown() and -1 or 1) tab(keyboard.isShiftDown() and -1 or 1)
elseif code == keyboard.keys.enter then elseif code == keyboard.keys.enter then
local cbx, cby = getCursor() if not match or (type(match) == "string" and match:match(line() or "")) or (type(match) == "function" and match(line() or "")) then
if cby ~= #history then -- bring entry to front local cbx, cby = getCursor()
history[#history] = line() if cby ~= #history then -- bring entry to front
table.remove(history, cby) history[#history] = line()
table.remove(history, cby)
end
return true, history[#history] .. "\n"
else
computer.beep(2000, 0.1)
end end
return true, history[#history] .. "\n"
elseif keyboard.isControlDown() and code == keyboard.keys.d then elseif keyboard.isControlDown() and code == keyboard.keys.d then
if line() == "" then if line() == "" then
history[#history] = "" history[#history] = ""