Merge branch master-MC1.10 into master-MC1.11

This commit is contained in:
payonel 2018-01-28 12:28:45 -08:00
commit 57de51b8b8
2 changed files with 12 additions and 26 deletions

View File

@ -25,30 +25,16 @@ package.loaded.coroutine = _G.coroutine
local kernel_load = _G.load
local intercept_load
intercept_load = function(source, label, mode, env)
if env then
local prev_load = env.load or intercept_load
local next_load = function(_source, _label, _mode, _env)
local prev_load = env and env.load or _G.load
local e = env and setmetatable({
load = function(_source, _label, _mode, _env)
return prev_load(_source, _label, _mode, _env or env)
end
if rawget(env, "load") then -- overwrite load
env.load = next_load
else -- else it must be an __index load, or it didn't have one
local env_mt = getmetatable(env) or {}
local env_mt_index = env_mt.__index
env_mt.__index = function(tbl, key)
if key == "load" then
return next_load
elseif type(env_mt_index) == "table" then
return env_mt_index[key]
elseif env_mt_index then
return env_mt_index(tbl, key)
end
return nil
end
setmetatable(env, env_mt)
end
end
return kernel_load(source, label, mode, env or process.info().env)
end}, {
__index = env,
__pairs = function(...) return pairs(env, ...) end,
__newindex = function(tbl, key, value) env[key] = value end,
})
return kernel_load(source, label, mode, e or process.info().env)
end
_G.load = intercept_load

View File

@ -47,7 +47,7 @@ local function clear_line(window, _, n)
n = tonumber(n) or 0
local x = n == 0 and window.x or 1
local rep = n == 1 and window.x or window.width
window.gpu.set(x, window.y, (" "):rep(rep))
window.gpu.fill(x, window.y, rep, 1, " ")
end
rules[{"%[", "[012]?", "K"}] = clear_line
@ -81,13 +81,13 @@ end
-- D scroll up one line -- moves cursor down
-- E move to next line (acts the same ^, but x=1)
-- M scroll down one line -- moves cursor up
rules[{"[DEM]"}] = function(window, dir)
rules[{"%[", "[DEM]"}] = function(window, _, dir)
if dir == "D" then
window.y = window.y + 1
elseif dir == "E" then
window.y = window.y + 1
window.x = 1
else -- M
window.y = window.y - 1
window.y = window.y - 1
end
end