From b969522dc88b5a6e41308a72095be007670ebd89 Mon Sep 17 00:00:00 2001 From: garret Date: Fri, 28 Oct 2022 00:48:11 +0100 Subject: consistency assistant: add named captures --- macros/garret.ctrl-c-ctrl-v.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'macros/garret.ctrl-c-ctrl-v.lua') diff --git a/macros/garret.ctrl-c-ctrl-v.lua b/macros/garret.ctrl-c-ctrl-v.lua index 8a1fcb6..28902ce 100644 --- a/macros/garret.ctrl-c-ctrl-v.lua +++ b/macros/garret.ctrl-c-ctrl-v.lua @@ -1,6 +1,6 @@ script_name = "consistency assistant" script_description = "ctrl-c ctrl-v" -script_version = "1.0.0" +script_version = "1.1.0" script_author = "garret" script_namespace = "garret.ctrl-c-ctrl-v" @@ -18,14 +18,17 @@ local function main(sub, sel) local line = sub[i] if line.class == "dialogue" then if line.comment ~= true then - if line.effect:match("ctrl%-c") then - aegisub.log(5, "ctrl-c: " .. line.text .. "\n") - table.insert(src, line) - elseif line.effect:match("ctrl%-v") then - aegisub.log(5, "ctrl-v: " .. line.text .. "\n") - line.text = src[1].text + local copy_name = line.effect:match("ctrl%-c ?([%S]*)") + local paste_name = line.effect:match("ctrl%-v ?([%S]*)") + if copy_name ~= nil then + aegisub.log(5, "ctrl-c " .. copy_name .. ": " .. line.text .. "\n") + src[copy_name] = src[copy_name] or {} + table.insert(src[copy_name], line) + elseif paste_name ~= nil then + aegisub.log(5, "ctrl-v " .. paste_name .. ": " .. line.text .. "\n") + line.text = src[paste_name][1].text sub[i] = line - table.remove(src, 1) + table.remove(src[paste_name], 1) end end end -- cgit v1.2.3-70-g09d2