1
0
mirror of https://github.com/kepler155c/opus synced 2024-12-24 23:50: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 PASTEBIN_URL = 'http://pastebin.com/raw'
local GIT_URL = 'https://raw.githubusercontent.com' local GIT_URL = 'https://raw.githubusercontent.com'

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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