1
0
mirror of https://github.com/kepler155c/opus synced 2024-10-31 22:26:16 +00:00
opus/sys/autorun/hotkeys.lua
kepler155c@gmail.com 8279c1ae12 environments, error messages, and stack traces, oh my!
Changed the way processes are launched.
multishell.openTab and kernel.run now accept the current environment as a parameter.
That new process inherits a copy of the passed environment.
Reduces complexity as the calling process is not required to create a suitable env.
Stack traces have been greatly improved and now include the stack for coroutines that error.
2020-05-11 17:25:58 -06:00

48 lines
1.0 KiB
Lua

local Util = require('opus.util')
local kernel = _G.kernel
local keyboard = _G.device.keyboard
local multishell = _ENV.multishell
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(tab.env, {
path = tab.path,
args = tab.args,
focused = true,
})
end
end)
end
-- next tab
keyboard.addHotkey('control-tab', function()
local visibleTabs = { }
local currentTab = kernel.getFocused()
local function compareTab(a, b)
return a.uid < b.uid
end
for _,tab in Util.spairs(kernel.routines, compareTab) do
if not tab.hidden and not tab.noFocus then
table.insert(visibleTabs, tab)
end
end
for k,tab in ipairs(visibleTabs) do
if tab.uid == currentTab.uid then
if k < #visibleTabs then
kernel.raise(visibleTabs[k + 1].uid)
return
end
end
end
if #visibleTabs > 0 then
kernel.raise(visibleTabs[1].uid)
end
end)