mirror of
https://github.com/kepler155c/opus
synced 2025-10-20 18:27:40 +00:00
better colors - resizing
This commit is contained in:
@@ -7,42 +7,39 @@ multishell.setTitle(multishell.getCurrent(), 'Help')
|
||||
UI:configure('Help', ...)
|
||||
|
||||
local files = { }
|
||||
for _,f in pairs(fs.list('/rom/help')) do
|
||||
for _,f in pairs(help.topics()) do
|
||||
table.insert(files, { name = f })
|
||||
end
|
||||
|
||||
local page = UI.Page({
|
||||
labelText = UI.Text({
|
||||
y = 2,
|
||||
x = 3,
|
||||
local page = UI.Page {
|
||||
labelText = UI.Text {
|
||||
x = 3, y = 2,
|
||||
value = 'Search',
|
||||
}),
|
||||
filter = UI.TextEntry({
|
||||
y = 2,
|
||||
x = 10,
|
||||
width = UI.term.width - 13,
|
||||
},
|
||||
filter = UI.TextEntry {
|
||||
x = 10, y = 2, ex = -3,
|
||||
limit = 32,
|
||||
}),
|
||||
grid = UI.ScrollingGrid({
|
||||
},
|
||||
grid = UI.ScrollingGrid {
|
||||
y = 4,
|
||||
height = UI.term.height - 4,
|
||||
values = files,
|
||||
columns = {
|
||||
{ heading = 'Name', key = 'name', width = 12 },
|
||||
{ heading = 'Name', key = 'name' },
|
||||
},
|
||||
sortColumn = 'name',
|
||||
}),
|
||||
statusBar = UI.StatusBar(),
|
||||
accelerators = {
|
||||
q = 'quit',
|
||||
},
|
||||
})
|
||||
accelerators = {
|
||||
q = 'quit',
|
||||
enter = 'grid_select',
|
||||
},
|
||||
}
|
||||
|
||||
local function showHelp(name)
|
||||
UI.term:reset()
|
||||
shell.run('help ' .. name)
|
||||
print('Press enter to return')
|
||||
repeat
|
||||
os.pullEvent('key')
|
||||
local _, k = os.pullEvent('key_up')
|
||||
until k == keys.enter
|
||||
end
|
||||
@@ -52,18 +49,13 @@ function page:eventHandler(event)
|
||||
if event.type == 'quit' then
|
||||
Event.exitPullEvents()
|
||||
|
||||
elseif event.type == 'key' and event.key == 'enter' then
|
||||
elseif event.type == 'grid_select' then
|
||||
if self.grid:getSelected() then
|
||||
showHelp(self.grid:getSelected().name)
|
||||
self:setFocus(self.filter)
|
||||
self:draw()
|
||||
end
|
||||
|
||||
elseif event.type == 'grid_select' then
|
||||
showHelp(event.selected.name)
|
||||
self:setFocus(self.filter)
|
||||
self:draw()
|
||||
|
||||
elseif event.type == 'text_change' then
|
||||
local text = event.text
|
||||
if #text == 0 then
|
||||
|
@@ -15,7 +15,7 @@ local gridColumns = {
|
||||
}
|
||||
|
||||
if UI.term.width >= 30 then
|
||||
table.insert(gridColumns, { heading = 'Fuel', key = 'fuel' })
|
||||
table.insert(gridColumns, { heading = 'Fuel', key = 'fuel', width = 5 })
|
||||
table.insert(gridColumns, { heading = 'Uptime', key = 'uptime' })
|
||||
end
|
||||
|
||||
|
@@ -94,8 +94,8 @@ local systemPage = UI.Page {
|
||||
},
|
||||
selectable = false,
|
||||
columns = {
|
||||
{ key = 'name', width = 12 },
|
||||
{ key = 'value', width = UI.term.width - 15 },
|
||||
{ key = 'name', width = 12 },
|
||||
{ key = 'value' },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -53,7 +53,7 @@ function shell.run(...)
|
||||
if path then
|
||||
tProgramStack[#tProgramStack + 1] = path
|
||||
local oldTitle
|
||||
|
||||
|
||||
if multishell and multishell.getTitle then
|
||||
oldTitle = multishell.getTitle(multishell.getCurrent())
|
||||
multishell.setTitle(multishell.getCurrent(), fs.getName(path))
|
||||
@@ -67,11 +67,9 @@ function shell.run(...)
|
||||
else
|
||||
result, err = Util.run(env, path, unpack(args))
|
||||
end
|
||||
tProgramStack[#tProgramStack] = nil
|
||||
|
||||
if multishell and multishell.getTitle then
|
||||
local title = 'shell'
|
||||
if #tProgramStack > 0 then
|
||||
title = fs.getName(tProgramStack[#tProgramStack])
|
||||
end
|
||||
multishell.setTitle(multishell.getCurrent(), oldTitle or 'shell')
|
||||
end
|
||||
|
||||
@@ -257,6 +255,7 @@ if #tArgs > 0 then
|
||||
if not fn then
|
||||
error(err)
|
||||
end
|
||||
|
||||
tProgramStack[#tProgramStack + 1] = path
|
||||
return fn(table.unpack(args))
|
||||
end
|
||||
|
Reference in New Issue
Block a user