Only process selected lines in the Select Overlaps macro

And skip over commented lines as the description claimed it did already.

Closes #1751.
This commit is contained in:
tophf 2014-05-09 10:22:58 -07:00 committed by Thomas Goyne
parent b96edfebcc
commit 01dc7f9294
1 changed files with 17 additions and 7 deletions

View File

@ -19,13 +19,22 @@ export script_description = tr"Select lines which begin while another non-commen
export script_author = "Thomas Goyne" export script_author = "Thomas Goyne"
export script_version = "2" export script_version = "2"
select_overlaps = (subs) -> select_overlaps = (subs, selection) ->
-- filter subtitles lines to just dialogue lines and sort them by time is_dialogue = (line) ->
dialogue = {} line.class == "dialogue" and not line.comment
for i, line in ipairs subs
if line.class == "dialogue" -- Attach the original index to each line so that we know what to update in
line.i = i -- the subs object after sorting by time
table.insert dialogue, line prepare = (i, line) ->
line.i = i
line
-- Filter subtitles lines to just dialogue lines and sort them by time
dialogue = if #selection <= 1
[prepare i, line for i, line in ipairs subs when is_dialogue line]
else
[prepare i, subs[i] for i in *selection when is_dialogue subs[i]]
table.sort dialogue, (a,b) -> table.sort dialogue, (a,b) ->
a.start_time < b.start_time or (a.start_time == b.start_time and a.i < b.i) a.start_time < b.start_time or (a.start_time == b.start_time and a.i < b.i)
@ -36,6 +45,7 @@ select_overlaps = (subs) ->
end_time = line.end_time end_time = line.end_time
else else
table.insert overlaps, line.i table.insert overlaps, line.i
overlaps overlaps
aegisub.register_macro script_name, script_description, select_overlaps aegisub.register_macro script_name, script_description, select_overlaps