aegisub hotkeys and scripts

This commit is contained in:
odrling 2019-07-05 21:44:41 +02:00
parent d2df53804c
commit 210e7273c5
29 changed files with 470 additions and 0 deletions

View file

@ -0,0 +1,72 @@
local tr = aegisub.gettext
script_name = tr"Karaoke 1sec adjust lead-in"
script_description = tr"Adjust karaoke leadin to 1sec"
script_author = "Flore"
script_version = "1.00"
include("cleantags.lua")
leadinmsec = 1000 --lead in time can be changed here
ktag = "\\[kK][fo]?%d+" --pattern used to detect karaoke tags
function adjust_1sec(subs, sel)
function hasleadin(line)--check if there is an existing lead in (2 consecutive bracket with karaoke tags at the start of the line)
return line.text:find("^{[^{}]-" .. ktag .. "[^{}]-}{[^{}]-" .. ktag .. "[^{}]-}")
end
function removeleadin(line)
if not hasleadin(line) then
return line
end
leadin = tonumber( line.text:match("^{[^{}]-\\[kK][fo]?(%d+)[^{}]-}{[^{}]-" .. ktag .. "[^{}]-}") ) --read lead-in value
line.text = line.text:gsub("^({[^{}]-)\\[kK][fo]?%d+(.-}{[^{}]-" .. ktag .. ".-})","%1%2") --remove lead in
line.text = cleantags(line.text) --clean tags
line.start_time = line.start_time + leadin*10 --adjust start time
--aegisub.log(line.text)
return line
end
for _, i in ipairs(sel) do
local line = subs[i]
line.text = cleantags(line.text)
if( line.text:find(ktag)) then--don't do anything if there is no ktags in this line
--start by removing existing lead-in
while hasleadin(line) do
if aegisub.progress.is_cancelled() then return end
line = removeleadin(line)
end
--then add our lead in
if line.start_time >= leadinmsec then
line.text = string.format("{\\k%d}%s",leadinmsec/10, line.text)
line.start_time = line.start_time - leadinmsec
else --if line starts too early to put the needed lead in, make the line start at time 0 and fill with appropriate lead in
line.text = string.format("{\\k%d}%s",line.start_time/10, line.text)
line.start_time = 0
end
subs[i] = line
end
end
aegisub.set_undo_point(tr"1sec adjust lead-in")
end
aegisub.register_macro(script_name, script_description, adjust_1sec)

View file

@ -0,0 +1 @@
../unanimated/ua.BlurAndGlow.lua

View file

@ -0,0 +1 @@
../unanimated/ua.ChangeCase.lua

View file

@ -0,0 +1 @@
../unanimated/ua.Colorize.lua

View file

@ -0,0 +1 @@
../unanimated/ua.Cycles.lua

View file

@ -0,0 +1 @@
../unanimated/ua.EncodeHardsub.lua

View file

@ -0,0 +1 @@
../unanimated/ua.FadeWorks.lua

View file

@ -0,0 +1 @@
../unanimated/ua.HYDRA.lua

View file

@ -0,0 +1 @@
../unanimated/ua.JoinSplitSnap.lua

View file

@ -0,0 +1 @@
../unanimated/ua.JumpToNext.lua

View file

@ -0,0 +1 @@
../unanimated/ua.LineBreaker.lua

View file

@ -0,0 +1 @@
../unanimated/ua.Masquerade.lua

View file

@ -0,0 +1 @@
../unanimated/ua.MultiCopy.lua

View file

@ -0,0 +1 @@
../unanimated/ua.MultiLineEditor.lua

View file

@ -0,0 +1 @@
../unanimated/ua.Multiplexer.lua

View file

@ -0,0 +1 @@
../unanimated/ua.NecrosCopy.lua

View file

@ -0,0 +1 @@
../unanimated/ua.QC.lua

View file

@ -0,0 +1 @@
../unanimated/ua.Recalculator.lua

View file

@ -0,0 +1 @@
../unanimated/ua.Relocator.lua

View file

@ -0,0 +1 @@
../unanimated/ua.ScriptCleanup.lua

