mirror of
https://github.com/kepler155c/opus
synced 2025-01-03 20:30:28 +00:00
package manager update + UI built-in extended char detection
This commit is contained in:
parent
3f9c219f6b
commit
daa86d50b2
@ -39,15 +39,7 @@ function Packages:downloadList()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Packages:getManifest(package)
|
function Packages:downloadManifest(package)
|
||||||
local fname = 'packages/' .. package .. '/.package'
|
|
||||||
if fs.exists(fname) then
|
|
||||||
local c = Util.readTable(fname)
|
|
||||||
if c then
|
|
||||||
c.repository = c.repository:gsub('{{OPUS_BRANCH}}', _G.OPUS_BRANCH)
|
|
||||||
return c
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local list = self:list()
|
local list = self:list()
|
||||||
local url = list and list[package]
|
local url = list and list[package]
|
||||||
|
|
||||||
@ -63,4 +55,16 @@ function Packages:getManifest(package)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Packages:getManifest(package)
|
||||||
|
local fname = 'packages/' .. package .. '/.package'
|
||||||
|
if fs.exists(fname) then
|
||||||
|
local c = Util.readTable(fname)
|
||||||
|
if c and c.repository then
|
||||||
|
c.repository = c.repository:gsub('{{OPUS_BRANCH}}', _G.OPUS_BRANCH)
|
||||||
|
return c
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self:downloadManifest(package)
|
||||||
|
end
|
||||||
|
|
||||||
return Packages
|
return Packages
|
||||||
|
@ -35,6 +35,8 @@ end
|
|||||||
local Manager = class()
|
local Manager = class()
|
||||||
function Manager:init()
|
function Manager:init()
|
||||||
self.devices = { }
|
self.devices = { }
|
||||||
|
self.theme = { }
|
||||||
|
self.extChars = Util.getVersion() >= 1.76
|
||||||
|
|
||||||
local function keyFunction(event, code, held)
|
local function keyFunction(event, code, held)
|
||||||
local ie = Input:translate(event, code, held)
|
local ie = Input:translate(event, code, held)
|
||||||
@ -1195,37 +1197,7 @@ local function loadComponents()
|
|||||||
end
|
end
|
||||||
|
|
||||||
loadComponents()
|
loadComponents()
|
||||||
|
|
||||||
UI.theme = { }
|
|
||||||
if Util.getVersion() >= 1.76 then
|
|
||||||
UI.theme = {
|
|
||||||
ScrollBar = {
|
|
||||||
lineChar = '|',
|
|
||||||
sliderChar = '\127',
|
|
||||||
upArrowChar = '\30',
|
|
||||||
downArrowChar = '\31',
|
|
||||||
},
|
|
||||||
Checkbox = {
|
|
||||||
checkedIndicator = '\4',
|
|
||||||
leftMarker = '\124',
|
|
||||||
rightMarker = '\124',
|
|
||||||
},
|
|
||||||
Chooser = {
|
|
||||||
leftIndicator = '\17',
|
|
||||||
rightIndicator = '\16',
|
|
||||||
},
|
|
||||||
Grid = {
|
|
||||||
focusIndicator = '\183',
|
|
||||||
inverseSortIndicator = '\24',
|
|
||||||
},
|
|
||||||
TitleBar = {
|
|
||||||
frameChar = '\140',
|
|
||||||
closeInd = '\215',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
UI:loadTheme('usr/config/ui.theme')
|
UI:loadTheme('usr/config/ui.theme')
|
||||||
|
|
||||||
UI:setDefaultDevice(UI.Device({ device = term.current() }))
|
UI:setDefaultDevice(UI.Device({ device = term.current() }))
|
||||||
|
|
||||||
return UI
|
return UI
|
||||||
|
@ -7,9 +7,9 @@ UI.Checkbox = class(UI.Window)
|
|||||||
UI.Checkbox.defaults = {
|
UI.Checkbox.defaults = {
|
||||||
UIElement = 'Checkbox',
|
UIElement = 'Checkbox',
|
||||||
nochoice = 'Select',
|
nochoice = 'Select',
|
||||||
checkedIndicator = 'X',
|
checkedIndicator = UI.extChars and '\4' or 'X',
|
||||||
leftMarker = '[',
|
leftMarker = UI.extChars and '\124' or '[',
|
||||||
rightMarker = ']',
|
rightMarker = UI.extChars and '\124' or ']',
|
||||||
value = false,
|
value = false,
|
||||||
textColor = colors.white,
|
textColor = colors.white,
|
||||||
backgroundColor = colors.black,
|
backgroundColor = colors.black,
|
||||||
|
@ -11,8 +11,8 @@ UI.Chooser.defaults = {
|
|||||||
nochoice = 'Select',
|
nochoice = 'Select',
|
||||||
backgroundFocusColor = colors.lightGray,
|
backgroundFocusColor = colors.lightGray,
|
||||||
textInactiveColor = colors.gray,
|
textInactiveColor = colors.gray,
|
||||||
leftIndicator = '<',
|
leftIndicator = UI.extChars and '\17' or '<',
|
||||||
rightIndicator = '>',
|
rightIndicator = UI.extChars and '\16' or '>',
|
||||||
height = 1,
|
height = 1,
|
||||||
}
|
}
|
||||||
function UI.Chooser:setParent()
|
function UI.Chooser:setParent()
|
||||||
|
@ -65,9 +65,9 @@ UI.Grid.defaults = {
|
|||||||
headerSortColor = colors.yellow,
|
headerSortColor = colors.yellow,
|
||||||
unfocusedTextSelectedColor = colors.white,
|
unfocusedTextSelectedColor = colors.white,
|
||||||
unfocusedBackgroundSelectedColor = colors.gray,
|
unfocusedBackgroundSelectedColor = colors.gray,
|
||||||
focusIndicator = '>',
|
focusIndicator = UI.extChars and '\183' or '>',
|
||||||
sortIndicator = ' ',
|
sortIndicator = ' ',
|
||||||
inverseSortIndicator = '^',
|
inverseSortIndicator = UI.extChars and '\24' or '^',
|
||||||
values = { },
|
values = { },
|
||||||
columns = { },
|
columns = { },
|
||||||
accelerators = {
|
accelerators = {
|
||||||
|
@ -10,7 +10,9 @@ UI.Notification = class(UI.Window)
|
|||||||
UI.Notification.defaults = {
|
UI.Notification.defaults = {
|
||||||
UIElement = 'Notification',
|
UIElement = 'Notification',
|
||||||
backgroundColor = colors.gray,
|
backgroundColor = colors.gray,
|
||||||
|
closeInd = '\215',
|
||||||
height = 3,
|
height = 3,
|
||||||
|
timeout = 3,
|
||||||
}
|
}
|
||||||
function UI.Notification:draw()
|
function UI.Notification:draw()
|
||||||
end
|
end
|
||||||
@ -49,8 +51,8 @@ end
|
|||||||
|
|
||||||
function UI.Notification:display(value, timeout)
|
function UI.Notification:display(value, timeout)
|
||||||
self.enabled = true
|
self.enabled = true
|
||||||
local lines = Util.wordWrap(value, self.width - 2)
|
local lines = Util.wordWrap(value, self.width - 3)
|
||||||
self.height = #lines + 1
|
self.height = #lines
|
||||||
self.y = self.parent.height - self.height + 1
|
self.y = self.parent.height - self.height + 1
|
||||||
if self.canvas then
|
if self.canvas then
|
||||||
self.canvas:removeLayer()
|
self.canvas:removeLayer()
|
||||||
@ -63,9 +65,22 @@ function UI.Notification:display(value, timeout)
|
|||||||
for k,v in pairs(lines) do
|
for k,v in pairs(lines) do
|
||||||
self:write(2, k, v)
|
self:write(2, k, v)
|
||||||
end
|
end
|
||||||
|
self:write(self.width, 1, self.closeInd)
|
||||||
|
|
||||||
self.timer = Event.onTimeout(timeout or 3, function()
|
timeout = timeout or self.timeout
|
||||||
self:cancel()
|
if timeout > 0 then
|
||||||
self:sync()
|
self.timer = Event.onTimeout(timeout or self.timeout, function()
|
||||||
end)
|
self:cancel()
|
||||||
|
self:sync()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function UI.Notification:eventHandler(event)
|
||||||
|
if event.type == 'mouse_click' then
|
||||||
|
if event.x == self.width then
|
||||||
|
self:cancel()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -8,9 +8,9 @@ UI.ScrollBar = class(UI.Window)
|
|||||||
UI.ScrollBar.defaults = {
|
UI.ScrollBar.defaults = {
|
||||||
UIElement = 'ScrollBar',
|
UIElement = 'ScrollBar',
|
||||||
lineChar = '|',
|
lineChar = '|',
|
||||||
sliderChar = '#',
|
sliderChar = UI.extChars and '\127' or '#',
|
||||||
upArrowChar = '^',
|
upArrowChar = UI.extChars and '\30' or '^',
|
||||||
downArrowChar = 'v',
|
downArrowChar = UI.extChars and '\31' or 'v',
|
||||||
scrollbarColor = colors.lightGray,
|
scrollbarColor = colors.lightGray,
|
||||||
width = 1,
|
width = 1,
|
||||||
x = -1,
|
x = -1,
|
||||||
|
@ -41,8 +41,8 @@ UI.TitleBar.defaults = {
|
|||||||
textColor = colors.white,
|
textColor = colors.white,
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
title = '',
|
title = '',
|
||||||
frameChar = '-',
|
frameChar = UI.extChars and '\140' or '-',
|
||||||
closeInd = '*',
|
closeInd = UI.extChars and '\215' or '*',
|
||||||
}
|
}
|
||||||
function UI.TitleBar:draw()
|
function UI.TitleBar:draw()
|
||||||
local sb = SB(self.width)
|
local sb = SB(self.width)
|
||||||
|
@ -83,6 +83,7 @@ local Browser = UI.Page {
|
|||||||
{ key = 'totalSize', width = 6 },
|
{ key = 'totalSize', width = 6 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
notification = UI.Notification { },
|
||||||
associations = UI.SlideOut {
|
associations = UI.SlideOut {
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
menuBar = UI.MenuBar {
|
menuBar = UI.MenuBar {
|
||||||
@ -215,7 +216,7 @@ function Browser.statusBar:draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Browser:setStatus(status, ...)
|
function Browser:setStatus(status, ...)
|
||||||
self.statusBar:timedStatus(string.format(status, ...))
|
self.notification:info(string.format(status, ...))
|
||||||
end
|
end
|
||||||
|
|
||||||
function Browser:unmarkAll()
|
function Browser:unmarkAll()
|
||||||
|
@ -37,12 +37,6 @@ local page = UI.Page {
|
|||||||
x = 16, y = 3, ey = -5,
|
x = 16, y = 3, ey = -5,
|
||||||
marginRight = 0, marginLeft = 0,
|
marginRight = 0, marginLeft = 0,
|
||||||
},
|
},
|
||||||
load = UI.Button {
|
|
||||||
x = 22, y = -3,
|
|
||||||
text = 'Update packages',
|
|
||||||
event = 'reload',
|
|
||||||
help = 'Download the latest package list',
|
|
||||||
},
|
|
||||||
action = UI.SlideOut {
|
action = UI.SlideOut {
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
titleBar = UI.TitleBar {
|
titleBar = UI.TitleBar {
|
||||||
@ -144,10 +138,6 @@ function page:eventHandler(event)
|
|||||||
self.description:draw()
|
self.description:draw()
|
||||||
self:updateSelection(event.selected)
|
self:updateSelection(event.selected)
|
||||||
|
|
||||||
elseif event.type == 'reload' then
|
|
||||||
Packages:downloadList()
|
|
||||||
self:loadPackages()
|
|
||||||
|
|
||||||
elseif event.type == 'action' then
|
elseif event.type == 'action' then
|
||||||
local selected = self.grid:getSelected()
|
local selected = self.grid:getSelected()
|
||||||
if selected then
|
if selected then
|
||||||
@ -178,7 +168,11 @@ function page:eventHandler(event)
|
|||||||
UI.Page.eventHandler(self, event)
|
UI.Page.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
|
|
||||||
page:loadPackages()
|
|
||||||
|
|
||||||
UI:setPage(page)
|
UI:setPage(page)
|
||||||
|
page.statusBar:setStatus('Downloading...')
|
||||||
|
page:sync()
|
||||||
|
Packages:downloadList()
|
||||||
|
page:loadPackages()
|
||||||
|
page:sync()
|
||||||
|
|
||||||
UI:pullEvents()
|
UI:pullEvents()
|
||||||
|
@ -36,7 +36,7 @@ local function progress(max)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function install(name, isUpdate)
|
local function install(name, isUpdate)
|
||||||
local manifest = Packages:getManifest(name) or error('Invalid package')
|
local manifest = Packages:downloadManifest(name) or error('Invalid package')
|
||||||
|
|
||||||
if manifest.required then
|
if manifest.required then
|
||||||
for _, v in pairs(manifest.required) do
|
for _, v in pairs(manifest.required) do
|
||||||
|
Loading…
Reference in New Issue
Block a user