2017-10-08 21:45:01 +00:00
|
|
|
_G.requireInjector()
|
2017-09-05 06:09:31 +00:00
|
|
|
|
2016-12-11 19:24:52 +00:00
|
|
|
local Terminal = require('terminal')
|
2017-09-05 06:09:31 +00:00
|
|
|
local Util = require('util')
|
2016-12-11 19:24:52 +00:00
|
|
|
|
2018-01-10 21:46:37 +00:00
|
|
|
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
|
|
|
|
|
2016-12-11 19:24:52 +00:00
|
|
|
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')
|
|
|
|
|
2018-01-10 21:46:37 +00:00
|
|
|
keyboard.addHotkey('control-d', function()
|
2016-12-11 19:24:52 +00:00
|
|
|
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
|
2018-01-10 21:46:37 +00:00
|
|
|
keyboard.removeHotkey('control-d')
|