defaults.lua: fix some lint warnings

This commit is contained in:
Kacper Michajłow 2024-05-12 02:47:08 +02:00
parent 5e77d3b640
commit fe488151dc
1 changed files with 7 additions and 6 deletions

View File

@ -1,5 +1,6 @@
-- Compatibility shim for lua 5.2/5.3 -- Compatibility shim for lua 5.2/5.3
unpack = unpack or table.unpack -- luacheck: globals unpack
unpack = unpack or table.unpack -- luacheck: globals table.unpack
-- these are used internally by lua.c -- these are used internally by lua.c
mp.UNKNOWN_TYPE.info = "this value is inserted if the C type is not supported" mp.UNKNOWN_TYPE.info = "this value is inserted if the C type is not supported"
@ -95,7 +96,7 @@ function mp.set_key_bindings(list, section, flags)
local cb_up = entry[4] local cb_up = entry[4]
if type(cb) ~= "string" then if type(cb) ~= "string" then
local mangle = reserve_binding() local mangle = reserve_binding()
dispatch_key_bindings[mangle] = function(name, state) dispatch_key_bindings[mangle] = function(_, state)
local event = state:sub(1, 1) local event = state:sub(1, 1)
local is_mouse = state:sub(2, 2) == "m" local is_mouse = state:sub(2, 2) == "m"
local def = (is_mouse and "u") or "d" local def = (is_mouse and "u") or "d"
@ -156,7 +157,7 @@ function mp.flush_keybindings()
flags = "force" flags = "force"
end end
local bindings = {} local bindings = {}
for k, v in pairs(key_bindings) do for _, v in pairs(key_bindings) do
if v.bind and v.forced ~= def then if v.bind and v.forced ~= def then
bindings[#bindings + 1] = v bindings[#bindings + 1] = v
end end
@ -199,7 +200,7 @@ local function add_binding(attrs, key, name, fn, rp)
["r"] = "repeat", ["r"] = "repeat",
["p"] = "press", ["p"] = "press",
} }
key_cb = function(name, state, key_name, key_text) key_cb = function(_, state, key_name, key_text)
if key_text == "" then if key_text == "" then
key_text = nil key_text = nil
end end
@ -214,7 +215,7 @@ local function add_binding(attrs, key, name, fn, rp)
fn({event = "press", is_mouse = false}) fn({event = "press", is_mouse = false})
end end
else else
key_cb = function(name, state) key_cb = function(_, state)
-- Emulate the same semantics as input.c uses for most bindings: -- Emulate the same semantics as input.c uses for most bindings:
-- For keyboard, "down" runs the command, "up" does nothing; -- For keyboard, "down" runs the command, "up" does nothing;
-- for mouse, "down" does nothing, "up" runs the command. -- for mouse, "down" does nothing, "up" runs the command.
@ -428,7 +429,7 @@ end
function mp.unregister_event(cb) function mp.unregister_event(cb)
for name, sub in pairs(event_handlers) do for name, sub in pairs(event_handlers) do
local found = false local found = false
for i, e in ipairs(sub) do for _, e in ipairs(sub) do
if e == cb then if e == cb then
found = true found = true
break break