restructured code in separated files
This commit is contained in:
@ -1,71 +1,6 @@
|
||||
#import "utils.typ": get-group-span
|
||||
#import "renderer.typ": render
|
||||
|
||||
#let _seq(
|
||||
p1,
|
||||
p2,
|
||||
comment: none,
|
||||
dashed: false,
|
||||
tip: "default",
|
||||
color: black,
|
||||
flip: false,
|
||||
enable-dst: false,
|
||||
disable-dst: false,
|
||||
destroy-dst: false,
|
||||
disable-src: false,
|
||||
destroy-src: false,
|
||||
) = {
|
||||
return ((
|
||||
type: "seq",
|
||||
p1: p1,
|
||||
p2: p2,
|
||||
comment: comment,
|
||||
dashed: dashed,
|
||||
tip: tip,
|
||||
color: color,
|
||||
flip: flip,
|
||||
enable-dst: enable-dst,
|
||||
disable-dst: disable-dst,
|
||||
destroy-dst: destroy-dst,
|
||||
disable-src: disable-src,
|
||||
destroy-src: destroy-src,
|
||||
),)
|
||||
}
|
||||
|
||||
#let _par(name, display-name: auto, start-at: 0) = {
|
||||
return ((
|
||||
type: "par",
|
||||
name: name,
|
||||
display-name: if display-name == auto {name} else {display-name},
|
||||
start-at: start-at
|
||||
),)
|
||||
}
|
||||
|
||||
#let _par-exists(participants, name) = {
|
||||
for p in participants {
|
||||
if name == p.name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
#let _grp(name, desc: none, type: "default", elmts) = {
|
||||
return ((
|
||||
type: "grp",
|
||||
name: name,
|
||||
desc: desc,
|
||||
grp-type: type,
|
||||
elmts: elmts
|
||||
),)
|
||||
}
|
||||
|
||||
#let _sep(name) = {
|
||||
return ((
|
||||
type: "sep",
|
||||
name: name
|
||||
),)
|
||||
}
|
||||
#import "participant.typ" as participant: _par
|
||||
|
||||
#let _gap(size: 20) = {
|
||||
return ((
|
||||
@ -78,6 +13,8 @@
|
||||
let participants = ()
|
||||
let elmts = elements
|
||||
let i = 0
|
||||
|
||||
// Flatten groups
|
||||
while i < elmts.len() {
|
||||
let elmt = elmts.at(i)
|
||||
if elmt.type == "grp" {
|
||||
@ -93,19 +30,21 @@
|
||||
i += 1
|
||||
}
|
||||
|
||||
// List participants
|
||||
for elmt in elmts {
|
||||
if elmt.type == "par" {
|
||||
participants.push(elmt)
|
||||
} else if elmt.type == "seq" {
|
||||
if not _par-exists(participants, elmt.p1) {
|
||||
if not participant._exists(participants, elmt.p1) {
|
||||
participants.push(_par(elmt.p1).first())
|
||||
}
|
||||
if not _par-exists(participants, elmt.p2) {
|
||||
if not participant._exists(participants, elmt.p2) {
|
||||
participants.push(_par(elmt.p2).first())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute groups spans (horizontal)
|
||||
for (i, elmt) in elmts.enumerate() {
|
||||
if elmt.type == "grp" {
|
||||
let (min-i, max-i) = get-group-span(participants, elmt)
|
||||
|
Reference in New Issue
Block a user