Skip to content

Commit 74a8f84

Browse files
committed
LineCollection: add convenience initializer for choosing from all lines.
1 parent 2b75c88 commit 74a8f84

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

VersionDetemplater.moon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ versions = {
33
'src/DataHandler': '1.0.5'
44
'src/DataWrapper': '1.0.2'
55
'src/Line': '1.5.2'
6-
'src/LineCollection': '1.1.4'
6+
'src/LineCollection': '1.2.0'
77
'src/Log': '1.0.0'
88
'src/Math': '1.0.0'
99
'src/MotionHandler': '1.1.7'

src/LineCollection.moon

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ frameFromMs = aegisub.frame_from_ms
2828
class LineCollection
2929
@version: version
3030

31-
new: ( @sub, sel, validationCb, selectLines=true ) =>
31+
@fromAllLines: ( sub, validationCb, selectLines ) =>
32+
sel = { }
33+
for i = 1, #@sub
34+
table.insert( sel, i ) if @sub[i].class == "dialogue"
35+
@ sub, sel, validationCb, selectLines
36+
37+
new: ( @sub, sel, validationCb, selectLines = true ) =>
3238
@lines = { }
33-
if sel and #sel > 0
39+
if type( sel ) == "table" and #sel > 0
3440
@collectLines sel, validationCb, selectLines
3541
if frameFromMs 0
3642
@getFrameInfo!
@@ -43,7 +49,7 @@ class LineCollection
4349

4450
-- This method should update various properties such as
4551
-- (start|end)(Time|Frame).
46-
addLine: ( line, validationCb = (-> return true), selectLine=true, index=false ) =>
52+
addLine: ( line, validationCb = (-> return true), selectLine = true, index = false ) =>
4753
if validationCb line
4854
line.parentCollection = @
4955
line.inserted = false
@@ -95,7 +101,7 @@ class LineCollection
95101

96102
@hasMetaStyles = true
97103

98-
collectLines: ( sel, validationCb = ( ( line ) -> return not line.comment), selectLines=true ) =>
104+
collectLines: ( sel, validationCb = (( line ) -> return not line.comment), selectLines = true ) =>
99105
unless @hasMetaStyles
100106
@generateMetaAndStyles!
101107

0 commit comments

Comments
 (0)