From 215725e8cedec354aad57900917a8e1a67b0569c Mon Sep 17 00:00:00 2001 From: Bryan Date: Wed, 1 Oct 2025 22:27:14 -0600 Subject: [PATCH] try fix --- main.lua | 145 ++++++++++++++++++++++++------------------------------- 1 file changed, 64 insertions(+), 81 deletions(-) diff --git a/main.lua b/main.lua index 949b326..8055b59 100644 --- a/main.lua +++ b/main.lua @@ -1,97 +1,80 @@ local selected_or_hovered = ya.sync(function() - local tab, urls = cx.active, {} - for _, u in pairs(tab.selected) do - urls[#urls + 1] = { name = u:name(), url = tostring(u) } - end - if #urls == 0 and tab.current.hovered then - urls[1] = { name = tab.current.hovered.url:name(), url = tostring(tab.current.hovered.url) } - end - return urls + local tab, urls = cx.active, {} + for _, u in pairs(tab.selected) do + urls[#urls + 1] = { name = u:name(), url = tostring(u) } + end + if #urls == 0 and tab.current.hovered then + urls[1] = { name = tab.current.hovered.url:name(), url = tostring(tab.current.hovered.url) } + end + return urls end) local confirm_remove = function(file) - local title = "Remove " .. file.name .. "? y/n/a/c " - local w = #title - local input = ya.input({ - title = title, - value = "y", - position = { "top-center", w = w }, - }) + local title = "Remove " .. file.name .. "? y/n/a/c " + local w = #title + local input = ya.input({ + title = title, + value = "y", + position = { "top-center", w = w }, + }) - if input == "y" then - return "y" - elseif input == "a" then - return "a" - elseif input == "n" then - return "n" - else - return "c" - end - -- end - -- local cand = ya.which({ - -- cands = { - -- { on = "y", desc = "Yes" }, - -- { on = "n", desc = "No" }, - -- { on = "a", desc = "All" }, - -- }, - -- silent = true, - -- }) - -- if cand == 1 then - -- return "y" - -- elseif cand == 2 then - -- return "n" - -- elseif cand == 3 then - -- return "a" - -- else - -- return "c" - -- end + if input == "y" then + return "y" + elseif input == "a" then + return "a" + elseif input == "n" then + return "n" + else + return "c" + end end local remove_file = function(file) - local notify_success = function(name) - ya.notify({ - title = "Rip File", - content = "Burried " .. name, - timeout = 2, - }) - end - local notify_error = function(name) - ya.notify({ - title = "Rip File", - content = "Error removing " .. name, - timeout = 2, - }) - end + local notify_success = function(name) + ya.notify({ + title = "Rip File", + content = "Burried " .. name, + timeout = 2, + }) + end + local notify_error = function(name) + ya.notify({ + title = "Rip File", + content = "Error removing " .. name, + timeout = 2, + }) + end - local status, err = Command("rip"):arg(file.url):status() - if not status or status.code ~= 0 then - notify_error(file.name) - else - notify_success(file.name) - end + local status, err = Command("rip"):arg(file.url):status() + if not status or status.code ~= 0 then + notify_error(file.name) + else + notify_success(file.name) + end end +--- @sync entry return { - entry = function() - ya.manager_emit("escape", { visual = true }) + entry = function() + ya.manager_emit("escape", { visual = true }) - local files = selected_or_hovered() - local confirm_all = false + local files = selected_or_hovered() + local confirm_all = false - for _, file in ipairs(files) do - if not confirm_all then - local should_remove = confirm_remove(file) - if should_remove == "n" then - goto continue - elseif should_remove ~= "y" and should_remove ~= "a" then - return - elseif should_remove == "a" then - confirm_all = true - end - end + for _, file in ipairs(files) do + if not confirm_all then + local should_remove = confirm_remove(file) + if should_remove == "n" then + goto continue + elseif should_remove ~= "y" and should_remove ~= "a" then + return + elseif should_remove == "a" then + confirm_all = true + end + end - remove_file(file) - ::continue:: - end - end, + remove_file(file) + ::continue:: + end + end, }