autorun overhaul + shell input readline commands + launcher option + shell colors
This commit is contained in:
@@ -27,16 +27,16 @@ if _G.http.websocket then
|
||||
event = 'update_key',
|
||||
},
|
||||
labelText = UI.TextArea {
|
||||
x = 2, ex = -2, y = 6,
|
||||
x = 3, ex = -3, y = 6,
|
||||
textColor = colors.yellow,
|
||||
marginRight = 0,
|
||||
marginLeft = 0, marginRight = 0,
|
||||
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:
|
||||
%shttps://cloud-catcher.squiddev.cc%s then bookmark:
|
||||
%shttps://cloud-catcher.squiddev.cc/?id=%sKEY
|
||||
[[Use a non-changing cloud key. Note that only a single computer can use this session at one time.
|
||||
To obtain a key, visit:
|
||||
%shttps://cloud-catcher.squiddev.cc%s then bookmark:
|
||||
%shttps://cloud-catcher.squiddev.cc/?id=KEY
|
||||
]],
|
||||
Ansi.white, Ansi.reset, Ansi.white, Ansi.white),
|
||||
Ansi.white, Ansi.reset, Ansi.white),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
136
sys/apps/system/colors.lua
Normal file
136
sys/apps/system/colors.lua
Normal file
@@ -0,0 +1,136 @@
|
||||
local Config = require('config')
|
||||
local UI = require('ui')
|
||||
local Util = require('util')
|
||||
|
||||
local colors = _G.colors
|
||||
local os = _G.os
|
||||
|
||||
local config = Config.load('shellprompt')
|
||||
|
||||
local allColors = { }
|
||||
for k,v in pairs(colors) do
|
||||
if type(v) == 'number' then
|
||||
table.insert(allColors, { name = k, value = v })
|
||||
end
|
||||
end
|
||||
|
||||
local defaults = {
|
||||
textColor = colors.white,
|
||||
commandTextColor = colors.yellow,
|
||||
directoryTextColor = colors.orange,
|
||||
directoryBackgroundColor = colors.black,
|
||||
promptTextColor = colors.blue,
|
||||
promptBackgroundColor = colors.black,
|
||||
directoryColor = colors.green,
|
||||
fileColor = colors.white,
|
||||
backgroundColor = colors.black,
|
||||
}
|
||||
local _colors = config.color or Util.shallowCopy(defaults)
|
||||
|
||||
local allSettings = { }
|
||||
for k, v in pairs(defaults) do
|
||||
table.insert(allSettings, { name = k })
|
||||
end
|
||||
|
||||
local tab = UI.Tab {
|
||||
tabTitle = 'Shell',
|
||||
description = 'Shell option',
|
||||
grid1 = UI.ScrollingGrid {
|
||||
y = 2, ey = -10, x = 3, ex = -16,
|
||||
disableHeader = true,
|
||||
columns = { { key = 'name' } },
|
||||
values = allSettings,
|
||||
sortColumn = 'name',
|
||||
},
|
||||
grid2 = UI.ScrollingGrid {
|
||||
y = 2, ey = -10, x = -14, ex = -3,
|
||||
disableHeader = true,
|
||||
columns = { { key = 'name' } },
|
||||
values = allColors,
|
||||
sortColumn = 'name',
|
||||
},
|
||||
directoryLabel = UI.Text {
|
||||
x = 2, y = -2,
|
||||
value = 'Display directory',
|
||||
},
|
||||
directory = UI.Checkbox {
|
||||
x = 20, y = -2,
|
||||
value = config.displayDirectory
|
||||
},
|
||||
reset = UI.Button {
|
||||
x = -18, y = -2,
|
||||
text = 'Reset',
|
||||
event = 'reset',
|
||||
},
|
||||
button = UI.Button {
|
||||
x = -9, y = -2,
|
||||
text = 'Update',
|
||||
event = 'update',
|
||||
},
|
||||
display = UI.Window {
|
||||
x = 3, ex = -3, y = -8, height = 5,
|
||||
},
|
||||
}
|
||||
|
||||
function tab.grid2:getRowTextColor(row)
|
||||
local selected = tab.grid1:getSelected()
|
||||
if _colors[selected.name] == row.value then
|
||||
return colors.yellow
|
||||
end
|
||||
return UI.Grid.getRowTextColor(self, row)
|
||||
end
|
||||
|
||||
function tab.display:draw()
|
||||
self:clear(_colors.backgroundColor)
|
||||
local offset = 0
|
||||
if config.displayDirectory then
|
||||
self:write(1, 1,
|
||||
'==' .. os.getComputerLabel() .. ':/dir/etc',
|
||||
_colors.directoryBackgroundColor, _colors.directoryTextColor)
|
||||
offset = 1
|
||||
end
|
||||
|
||||
self:write(1, 1 + offset, '$ ',
|
||||
_colors.promptBackgroundColor, _colors.promptTextColor)
|
||||
|
||||
self:write(3, 1 + offset, 'ls /',
|
||||
_colors.backgroundColor, _colors.commandTextColor)
|
||||
|
||||
self:write(1, 2 + offset, 'sys usr',
|
||||
_colors.backgroundColor, _colors.directoryColor)
|
||||
|
||||
self:write(1, 3 + offset, 'startup',
|
||||
_colors.backgroundColor, _colors.fileColor)
|
||||
end
|
||||
|
||||
function tab:eventHandler(event)
|
||||
if event.type =='checkbox_change' then
|
||||
config.displayDirectory = not not event.checked
|
||||
self.display:draw()
|
||||
|
||||
elseif event.type == 'grid_focus_row' and event.element == self.grid1 then
|
||||
self.grid2:draw()
|
||||
|
||||
elseif event.type == 'grid_select' and event.element == self.grid2 then
|
||||
_colors[tab.grid1:getSelected().name] = event.selected.value
|
||||
self.display:draw()
|
||||
self.grid2:draw()
|
||||
|
||||
elseif event.type == 'reset' then
|
||||
config.color = defaults
|
||||
config.displayDirectory = true
|
||||
self.directory.value = true
|
||||
_colors = Util.shallowCopy(defaults)
|
||||
|
||||
Config.update('shellprompt', config)
|
||||
self:draw()
|
||||
|
||||
elseif event.type == 'update' then
|
||||
config.color = _colors
|
||||
Config.update('shellprompt', config)
|
||||
|
||||
end
|
||||
return UI.Tab.eventHandler(self, event)
|
||||
end
|
||||
|
||||
return tab
|
||||
81
sys/apps/system/launcher.lua
Normal file
81
sys/apps/system/launcher.lua
Normal file
@@ -0,0 +1,81 @@
|
||||
local Config = require('config')
|
||||
local UI = require('ui')
|
||||
|
||||
local colors = _G.colors
|
||||
local fs = _G.fs
|
||||
|
||||
local config = Config.load('multishell')
|
||||
|
||||
local tab = UI.Tab {
|
||||
tabTitle = 'Launcher',
|
||||
description = 'Set the application launcher',
|
||||
launcherLabel = UI.Text {
|
||||
x = 3, y = 2,
|
||||
value = 'Launcher',
|
||||
},
|
||||
launcher = UI.Chooser {
|
||||
x = 13, y = 2, width = 12,
|
||||
choices = {
|
||||
{ name = 'Overview', value = 'sys/apps/Overview.lua' },
|
||||
{ name = 'Shell', value = 'sys/apps/shell.lua' },
|
||||
{ name = 'Custom', value = 'custom' },
|
||||
},
|
||||
},
|
||||
custom = UI.TextEntry {
|
||||
x = 13, ex = -3, y = 3,
|
||||
limit = 128,
|
||||
shadowText = 'File name',
|
||||
},
|
||||
button = UI.Button {
|
||||
x = 3, y = 5,
|
||||
text = 'Update',
|
||||
event = 'update',
|
||||
},
|
||||
labelText = UI.TextArea {
|
||||
x = 3, ex = -3, y = 7,
|
||||
textColor = colors.yellow,
|
||||
value = 'Choose an application launcher',
|
||||
},
|
||||
}
|
||||
|
||||
function tab:enable()
|
||||
local launcher = config.launcher and 'custom' or 'sys/apps/Overview.lua'
|
||||
|
||||
for _, v in pairs(self.launcher.choices) do
|
||||
if v.value == config.launcher then
|
||||
launcher = v.value
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
UI.Tab.enable(self)
|
||||
|
||||
self.launcher.value = launcher
|
||||
self.custom.enabled = launcher == 'custom'
|
||||
end
|
||||
|
||||
function tab:eventHandler(event)
|
||||
if event.type == 'choice_change' then
|
||||
self.custom.enabled = event.value == 'custom'
|
||||
self:draw()
|
||||
|
||||
elseif event.type == 'update' then
|
||||
local launcher
|
||||
|
||||
if self.launcher.value ~= 'custom' then
|
||||
launcher = self.launcher.value
|
||||
elseif fs.exists(self.custom.value) and not fs.isDir(self.custom.value) then
|
||||
launcher = self.custom.value
|
||||
end
|
||||
|
||||
if launcher then
|
||||
config.launcher = launcher
|
||||
Config.update('multishell', config)
|
||||
self:emit({ type = 'success_message', message = 'Updated' })
|
||||
else
|
||||
self:emit({ type = 'error_message', message = 'Invalid file' })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return tab
|
||||
@@ -20,7 +20,7 @@ local tab = UI.Tab {
|
||||
disableHeader = true,
|
||||
columns = { { key = 'value' } },
|
||||
autospace = true,
|
||||
sort = 'index',
|
||||
sortColumn = 'index',
|
||||
help = 'double-click to remove, shift-arrow to move',
|
||||
accelerators = {
|
||||
delete = 'remove',
|
||||
|
||||
@@ -20,7 +20,7 @@ local tab = UI.Tab {
|
||||
disableHeader = true,
|
||||
columns = { { key = 'value' } },
|
||||
autospace = true,
|
||||
sort = 'index',
|
||||
sortColumn = 'index',
|
||||
help = 'double-click to remove, shift-arrow to move',
|
||||
accelerators = {
|
||||
delete = 'remove',
|
||||
|
||||
Reference in New Issue
Block a user