run lua commands from shell and other tweaks
This commit is contained in:
@@ -30,15 +30,8 @@ local page = UI.Page {
|
|||||||
getDisplayValues = function(_, row)
|
getDisplayValues = function(_, row)
|
||||||
row = Util.shallowCopy(row)
|
row = Util.shallowCopy(row)
|
||||||
|
|
||||||
local function tovalue(s)
|
|
||||||
if type(s) == 'table' then
|
|
||||||
return 'table'
|
|
||||||
end
|
|
||||||
return s
|
|
||||||
end
|
|
||||||
|
|
||||||
for k,v in pairs(row) do
|
for k,v in pairs(row) do
|
||||||
row[k] = tovalue(v)
|
row[k] = type(v) == 'table' and 'table' or v
|
||||||
end
|
end
|
||||||
|
|
||||||
return row
|
return row
|
||||||
@@ -95,30 +88,25 @@ local page = UI.Page {
|
|||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local updated = false
|
|
||||||
local timerId = os.startTimer(1)
|
local timerId = os.startTimer(1)
|
||||||
|
|
||||||
Event.addRoutine(function()
|
Event.addRoutine(function()
|
||||||
while true do
|
while true do
|
||||||
local _, id = os.pullEvent('timer')
|
local _, id = os.pullEvent('timer')
|
||||||
if id == timerId then
|
if id == timerId then
|
||||||
if updated then
|
while #page.grid.values > 100 do
|
||||||
while #page.grid.values > 100 do -- page.grid.height do
|
table.remove(page.grid.values)
|
||||||
table.remove(page.grid.values, 100) -- #page.grid.values)
|
|
||||||
end
|
end
|
||||||
updated = false
|
timerId = nil
|
||||||
page.grid:update()
|
page.grid:update()
|
||||||
page.grid:draw()
|
page.grid:draw()
|
||||||
page:sync()
|
page:sync()
|
||||||
end
|
end
|
||||||
timerId = os.startTimer(1)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local hookFunction = function(event, e)
|
local hookFunction = function(event, e)
|
||||||
if not page.filtered[event] and not page.paused and not (event == 'timer' and e[1] == timerId) then
|
if not page.filtered[event] and not page.paused and not (event == 'timer' and e[1] == timerId) then
|
||||||
updated = true
|
|
||||||
table.insert(page.grid.values, 1, {
|
table.insert(page.grid.values, 1, {
|
||||||
event = event,
|
event = event,
|
||||||
p1 = e[1],
|
p1 = e[1],
|
||||||
@@ -127,6 +115,7 @@ local hookFunction = function(event, e)
|
|||||||
p4 = e[4],
|
p4 = e[4],
|
||||||
p5 = e[5],
|
p5 = e[5],
|
||||||
})
|
})
|
||||||
|
timerId = timerId or os.startTimer(.1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,3 +6,49 @@ end
|
|||||||
|
|
||||||
_ENV.shell.setCompletionFunction("packages/common/edit.lua", c)
|
_ENV.shell.setCompletionFunction("packages/common/edit.lua", c)
|
||||||
_ENV.shell.setCompletionFunction("packages/common/hexedit.lua", c)
|
_ENV.shell.setCompletionFunction("packages/common/hexedit.lua", c)
|
||||||
|
|
||||||
|
_ENV.shell.registerHandler(function(env, command, args)
|
||||||
|
if command:match('^!') then
|
||||||
|
return {
|
||||||
|
title = 'lua',
|
||||||
|
path = table.concat({ command:match('^!(.+)'), table.unpack(args) }, ' '),
|
||||||
|
args = args,
|
||||||
|
load = function(s)
|
||||||
|
return function()
|
||||||
|
local fn, m
|
||||||
|
local wrapped
|
||||||
|
|
||||||
|
fn = load('return (' ..s.. ')', 'lua', nil, env)
|
||||||
|
|
||||||
|
if fn then
|
||||||
|
fn = load('return {' ..s.. '}', 'lua', nil, env)
|
||||||
|
wrapped = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if fn then
|
||||||
|
fn, m = pcall(fn)
|
||||||
|
if #m <= 1 and wrapped then
|
||||||
|
m = m[1]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
fn, m = load(s, 'lua', nil, env)
|
||||||
|
if fn then
|
||||||
|
fn, m = pcall(fn)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if fn then
|
||||||
|
if m or wrapped then
|
||||||
|
require('opus.util').print(m or 'nil')
|
||||||
|
else
|
||||||
|
print()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
_G.printError(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
env = env,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|||||||
@@ -4,3 +4,5 @@ packages/common/colors.lua urlfs https://raw.githubusercontent.com/kepler155c/op
|
|||||||
packages/common/cowsay.lua urlfs https://pastebin.com/raw/n00VQJsw
|
packages/common/cowsay.lua urlfs https://pastebin.com/raw/n00VQJsw
|
||||||
packages/common/calc.lua urlfs https://pastebin.com/raw/nAinUn1h
|
packages/common/calc.lua urlfs https://pastebin.com/raw/nAinUn1h
|
||||||
packages/common/write.lua urlfs https://pastebin.com/raw/RSyhCjqv
|
packages/common/write.lua urlfs https://pastebin.com/raw/RSyhCjqv
|
||||||
|
# pretty output
|
||||||
|
rom/modules/main/inpsect.lua urlfs https://raw.githubusercontent.com/kikito/inspect.lua/master/inspect.lua
|
||||||
|
|||||||
@@ -3,5 +3,6 @@
|
|||||||
run = "fileui --exec=debug.lua --title=debug",
|
run = "fileui --exec=debug.lua --title=debug",
|
||||||
title = "Debug",
|
title = "Debug",
|
||||||
category = "Apps",
|
category = "Apps",
|
||||||
|
iconExt = "\30\50\31\50\128\31\102\152\144\30\102\31\50\159\155\30\50\128\10\30\50\31\102\130\152\30\101\31\53\143\143\30\102\31\50\155\30\50\31\102\129\10\30\50\31\102\130\31\50\128\31\101\134\137\31\50\128\31\102\129",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,7 +219,9 @@ local s, m = pcall(function()
|
|||||||
UI:start()
|
UI:start()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
if turtle.setStatus then
|
||||||
turtle.setStatus('idle')
|
turtle.setStatus('idle')
|
||||||
|
end
|
||||||
|
|
||||||
_G._syslog = oldDebug
|
_G._syslog = oldDebug
|
||||||
if not s then error(m) end
|
if not s then error(m) end
|
||||||
|
|||||||
Reference in New Issue
Block a user