Skip to content

Commit 54fe0e1

Browse files
Apply automatic changes
1 parent 34ad38b commit 54fe0e1

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

portable_config/scripts/inputevent.lua

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,32 @@ function command_invert(command)
176176
end
177177
end
178178

179-
local value = mp.get_property(property)
180-
local semi = i == #command_list and "" or ";"
181-
182179
if table.has(commands, command) then
183-
invert = invert .. prefix .. "set " .. property .. " " .. value .. semi
180+
local restore = true
181+
local use_del = false
182+
local value = mp.get_property_native(property)
183+
local semi = i == #command_list and "" or "; "
184+
185+
if type(value) == 'number' then
186+
value = tostring(value)
187+
elseif type(value) == 'boolean' then
188+
value = value and 'yes' or 'no'
189+
elseif type(value) == 'string' then
190+
value = '"' .. value:replace('"', '\\"') .. '"'
191+
elseif type(value) == 'nil' then
192+
use_del = true
193+
else
194+
mp.msg.warn("the value type of \"" .. property .. "\" is " .. type(value) .. ", can't auto restore.")
195+
restore = false
196+
end
197+
198+
if restore then
199+
if not use_del then
200+
invert = invert .. prefix .. "set" .. " " .. property .. " " .. value .. semi
201+
else
202+
invert = invert .. prefix .. "del" .. " " .. property .. semi
203+
end
204+
end
184205
else
185206
mp.msg.warn("\"" .. trimed .. "\" doesn't support auto restore.")
186207
end

0 commit comments

Comments
 (0)