mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge branch 'master-MC1.10' of github.com:MightyPirates/OpenComputers into master-MC1.11
This commit is contained in:
commit
44e3b0ee46
@ -1,4 +1,7 @@
|
|||||||
function loadfile(filename, mode, env)
|
function loadfile(filename, mode, env)
|
||||||
|
if filename:sub(1,1) ~= "/" then
|
||||||
|
filename = (os.getenv("PWD") or "/") .. "/" .. filename
|
||||||
|
end
|
||||||
local handle, reason = require("filesystem").open(filename)
|
local handle, reason = require("filesystem").open(filename)
|
||||||
if not handle then
|
if not handle then
|
||||||
return nil, reason
|
return nil, reason
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
alias l="ls -lh"
|
alias l="ls -lhp"
|
||||||
alias ..="cd .."
|
alias ..="cd .."
|
||||||
alias df="df -h"
|
alias df="df -h"
|
||||||
|
|
||||||
|
@ -20,17 +20,13 @@ function event.register(key, callback, interval, times)
|
|||||||
local handler =
|
local handler =
|
||||||
{
|
{
|
||||||
key = key,
|
key = key,
|
||||||
times = times or 0,
|
times = times or math.huge,
|
||||||
callback = callback,
|
callback = callback,
|
||||||
interval = interval or math.huge,
|
interval = interval or math.huge,
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.timeout = computer.uptime() + handler.interval
|
handler.timeout = computer.uptime() + handler.interval
|
||||||
|
|
||||||
if not interval then
|
|
||||||
handler.times = math.huge
|
|
||||||
end
|
|
||||||
|
|
||||||
local id = 0
|
local id = 0
|
||||||
repeat
|
repeat
|
||||||
id = id + 1
|
id = id + 1
|
||||||
@ -60,8 +56,7 @@ local function dispatch(...)
|
|||||||
-- nil keys match anything
|
-- nil keys match anything
|
||||||
local key = handler.key
|
local key = handler.key
|
||||||
key = (key == nil and signal) or key
|
key = (key == nil and signal) or key
|
||||||
if key == signal or time >= handler.timeout then
|
if (signal and key == signal) or time >= handler.timeout then
|
||||||
|
|
||||||
-- push ticks to end of list (might be slightly faster to fire them last)
|
-- push ticks to end of list (might be slightly faster to fire them last)
|
||||||
table.insert(eligable, select(handler.key and 1 or 2, 1, {handler.callback, id}))
|
table.insert(eligable, select(handler.key and 1 or 2, 1, {handler.callback, id}))
|
||||||
|
|
||||||
@ -160,7 +155,7 @@ function event.listen(name, callback)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return event.register(name, callback, nil, nil)
|
return event.register(name, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
function event.onError(message)
|
function event.onError(message)
|
||||||
|
@ -27,6 +27,9 @@ keyboard.keys = {
|
|||||||
tab = 0x0F,
|
tab = 0x0F,
|
||||||
up = 0xC8,
|
up = 0xC8,
|
||||||
["end"] = 0xCF,
|
["end"] = 0xCF,
|
||||||
|
enter = 0x1C,
|
||||||
|
tab = 0x0F,
|
||||||
|
numpadenter = 0x9C,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Create inverse mapping for name lookup.
|
-- Create inverse mapping for name lookup.
|
||||||
|
@ -40,7 +40,7 @@ local function findFile(name, ext)
|
|||||||
for file in list do
|
for file in list do
|
||||||
files[file] = true
|
files[file] = true
|
||||||
end
|
end
|
||||||
if ext and unicode.sub(name, -(1 + unicode.len(ext))) == "." .. ext then
|
if ext and name:sub(-(1 + ext:len())) == "." .. ext then
|
||||||
-- Name already contains extension, prioritize.
|
-- Name already contains extension, prioritize.
|
||||||
if files[name] then
|
if files[name] then
|
||||||
return true, fs.concat(dir, name)
|
return true, fs.concat(dir, name)
|
||||||
@ -58,10 +58,10 @@ local function findFile(name, ext)
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if unicode.sub(name, 1, 1) == "/" then
|
if name:sub(1, 1) == "/" then
|
||||||
local found, where = findIn("/")
|
local found, where = findIn("/")
|
||||||
if found then return where end
|
if found then return where end
|
||||||
elseif unicode.sub(name, 1, 2) == "./" then
|
elseif name:sub(1, 2) == "./" then
|
||||||
local found, where = findIn(shell.getWorkingDirectory())
|
local found, where = findIn(shell.getWorkingDirectory())
|
||||||
if found then return where end
|
if found then return where end
|
||||||
else
|
else
|
||||||
@ -162,7 +162,7 @@ function shell.resolve(path, ext)
|
|||||||
return nil, "file not found"
|
return nil, "file not found"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if unicode.sub(path, 1, 1) == "/" then
|
if path:sub(1, 1) == "/" then
|
||||||
return fs.canonical(path)
|
return fs.canonical(path)
|
||||||
else
|
else
|
||||||
return fs.concat(shell.getWorkingDirectory(), path)
|
return fs.concat(shell.getWorkingDirectory(), path)
|
||||||
@ -198,13 +198,13 @@ function shell.parse(...)
|
|||||||
if not doneWithOptions and type(param) == "string" then
|
if not doneWithOptions and type(param) == "string" then
|
||||||
if param == "--" then
|
if param == "--" then
|
||||||
doneWithOptions = true -- stop processing options at `--`
|
doneWithOptions = true -- stop processing options at `--`
|
||||||
elseif unicode.sub(param, 1, 2) == "--" then
|
elseif param:sub(1, 2) == "--" then
|
||||||
if param:match("%-%-(.-)=") ~= nil then
|
if param:match("%-%-(.-)=") ~= nil then
|
||||||
options[param:match("%-%-(.-)=")] = param:match("=(.*)")
|
options[param:match("%-%-(.-)=")] = param:match("=(.*)")
|
||||||
else
|
else
|
||||||
options[unicode.sub(param, 3)] = true
|
options[param:sub(3)] = true
|
||||||
end
|
end
|
||||||
elseif unicode.sub(param, 1, 1) == "-" and param ~= "-" then
|
elseif param:sub(1, 1) == "-" and param ~= "-" then
|
||||||
for j = 2, unicode.len(param) do
|
for j = 2, unicode.len(param) do
|
||||||
options[unicode.sub(param, j, j)] = true
|
options[unicode.sub(param, j, j)] = true
|
||||||
end
|
end
|
||||||
|
@ -325,10 +325,11 @@ function term.readKeyboard(ops)
|
|||||||
hints.cache = nil
|
hints.cache = nil
|
||||||
local ctrl = kb.isControlDown(address)
|
local ctrl = kb.isControlDown(address)
|
||||||
if ctrl and code == keys.d then return
|
if ctrl and code == keys.d then return
|
||||||
elseif char == 9 then
|
elseif code == keys.tab then
|
||||||
hints.cache = backup_cache
|
hints.cache = backup_cache
|
||||||
term.internal.tab(input,hints)
|
term.internal.tab(input,hints)
|
||||||
elseif char == 13 and filter(input) then
|
elseif (code == keys.enter or code == keys.numpadenter)
|
||||||
|
and filter(input) then
|
||||||
input:move(math.huge)
|
input:move(math.huge)
|
||||||
if db ~= false then
|
if db ~= false then
|
||||||
draw("\n")
|
draw("\n")
|
||||||
@ -343,8 +344,8 @@ function term.readKeyboard(ops)
|
|||||||
elseif code == keys["end"] then input:move( math.huge)
|
elseif code == keys["end"] then input:move( math.huge)
|
||||||
elseif code == keys.back then c = -1
|
elseif code == keys.back then c = -1
|
||||||
elseif code == keys.delete then c = 0
|
elseif code == keys.delete then c = 0
|
||||||
elseif char >= 32 then c = unicode.char(char)
|
|
||||||
elseif ctrl and char == "w"then -- TODO: cut word
|
elseif ctrl and char == "w"then -- TODO: cut word
|
||||||
|
elseif char >= 32 then c = unicode.char(char)
|
||||||
else hints.cache = backup_cache -- ignored chars shouldn't clear hint cache
|
else hints.cache = backup_cache -- ignored chars shouldn't clear hint cache
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -43,11 +43,11 @@ local function stat(names, index)
|
|||||||
local info = {}
|
local info = {}
|
||||||
info.key = name
|
info.key = name
|
||||||
info.path = name:sub(1, 1) == "/" and "" or names.path
|
info.path = name:sub(1, 1) == "/" and "" or names.path
|
||||||
info.name = ops.p and name or name:gsub("/+$", "")
|
info.full_path = fs.concat(info.path, name)
|
||||||
info.sort_name = info.name:gsub("^%.","")
|
|
||||||
info.full_path = fs.concat(info.path, info.name)
|
|
||||||
info.isLink, info.link = fs.isLink(info.full_path)
|
|
||||||
info.isDir = fs.isDirectory(info.full_path)
|
info.isDir = fs.isDirectory(info.full_path)
|
||||||
|
info.name = name:gsub("/+$", "") .. (ops.p and info.isDir and "/" or "")
|
||||||
|
info.sort_name = info.name:gsub("^%.","")
|
||||||
|
info.isLink, info.link = fs.isLink(info.full_path)
|
||||||
info.size = info.isLink and 0 or fs.size(info.full_path)
|
info.size = info.isLink and 0 or fs.size(info.full_path)
|
||||||
info.time = fs.lastModified(info.full_path)
|
info.time = fs.lastModified(info.full_path)
|
||||||
info.fs = fs.get(info.full_path)
|
info.fs = fs.get(info.full_path)
|
||||||
|
@ -157,7 +157,7 @@ function --[[@delayloaded-start@]] lib.where(tbl,p,f,l)
|
|||||||
end,f,l)
|
end,f,l)
|
||||||
end --[[@delayloaded-end@]]
|
end --[[@delayloaded-end@]]
|
||||||
|
|
||||||
function --[[@delayloaded-start@]] lib.concat(...)
|
function lib.concat(...)
|
||||||
local r,rn,k={},0
|
local r,rn,k={},0
|
||||||
for _,tbl in ipairs({...})do
|
for _,tbl in ipairs({...})do
|
||||||
if type(tbl)~='table'then
|
if type(tbl)~='table'then
|
||||||
@ -171,7 +171,7 @@ function --[[@delayloaded-start@]] lib.concat(...)
|
|||||||
end
|
end
|
||||||
r.n=k and rn or nil
|
r.n=k and rn or nil
|
||||||
return r
|
return r
|
||||||
end --[[@delayloaded-end@]]
|
end
|
||||||
|
|
||||||
-- works with pairs on tables
|
-- works with pairs on tables
|
||||||
-- returns the kv pair, or nil and the number of pairs iterated
|
-- returns the kv pair, or nil and the number of pairs iterated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user