From 1db922d44d6c1f06cacb967501ac7d3e0188c6a4 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Mon, 28 Jul 2025 18:48:28 +0200 Subject: [PATCH] added id to notes --- src/core/renderer.typ | 2 +- src/core/setup.typ | 17 +++++++++-------- src/diagram.typ | 7 +++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/core/renderer.typ b/src/core/renderer.typ index 2f2603d..34b795a 100644 --- a/src/core/renderer.typ +++ b/src/core/renderer.typ @@ -382,7 +382,7 @@ } }) -#let render(participants, elements) = context canvas(length: 1pt, { +#let render(participants, elements, notes) = context canvas(length: 1pt, { setup-ctx(participants, elements) // Draw participants (start) diff --git a/src/core/setup.typ b/src/core/setup.typ index 7873526..8dca53b 100644 --- a/src/core/setup.typ +++ b/src/core/setup.typ @@ -126,6 +126,7 @@ "linked", note.pos == none and note.side != "across" ) + note.insert("id", ctx.notes.len()) let names = ctx.participants.map(p => p.name) if note.pos == none and note.side != "across" { let i1 = names.position(n => n == ctx.last-seq.p1) @@ -186,6 +187,8 @@ } } + ctx.notes.push(note) + ctx.elmts.at(ctx.i) = note ctx.last-note = ( @@ -226,6 +229,7 @@ linked: (), last-seq: none, last-note: none, + notes: (), participants: (), elmts: elmts, i: 0 @@ -290,10 +294,10 @@ ).first()) } - return (ctx.elmts, participants) + return (ctx.elmts, participants, ctx.notes) } -#let finalize-setup(elmts, participants) = { +#let finalize-setup(elmts, participants, notes) = { for (i, p) in participants.enumerate() { p.insert("i", i) participants.at(i) = p @@ -323,14 +327,11 @@ elmts.at(i).insert("max-i", max-i) } - return (elmts, participants) + return (elmts, participants, notes) } #let setup(elements) = { let (elmts, activation-history) = unwrap-containers(elements) - - let participants - (elmts, participants) = prepare-participants(elmts) - - return finalize-setup(elmts, participants) + let (elmts, participants, notes) = prepare-participants(elmts) + return finalize-setup(elmts, participants, notes) } \ No newline at end of file diff --git a/src/diagram.typ b/src/diagram.typ index a16809e..4f51675 100644 --- a/src/diagram.typ +++ b/src/diagram.typ @@ -1,16 +1,15 @@ -#import "core/draw/event.typ": render as evt-render #import "core/renderer.typ": render #import "core/setup.typ": setup -#import "core/utils.typ": fit-canvas, set-ctx +#import "core/utils.typ": fit-canvas #let diagram(elements, width: auto) = { if elements == none { return } - let (elmts, participants) = setup(elements) + let (elmts, participants, notes) = setup(elements) - let canvas = render(participants, elmts) + let canvas = render(participants, elmts, notes) fit-canvas(canvas, width: width) }