Release 0.2.0 #5
| @@ -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 | ||||
|   } | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| #let version = version(0, 1, 1) | ||||
| #import "diagram.typ": diagram, from-plantuml, _gap, _evt, _col | ||||
|  | ||||
| #import "sequence.typ": _seq | ||||
| #import "sequence.typ": _seq, _ret | ||||
| #import "group.typ": _grp, _loop, _alt, _opt, _break | ||||
| #import "participant.typ": _par | ||||
| #import "separator.typ": _sep | ||||
|   | ||||
| @@ -88,6 +88,13 @@ | ||||
|   ),) | ||||
| } | ||||
|  | ||||
| #let _ret(comment: none) = { | ||||
|   return (( | ||||
|     type: "ret", | ||||
|     comment: comment | ||||
|   ),) | ||||
| } | ||||
|  | ||||
| #let render(pars-i, x-pos, participants, elmt, y, lifelines) = { | ||||
|   let shapes = () | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user