1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-30 23:23:03 +00:00

kernel improvements

This commit is contained in:
kepler155c@gmail.com
2020-05-08 22:32:44 -06:00
parent 71bbd2d457
commit b0db0b86bd
7 changed files with 87 additions and 83 deletions

View File

@@ -104,12 +104,12 @@ function nativefs.delete(node, dir)
-- if a file is mounted over an existing directory
-- ie. sys/apps/MOUNT.LUA
-- then sys and sys/apps are created as temp nodes
-- therefore, trying to delete sys will was only
-- therefore, trying to delete sys was only
-- removing the node and not deleting the directory
-- Need a better way to backfill nodes in a way
-- that preserves the vfs functionality
-- perhaps a flag that denotes that this is a
-- perhaps a flag that denotes that this
-- file/directory is the actual mount
-- this hack will not fix

View File

@@ -1,6 +1,5 @@
local Blit = require('opus.ui.blit')
local Config = require('opus.config')
local trace = require('opus.trace')
local Util = require('opus.util')
local colors = _G.colors
@@ -103,48 +102,25 @@ function multishell.launch( tProgramEnv, sProgramPath, ... )
})
end
local function xprun(env, path, ...)
setmetatable(env, { __index = _G })
local fn, m = loadfile(path, env)
if fn then
return trace(fn, ...)
end
return fn, m
end
function multishell.openTab(tab)
if not tab.title and tab.path then
tab.title = fs.getName(tab.path):match('([^%.]+)')
end
tab.title = tab.title or 'untitled'
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)
routine.co = coroutine.create(function()
local result, err
if tab.fn then
result, err = Util.runFunction(routine.env, tab.fn, table.unpack(tab.args or { } ))
elseif tab.path then
result, err = xprun(routine.env, tab.path, table.unpack(tab.args or { } ))
else
err = 'multishell: invalid tab'
end
tab.onExit = function(self, result, err)
if not result and err and err ~= 'Terminated' or (err and err ~= 0) then
tab.terminal.setBackgroundColor(colors.black)
self.terminal.setBackgroundColor(colors.black)
if tonumber(err) then
tab.terminal.setTextColor(colors.orange)
self.terminal.setTextColor(colors.orange)
print('Process exited with error code: ' .. err)
elseif err then
printError(tostring(err))
end
tab.terminal.setTextColor(colors.white)
self.terminal.setTextColor(colors.white)
print('\nPress enter to close')
routine.isDead = true
routine.hidden = false
self.isDead = true
self.hidden = false
redrawMenu()
while true do
local e, code = os.pullEventRaw('key')
@@ -153,9 +129,9 @@ function multishell.openTab(tab)
end
end
end
end)
end
kernel.launch(routine)
local routine = kernel.run(tab)
if tab.focused then
multishell.setFocus(routine.uid)
@@ -256,9 +232,10 @@ kernel.hook('multishell_redraw', function()
if currentTab then
if currentTab.sx then
local textColor = currentTab.isDead and _colors.errorColor or _colors.focusTextColor
blit:write(currentTab.sx - 1,
' ' .. currentTab.title:sub(1, currentTab.width - 1) .. ' ',
_colors.focusBackgroundColor, _colors.focusTextColor)
_colors.focusBackgroundColor, textColor)
end
if not currentTab.noTerminate then
blit:write(w, closeInd, nil, _colors.focusTextColor)