key bind for list of delete marks (#27)
* key bind for list of delete marks https://github.com/zenyd/mpv-scripts/issues/14 * make show list a toggle so we don't spam the terminal * put showListTimer:resume() in condition * undelete all and globalize timer if timer is local showList() can't reference it * add new keybinds * add space to help wrapping * better matching
This commit is contained in:
parent
019fb5346c
commit
efa300fb6b
|
@ -65,3 +65,5 @@ First invoke the script using `alt + u`, input a movie name, or use the one prov
|
|||
As the name suggests this is a small script for deleting files played through mpv. You can mark a file to be deleted and can unmark it if desired. Once quitting mpv, the script starts the deletion process. This is platform-agnostic so should work everywhere.
|
||||
|
||||
`ctrl + DEL`: mark/unmark file to be deleted
|
||||
`alt + DEL`: show the list of files marked for deletion
|
||||
`ctrl + shift + DEL`: clear the list of marks
|
||||
|
|
|
@ -36,5 +36,37 @@ function delete()
|
|||
end
|
||||
end
|
||||
|
||||
function showList()
|
||||
local delString = "Delete Marks:\n"
|
||||
for _,v in pairs(del_list) do
|
||||
local dFile = v:gsub("/","\\")
|
||||
delString = delString..dFile:match("\\*([^\\]*)$").."; "
|
||||
end
|
||||
if delString:find(";") then
|
||||
mp.osd_message(delString)
|
||||
return delString
|
||||
elseif showListTimer then
|
||||
showListTimer:kill()
|
||||
end
|
||||
end
|
||||
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()
|
||||
if delString and delString:find(";") then
|
||||
showListTimer:resume()
|
||||
print(delString)
|
||||
else
|
||||
showListTimer:kill()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mp.add_key_binding("ctrl+DEL", "delete_file", mark_delete)
|
||||
mp.add_key_binding("alt+DEL", "list_marks", list_marks)
|
||||
mp.add_key_binding("ctrl+shift+DEL", "clear_list", function() mp.osd_message("Undelete all"); del_list = {}; end)
|
||||
mp.register_event("shutdown", delete)
|
||||
|
|
Loading…
Reference in New Issue