Skip to content

Commit

Permalink
Add progress reporting to Revert macro.
Browse files Browse the repository at this point in the history
Fixes #15.
  • Loading branch information
torque committed Sep 16, 2014
1 parent 51b75b9 commit 9731762
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Aegisub-Motion.moon
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ trimProcessorEach = ( subtitles, selectedLines ) ->
trimProcessor subtitles, selectedLines, nil, true

revertProcessor = ( subtitles, selectedLines ) ->
setTask = aegisub.progress.task
setProgress = aegisub.progress.set
setTask "Collecting UUIDs"
-- A table of all UUIDs found in the selected lines
uuids = { }
-- Indices of lines that need to be removed later (are part of a
Expand All @@ -504,7 +507,10 @@ revertProcessor = ( subtitles, selectedLines ) ->

indicesToNuke = { }

for index = 1, #subtitles
setTask "Gathering Matching Lines"
totalLines = #subtitles

for index = 1, totalLines
with line = subtitles[index]
if line.extra
-- Catch lines containing our signature extradata.
Expand All @@ -525,6 +531,9 @@ revertProcessor = ( subtitles, selectedLines ) ->
elseif index > oldLine.number
indicesToNuke[#indicesToNuke+1] = index

setProgress index/totalLines

setTask "Replacing Lines"
-- Replace the lines.
for _, line in pairs uuids
subtitles[line.number] = line
Expand Down

0 comments on commit 9731762

Please sign in to comment.