diff options
author | garret <garret@airmail.cc> | 2021-04-10 11:49:58 +0100 |
---|---|---|
committer | garret <garret@airmail.cc> | 2021-04-10 11:49:58 +0100 |
commit | 7342f68069df93f2dfb90df8a53a06f090edc866 (patch) | |
tree | 88344b2ee125f9d7f22ecfab5a0fa6f037e99c5b | |
parent | f779a76612fc8d1b8b5db1173fd17284be1a05b0 (diff) | |
download | aegisub-scripts-7342f68069df93f2dfb90df8a53a06f090edc866.tar.gz aegisub-scripts-7342f68069df93f2dfb90df8a53a06f090edc866.tar.bz2 aegisub-scripts-7342f68069df93f2dfb90df8a53a06f090edc866.zip |
[Dupe and Comment] add undo
-rw-r--r-- | dupe-and-comment.lua | 17 |
1 files changed, 17 insertions, 0 deletions
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) |