forked from HEL/chronos
		
	added _ret for return sequences
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
#import "utils.typ": get-group-span, fit-canvas
 | 
			
		||||
#import "renderer.typ": render
 | 
			
		||||
#import "participant.typ" as participant: _par, PAR-SPECIALS
 | 
			
		||||
#import "sequence.typ": _seq
 | 
			
		||||
 | 
			
		||||
#let _gap(size: 20) = {
 | 
			
		||||
  return ((
 | 
			
		||||
@@ -38,7 +39,9 @@
 | 
			
		||||
  let elmts = elements
 | 
			
		||||
  let i = 0
 | 
			
		||||
 | 
			
		||||
  // Flatten groups
 | 
			
		||||
  let activation-history = ()
 | 
			
		||||
 | 
			
		||||
  // Flatten groups + convert returns
 | 
			
		||||
  while i < elmts.len() {
 | 
			
		||||
    let elmt = elmts.at(i)
 | 
			
		||||
    if elmt.type == "grp" {
 | 
			
		||||
@@ -62,6 +65,30 @@
 | 
			
		||||
        ),) +
 | 
			
		||||
        elmts.slice(i+1)
 | 
			
		||||
      )
 | 
			
		||||
    } else if elmt.type == "seq" {
 | 
			
		||||
      if elmt.enable-dst {
 | 
			
		||||
        activation-history.push(elmt)
 | 
			
		||||
      }
 | 
			
		||||
    } else if elmt.type == "evt" {
 | 
			
		||||
      if elmt.event == "enable" {
 | 
			
		||||
        for elmt2 in elmts.slice(0, i).rev() {
 | 
			
		||||
          if elmt2.type == "seq" {
 | 
			
		||||
            activation-history.push(elmt2)
 | 
			
		||||
            break
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    } else if elmt.type == "ret" {
 | 
			
		||||
      if activation-history.len() == 0 {
 | 
			
		||||
        panic("Cannot return if no lifeline is activated")
 | 
			
		||||
      }
 | 
			
		||||
      let seq = activation-history.pop()
 | 
			
		||||
      elmts.at(i) = _seq(
 | 
			
		||||
        seq.p2, seq.p1,
 | 
			
		||||
        comment: elmt.comment,
 | 
			
		||||
        disable-src: true,
 | 
			
		||||
        dashed: true
 | 
			
		||||
      ).first()
 | 
			
		||||
    }
 | 
			
		||||
    i += 1
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user