mirror of
https://github.com/kepler155c/opus
synced 2025-03-01 07:10:19 +00:00
better startup
This commit is contained in:
parent
ea56ac325b
commit
80f3ba1fb0
@ -10,13 +10,24 @@ local function runDir(directory, desc, open)
|
|||||||
table.sort(files)
|
table.sort(files)
|
||||||
|
|
||||||
for _,file in ipairs(files) do
|
for _,file in ipairs(files) do
|
||||||
--print(desc .. file)
|
|
||||||
os.sleep(0)
|
os.sleep(0)
|
||||||
local result, err = open(directory .. '/' .. file)
|
local result, err = open(directory .. '/' .. file)
|
||||||
if not result then
|
if result then
|
||||||
printError(err)
|
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
|
success = false
|
||||||
end
|
end
|
||||||
|
print()
|
||||||
end
|
end
|
||||||
|
|
||||||
return success
|
return success
|
||||||
|
@ -1500,7 +1500,7 @@ UI.Grid.defaults = {
|
|||||||
textSelectedColor = colors.white,
|
textSelectedColor = colors.white,
|
||||||
backgroundColor = colors.black,
|
backgroundColor = colors.black,
|
||||||
backgroundSelectedColor = colors.gray,
|
backgroundSelectedColor = colors.gray,
|
||||||
headerBackgroundColor = colors.blue,
|
headerBackgroundColor = colors.cyan,
|
||||||
headerTextColor = colors.white,
|
headerTextColor = colors.white,
|
||||||
unfocusedTextSelectedColor = colors.white,
|
unfocusedTextSelectedColor = colors.white,
|
||||||
unfocusedBackgroundSelectedColor = colors.gray,
|
unfocusedBackgroundSelectedColor = colors.gray,
|
||||||
@ -2032,7 +2032,7 @@ end
|
|||||||
UI.ViewportWindow = class(UI.Window)
|
UI.ViewportWindow = class(UI.Window)
|
||||||
UI.ViewportWindow.defaults = {
|
UI.ViewportWindow.defaults = {
|
||||||
UIElement = 'ViewportWindow',
|
UIElement = 'ViewportWindow',
|
||||||
backgroundColor = colors.blue,
|
backgroundColor = colors.cyan,
|
||||||
accelerators = {
|
accelerators = {
|
||||||
down = 'scroll_down',
|
down = 'scroll_down',
|
||||||
up = 'scroll_up',
|
up = 'scroll_up',
|
||||||
@ -2163,7 +2163,7 @@ UI.MenuBar.defaults = {
|
|||||||
UIElement = 'MenuBar',
|
UIElement = 'MenuBar',
|
||||||
buttons = { },
|
buttons = { },
|
||||||
height = 1,
|
height = 1,
|
||||||
backgroundColor = colors.lightBlue,
|
backgroundColor = colors.lightGray,
|
||||||
textColor = colors.black,
|
textColor = colors.black,
|
||||||
spacing = 2,
|
spacing = 2,
|
||||||
showBackButton = false,
|
showBackButton = false,
|
||||||
@ -2311,7 +2311,7 @@ end
|
|||||||
UI.TabBar = class(UI.MenuBar)
|
UI.TabBar = class(UI.MenuBar)
|
||||||
UI.TabBar.defaults = {
|
UI.TabBar.defaults = {
|
||||||
UIElement = 'TabBar',
|
UIElement = 'TabBar',
|
||||||
selectedBackgroundColor = colors.blue,
|
selectedBackgroundColor = colors.cyan,
|
||||||
focusBackgroundColor = colors.green,
|
focusBackgroundColor = colors.green,
|
||||||
}
|
}
|
||||||
function UI.TabBar:init(args)
|
function UI.TabBar:init(args)
|
||||||
|
@ -18,7 +18,7 @@ Config.load('multishell', env)
|
|||||||
UI.TextEntry.defaults.backgroundFocusColor = colors.black
|
UI.TextEntry.defaults.backgroundFocusColor = colors.black
|
||||||
|
|
||||||
local systemPage = UI.Page {
|
local systemPage = UI.Page {
|
||||||
backgroundColor = colors.blue,
|
backgroundColor = colors.cyan,
|
||||||
tabs = UI.Tabs {
|
tabs = UI.Tabs {
|
||||||
pathTab = UI.Window {
|
pathTab = UI.Window {
|
||||||
tabTitle = 'Path',
|
tabTitle = 'Path',
|
||||||
@ -86,8 +86,9 @@ local systemPage = UI.Page {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
grid = UI.ScrollingGrid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 4,
|
y = 3,
|
||||||
values = {
|
values = {
|
||||||
|
{ name = '', value = '' },
|
||||||
{ name = 'CC version', value = Util.getVersion() },
|
{ name = 'CC version', value = Util.getVersion() },
|
||||||
{ name = 'Lua version', value = _VERSION },
|
{ name = 'Lua version', value = _VERSION },
|
||||||
{ name = 'MC version', value = _MC_VERSION or 'unknown' },
|
{ name = 'MC version', value = _MC_VERSION or 'unknown' },
|
||||||
@ -96,7 +97,7 @@ local systemPage = UI.Page {
|
|||||||
{ name = 'Day', value = tostring(os.day()) },
|
{ name = 'Day', value = tostring(os.day()) },
|
||||||
},
|
},
|
||||||
selectable = false,
|
selectable = false,
|
||||||
backgroundColor = colors.blue,
|
--backgroundColor = colors.blue,
|
||||||
columns = {
|
columns = {
|
||||||
{ key = 'name', width = 12 },
|
{ key = 'name', width = 12 },
|
||||||
{ key = 'value', width = UI.term.width - 15 },
|
{ key = 'value', width = UI.term.width - 15 },
|
||||||
|
@ -46,11 +46,11 @@ local config = {
|
|||||||
},
|
},
|
||||||
color = {
|
color = {
|
||||||
focusTextColor = colors.white,
|
focusTextColor = colors.white,
|
||||||
focusBackgroundColor = colors.brown,
|
focusBackgroundColor = colors.black,
|
||||||
textColor = colors.gray,
|
textColor = colors.lightGray,
|
||||||
backgroundColor = colors.brown,
|
backgroundColor = colors.black,
|
||||||
tabBarTextColor = colors.lightGray,
|
tabBarTextColor = colors.lightGray,
|
||||||
tabBarBackgroundColor = colors.brown,
|
tabBarBackgroundColor = colors.black,
|
||||||
},
|
},
|
||||||
-- path = '.:/apps:' .. shell.path():sub(3),
|
-- path = '.:/apps:' .. shell.path():sub(3),
|
||||||
path = 'usr/apps:sys/apps:' .. shell.path(),
|
path = 'usr/apps:sys/apps:' .. shell.path(),
|
||||||
@ -124,7 +124,7 @@ local function draw()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if currentTab and not currentTab.isOverview then
|
if currentTab and not currentTab.isOverview then
|
||||||
parentTerm.setTextColor(_colors.textColor)
|
parentTerm.setTextColor(_colors.focusTextColor)
|
||||||
parentTerm.setBackgroundColor(_colors.backgroundColor)
|
parentTerm.setBackgroundColor(_colors.backgroundColor)
|
||||||
parentTerm.setCursorPos( w, 1 )
|
parentTerm.setCursorPos( w, 1 )
|
||||||
parentTerm.write('*')
|
parentTerm.write('*')
|
||||||
@ -215,7 +215,7 @@ local function launchProcess(tab)
|
|||||||
if err then
|
if err then
|
||||||
printError(tostring(err))
|
printError(tostring(err))
|
||||||
end
|
end
|
||||||
printError('Press enter to exit')
|
printError('Press enter to close')
|
||||||
tab.isDead = true
|
tab.isDead = true
|
||||||
while true do
|
while true do
|
||||||
local e, code = os.pullEventRaw('key')
|
local e, code = os.pullEventRaw('key')
|
||||||
@ -484,6 +484,7 @@ local function startup()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if hasError then
|
if hasError then
|
||||||
|
print()
|
||||||
error('An autorun program has errored')
|
error('An autorun program has errored')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -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({
|
local env = setmetatable({
|
||||||
LUA_PATH = '/sys/apis:/usr/apis'
|
LUA_PATH = '/sys/apis:/usr/apis'
|
||||||
}, { __index = _G })
|
}, { __index = _G })
|
||||||
for k,v in pairs(getfenv(1)) do
|
for k,v in pairs(getfenv(1)) do
|
||||||
env[k] = v
|
env[k] = v
|
||||||
end
|
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
|
if s then
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
s, m = pcall(function()
|
s, m = pcall(function()
|
||||||
@ -23,9 +39,33 @@ local function run(file, ...)
|
|||||||
return m
|
return m
|
||||||
end
|
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())
|
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
|
-- user environment
|
||||||
if not fs.exists('usr/apps') then
|
if not fs.exists('usr/apps') then
|
||||||
fs.makeDir('usr/apps')
|
fs.makeDir('usr/apps')
|
||||||
@ -39,14 +79,22 @@ if not fs.exists('usr/etc/fstab') then
|
|||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- extensions
|
||||||
local dir = 'sys/extensions'
|
local dir = 'sys/extensions'
|
||||||
for _,file in ipairs(fs.list(dir)) do
|
for _,file in ipairs(fs.list(dir)) do
|
||||||
run('sys/apps/shell', fs.combine(dir, file))
|
run('sys/apps/shell', fs.combine(dir, file))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- install user file systems
|
||||||
fs.loadTab('usr/etc/fstab')
|
fs.loadTab('usr/etc/fstab')
|
||||||
|
|
||||||
local args = { ... }
|
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'
|
args[1] = args[1] or 'sys/apps/multishell'
|
||||||
|
|
||||||
run('sys/apps/shell', table.unpack(args))
|
run('sys/apps/shell', table.unpack(args))
|
||||||
|
|
||||||
|
fs.restore()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user