blob: 28902cef9936454364100ef1494f296894bda076 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
script_name = "consistency assistant"
script_description = "ctrl-c ctrl-v"
script_version = "1.1.0"
script_author = "garret"
script_namespace = "garret.ctrl-c-ctrl-v"
local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl")
local util
if haveDepCtrl then
depctrl = DependencyControl({
--feed="TODO",
})
end
local function main(sub, sel)
local src = {}
for i = 1, #sub do
local line = sub[i]
if line.class == "dialogue" then
if line.comment ~= true then
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[paste_name], 1)
end
end
end
end
end
if haveDepCtrl then
depctrl:registerMacro(main)
else
aegisub.register_macro(script_name, script_description, main)
end
|