mirror of
https://github.com/kepler155c/opus
synced 2025-01-29 00:24:46 +00:00
tweaks
This commit is contained in:
parent
424fff7842
commit
28b2ba3386
@ -8,12 +8,10 @@ UI:configure('Help', ...)
|
|||||||
|
|
||||||
local topics = { }
|
local topics = { }
|
||||||
for _,topic in pairs(help.topics()) do
|
for _,topic in pairs(help.topics()) do
|
||||||
if help.lookup(topic) then
|
table.insert(topics, { name = topic, lname = topic:lower() })
|
||||||
table.insert(topics, { name = topic })
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local page = UI.Page {
|
UI:addPage('main', UI.Page {
|
||||||
labelText = UI.Text {
|
labelText = UI.Text {
|
||||||
x = 3, y = 2,
|
x = 3, y = 2,
|
||||||
value = 'Search',
|
value = 'Search',
|
||||||
@ -21,7 +19,6 @@ local page = UI.Page {
|
|||||||
filter = UI.TextEntry {
|
filter = UI.TextEntry {
|
||||||
x = 10, y = 2, ex = -3,
|
x = 10, y = 2, ex = -3,
|
||||||
limit = 32,
|
limit = 32,
|
||||||
transform = 'lowercase',
|
|
||||||
},
|
},
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 4,
|
y = 4,
|
||||||
@ -29,15 +26,44 @@ local page = UI.Page {
|
|||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Topic', key = 'name' },
|
{ heading = 'Topic', key = 'name' },
|
||||||
},
|
},
|
||||||
sortColumn = 'name',
|
sortColumn = 'lname',
|
||||||
},
|
},
|
||||||
accelerators = {
|
accelerators = {
|
||||||
[ 'control-q' ] = 'quit',
|
[ 'control-q' ] = 'quit',
|
||||||
enter = 'grid_select',
|
enter = 'grid_select',
|
||||||
},
|
},
|
||||||
}
|
eventHandler = function(self, event)
|
||||||
|
if event.type == 'quit' then
|
||||||
|
UI:quit()
|
||||||
|
|
||||||
local topicPage = UI.Page {
|
elseif event.type == 'grid_select' then
|
||||||
|
if self.grid:getSelected() then
|
||||||
|
local name = self.grid:getSelected().name
|
||||||
|
|
||||||
|
UI:setPage('topic', name)
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif event.type == 'text_change' then
|
||||||
|
if not event.text then
|
||||||
|
self.grid.values = topics
|
||||||
|
else
|
||||||
|
self.grid.values = { }
|
||||||
|
for _,f in pairs(topics) do
|
||||||
|
if string.find(f.lname, event.text:lower()) then
|
||||||
|
table.insert(self.grid.values, f)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.grid:update()
|
||||||
|
self.grid:setIndex(1)
|
||||||
|
self.grid:draw()
|
||||||
|
else
|
||||||
|
return UI.Page.eventHandler(self, event)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
UI:addPage('topic', UI.Page {
|
||||||
backgroundColor = colors.black,
|
backgroundColor = colors.black,
|
||||||
titleBar = UI.TitleBar {
|
titleBar = UI.TitleBar {
|
||||||
title = 'text',
|
title = 'text',
|
||||||
@ -51,54 +77,22 @@ local topicPage = UI.Page {
|
|||||||
[ 'control-q' ] = 'back',
|
[ 'control-q' ] = 'back',
|
||||||
backspace = 'back',
|
backspace = 'back',
|
||||||
},
|
},
|
||||||
}
|
enable = function(self, name)
|
||||||
|
local f = help.lookup(name)
|
||||||
|
|
||||||
function topicPage:enable(name)
|
self.titleBar.title = name
|
||||||
local f = help.lookup(name)
|
self.helpText:setText(f and Util.readFile(f) or 'No help available for ' .. name)
|
||||||
|
|
||||||
self.titleBar.title = name
|
return UI.Page.enable(self)
|
||||||
self.helpText:setText(f and Util.readFile(f) or 'No help available for ' .. name)
|
end,
|
||||||
|
eventHandler = function(self, event)
|
||||||
return UI.Page.enable(self)
|
if event.type == 'back' then
|
||||||
end
|
UI:setPage('main')
|
||||||
|
|
||||||
function topicPage:eventHandler(event)
|
|
||||||
if event.type == 'back' then
|
|
||||||
UI:setPage(page)
|
|
||||||
end
|
|
||||||
return UI.Page.eventHandler(self, event)
|
|
||||||
end
|
|
||||||
|
|
||||||
function page:eventHandler(event)
|
|
||||||
if event.type == 'quit' then
|
|
||||||
UI:exitPullEvents()
|
|
||||||
|
|
||||||
elseif event.type == 'grid_select' then
|
|
||||||
if self.grid:getSelected() then
|
|
||||||
local name = self.grid:getSelected().name
|
|
||||||
|
|
||||||
UI:setPage(topicPage, name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif event.type == 'text_change' then
|
|
||||||
if not event.text then
|
|
||||||
self.grid.values = topics
|
|
||||||
else
|
|
||||||
self.grid.values = { }
|
|
||||||
for _,f in pairs(topics) do
|
|
||||||
if string.find(f.name, event.text) then
|
|
||||||
table.insert(self.grid.values, f)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.grid:update()
|
|
||||||
self.grid:setIndex(1)
|
|
||||||
self.grid:draw()
|
|
||||||
else
|
|
||||||
return UI.Page.eventHandler(self, event)
|
return UI.Page.eventHandler(self, event)
|
||||||
end
|
end,
|
||||||
end
|
})
|
||||||
|
|
||||||
local args = Util.parse(...)
|
local args = Util.parse(...)
|
||||||
UI:setPage(args[1] and topicPage or page, args[1])
|
UI:setPage(args[1] and 'topic' or 'main', args[1])
|
||||||
UI:pullEvents()
|
UI:start()
|
||||||
|
@ -27,6 +27,12 @@ local DEFAULT_ICON = NFT.parse("\0308\0317\153\153\153\153\153\
|
|||||||
\0307\0318\153\153\153\153\153\
|
\0307\0318\153\153\153\153\153\
|
||||||
\0308\0317\153\153\153\153\153")
|
\0308\0317\153\153\153\153\153")
|
||||||
|
|
||||||
|
-- overview
|
||||||
|
local uid = _ENV.multishell.getCurrent()
|
||||||
|
device.keyboard.addHotkey('control-o', function()
|
||||||
|
_ENV.multishell.setFocus(uid)
|
||||||
|
end)
|
||||||
|
|
||||||
UI:configure('Overview', ...)
|
UI:configure('Overview', ...)
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
|
@ -4,58 +4,45 @@ local kernel = _G.kernel
|
|||||||
local keyboard = _G.device.keyboard
|
local keyboard = _G.device.keyboard
|
||||||
local multishell = _ENV.multishell
|
local multishell = _ENV.multishell
|
||||||
|
|
||||||
if not multishell or not multishell.getTabs then
|
if multishell and multishell.getTabs then
|
||||||
return
|
-- restart tab
|
||||||
end
|
keyboard.addHotkey('control-backspace', function()
|
||||||
|
local tab = kernel.getFocused()
|
||||||
-- overview
|
if tab and not tab.noTerminate then
|
||||||
keyboard.addHotkey('control-o', function()
|
multishell.terminate(tab.uid)
|
||||||
for _,tab in pairs(multishell.getTabs()) do
|
multishell.openTab({
|
||||||
if tab.isOverview then
|
path = tab.path,
|
||||||
multishell.setFocus(tab.uid)
|
env = tab.env,
|
||||||
|
args = tab.args,
|
||||||
|
focused = true,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
end)
|
end
|
||||||
|
|
||||||
-- restart tab
|
|
||||||
keyboard.addHotkey('control-backspace', function()
|
|
||||||
local uid = multishell.getFocus()
|
|
||||||
local tab = kernel.find(uid)
|
|
||||||
if not tab.isOverview then
|
|
||||||
multishell.terminate(uid)
|
|
||||||
multishell.openTab({
|
|
||||||
path = tab.path,
|
|
||||||
env = tab.env,
|
|
||||||
args = tab.args,
|
|
||||||
focused = true,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- next tab
|
-- next tab
|
||||||
keyboard.addHotkey('control-tab', function()
|
keyboard.addHotkey('control-tab', function()
|
||||||
local tabs = multishell.getTabs()
|
|
||||||
local visibleTabs = { }
|
local visibleTabs = { }
|
||||||
local currentTabId = multishell.getFocus()
|
local currentTab = kernel.getFocused()
|
||||||
|
|
||||||
local function compareTab(a, b)
|
local function compareTab(a, b)
|
||||||
return a.uid < b.uid
|
return a.uid < b.uid
|
||||||
end
|
end
|
||||||
for _,tab in Util.spairs(tabs, compareTab) do
|
for _,tab in Util.spairs(kernel.routines, compareTab) do
|
||||||
if not tab.hidden and not tab.noFocus then
|
if not tab.hidden and not tab.noFocus then
|
||||||
table.insert(visibleTabs, tab)
|
table.insert(visibleTabs, tab)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for k,tab in ipairs(visibleTabs) do
|
for k,tab in ipairs(visibleTabs) do
|
||||||
if tab.uid == currentTabId then
|
if tab.uid == currentTab.uid then
|
||||||
if k < #visibleTabs then
|
if k < #visibleTabs then
|
||||||
multishell.setFocus(visibleTabs[k + 1].uid)
|
kernel.raise(visibleTabs[k + 1].uid)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #visibleTabs > 0 then
|
if #visibleTabs > 0 then
|
||||||
multishell.setFocus(visibleTabs[1].uid)
|
kernel.raise(visibleTabs[1].uid)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -50,16 +50,9 @@ local function systemLog()
|
|||||||
keyboard.removeHotkey('control-d')
|
keyboard.removeHotkey('control-d')
|
||||||
end
|
end
|
||||||
|
|
||||||
if multishell and multishell.openTab then
|
kernel.run({
|
||||||
multishell.openTab({
|
title = 'System Log',
|
||||||
title = 'System Log',
|
fn = systemLog,
|
||||||
fn = systemLog,
|
noTerminate = true,
|
||||||
noTerminate = true,
|
hidden = true,
|
||||||
hidden = true,
|
})
|
||||||
})
|
|
||||||
else
|
|
||||||
kernel.run({
|
|
||||||
title = 'Syslog',
|
|
||||||
fn = systemLog,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
@ -18,3 +18,7 @@ deleteIfExists('sys/autorun/gpshost.lua')
|
|||||||
deleteIfExists('sys/apps/network/redserver.lua')
|
deleteIfExists('sys/apps/network/redserver.lua')
|
||||||
deleteIfExists('sys/apis')
|
deleteIfExists('sys/apis')
|
||||||
deleteIfExists('sys/autorun/apps.lua')
|
deleteIfExists('sys/autorun/apps.lua')
|
||||||
|
deleteIfExists('sys/init/6.tl3.lua')
|
||||||
|
|
||||||
|
-- remove this file
|
||||||
|
deleteIfExists('sys/autorun/upgraded.lua')
|
@ -388,9 +388,9 @@ function Manager:pullEvents(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Manager:exitPullEvents()
|
Manager.exitPullEvents = Event.exitPullEvents
|
||||||
Event.exitPullEvents()
|
Manager.quit = Event.exitPullEvents
|
||||||
end
|
Manager.start = Manager.pullEvents
|
||||||
|
|
||||||
local UI = Manager()
|
local UI = Manager()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user