aboutsummaryrefslogtreecommitdiffstats
path: root/macros/garret.a-b.lua
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2022-12-22 18:42:48 +0000
committergarret <garret@airmail.cc>2022-12-22 19:04:27 +0000
commite8e7dc9909482897c6e7c4212a28cb99cf7bed02 (patch)
tree6e44905259b6dba9cd50675722d38460cc2f5208 /macros/garret.a-b.lua
parentaeb5c6182f5a8e13dc60799f0177ed92407b6d8b (diff)
downloadaegisub-scripts-e8e7dc9909482897c6e7c4212a28cb99cf7bed02.tar.gz
aegisub-scripts-e8e7dc9909482897c6e7c4212a28cb99cf7bed02.tar.bz2
aegisub-scripts-e8e7dc9909482897c6e7c4212a28cb99cf7bed02.zip
A-B: add revert function
to get the script back to how it was, but with any changes you've made
Diffstat (limited to 'macros/garret.a-b.lua')
-rw-r--r--macros/garret.a-b.lua27
1 files changed, 25 insertions, 2 deletions
diff --git a/macros/garret.a-b.lua b/macros/garret.a-b.lua
index b57b4f8..ddbfde4 100644
--- a/macros/garret.a-b.lua
+++ b/macros/garret.a-b.lua
@@ -51,8 +51,31 @@ local function main(sub, sel)
aegisub.set_undo_point(script_name)
end
+local function undo(sub, sel)
+ local i = "a"
+ for _,li in ipairs(sel) do
+ local line = sub[li]
+ local indicator = get_indicator(i, line.actor)
+
+ if line.text == indicator then
+ line.text = ""
+ else
+ line.text = line.text:gsub(indicator.."$", "")
+ end
+ sub[li] = line
+ i = switch_indicator(i)
+ end
+end
+
+local macros = {
+ {"Add indicators", script_description, main},
+ {"Clean up","Gets rid of the indicators once you've adjusted the lines", undo}
+}
if haveDepCtrl then
- depctrl:registerMacro(main)
+ depctrl:registerMacros(macros)
else
- aegisub.register_macro(script_name, script_description, main)
+ for _,macro in ipairs(macros) do
+ local name, desc, fun = unpack(macro)
+ aegisub.register_macro(script_name .. '/' .. name, desc, fun)
+ end
end