From 983185f5f22ff3837e997fc846612360c56dbedd Mon Sep 17 00:00:00 2001 From: payonel Date: Sun, 21 Jan 2018 17:42:04 -0800 Subject: [PATCH 1/3] fix vt code for scroll --- .../assets/opencomputers/loot/openos/lib/core/full_vt.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua index a69b4b6a9..fa56aaf86 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua @@ -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 From 7e776621601bb6cd03bf8dd148746c3927a20a72 Mon Sep 17 00:00:00 2001 From: payonel Date: Sun, 21 Jan 2018 18:03:42 -0800 Subject: [PATCH 2/3] for clear line use gpu fill and not set --- .../assets/opencomputers/loot/openos/lib/core/full_vt.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua index fa56aaf86..de6a64eb1 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua @@ -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 From 03c0fda5303deae90c8f309251a608d370c58c55 Mon Sep 17 00:00:00 2001 From: payonel Date: Fri, 26 Jan 2018 20:28:21 -0800 Subject: [PATCH 3/3] remove mem leak is load intercept --- .../loot/openos/boot/01_process.lua | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/boot/01_process.lua b/src/main/resources/assets/opencomputers/loot/openos/boot/01_process.lua index 6b9943e69..0829e7372 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/boot/01_process.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/boot/01_process.lua @@ -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