Fix keymap binding on macos

This commit is contained in:
Francesco Abbate 2021-04-21 01:42:56 -07:00
parent 9d9c7f291c
commit dd9b4f06ab
3 changed files with 6 additions and 10 deletions

View File

@ -17,7 +17,7 @@ local function keymap_macos(keymap)
["alt+i"] = "root:switch-to-up",
["alt+k"] = "root:switch-to-down",
["cmd+w"] = "root:close",
["ctrl+w"] = "root:close",
["cmd+tab"] = "root:switch-to-next-tab",
["cmd+shift+tab"] = "root:switch-to-previous-tab",
["cmd+pageup"] = "root:move-tab-left",

View File

@ -36,16 +36,12 @@ function keymap.add_direct(map)
end
function keymap.add(map, overwrite)
local control_translate = function(s)
return macos and s:gsub("%f[%a]ctrl%f[%A]", "cmd") or s
end
for stroke, commands in pairs(map) do
if macos then
stroke = stroke:gsub("%f[%a]ctrl%f[%A]", "cmd")
end
if type(commands) == "string" then
commands = { control_translate(commands) }
else
for i = 1, #commands do
commands[i] = control_translate(commands[i])
end
commands = { commands }
end
if overwrite then
keymap.map[stroke] = commands

View File

@ -59,6 +59,6 @@ command.add("core.docview", {
})
keymap.add {
keymap.add_direct {
["ctrl+shift+q"] = "reflow:reflow"
}