From 7342f68069df93f2dfb90df8a53a06f090edc866 Mon Sep 17 00:00:00 2001 From: garret Date: Sat, 10 Apr 2021 11:49:58 +0100 Subject: [Dupe and Comment] add undo --- dupe-and-comment.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'dupe-and-comment.lua') diff --git a/dupe-and-comment.lua b/dupe-and-comment.lua index 6c31c81..c42ce0a 100644 --- a/dupe-and-comment.lua +++ b/dupe-and-comment.lua @@ -16,4 +16,21 @@ function comment(subs, sel) aegisub.set_undo_point(script_name) end +function undo(subs, sel) + for i=#sel,1,-1 do + local edit=subs[sel[i]] + local original=subs[sel[i]+1] + --aegisub.log("Edit\nindex = "..i..", text = "..edit.text.."\n") + --aegisub.log("Original\nindex = "..(i + 1)..", text = "..original.text.."\n") + if edit.comment == false and original.comment == true then + + original.comment = false + subs[sel[i]+1] = original + subs.delete(sel[i]) + end + end + aegisub.set_undo_point("Undo "..script_name) +end + aegisub.register_macro(script_name, script_description, comment) +aegisub.register_macro(script_name.." - Undo", "Uncomments a line and restores the original", undo) -- cgit v1.2.3-70-g09d2