1
0
mirror of https://github.com/kepler155c/opus synced 2024-12-27 09:00:41 +00:00
opus/sys/services/log.lua
2017-10-15 19:55:05 -04:00

44 lines
961 B
Lua

_G.requireInjector()
local Terminal = require('terminal')
local Util = require('util')
local multishell = _ENV.multishell
local os = _G.os
local term = _G.term
multishell.setTitle(multishell.getCurrent(), 'Debug')
term.redirect(Terminal.scrollable(term.current(), 50))
local tabId = multishell.getCurrent()
local terminal = term.current()
local previousId
_G.debug = function(pattern, ...)
local oldTerm = term.current()
term.redirect(terminal)
Util.print(pattern, ...)
term.redirect(oldTerm)
end
print('Debug started')
print('Press ^d to activate debug window')
multishell.addHotkey('control-d', function()
local currentId = multishell.getFocus()
if currentId ~= tabId then
previousId = currentId
multishell.setFocus(tabId)
elseif previousId then
multishell.setFocus(previousId)
end
end)
os.pullEventRaw('terminate')
print('Debug stopped')
_G.debug = function() end
multishell.removeHotkey('control-d')