color rework + cleanup
This commit is contained in:
@@ -184,9 +184,7 @@ local Browser = UI.Page {
|
||||
text = 'Add', event = 'add_association',
|
||||
},
|
||||
},
|
||||
statusBar = UI.StatusBar {
|
||||
backgroundColor = colors.cyan,
|
||||
},
|
||||
statusBar = UI.StatusBar { },
|
||||
},
|
||||
accelerators = {
|
||||
[ 'control-q' ] = 'quit',
|
||||
@@ -547,6 +545,4 @@ local args = Util.parse(...)
|
||||
Browser:setDir(args[1] or shell.dir())
|
||||
|
||||
UI:setPage(Browser)
|
||||
|
||||
Event.pullEvents()
|
||||
UI.term:reset()
|
||||
UI:start()
|
||||
|
||||
@@ -382,11 +382,12 @@ function page:executeStatement(statement)
|
||||
end
|
||||
end
|
||||
|
||||
local args = Util.parse(...)
|
||||
local args = { ... }
|
||||
if args[1] then
|
||||
command = 'args[1]'
|
||||
sandboxEnv.args = args
|
||||
page:setResult(args[1])
|
||||
page:setPrompt(command)
|
||||
end
|
||||
|
||||
UI:setPage(page)
|
||||
|
||||
@@ -95,6 +95,7 @@ local page = UI.Page {
|
||||
ey = -2,
|
||||
width = 8,
|
||||
selectedBackgroundColor = UI.colors.primary,
|
||||
backgroundColor = UI.colors.tertiary,
|
||||
layout = function(self)
|
||||
self.height = nil
|
||||
UI.TabBar.layout(self)
|
||||
|
||||
@@ -12,7 +12,7 @@ local gridColumns = {}
|
||||
table.insert(gridColumns, { heading = '#', key = 'id', width = 5, align = 'right' })
|
||||
table.insert(gridColumns, { heading = 'Port', key = 'portid', width = 5, align = 'right' })
|
||||
table.insert(gridColumns, { heading = 'Reply', key = 'replyid', width = 5, align = 'right' })
|
||||
if UI.defaultDevice.width > 50 then
|
||||
if UI.term.width > 50 then
|
||||
table.insert(gridColumns, { heading = 'Dist', key = 'distance', width = 6, align = 'right' })
|
||||
end
|
||||
table.insert(gridColumns, { heading = 'Msg', key = 'packetStr' })
|
||||
@@ -42,7 +42,7 @@ local page = UI.Page {
|
||||
|
||||
configSlide = UI.SlideOut {
|
||||
y = -11,
|
||||
titleBar = UI.TitleBar { title = 'Sniffer Config', event = 'config_close' },
|
||||
titleBar = UI.TitleBar { title = 'Sniffer Config', event = 'config_close', backgroundColor = colors.black },
|
||||
accelerators = { ['backspace'] = 'config_close' },
|
||||
configTabs = UI.Tabs {
|
||||
y = 2,
|
||||
|
||||
@@ -28,10 +28,10 @@ if _G.http.websocket then
|
||||
event = 'update_key',
|
||||
},
|
||||
labelText = UI.TextArea {
|
||||
x = 2, ex = -2, y = 6, ey = -4,
|
||||
x = 2, ex = -2, y = 5, ey = -4,
|
||||
textColor = colors.yellow,
|
||||
backgroundColor = colors.black,
|
||||
marginLeft = 0, marginRight = 0,
|
||||
marginLeft = 1, marginRight = 1, marginTop = 1,
|
||||
value = string.format(
|
||||
[[Use a non-changing cloud key. Note that only a single computer can use this session at one time.
|
||||
To obtain a key, visit:
|
||||
|
||||
@@ -23,7 +23,7 @@ return UI.Tab {
|
||||
x = 2, y = 2, ex = -2, ey = 4,
|
||||
},
|
||||
grid = UI.ScrollingGrid {
|
||||
x = 2, y = 6, ex = -2, ey = -2,
|
||||
x = 2, y = 5, ex = -2, ey = -2,
|
||||
values = {
|
||||
{ name = '', value = '' },
|
||||
{ name = 'CC version', value = Util.getVersion() },
|
||||
|
||||
@@ -35,9 +35,10 @@ local tab = UI.Tab {
|
||||
event = 'update',
|
||||
},
|
||||
labelText = UI.TextArea {
|
||||
x = 2, ex = -2, y = 7, ey = -4,
|
||||
x = 2, ex = -2, y = 6, ey = -4,
|
||||
backgroundColor = colors.black,
|
||||
textColor = colors.yellow,
|
||||
marginLeft = 1, marginRight = 1, marginTop = 1,
|
||||
value = 'Choose an application launcher',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@ return UI.Tab {
|
||||
tabTitle = 'Network',
|
||||
description = 'Networking options',
|
||||
info = UI.TextArea {
|
||||
x = 2, y = 6, ex = -2, ey = -2,
|
||||
x = 2, y = 5, ex = -2, ey = -2,
|
||||
backgroundColor = colors.black,
|
||||
marginLeft = 1, marginRight = 1, marginTop = 1,
|
||||
value = string.format(
|
||||
[[%sSet the primary modem used for wireless communications.%s
|
||||
|
||||
|
||||
@@ -25,10 +25,11 @@ return UI.Tab {
|
||||
event = 'update_password',
|
||||
},
|
||||
info = UI.TextArea {
|
||||
x = 2, ex = -2, y = 6, ey = -4,
|
||||
x = 2, ex = -2, y = 5, ey = -4,
|
||||
backgroundColor = colors.black,
|
||||
textColor = colors.yellow,
|
||||
inactive = true,
|
||||
marginLeft = 1, marginRight = 1, marginTop = 1,
|
||||
value = 'Add a password to enable other computers to connect to this one.',
|
||||
},
|
||||
eventHandler = function(self, event)
|
||||
|
||||
@@ -2,49 +2,94 @@ local UI = require('opus.ui')
|
||||
|
||||
local settings = _G.settings
|
||||
|
||||
if settings then
|
||||
local settingsTab = UI.Tab {
|
||||
tabTitle = 'Settings',
|
||||
description = 'Computercraft configurable settings',
|
||||
grid = UI.Grid {
|
||||
x = 2, y = 2, ex = -2, ey = -2,
|
||||
autospace = true,
|
||||
sortColumn = 'name',
|
||||
columns = {
|
||||
{ heading = 'Setting', key = 'name' },
|
||||
{ heading = 'Value', key = 'value' },
|
||||
},
|
||||
},
|
||||
}
|
||||
local transform = {
|
||||
string = tostring,
|
||||
number = tonumber,
|
||||
}
|
||||
|
||||
function settingsTab:enable()
|
||||
return settings and UI.Tab {
|
||||
tabTitle = 'Settings',
|
||||
description = 'Computercraft settings',
|
||||
grid = UI.Grid {
|
||||
x = 2, y = 2, ex = -2, ey = -2,
|
||||
sortColumn = 'name',
|
||||
columns = {
|
||||
{ heading = 'Setting', key = 'name' },
|
||||
{ heading = 'Value', key = 'value' },
|
||||
},
|
||||
},
|
||||
editor = UI.SlideOut {
|
||||
y = -6, height = 6,
|
||||
titleBar = UI.TitleBar {
|
||||
event = 'slide_hide',
|
||||
title = 'Enter value',
|
||||
},
|
||||
form = UI.Form {
|
||||
y = 2,
|
||||
value = UI.TextEntry {
|
||||
limit = 256,
|
||||
formIndex = 1,
|
||||
formLabel = 'Value',
|
||||
formKey = 'value',
|
||||
},
|
||||
validateField = function(self, entry)
|
||||
if entry.value then
|
||||
return transform[self.type](entry.value)
|
||||
end
|
||||
return true
|
||||
end,
|
||||
},
|
||||
accelerators = {
|
||||
form_cancel = 'slide_hide',
|
||||
},
|
||||
show = function(self, entry)
|
||||
self.form.type = type(entry.value) or 'string'
|
||||
self.form:setValues(entry)
|
||||
self.titleBar.title = entry.name
|
||||
UI.SlideOut.show(self)
|
||||
end,
|
||||
eventHandler = function(self, event)
|
||||
if event.type == 'form_complete' then
|
||||
if not event.values.value then
|
||||
settings.unset(event.values.name)
|
||||
self.parent:reload()
|
||||
else
|
||||
event.values.value = transform[self.form.type](event.values.value)
|
||||
settings.set(event.values.name, event.values.value)
|
||||
end
|
||||
self.parent.grid:draw()
|
||||
self:hide()
|
||||
settings.save('.settings')
|
||||
end
|
||||
return UI.SlideOut.eventHandler(self, event)
|
||||
end,
|
||||
},
|
||||
reload = function(self)
|
||||
local values = { }
|
||||
for _,v in pairs(settings.getNames()) do
|
||||
local value = settings.get(v)
|
||||
if not value then
|
||||
value = false
|
||||
end
|
||||
table.insert(values, {
|
||||
name = v,
|
||||
value = value,
|
||||
value = settings.get(v) or false,
|
||||
})
|
||||
end
|
||||
self.grid:setValues(values)
|
||||
self.grid:setIndex(1)
|
||||
end,
|
||||
enable = function(self)
|
||||
self:reload()
|
||||
UI.Tab.enable(self)
|
||||
end
|
||||
|
||||
function settingsTab:eventHandler(event)
|
||||
end,
|
||||
eventHandler = function(self, event)
|
||||
if event.type == 'grid_select' then
|
||||
if not event.selected.value or type(event.selected.value) == 'boolean' then
|
||||
if type(event.selected.value) == 'boolean' then
|
||||
event.selected.value = not event.selected.value
|
||||
settings.set(event.selected.name, event.selected.value)
|
||||
settings.save('.settings')
|
||||
self.grid:draw()
|
||||
else
|
||||
self.editor:show(event.selected)
|
||||
end
|
||||
settings.set(event.selected.name, event.selected.value)
|
||||
settings.save('.settings')
|
||||
self.grid:draw()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- this needs lots of work - currently only works with booleans
|
||||
--return settingsTab
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user