From e8e7dc9909482897c6e7c4212a28cb99cf7bed02 Mon Sep 17 00:00:00 2001 From: garret Date: Thu, 22 Dec 2022 18:42:48 +0000 Subject: A-B: add revert function to get the script back to how it was, but with any changes you've made --- macros/garret.a-b.lua | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'macros/garret.a-b.lua') 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 -- cgit v1.2.3-70-g09d2