1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-14 15:27:40 +00:00

transition to kernel

This commit is contained in:
kepler155c@gmail.com
2018-01-20 07:18:13 -05:00
parent d85e9b96b2
commit 1c1eb9b782
28 changed files with 398 additions and 228 deletions

View File

@@ -1,44 +0,0 @@
if false then
local colors = _G.colors
local term = _G.term
local window = _G.window
local terminal = term.current()
local w, h = term.getSize()
local splashWindow = window.create(terminal.parent, 1, 1, w, h, false)
splashWindow.setTextColor(colors.white)
if splashWindow.isColor() then
splashWindow.setBackgroundColor(colors.black)
splashWindow.clear()
local opus = {
'fffff00',
'ffff07000',
'ff00770b00 4444',
'ff077777444444444',
'f07777744444444444',
'f0000777444444444',
'070000111744444',
'777770000',
'7777000000',
'70700000000',
'077000000000',
}
for k,line in ipairs(opus) do
splashWindow.setCursorPos((w - 18) / 2, k + (h - #opus) / 2)
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)
terminal.setVisible(false)
splashWindow.setVisible(true)
kernel.hook('kernel_ready', function()
kernel.window.setVisible(true)
end)
end

View File

@@ -1,7 +1,7 @@
local os = _G.os
-- Default label
if not os.getComputerLabel() then
showStatus('Setting computer label')
local id = os.getComputerID()
if _G.turtle then
os.setComputerLabel('turtle_' .. id)

View File

@@ -11,8 +11,8 @@ end
if not fs.exists('usr/autorun') then
fs.makeDir('usr/autorun')
end
if not fs.exists('usr/etc/fstab') then
Util.writeFile('usr/etc/fstab', 'usr gitfs kepler155c/opus-apps/' .. _ENV.BRANCH)
if not fs.exists('usr/config/fstab') then
Util.writeFile('usr/config/fstab', 'usr gitfs kepler155c/opus-apps/' .. _ENV.BRANCH)
end
if not fs.exists('usr/config/shell') then
@@ -35,4 +35,4 @@ end
shell.setPath(config.path)
shell.setEnv('LUA_PATH', config.lua_path)
fs.loadTab('usr/etc/fstab')
fs.loadTab('usr/config/fstab')

View File

@@ -21,3 +21,4 @@ if _G.device.wireless_modem then
startNetwork()
os.sleep(0) -- give the network a cycle to start
end

View File

@@ -54,7 +54,7 @@ local function redrawMenu()
end
function multishell.getFocus()
local currentTab = kernel.routines[1]
local currentTab = kernel.getFocused()
return currentTab.uid
end
@@ -70,9 +70,7 @@ end
function multishell.setTitle(tabId, title)
local tab = kernel.find(tabId)
if tab then
if not tab.isOverview then
tab.title = title or ''
end
tab.title = title
redrawMenu()
end
end
@@ -105,15 +103,15 @@ end
function multishell.openTab(tab)
if not tab.title and tab.path then
tab.title = fs.getName(tab.path)
tab.title = fs.getName(tab.path):match('([^%.]+)')
end
tab.title = tab.title or 'untitled'
tab.window = window.create(parentTerm, 1, 2, w, h - 1, false)
tab.terminal = tab.window
tab.window = tab.window or window.create(parentTerm, 1, 2, w, h - 1, false)
tab.terminal = tab.terminal or tab.window
local routine = kernel.newRoutine(tab)
tab.co = coroutine.create(function()
routine.co = coroutine.create(function()
local result, err
if tab.fn then
@@ -128,9 +126,9 @@ function multishell.openTab(tab)
if err then
printError(tostring(err))
end
printError('Press enter to close')
tab.isDead = true
tab.hidden = false
print('\nPress enter to close')
routine.isDead = true
routine.hidden = false
while true do
local e, code = os.pullEventRaw('key')
if e == 'terminate' or e == 'key' and code == keys.enter then
@@ -147,8 +145,7 @@ function multishell.openTab(tab)
else
redrawMenu()
end
return tab.uid
return routine.uid
end
function multishell.hideTab(tabId)
@@ -217,10 +214,9 @@ kernel.hook('multishell_redraw', function()
parentTerm.setCursorPos(1, 1)
parentTerm.clearLine()
local currentTab = kernel.routines[1]
local currentTab = kernel.getFocused()
for _,tab in pairs(kernel.routines) do
tab.title = tab.env._APP_TITLE or tab.title
if tab.hidden and tab ~= currentTab then
tab.width = 0
else
@@ -241,7 +237,8 @@ tab.title = tab.env._APP_TITLE or tab.title
end
local function compareTab(a, b)
return b.hidden and -1 or a.uid < b.uid
if a.hidden then return false end
return b.hidden or a.uid < b.uid
end
local tabX = 0
@@ -295,12 +292,12 @@ end)
kernel.hook('mouse_click', function(_, eventData)
local x, y = eventData[2], eventData[3]
local currentTab = kernel.routines[1]
if y == 1 then
if x == 1 then
multishell.setFocus(overviewId)
elseif x == w then
local currentTab = kernel.getFocused()
if currentTab then
multishell.terminate(currentTab.uid)
end
@@ -344,6 +341,7 @@ local function startup()
for _,file in ipairs(files) do
os.sleep(0)
local result, err = open(directory .. '/' .. file)
if result then
if term.isColor() then
term.setTextColor(colors.green)
@@ -362,6 +360,7 @@ local function startup()
if err then
_G.printError('\n' .. err)
end
print()
success = false
end
end
@@ -383,8 +382,8 @@ kernel.hook('kernel_ready', function()
path = 'sys/apps/Overview.lua',
isOverview = true,
focused = true,
title = '+',
})
kernel.find(overviewId).title = '+'
multishell.openTab({
fn = startup,