better startup

This commit is contained in:
kepler155c@gmail.com 2017-09-25 22:49:44 -04:00
parent ea56ac325b
commit 80f3ba1fb0
5 changed files with 82 additions and 21 deletions

View File

@ -10,13 +10,24 @@ local function runDir(directory, desc, open)
table.sort(files)
for _,file in ipairs(files) do
--print(desc .. file)
os.sleep(0)
local result, err = open(directory .. '/' .. file)
if not result then
printError(err)
if result then
term.setTextColor(colors.green)
term.write('[PASS] ')
term.setTextColor(colors.white)
term.write(fs.combine(directory, file))
else
term.setTextColor(colors.red)
term.write('[FAIL] ')
term.setTextColor(colors.white)
term.write(fs.combine(directory, file))
if err then
printError(err)
end
success = false
end
print()
end
return success

View File

@ -1500,7 +1500,7 @@ UI.Grid.defaults = {
textSelectedColor = colors.white,
backgroundColor = colors.black,
backgroundSelectedColor = colors.gray,
headerBackgroundColor = colors.blue,
headerBackgroundColor = colors.cyan,
headerTextColor = colors.white,
unfocusedTextSelectedColor = colors.white,
unfocusedBackgroundSelectedColor = colors.gray,
@ -2032,7 +2032,7 @@ end
UI.ViewportWindow = class(UI.Window)
UI.ViewportWindow.defaults = {
UIElement = 'ViewportWindow',
backgroundColor = colors.blue,
backgroundColor = colors.cyan,
accelerators = {
down = 'scroll_down',
up = 'scroll_up',
@ -2163,7 +2163,7 @@ UI.MenuBar.defaults = {
UIElement = 'MenuBar',
buttons = { },
height = 1,
backgroundColor = colors.lightBlue,
backgroundColor = colors.lightGray,
textColor = colors.black,
spacing = 2,
showBackButton = false,
@ -2311,7 +2311,7 @@ end
UI.TabBar = class(UI.MenuBar)
UI.TabBar.defaults = {
UIElement = 'TabBar',
selectedBackgroundColor = colors.blue,
selectedBackgroundColor = colors.cyan,
focusBackgroundColor = colors.green,
}
function UI.TabBar:init(args)

View File

@ -18,7 +18,7 @@ Config.load('multishell', env)
UI.TextEntry.defaults.backgroundFocusColor = colors.black
local systemPage = UI.Page {
backgroundColor = colors.blue,
backgroundColor = colors.cyan,
tabs = UI.Tabs {
pathTab = UI.Window {
tabTitle = 'Path',
@ -86,8 +86,9 @@ local systemPage = UI.Page {
},
},
grid = UI.ScrollingGrid {
y = 4,
y = 3,
values = {
{ name = '', value = '' },
{ name = 'CC version', value = Util.getVersion() },
{ name = 'Lua version', value = _VERSION },
{ name = 'MC version', value = _MC_VERSION or 'unknown' },
@ -96,7 +97,7 @@ local systemPage = UI.Page {
{ name = 'Day', value = tostring(os.day()) },
},
selectable = false,
backgroundColor = colors.blue,
--backgroundColor = colors.blue,
columns = {
{ key = 'name', width = 12 },
{ key = 'value', width = UI.term.width - 15 },

View File

@ -46,11 +46,11 @@ local config = {
},
color = {
focusTextColor = colors.white,
focusBackgroundColor = colors.brown,
textColor = colors.gray,
backgroundColor = colors.brown,
focusBackgroundColor = colors.black,
textColor = colors.lightGray,
backgroundColor = colors.black,
tabBarTextColor = colors.lightGray,
tabBarBackgroundColor = colors.brown,
tabBarBackgroundColor = colors.black,
},
-- path = '.:/apps:' .. shell.path():sub(3),
path = 'usr/apps:sys/apps:' .. shell.path(),
@ -124,7 +124,7 @@ local function draw()
end
end
if currentTab and not currentTab.isOverview then
parentTerm.setTextColor(_colors.textColor)
parentTerm.setTextColor(_colors.focusTextColor)
parentTerm.setBackgroundColor(_colors.backgroundColor)
parentTerm.setCursorPos( w, 1 )
parentTerm.write('*')
@ -215,7 +215,7 @@ local function launchProcess(tab)
if err then
printError(tostring(err))
end
printError('Press enter to exit')
printError('Press enter to close')
tab.isDead = true
while true do
local e, code = os.pullEventRaw('key')
@ -484,6 +484,7 @@ local function startup()
end
if hasError then
print()
error('An autorun program has errored')
end
end

View File

@ -1,14 +1,30 @@
print('\nStarting Opus..')
-- Loads the Opus environment regardless if the file system is local or not
local function run(file, ...)
local w, h = term.getSize()
local str = 'Opus OS'
term.setTextColor(colors.white)
term.setBackgroundColor(colors.cyan)
term.setCursorPos((w - #str) / 2, h / 2)
term.clear()
term.write(str)
term.setCursorPos(1, h / 2 + 2)
local GIT_REPO = 'kepler155c/opus/develop'
local BASE = 'https://raw.githubusercontent.com/' .. GIT_REPO
local function makeEnv()
local env = setmetatable({
LUA_PATH = '/sys/apis:/usr/apis'
}, { __index = _G })
for k,v in pairs(getfenv(1)) do
env[k] = v
end
return env
end
local s, m = loadfile(file, env)
-- os.run doesn't provide return values :(
local function run(file, ...)
local s, m = loadfile(file, makeEnv())
if s then
local args = { ... }
s, m = pcall(function()
@ -23,9 +39,33 @@ local function run(file, ...)
return m
end
_G.requireInjector = run('sys/apis/injector.lua')
local function runUrl(file, ...)
local url = BASE .. '/' .. file
local h = http.get(url)
if h then
local fn, m = load(h.readAll(), url, nil, makeEnv())
h.close()
if fn then
return fn(...)
end
end
error('Failed to download ' .. url)
end
shell.setPath('usr/apps:sys/apps:' .. shell.path())
if fs.exists('sys/apis/injector.lua') then
_G.requireInjector = run('sys/apis/injector.lua')
else
-- not local, run the file system directly from git
_G.requireInjector = runUrl('/sys/apis/injector.lua')
runUrl('/sys/extensions/vfs.lua')
-- install file system
fs.mount('', 'gitfs', GIT_REPO)
end
-- user environment
if not fs.exists('usr/apps') then
fs.makeDir('usr/apps')
@ -39,14 +79,22 @@ if not fs.exists('usr/etc/fstab') then
file:close()
end
-- extensions
local dir = 'sys/extensions'
for _,file in ipairs(fs.list(dir)) do
run('sys/apps/shell', fs.combine(dir, file))
end
-- install user file systems
fs.loadTab('usr/etc/fstab')
local args = { ... }
if args[1] then
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1, 1)
end
args[1] = args[1] or 'sys/apps/multishell'
run('sys/apps/shell', table.unpack(args))
fs.restore()