alot of stuff
This commit is contained in:
@@ -520,6 +520,7 @@ function lib.setupENV(win)
|
||||
if http then load_apis("rom/apis/http") end
|
||||
if turtle then load_apis("rom/apis/turtle") end
|
||||
if pocket then load_apis("rom/apis/pocket") end
|
||||
env.shell = shell
|
||||
env._ENV = env
|
||||
env._G = env
|
||||
|
||||
@@ -534,7 +535,7 @@ local function generate_id(length)
|
||||
return id
|
||||
end
|
||||
|
||||
local function runInRuntime(func, win)
|
||||
local function runInRuntime(func, win, close_handled)
|
||||
expect(1, func, "function")
|
||||
expect(2, win, "table")
|
||||
local co = coroutine.create(func)
|
||||
@@ -570,8 +571,14 @@ local function runInRuntime(func, win)
|
||||
os.queueEvent("key_up_" .. winid, key, winid)
|
||||
end
|
||||
|
||||
function win.closeRequested()
|
||||
run = false
|
||||
function win.resized()
|
||||
os.queueEvent("term_resize_"..winid, winid)
|
||||
end
|
||||
|
||||
if close_handled then
|
||||
function win.closeRequested()
|
||||
run = false
|
||||
end
|
||||
end
|
||||
|
||||
local function escape_lua_pattern(s)
|
||||
@@ -628,6 +635,11 @@ local function runInRuntime(func, win)
|
||||
data.n = data.n - 1
|
||||
event_data = data
|
||||
end
|
||||
elseif data[1] == "term_resize" then
|
||||
if data[#data] == winid then
|
||||
data.n = data.n - 1
|
||||
event_data = data
|
||||
end
|
||||
else
|
||||
event_data = data
|
||||
end
|
||||
@@ -637,13 +649,13 @@ local function runInRuntime(func, win)
|
||||
end
|
||||
end
|
||||
|
||||
function lib.runFunc(func, win)
|
||||
runInRuntime(setfenv(func, lib.setupENV(win)), win)
|
||||
function lib.runFunc(func, win, close_handled)
|
||||
runInRuntime(setfenv(func, lib.setupENV(win)), win, close_handled)
|
||||
end
|
||||
|
||||
function lib.runFile(file, win)
|
||||
function lib.runFile(file, win, close_handled)
|
||||
local func = loadfile(file)
|
||||
runInRuntime(setfenv(func, lib.setupENV(win)), win)
|
||||
runInRuntime(setfenv(func, lib.setupENV(win)), win, close_handled)
|
||||
end
|
||||
|
||||
return lib
|
||||
|
||||
@@ -65,6 +65,8 @@ function lib.create(name, w, h, x, y)
|
||||
name = name,
|
||||
w = w,
|
||||
h = h,
|
||||
min_w = 3,
|
||||
min_h = 3,
|
||||
x = x or 1,
|
||||
y = y or 2,
|
||||
|
||||
@@ -75,6 +77,8 @@ function lib.create(name, w, h, x, y)
|
||||
textColor = colors.white,
|
||||
bgColor = colors.black,
|
||||
cursorBlink = false,
|
||||
resizable = true,
|
||||
draggable = true,
|
||||
decorations = true,
|
||||
alwaysOnTop = false,
|
||||
alwaysBelow = false,
|
||||
@@ -96,6 +100,7 @@ function lib.create(name, w, h, x, y)
|
||||
init_col(xi)
|
||||
for yy = 1, t.h do
|
||||
local cell = t.buffer[xi][yy]
|
||||
if not cell then cell = { char = " ", tc = t.textColor, bc = t.bgColor } end
|
||||
cell.char, cell.tc, cell.bc = " ", t.textColor, t.bgColor
|
||||
end
|
||||
end
|
||||
@@ -286,6 +291,8 @@ function lib.create(name, w, h, x, y)
|
||||
|
||||
function t.key_up(key) end
|
||||
|
||||
function t.resized(w,h) end
|
||||
|
||||
function t.closeRequested() t.closing = true end
|
||||
|
||||
function t.close()
|
||||
|
||||
Reference in New Issue
Block a user