View file

@ -0,0 +1 @@
../unanimated/ua.Selectrix.lua

View file

@ -0,0 +1 @@
../unanimated/ua.ShiftCut.lua

View file

@ -0,0 +1 @@
../unanimated/ua.Significance.lua

View file

@ -0,0 +1 @@
../unanimated/ua.TimeSigns.lua

View file

@ -0,0 +1 @@
../unanimated/ua.iBus.lua

@ -0,0 +1 @@
Subproject commit efc98e26dacf08cd67234c5e569032581ed4849c

365
.aegisub/hotkey.json Normal file
View file

@ -0,0 +1,365 @@
{
"Always" : {
"audio/commit" : [
"KP_Enter"
],
"audio/play/selection" : [
"KP_5"
],
"audio/play/selection/after" : [
"KP_3"
],
"audio/play/selection/before" : [
"KP_1"
],
"audio/stop" : [
"KP_8"
],
"time/length/decrease" : [
"KP_7"
],
"time/length/increase" : [
"KP_9"
],
"time/next" : [
"KP_2"
],
"time/prev" : [
"KP_0"
],
"time/start/decrease" : [
"KP_4"
],
"time/start/increase" : [
"KP_6"
]
},
"Audio" : {
"app/toggle/global_hotkeys" : [
"Ctrl-KP_Multiply"
],
"audio/commit" : [
"Enter",
"G"
],
"audio/commit/default" : [
"Shift-G"
],
"audio/play/line" : [
"R"
],
"audio/play/selection" : [
"E",
"Space"
],
"audio/play/selection/after" : [
"F"
],
"audio/play/selection/before" : [
"Q"
],
"audio/play/selection/begin" : [
"S"
],
"audio/play/selection/end" : [
"D"
],
"audio/play/to_end" : [
"T"
],
"audio/play/toggle" : [
"B"
],
"audio/scroll/left" : [
"A"
],
"audio/scroll/right" : [
"F"
],
"audio/stop" : [
"H"
],
"time/lead/in" : [
"C"
],
"time/lead/out" : [
"V"
],
"time/length/decrease" : [
"KP_Subtract"
],
"time/length/decrease/shift" : [
"Shift-KP_Subtract"
],
"time/length/increase" : [
"KP_Add"
],
"time/length/increase/shift" : [
"Shift-KP_Add"
],
"time/next" : [
"Right",
"X"
],
"time/prev" : [
"Left",
"Z"
]
},
"Default" : {
"app/exit" : [
"Ctrl-Q"
],
"app/options" : [
"Alt-O"
],
"automation/lua/karaoke-adjust-1sec/Karaoke 1sec adjust lead-in" : [
"Ctrl-K"
],
"edit/find_replace" : [
"Ctrl-H"
],
"edit/line/copy" : [
"Ctrl-C"
],
"edit/line/cut" : [
"Ctrl-X"
],
"edit/line/delete" : [
"Ctrl-Delete"
],
"edit/line/paste" : [
"Ctrl-V"
],
"edit/line/paste/over" : [
"Ctrl-Shift-V"
],
"edit/line/split/after" : [
"Ctrl-Shift-D"
],
"edit/line/split/before" : [
"Ctrl-D"
],
"edit/redo" : [
"Ctrl-Y"
],
"edit/undo" : [
"Ctrl-Z"
],
"grid/line/next" : [
"Ctrl-KP_2"
],
"grid/line/prev" : [
"Ctrl-KP_8"
],
"grid/move/down" : [
"Alt-Down"
],
"grid/move/up" : [
"Alt-Up"
],
"help/contents" : [
"F1"
],
"subtitle/find" : [
"Ctrl-F"
],
"subtitle/find/next" : [
"F3"
],
"subtitle/new" : [
"Ctrl-N"
],
"subtitle/open" : [
"Ctrl-O"
],
"subtitle/save" : [
"Ctrl-S",
"F2"
],
"subtitle/save/as" : [
"Ctrl-Shift-S"
],
"time/frame/current" : [
"Ctrl-6"
],
"time/shift" : [
"Ctrl-I"
],
"time/snap/end_video" : [
"Ctrl-4"
],
"time/snap/scene" : [
"Ctrl-5"
],
"time/snap/start_video" : [
"Ctrl-3"
],
"video/focus_seek" : [
"Ctrl-Space"
],
"video/frame/next" : [
"Ctrl-KP_6"
],
"video/frame/prev" : [
"Ctrl-KP_4"
],
"video/jump" : [
"Ctrl-G"
],
"video/jump/end" : [
"Ctrl-2"
],
"video/jump/start" : [
"Ctrl-1"
],
"video/play" : [
"Ctrl-P"
],
"video/zoom/in" : [
"Ctrl-KP_Add"
],
"video/zoom/out" : [
"Ctrl-KP_Subtract"
]
},
"Styling Assistant" : {
"audio/play/selection" : [
"End"
],
"grid/line/next" : [
"PageDown"
],
"grid/line/prev" : [
"PageUp"
],
"tool/styling_assistant/commit" : [
"Enter",
"KP_Enter"
],
"tool/styling_assistant/preview" : [
"F8"
],
"video/play/line" : [
"Home"
]
},
"Subtitle Edit Box" : {
"edit/color/outline" : [
"Alt-3"
],
"edit/color/primary" : [
"Alt-1"
],
"edit/color/secondary" : [
"Alt-2"
],
"edit/color/shadow" : [
"Alt-4"
],
"grid/line/next/create" : [
"Enter",
"KP_Enter"
]
},
"Subtitle Grid" : {
"subtitle/select/all" : [
"Ctrl-A"
],
"video/frame/next" : [
"Right"
],
"video/frame/next/boundary" : [
"Ctrl-Right"
],
"video/frame/next/keyframe" : [
"Shift-Right"
],
"video/frame/next/large" : [
"Alt-Right"
],
"video/frame/prev" : [
"Left"
],
"video/frame/prev/boundary" : [
"Ctrl-Left"
],
"video/frame/prev/keyframe" : [
"Shift-Left"
],
"video/frame/prev/large" : [
"Alt-Left"
]
},
"Translation Assistant" : {
"audio/play/selection" : [
"End"
],
"tool/translation_assistant/commit" : [
"Enter",
"KP_Enter"
],
"tool/translation_assistant/insert_original" : [
"Insert"
],
"tool/translation_assistant/next" : [
"PageDown"
],
"tool/translation_assistant/prev" : [
"PageUp"
],
"tool/translation_assistant/preview" : [
"F8"
],
"video/play/line" : [
"Home"
]
},
"Video" : {
"video/frame/next" : [
"Right"
],
"video/frame/next/boundary" : [
"Ctrl-Right"
],
"video/frame/next/keyframe" : [
"Shift-Right"
],
"video/frame/next/large" : [
"Alt-Right"
],
"video/frame/prev" : [
"Left"
],
"video/frame/prev/boundary" : [
"Ctrl-Left"
],
"video/frame/prev/keyframe" : [
"Shift-Left"
],
"video/frame/prev/large" : [
"Alt-Left"
],
"video/tool/clip" : [
"H"
],
"video/tool/cross" : [
"A"
],
"video/tool/drag" : [
"S"
],
"video/tool/rotate/xy" : [
"F"
],
"video/tool/rotate/z" : [
"D"
],
"video/tool/scale" : [
"G"
],
"video/tool/vector_clip" : [
"J"
]
}
}

5
.gitignore vendored
View file

@ -99,3 +99,8 @@ Cache
# dunst
!/.config/dunst
# aegisub
!/.aegisub
/.aegisub/*
!/.aegisub/hotkey.json
!/.aegisub/automation

3
.gitmodules vendored
View file

@ -59,3 +59,6 @@
[submodule ".vim/bundle/vim-repeat"]
path = .vim/bundle/vim-repeat
url = https://github.com/tpope/vim-repeat.git
[submodule ".aegisub/automation/unanimated"]
path = .aegisub/automation/unanimated
url = https://github.com/unanimated/luaegisub.git