diff options
author | garret <garret@airmail.cc> | 2024-02-25 23:01:13 +0000 |
---|---|---|
committer | garret <garret@airmail.cc> | 2024-02-25 23:08:47 +0000 |
commit | 67d261ab378fa9166ee6e0c31b7cb4e32a019925 (patch) | |
tree | 1fbd2153481e675f283f731c1da59d584513f2c9 /a-b.lua | |
parent | 5edf42a777b02ab939ab751a7d3e7eb0a7efde70 (diff) | |
download | aegisub-scripts-67d261ab378fa9166ee6e0c31b7cb4e32a019925.tar.gz aegisub-scripts-67d261ab378fa9166ee6e0c31b7cb4e32a019925.tar.bz2 aegisub-scripts-67d261ab378fa9166ee6e0c31b7cb4e32a019925.zip |
get rid of dependencycontrol bullshit
there is no sense in me keeping it around when all it does is
add faff to writing the script
add useless noise to the filenames/paths
and enforces its opinions upon me which i dont agree with
and all for absolutely ZERO reason since i don't even have a feed in the
first place
if you want to take my scripts and package them into a dependencycontrol
feed, you are more than welcome to do so, provided you comply with the
terms of the licence. but your life is going to be a little bit harder
i'm afraid, sorry about that.
i will keep all the script_namespace, depctrl registration and such
around for the time being (removing it is >effort)
Diffstat (limited to 'a-b.lua')
-rw-r--r-- | a-b.lua | 87 |
1 files changed, 87 insertions, 0 deletions
@@ -0,0 +1,87 @@ +script_name = "A-B" +script_description = "makes checking pre-timing possible." +script_author = "garret" +script_version = "3.0.0" +script_namespace = "garret.a-b" + +local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl") +if haveDepCtrl then + depctrl = DependencyControl { + --feed="TODO", + } +end + +local function switch_indicator(i) + if i == "a" then + return "b" + elseif i == "b" then + return "a" + end +end + +local function strip_tags(text) + return text:gsub("{[^}]-}","") +end + +local function get_indicator(letter, actor) + local indicator + if actor == "" then + indicator = letter + else + indicator = actor.." "..letter + end + return indicator +end + +local function escape_pattern(txt) + local magic_chars = "%^%$%(%)%%.%[%]%*%+%-%?" + return txt:gsub("(["..magic_chars.."])", "%%%1") +end + +local function main(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 == "" then + line.text = indicator + elseif strip_tags(line.text) == "" then + line.text = line.text .. indicator -- apply tags + end + + sub[li] = line + i = switch_indicator(i) + end + 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 + local escaped = escape_pattern(indicator) + line.text = line.text:gsub(escaped, "") + 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:registerMacros(macros) +else + for _,macro in ipairs(macros) do + local name, desc, fun = unpack(macro) + aegisub.register_macro(script_name .. '/' .. name, desc, fun) + end +end |