-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBindings.lua
More file actions
62 lines (53 loc) · 1.26 KB
/
Copy pathBindings.lua
File metadata and controls
62 lines (53 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---@class ns
local ns = select(2, ...)
local AceLocale = LibStub("AceLocale-3.0")
local L = AceLocale:GetLocale("GlobalSearch")
BINDING_HEADER_GLOBALSEARCH = L.global_search
BINDING_NAME_GLOBALSEARCH_SHOW = L.show
local Bindings = {}
function Bindings.GetCurrentModifiers()
local modifiers = ""
if IsShiftKeyDown() then
modifiers = "SHIFT-"
end
if IsControlKeyDown() then
modifiers = "CTRL-" .. modifiers
end
if IsAltKeyDown() then
modifiers = "ALT-" .. modifiers
end
return modifiers
end
do
local cache = {}
local frame = CreateFrame("Frame")
frame:RegisterEvent("UPDATE_BINDINGS")
frame:SetScript("OnEvent", function()
cache = {}
end)
---@param name string
---@return string[]
local function GetBindingsByName(name)
for i = 1, GetNumBindings() do
local binding = { GetBinding(i) }
if binding[1] == name then
return { select(3, unpack(binding)) }
end
end
return {}
end
---@param name string
---@return table<string, boolean>
function Bindings.GetKeyBinding(name)
if not cache[name] then
local bindingsList = GetBindingsByName("GLOBALSEARCH_" .. name)
local bindingsSet = ns.Util.ListToSet(bindingsList)
cache[name] = bindingsSet
end
return cache[name]
end
end
if ns then
ns.Bindings = Bindings
end
return Bindings