opus/sys/services/log.lua

57 lines
1.2 KiB
Lua

_G.requireInjector()
--[[
Adds the control-d hotkey to view the kernel log.
]]
local Terminal = require('terminal')
local kernel = _G.kernel
local keyboard = _G.device.keyboard
local multishell = _ENV.multishell
local os = _G.os
local term = _G.term
if multishell and multishell.setTitle then
multishell.setTitle(multishell.getCurrent(), 'System Log')
end
local routine = kernel.getCurrent()
local previousId
kernel.window.reposition(1, 2)
Terminal.scrollable(kernel.window, 50)
routine.terminal = kernel.window
routine.window = kernel.window
term.redirect(routine.window)
kernel.hook('mouse_scroll', function(_, eventData)
local dir, y = eventData[1], eventData[3]
if y > 1 then
local currentTab = kernel.routines[1]
if currentTab.terminal.scrollUp then
if dir == -1 then
currentTab.terminal.scrollUp()
else
currentTab.terminal.scrollDown()
end
end
end
end)
keyboard.addHotkey('control-d', function()
local current = kernel.getFocused()
if current.uid ~= routine.uid then
previousId = current.uid
kernel.raise(routine.uid)
elseif previousId then
kernel.raise(previousId)
end
end)
os.pullEventRaw('terminate')
keyboard.removeHotkey('control-d')