2018-01-24 22:39:38 +00:00
|
|
|
_G.requireInjector(_ENV)
|
2017-10-15 06:36:54 +00:00
|
|
|
|
|
|
|
local Util = require('util')
|
|
|
|
|
2018-01-12 01:53:32 +00:00
|
|
|
local kernel = _G.kernel
|
2018-01-10 21:46:37 +00:00
|
|
|
local keyboard = _G.device.keyboard
|
2017-10-15 06:36:54 +00:00
|
|
|
local multishell = _ENV.multishell
|
|
|
|
|
2017-10-15 23:55:05 +00:00
|
|
|
-- overview
|
2018-01-10 21:46:37 +00:00
|
|
|
keyboard.addHotkey('control-o', function()
|
2018-01-24 22:39:38 +00:00
|
|
|
for _,tab in pairs(multishell.getTabs()) do
|
|
|
|
if tab.isOverview then
|
|
|
|
multishell.setFocus(tab.uid)
|
|
|
|
end
|
|
|
|
end
|
2017-10-15 06:36:54 +00:00
|
|
|
end)
|
|
|
|
|
2017-10-15 23:55:05 +00:00
|
|
|
-- restart tab
|
2018-01-10 21:46:37 +00:00
|
|
|
keyboard.addHotkey('control-backspace', function()
|
2018-01-24 22:39:38 +00:00
|
|
|
local uid = multishell.getFocus()
|
|
|
|
local tab = kernel.find(uid)
|
|
|
|
if not tab.isOverview then
|
|
|
|
multishell.terminate(uid)
|
|
|
|
tab = Util.shallowCopy(tab)
|
|
|
|
tab.isDead = false
|
|
|
|
tab.focused = true
|
|
|
|
multishell.openTab(tab)
|
|
|
|
end
|
2017-10-15 06:36:54 +00:00
|
|
|
end)
|
|
|
|
|
2017-10-15 23:55:05 +00:00
|
|
|
-- next tab
|
2018-01-10 21:46:37 +00:00
|
|
|
keyboard.addHotkey('control-tab', function()
|
2018-01-24 22:39:38 +00:00
|
|
|
local tabs = multishell.getTabs()
|
|
|
|
local visibleTabs = { }
|
|
|
|
local currentTabId = multishell.getFocus()
|
2017-10-15 06:36:54 +00:00
|
|
|
|
2018-01-24 22:39:38 +00:00
|
|
|
local function compareTab(a, b)
|
|
|
|
return a.uid < b.uid
|
|
|
|
end
|
|
|
|
for _,tab in Util.spairs(tabs, compareTab) do
|
|
|
|
if not tab.hidden then
|
|
|
|
table.insert(visibleTabs, tab)
|
|
|
|
end
|
|
|
|
end
|
2017-10-15 06:36:54 +00:00
|
|
|
|
2018-01-24 22:39:38 +00:00
|
|
|
for k,tab in ipairs(visibleTabs) do
|
|
|
|
if tab.uid == currentTabId then
|
|
|
|
if k < #visibleTabs then
|
|
|
|
multishell.setFocus(visibleTabs[k + 1].uid)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #visibleTabs > 0 then
|
|
|
|
multishell.setFocus(visibleTabs[1].uid)
|
|
|
|
end
|
2017-10-15 06:36:54 +00:00
|
|
|
end)
|