Make control to cmd translate on macos automatic
This commit is contained in:
parent
12ca5f3d2a
commit
9d9c7f291c
|
@ -1,5 +1,5 @@
|
||||||
local function keymap_macos(keymap)
|
local function keymap_macos(keymap)
|
||||||
keymap.add {
|
keymap.add_direct {
|
||||||
["cmd+shift+p"] = "core:find-command",
|
["cmd+shift+p"] = "core:find-command",
|
||||||
["cmd+p"] = "core:find-file",
|
["cmd+p"] = "core:find-file",
|
||||||
["cmd+o"] = "core:open-file",
|
["cmd+o"] = "core:open-file",
|
||||||
|
@ -45,7 +45,7 @@ local function keymap_macos(keymap)
|
||||||
["cmd+x"] = "doc:cut",
|
["cmd+x"] = "doc:cut",
|
||||||
["cmd+c"] = "doc:copy",
|
["cmd+c"] = "doc:copy",
|
||||||
["cmd+v"] = "doc:paste",
|
["cmd+v"] = "doc:paste",
|
||||||
["cmd+insert"] = "doc:copy",
|
["ctrl+insert"] = "doc:copy",
|
||||||
["shift+insert"] = "doc:paste",
|
["shift+insert"] = "doc:paste",
|
||||||
["escape"] = { "command:escape", "doc:select-none", "dialog:select-no" },
|
["escape"] = { "command:escape", "doc:select-none", "dialog:select-no" },
|
||||||
["tab"] = { "command:complete", "doc:indent" },
|
["tab"] = { "command:complete", "doc:indent" },
|
||||||
|
|
|
@ -23,11 +23,30 @@ local function key_to_stroke(k)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function keymap.add(map, overwrite)
|
function keymap.add_direct(map)
|
||||||
for stroke, commands in pairs(map) do
|
for stroke, commands in pairs(map) do
|
||||||
if type(commands) == "string" then
|
if type(commands) == "string" then
|
||||||
commands = { commands }
|
commands = { commands }
|
||||||
end
|
end
|
||||||
|
keymap.map[stroke] = commands
|
||||||
|
for _, cmd in ipairs(commands) do
|
||||||
|
keymap.reverse_map[cmd] = stroke
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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 type(commands) == "string" then
|
||||||
|
commands = { control_translate(commands) }
|
||||||
|
else
|
||||||
|
for i = 1, #commands do
|
||||||
|
commands[i] = control_translate(commands[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
if overwrite then
|
if overwrite then
|
||||||
keymap.map[stroke] = commands
|
keymap.map[stroke] = commands
|
||||||
else
|
else
|
||||||
|
@ -85,7 +104,7 @@ if macos then
|
||||||
return keymap
|
return keymap
|
||||||
end
|
end
|
||||||
|
|
||||||
keymap.add {
|
keymap.add_direct {
|
||||||
["ctrl+shift+p"] = "core:find-command",
|
["ctrl+shift+p"] = "core:find-command",
|
||||||
["ctrl+p"] = "core:find-file",
|
["ctrl+p"] = "core:find-file",
|
||||||
["ctrl+o"] = "core:open-file",
|
["ctrl+o"] = "core:open-file",
|
||||||
|
|
Loading…
Reference in New Issue