run lua commands from shell and other tweaks
This commit is contained in:
@@ -30,15 +30,8 @@ local page = UI.Page {
|
||||
getDisplayValues = function(_, 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
|
||||
row[k] = tovalue(v)
|
||||
row[k] = type(v) == 'table' and 'table' or v
|
||||
end
|
||||
|
||||
return row
|
||||
@@ -95,30 +88,25 @@ local page = UI.Page {
|
||||
end,
|
||||
}
|
||||
|
||||
local updated = false
|
||||
local timerId = os.startTimer(1)
|
||||
|
||||
Event.addRoutine(function()
|
||||
while true do
|
||||
local _, id = os.pullEvent('timer')
|
||||
if id == timerId then
|
||||
if updated then
|
||||
while #page.grid.values > 100 do -- page.grid.height do
|
||||
table.remove(page.grid.values, 100) -- #page.grid.values)
|
||||
end
|
||||
updated = false
|
||||
page.grid:update()
|
||||
page.grid:draw()
|
||||
page:sync()
|
||||
while #page.grid.values > 100 do
|
||||
table.remove(page.grid.values)
|
||||
end
|
||||
timerId = os.startTimer(1)
|
||||
timerId = nil
|
||||
page.grid:update()
|
||||
page.grid:draw()
|
||||
page:sync()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local hookFunction = function(event, e)
|
||||
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, {
|
||||
event = event,
|
||||
p1 = e[1],
|
||||
@@ -127,6 +115,7 @@ local hookFunction = function(event, e)
|
||||
p4 = e[4],
|
||||
p5 = e[5],
|
||||
})
|
||||
timerId = timerId or os.startTimer(.1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,3 +6,49 @@ end
|
||||
|
||||
_ENV.shell.setCompletionFunction("packages/common/edit.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/calc.lua urlfs https://pastebin.com/raw/nAinUn1h
|
||||
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",
|
||||
title = "Debug",
|
||||
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()
|
||||
end)
|
||||
|
||||
turtle.setStatus('idle')
|
||||
if turtle.setStatus then
|
||||
turtle.setStatus('idle')
|
||||
end
|
||||
|
||||
_G._syslog = oldDebug
|
||||
if not s then error(m) end
|
||||
|
||||
Reference in New Issue
Block a user