1
0
mirror of https://github.com/kepler155c/opus synced 2024-12-27 00:50:26 +00:00

overview cleanup + chooser better events

This commit is contained in:
kepler155c@gmail.com 2018-11-12 20:21:35 -05:00
parent f9359cf77f
commit 62ac7a52ec
2 changed files with 17 additions and 16 deletions

View File

@ -3001,22 +3001,26 @@ function UI.Chooser:eventHandler(event)
if event.type == 'key' then
if event.key == 'right' or event.key == 'space' then
local _,k = Util.find(self.choices, 'value', self.value)
local choice
if k and k < #self.choices then
self.value = self.choices[k+1].value
choice = self.choices[k+1]
else
self.value = self.choices[1].value
choice = self.choices[1]
end
self:emit({ type = 'choice_change', value = self.value })
self.value = choice.value
self:emit({ type = 'choice_change', value = self.value, element = self, choice = choice })
self:draw()
return true
elseif event.key == 'left' then
local _,k = Util.find(self.choices, 'value', self.value)
local choice
if k and k > 1 then
self.value = self.choices[k-1].value
choice = self.choices[k-1]
else
self.value = self.choices[#self.choices].value
choice = self.choices[#self.choices]
end
self:emit({ type = 'choice_change', value = self.value })
self.value = choice.value
self:emit({ type = 'choice_change', value = self.value, element = self, choice = choice })
self:draw()
return true
end

View File

@ -37,12 +37,12 @@ local extSupport = Util.getVersion() >= 1.76
local function loadApplications()
local requirements = {
turtle = function() return turtle end,
advancedTurtle = function() return turtle and term.isColor() end,
advanced = function() return term.isColor() end,
pocket = function() return pocket end,
advancedPocket = function() return pocket and term.isColor() end,
advancedComputer = function() return not turtle and not pocket and term.isColor() end,
turtle = not not turtle,
advancedTurtle = turtle and term.isColor(),
advanced = term.isColor(),
pocket = not not pocket,
advancedPocket = pocket and term.isColor(),
advancedComputer = not turtle and not pocket and term.isColor(),
}
applications = Util.readTable('sys/etc/app.db')
@ -76,10 +76,7 @@ local function loadApplications()
end
if a.requires then
local fn = requirements[a.requires]
if fn and not fn() then
return false
end
return requirements[a.requires]
end
return true -- Util.startsWith(a.run, 'http') or shell.resolveProgram(a.run)