2019-06-28 17:50:02 +00:00
|
|
|
local Util = require('opus.util')
|
2017-10-15 06:36:54 +00:00
|
|
|
|
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
|
|
|
|
|
2019-12-07 19:04:58 +00:00
|
|
|
if multishell and multishell.getTabs then
|
|
|
|
-- restart tab
|
|
|
|
keyboard.addHotkey('control-backspace', function()
|
|
|
|
local tab = kernel.getFocused()
|
|
|
|
if tab and not tab.noTerminate then
|
|
|
|
multishell.terminate(tab.uid)
|
|
|
|
multishell.openTab({
|
|
|
|
path = tab.path,
|
|
|
|
env = tab.env,
|
|
|
|
args = tab.args,
|
|
|
|
focused = true,
|
|
|
|
})
|
2018-01-24 22:39:38 +00:00
|
|
|
end
|
2019-12-07 19:04:58 +00:00
|
|
|
end)
|
|
|
|
end
|
2017-10-15 06:36:54 +00:00
|
|
|
|
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 visibleTabs = { }
|
2019-12-07 19:04:58 +00:00
|
|
|
local currentTab = kernel.getFocused()
|
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
|
2019-12-07 19:04:58 +00:00
|
|
|
for _,tab in Util.spairs(kernel.routines, compareTab) do
|
2019-11-10 22:58:36 +00:00
|
|
|
if not tab.hidden and not tab.noFocus then
|
2018-01-24 22:39:38 +00:00
|
|
|
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
|
2019-12-07 19:04:58 +00:00
|
|
|
if tab.uid == currentTab.uid then
|
2018-01-24 22:39:38 +00:00
|
|
|
if k < #visibleTabs then
|
2019-12-07 19:04:58 +00:00
|
|
|
kernel.raise(visibleTabs[k + 1].uid)
|
2018-01-24 22:39:38 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #visibleTabs > 0 then
|
2019-12-07 19:04:58 +00:00
|
|
|
kernel.raise(visibleTabs[1].uid)
|
2018-01-24 22:39:38 +00:00
|
|
|
end
|
2017-10-15 06:36:54 +00:00
|
|
|
end)
|