mirror of
https://github.com/kepler155c/opus
synced 2025-01-03 20:30:28 +00:00
stack traces
This commit is contained in:
parent
a4145951f7
commit
89f95ca45b
@ -567,24 +567,21 @@ function Util.widthify(s, len, align)
|
||||
|
||||
if slen > len then
|
||||
return _ssub(s, 1, len)
|
||||
|
||||
elseif slen == len then
|
||||
return s
|
||||
end
|
||||
|
||||
if align == 'center' then
|
||||
local space = math.floor((len-slen) / 2)
|
||||
local filler = _srep(' ', space + 1)
|
||||
s = _ssub(filler, 1, space) .. s
|
||||
s = s .. _srep(' ', len - #s)
|
||||
elseif align == 'center' then
|
||||
local space = math.floor((len - slen) / 2)
|
||||
s = _srep(' ', space) .. s
|
||||
return s .. _srep(' ', len - #s)
|
||||
|
||||
elseif align == 'right' then
|
||||
s = _srep(' ', len - #s) .. s
|
||||
return _srep(' ', len - slen) .. s
|
||||
|
||||
else -- 'left'
|
||||
s = s .. _srep(' ', len - #s)
|
||||
end
|
||||
|
||||
return s
|
||||
return s .. _srep(' ', len - slen)
|
||||
end
|
||||
|
||||
-- http://snippets.luacode.org/?p=snippets/trim_whitespace_from_string_76
|
||||
|
@ -15,17 +15,17 @@ UI:configure('Network', ...)
|
||||
|
||||
local gridColumns = {
|
||||
{ heading = 'Label', key = 'label' },
|
||||
{ heading = 'Dist', key = 'distance' },
|
||||
{ heading = 'Dist', key = 'distance', align = 'right' },
|
||||
{ heading = 'Status', key = 'status' },
|
||||
}
|
||||
|
||||
local config = Config.load('network', { })
|
||||
|
||||
if UI.term.width >= 30 then
|
||||
table.insert(gridColumns, { heading = 'Fuel', key = 'fuel', width = 5 })
|
||||
table.insert(gridColumns, { heading = 'Fuel', key = 'fuel', width = 5, align = 'right' })
|
||||
end
|
||||
if UI.term.width >= 40 then
|
||||
table.insert(gridColumns, { heading = 'Uptime', key = 'uptime' })
|
||||
table.insert(gridColumns, { heading = 'Uptime', key = 'uptime', align = 'right' })
|
||||
end
|
||||
|
||||
local page = UI.Page {
|
||||
@ -262,8 +262,10 @@ function page.grid:getDisplayValues(row)
|
||||
if row.uptime then
|
||||
if row.uptime < 60 then
|
||||
row.uptime = string.format("%ds", math.floor(row.uptime))
|
||||
elseif row.uptime < 3600 then
|
||||
row.uptime = string.format("%sm", math.floor(row.uptime / 60))
|
||||
else
|
||||
row.uptime = string.format("%sm", math.floor(row.uptime/6)/10)
|
||||
row.uptime = string.format("%sh", math.floor(row.uptime / 3600))
|
||||
end
|
||||
end
|
||||
if row.fuel then
|
||||
|
@ -13,6 +13,7 @@ sandboxEnv.shell = shell
|
||||
|
||||
_G.requireInjector(_ENV)
|
||||
|
||||
local trace = require('trace')
|
||||
local Util = require('util')
|
||||
|
||||
local DIR = (parentShell and parentShell.dir()) or ""
|
||||
@ -88,7 +89,7 @@ function shell.run(...)
|
||||
local env = setmetatable(Util.shallowCopy(sandboxEnv), { __index = _G })
|
||||
_G.requireInjector(env)
|
||||
|
||||
local r = { pcall(run, env, ...) }
|
||||
local r = { trace(run, env, ...) }
|
||||
|
||||
if _ENV.multishell then
|
||||
_ENV.multishell.setTitle(_ENV.multishell.getCurrent(), oldTitle or 'shell')
|
||||
|
@ -139,7 +139,7 @@ function multishell.openTab(tab)
|
||||
if err then
|
||||
printError(tostring(err))
|
||||
if stacktrace then -- alternatively log stack to _debug
|
||||
print('\n' .. stacktrace)
|
||||
--print('\n' .. stacktrace)
|
||||
end
|
||||
end
|
||||
print('\nPress enter to close')
|
||||
|
Loading…
Reference in New Issue
Block a user