1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-29 06:37:40 +00:00

transition to kernel

This commit is contained in:
kepler155c@gmail.com
2018-01-13 23:40:53 -05:00
parent bd37b57780
commit 9de9452dd3
15 changed files with 157 additions and 180 deletions

View File

@@ -11,22 +11,60 @@ local keyboard = _G.device.keyboard
local multishell = _ENV.multishell
local os = _G.os
local term = _G.term
local window = _G.window
if multishell and multishell.setTitle then
multishell.setTitle(multishell.getCurrent(), 'System Log')
end
-- jump through a lot of hoops to get around window api limitations
-- mainly failing to provide access to window buffer or knowledge of parent
-- need: window.getParent()
-- window.copy(target)
local terminal = _G.kernel.terminal.parent
local w, h = kernel.window.getSize()
local win = window.create(kernel.window, 1, 1, w, h + 50, false)
-- copy windows contents from parent window to child
local oblit, oscp = terminal.blit, terminal.setCursorPos
kernel.window.setVisible(false)
terminal.blit = function(...)
win.blit(...)
end
terminal.setCursorPos = function(...)
win.setCursorPos(...)
end
kernel.window.setVisible(true)
-- position and resize window for multishell (but don't update screen)
terminal.blit = function() end
terminal.setCursorPos = function() end
kernel.window.reposition(1, 2, w, h - 1)
-- restore original terminal
terminal.blit = oblit
terminal.setCursorPos = oscp
-- add scrolling methods
Terminal.scrollable(win, kernel.window)
-- update kernel with new window, set this tab with the new kernal window
local routine = kernel.getCurrent()
local previousId
kernel.window.reposition(1, 2)
Terminal.scrollable(kernel.window, 50)
routine.terminal = kernel.window
routine.window = kernel.window
for _,r in pairs(kernel.routines) do
if r.terminal == kernel.terminal then
r.terminal = win
r.window = win
end
end
kernel.terminal = win
kernel.window = win
routine.terminal = win
routine.window = win
term.redirect(routine.window)
local previousId
kernel.hook('mouse_scroll', function(_, eventData)
local dir, y = eventData[1], eventData[3]

View File

@@ -1,47 +0,0 @@
_G.requireInjector()
local Event = require('event')
local Util = require('util')
local device = _G.device
local fs = _G.fs
local multishell = _ENV.multishell
local network = _G.network
local os = _G.os
local printError = _G.printError
if not device.wireless_modem then
return
end
if multishell and multishell.setTitle then
multishell.setTitle(multishell.getCurrent(), 'Net Daemon')
end
print('Net daemon started')
for _,file in pairs(fs.list('sys/network')) do
local fn, msg = Util.run(_ENV, 'sys/network/' .. file)
if not fn then
printError(msg)
end
end
Event.on('device_detach', function()
if not device.wireless_modem then
Event.exitPullEvents()
end
end)
Event.pullEvents()
for _,c in pairs(network) do
c.active = false
os.queueEvent('network_detach', c)
end
os.queueEvent('network_down')
Event.pullEvent('network_down')
Util.clear(_G.network)
print('Net daemon stopped')