1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-16 05:34:49 +00:00
opus/sys/autorun/log.lua
kepler155c@gmail.com 8279c1ae12 environments, error messages, and stack traces, oh my!
Changed the way processes are launched.
multishell.openTab and kernel.run now accept the current environment as a parameter.
That new process inherits a copy of the passed environment.
Reduces complexity as the calling process is not required to create a suitable env.
Stack traces have been greatly improved and now include the stack for coroutines that error.
2020-05-11 17:25:58 -06:00

48 lines
1010 B
Lua

--[[
Adds a task and the control-d hotkey to view the kernel log.
--]]
local kernel = _G.kernel
local keyboard = _G.device.keyboard
local os = _G.os
local function systemLog()
local routine = kernel.getCurrent()
kernel.hook('mouse_scroll', function(_, eventData)
local dir, y = eventData[1], eventData[3]
if y > 1 then
local currentTab = kernel.getFocused()
if currentTab == routine then
if currentTab.terminal.scrollUp then
if dir == -1 then
currentTab.terminal.scrollUp()
else
currentTab.terminal.scrollDown()
end
end
end
end
end)
keyboard.addHotkey('control-d', function()
local current = kernel.getFocused()
if current.uid ~= routine.uid then
kernel.raise(routine.uid)
elseif kernel.routines[2] then
kernel.raise(kernel.routines[2].uid)
end
end)
os.pullEventRaw('terminate')
keyboard.removeHotkey('control-d')
end
kernel.run(_ENV, {
title = 'System Log',
fn = systemLog,
noTerminate = true,
hidden = true,
})