make show list a toggle so we don't spam the terminal

This commit is contained in:
bitingsock 2021-03-06 10:37:12 -08:00 committed by GitHub
parent c8bd7c057c
commit 4d9e32a36e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 5 deletions

View File

@ -36,18 +36,39 @@ function delete()
end
end
function list_marks()
function showList()
local delString = "Delete Marks:\n"
for _,v in pairs(del_list) do
if v:find("\\") then
delString = delString..v:match("\\([^\\]*)$").."\n"
delString = delString..v:match("\\([^\\]*)$")..";"
else
delString = delString..v:match("/([^/]*)$").."\n"
delString = delString..v:match("/([^/]*)$")..";"
end
end
if delString:find(";") then
mp.osd_message(delString)
return delString
elseif showListTimer then
showListTimer:kill()
end
end
local showListTimer = mp.add_periodic_timer(1,showList)
showListTimer:kill()
function list_marks()
if showListTimer:is_enabled() then
showListTimer:kill()
mp.osd_message("",0)
else
local delString = showList()
showListTimer:resume()
if delString and delString:find(";") then
print(delString)
else
showListTimer:kill()
end
end
mp.osd_message(delString)
end
mp.add_key_binding("ctrl+DEL", "delete_file", mark_delete)
mp.add_key_binding("alt+DEL", "list_marks", list_marks, {repeatable=true})
mp.add_key_binding("alt+DEL", "list_marks", list_marks)
mp.register_event("shutdown", delete)