diff options
author | garret <garret@airmail.cc> | 2021-09-30 00:23:28 +0100 |
---|---|---|
committer | garret <garret@airmail.cc> | 2021-09-30 00:37:09 +0100 |
commit | 04a61982e82a5df1cb2ec77a5d9752782a7c41e0 (patch) | |
tree | 35ec751a28b717a7cc6158f84357408173339bff /macros/dupe-and-comment.lua | |
parent | 2a9e07ff9a5f7084d3e2e54ff5d065f9b0a93591 (diff) | |
download | aegisub-scripts-04a61982e82a5df1cb2ec77a5d9752782a7c41e0.tar.gz aegisub-scripts-04a61982e82a5df1cb2ec77a5d9752782a7c41e0.tar.bz2 aegisub-scripts-04a61982e82a5df1cb2ec77a5d9752782a7c41e0.zip |
macro folder
the beginning of becoming like every other cartel-aproved script repo in existence
Diffstat (limited to 'macros/dupe-and-comment.lua')
-rw-r--r-- | macros/dupe-and-comment.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/macros/dupe-and-comment.lua b/macros/dupe-and-comment.lua new file mode 100644 index 0000000..97b71dd --- /dev/null +++ b/macros/dupe-and-comment.lua @@ -0,0 +1,33 @@ +script_name="Dupe and Comment" +script_description="Copies a line and comments out the original." +script_author = "garret" +script_version = "2021-04-11" +include("utils.lua") +-- i like seeing the original while editing, and being able to go back to it easily + +function comment(subs, sel) + for i=#sel,1,-1 do + local line=subs[sel[i]] + local dupe = util.copy(line) + line.comment = false -- going to edit it, so we probably want to see it on the video + dupe.comment = true -- this is the actual original one + subs.insert(sel[i]+1,dupe) -- putting it on the next line so i don't have to change line + end + 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] + 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.."/Do", script_description, comment) +aegisub.register_macro(script_name.."/Undo", "Deletes selected line and restores the original", undo) |