1
0
mirror of https://github.com/kepler155c/opus synced 2024-06-18 11:20:01 +00:00
opus/sys/autorun/log.lua

52 lines
1.2 KiB
Lua
Raw Normal View History

2018-01-20 12:18:13 +00:00
_G.requireInjector(_ENV)
2018-01-13 20:17:26 +00:00
--[[
2018-01-20 12:18:13 +00:00
Adds a task and the control-d hotkey to view the kernel log.
--]]
2016-12-11 19:24:52 +00:00
2018-01-12 01:53:32 +00:00
local kernel = _G.kernel
local keyboard = _G.device.keyboard
2017-10-08 21:45:01 +00:00
local multishell = _ENV.multishell
local os = _G.os
local term = _G.term
2018-01-21 10:44:13 +00:00
local routine = kernel.getCurrent()
2018-01-20 12:18:13 +00:00
if multishell then
2018-01-13 20:17:26 +00:00
multishell.setTitle(multishell.getCurrent(), 'System Log')
2018-01-21 10:44:13 +00:00
multishell.hideTab(routine.uid)
2018-01-13 20:17:26 +00:00
end
2016-12-11 19:24:52 +00:00
2018-01-14 04:40:53 +00:00
local w, h = kernel.window.getSize()
kernel.window.reposition(1, 2, w, h - 1)
2018-01-13 20:17:26 +00:00
2018-01-20 12:18:13 +00:00
routine.terminal = kernel.window
routine.window = kernel.window
term.redirect(kernel.window)
2016-12-11 19:24:52 +00:00
2018-01-12 01:53:32 +00:00
kernel.hook('mouse_scroll', function(_, eventData)
local dir, y = eventData[1], eventData[3]
if y > 1 then
2018-01-20 12:18:13 +00:00
local currentTab = kernel.getFocused()
if currentTab.terminal.scrollUp and not currentTab.terminal.noAutoScroll then
2018-01-12 01:53:32 +00:00
if dir == -1 then
currentTab.terminal.scrollUp()
else
currentTab.terminal.scrollDown()
end
end
end
end)
keyboard.addHotkey('control-d', function()
2018-01-13 20:17:26 +00:00
local current = kernel.getFocused()
if current.uid ~= routine.uid then
kernel.raise(routine.uid)
2018-01-21 10:44:13 +00:00
elseif kernel.routines[2] then
kernel.raise(kernel.routines[2].uid)
2016-12-11 19:24:52 +00:00
end
end)
os.pullEventRaw('terminate')
keyboard.removeHotkey('control-d')