1
0
mirror of https://github.com/kepler155c/opus synced 2024-12-24 15:40:26 +00:00

transition to kernel

This commit is contained in:
kepler155c@gmail.com 2018-01-15 16:28:10 -05:00
parent 7db1db2957
commit bd37d32750
7 changed files with 55 additions and 53 deletions

View File

@ -1,4 +1,4 @@
local DEFAULT_UPATH = 'https://raw.githubusercontent.com/kepler155c/opus/develop-1.8/sys/apis'
local DEFAULT_UPATH = 'https://raw.githubusercontent.com/kepler155c/opus/' .. _ENV.BRANCH .. '/sys/apis'
local PASTEBIN_URL = 'http://pastebin.com/raw'
local GIT_URL = 'https://raw.githubusercontent.com'

View File

@ -366,13 +366,15 @@ function page:eventHandler(event)
elseif event.type == 'lua' then
multishell.openTab({
path = 'sys/apps/Lua.lua',
path ='sys/apps/shell',
args = { 'sys/apps/Lua.lua' },
focused = true,
})
elseif event.type == 'files' then
multishell.openTab({
path = 'sys/apps/Files.lua',
path ='sys/apps/shell',
args = { 'sys/apps/Files.lua' },
focused = true,
})

View File

@ -1,8 +1,6 @@
_G.requireInjector()
print('require event')
local Event = require('event')
print('require util')
local Util = require('util')
local device = _G.device
@ -11,7 +9,6 @@ local network = _G.network
local os = _G.os
local printError = _G.printError
print('check wireless_modem')
if not device.wireless_modem then
return
end

View File

@ -24,15 +24,6 @@ term.redirect(kernelWindow)
kernelWindow.parent = terminal
local splashWindow
local function showStatus(status, ...)
local str = string.format(status, ...)
print(str)
splashWindow.setCursorPos(1, h)
splashWindow.clearLine()
splashWindow.setCursorPos((w - #str) / 2, h)
splashWindow.write(str)
end
local function splash()
splashWindow = window.create(terminal, 1, 1, w, h, false)
splashWindow.setTextColor(colors.white)
@ -57,6 +48,11 @@ local function splash()
splashWindow.blit(string.rep(' ', #line), string.rep('a', #line), line)
end
end
local str = 'Loading Opus OS...'
print(str)
splashWindow.setCursorPos((w - #str) / 2, h)
splashWindow.write(str)
splashWindow.setVisible(true)
return splashWindow
end
@ -98,8 +94,6 @@ local args = { ... }
splash()
local s, m = pcall(function()
showStatus('Loading Opus OS...')
-- Install require shim
if fs.exists('sys/apis/injector.lua') then
_G.requireInjector = run('sys/apis/injector.lua')
@ -112,25 +106,28 @@ local s, m = pcall(function()
fs.mount('', 'gitfs', GIT_REPO)
end
--showStatus('Starting kernel')
-- runLevel 6 if passed a program to run
-- otherwise, runLevel 7 (multishell)
run('sys/apps/shell', 'sys/kernel.lua', args[1] and 6 or 7)
if args[1] then
local s, m = _G.kernel.run({
title = 'startup',
path = 'sys/apps/shell',
args = args,
haltOnExit = true,
})
if s then
_G.kernel.raise(s.uid)
else
error(m)
kernel.hook('kernel_ready', function()
splashWindow.setVisible(false)
kernelWindow.setVisible(true)
if args[1] then
local s, m = _G.kernel.run({
title = 'startup',
path = 'sys/apps/shell',
args = args,
haltOnExit = true,
})
if s then
_G.kernel.raise(s.uid)
else
error(m)
end
end
end
splashWindow.setVisible(false)
kernelWindow.setVisible(true)
end)
_G.kernel.start()
end)

View File

@ -378,14 +378,16 @@ local function startup()
end
end
overviewId = multishell.openTab({
path = 'sys/apps/Overview.lua',
isOverview = true,
focused = true,
})
kernel.find(overviewId).title = '+'
kernel.hook('kernel_ready', function()
overviewId = multishell.openTab({
path = 'sys/apps/Overview.lua',
isOverview = true,
focused = true,
})
kernel.find(overviewId).title = '+'
multishell.openTab({
fn = startup,
title = 'Autorun',
})
multishell.openTab({
fn = startup,
title = 'Autorun',
})
end)

View File

@ -230,22 +230,26 @@ function kernel.start()
term.redirect(kernel.terminal)
end
local function loadExtensions(runLevel)
local function init(runLevel)
runLevel = tonumber(runLevel) or error('Invalid run level')
local dir = 'sys/extensions'
local files = fs.list(dir)
table.sort(files)
for _,file in ipairs(files) do
local level, name = file:match('(%d).(%S+).lua')
--print(name)
if tonumber(level) <= runLevel then
local s, m = shell.run(fs.combine(dir, file))
if not s then
error(m)
end
--os.sleep(0)
end
end
os.queueEvent('kernel_ready')
end
local args = { ... }
loadExtensions(args[1] and tonumber(args[1]) or 7)
kernel.run({
fn = init,
title = 'init',
args = { ... },
})

View File

@ -3,11 +3,11 @@ local GPS = require('gps')
local Socket = require('socket')
local Util = require('util')
local device = _G.device
local multishell = _ENV.multishell
local network = _G.network
local os = _G.os
local turtle = _G.turtle
local device = _G.device
local kernel = _G.kernel
local network = _G.network
local os = _G.os
local turtle = _G.turtle
-- move this into gps api
local gpsRequested
@ -33,7 +33,7 @@ local function snmpConnection(socket)
elseif msg.type == 'script' then
local fn, err = loadstring(msg.args, 'script')
if fn then
multishell.openTab({
kernel.run({
fn = fn,
title = 'script',
})