Fix #845 by counting how many output lines were produced by applying a template to a line, instead of assuming that a template always gets applied, even if it's a code template.
Originally committed to SVN as r2922.
This commit is contained in:
parent
f4808b82a0
commit
2acf887157
1 changed files with 13 additions and 13 deletions
|
@ -648,7 +648,7 @@ function run_text_template(template, tenv, varctx)
|
||||||
end
|
end
|
||||||
|
|
||||||
function apply_syllable_templates(syl, line, templates, tenv, varctx, subs)
|
function apply_syllable_templates(syl, line, templates, tenv, varctx, subs)
|
||||||
local applied_templates = false
|
local applied = 0
|
||||||
|
|
||||||
-- Loop over all templates matching the line style
|
-- Loop over all templates matching the line style
|
||||||
for t in matching_templates(templates, line, tenv) do
|
for t in matching_templates(templates, line, tenv) do
|
||||||
|
@ -658,12 +658,10 @@ function apply_syllable_templates(syl, line, templates, tenv, varctx, subs)
|
||||||
tenv.basesyl = syl
|
tenv.basesyl = syl
|
||||||
set_ctx_syl(varctx, line, syl)
|
set_ctx_syl(varctx, line, syl)
|
||||||
|
|
||||||
if apply_one_syllable_template(syl, line, t, tenv, varctx, subs, false, false) then
|
applied = applied + apply_one_syllable_template(syl, line, t, tenv, varctx, subs, false, false)
|
||||||
applied_templates = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return applied_templates
|
return applied > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function is_syl_blank(syl)
|
function is_syl_blank(syl)
|
||||||
|
@ -680,20 +678,21 @@ function is_syl_blank(syl)
|
||||||
end
|
end
|
||||||
|
|
||||||
function apply_one_syllable_template(syl, line, template, tenv, varctx, subs, skip_perchar, skip_multi)
|
function apply_one_syllable_template(syl, line, template, tenv, varctx, subs, skip_perchar, skip_multi)
|
||||||
|
if aegisub.progress.is_cancelled() then return 0 end
|
||||||
local t = template
|
local t = template
|
||||||
if aegisub.progress.is_cancelled() then return false end
|
local applied = 0
|
||||||
|
|
||||||
aegisub.debug.out(5, "Applying template to one syllable with text: %s\n", syl.text)
|
aegisub.debug.out(5, "Applying template to one syllable with text: %s\n", syl.text)
|
||||||
|
|
||||||
-- Check for right inline_fx
|
-- Check for right inline_fx
|
||||||
if t.fx and t.fx ~= syl.inline_fx then
|
if t.fx and t.fx ~= syl.inline_fx then
|
||||||
aegisub.debug.out(5, "Syllable has wrong inline-fx (wanted '%s', got '%s'), skipping.\n", t.inline_fx, syl.inline_fx)
|
aegisub.debug.out(5, "Syllable has wrong inline-fx (wanted '%s', got '%s'), skipping.\n", t.inline_fx, syl.inline_fx)
|
||||||
return false
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if t.noblank and is_syl_blank(syl) then
|
if t.noblank and is_syl_blank(syl) then
|
||||||
aegisub.debug.out(5, "Syllable is blank, skipping.\n")
|
aegisub.debug.out(5, "Syllable is blank, skipping.\n")
|
||||||
return false
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Recurse to per-char if required
|
-- Recurse to per-char if required
|
||||||
|
@ -716,10 +715,10 @@ function apply_one_syllable_template(syl, line, template, tenv, varctx, subs, sk
|
||||||
left = left + width
|
left = left + width
|
||||||
set_ctx_syl(varctx, line, charsyl)
|
set_ctx_syl(varctx, line, charsyl)
|
||||||
|
|
||||||
apply_one_syllable_template(charsyl, line, t, tenv, varctx, subs, true, false)
|
applied = applied + apply_one_syllable_template(charsyl, line, t, tenv, varctx, subs, true, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return applied
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Recurse to multi-hl if required
|
-- Recurse to multi-hl if required
|
||||||
|
@ -735,10 +734,10 @@ function apply_one_syllable_template(syl, line, template, tenv, varctx, subs, sk
|
||||||
hlsyl.duration = hldata.duration
|
hlsyl.duration = hldata.duration
|
||||||
set_ctx_syl(varctx, line, hlsyl)
|
set_ctx_syl(varctx, line, hlsyl)
|
||||||
|
|
||||||
apply_one_syllable_template(hlsyl, line, t, tenv, varctx, subs, true, true)
|
applied = applied + apply_one_syllable_template(hlsyl, line, t, tenv, varctx, subs, true, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return applied
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Regular processing
|
-- Regular processing
|
||||||
|
@ -763,10 +762,11 @@ function apply_one_syllable_template(syl, line, template, tenv, varctx, subs, sk
|
||||||
newline.effect = "fx"
|
newline.effect = "fx"
|
||||||
aegisub.debug.out(5, "Generated line with text: %s\n", newline.text)
|
aegisub.debug.out(5, "Generated line with text: %s\n", newline.text)
|
||||||
subs.append(newline)
|
subs.append(newline)
|
||||||
|
applied = applied + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return applied
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue