Skip to main content

Module marks

Module marks 

Expand description

Inline marks model used by RichTextLine.

A MarkSpan is a half-open byte range [start, end) over a RichTextLine’s text plus a Mark tag, stored sorted by start. Multiple marks may cover the same byte range — bold + italic on the same word produces two MarkSpans, not one fused BoldItalic variant.

Two marks of different kinds may share a range, but two marks of the same kind never overlap — the mutation helpers (toggle_mark_range) enforce this by merging touching same-kind spans and removing same-kind spans fully covered by the toggle range.

Nested markdown (**bold *italic***) is out of scope: the serialiser emits it and the parser accepts it, but the model treats bold + italic as independent marks rather than materialising a “bold-italic” variant — enough for round-trip stability on documents we produce.

Structs§

MarkSegment
A contiguous [start, end) segment tagged with the set of marks active inside it. One draw_text call per segment on the render path.
MarkSpan
A byte range + a single Mark. Multiple MarkSpans with the same kind never overlap (the toggle helpers merge them); different kinds may share a range.
MentionColors
How a mention of one participant is painted.

Enums§

Mark
One inline mark applied to a byte range of a RichTextLine.
ToggleOutcome
Result of toggle_mark_range: did the toggle add or remove the mark on this range? Returned so the caller can update any pending “next character will be marked” state.

Functions§

add_mark_to_range
Add a same-kind span covering range and merge any touching / overlapping same-kind spans into a single run.
range_fully_covered
True iff every byte in range (a non-empty sub-range of the line) is covered by at least one same-kind span. Used to decide whether a toggle should add or remove the mark.
remove_mark_from_range
Remove every same-kind coverage from range. Spans that straddle either edge of range get clipped or split.
segments_for
Produce the partition. Boundaries: every span’s start and end, plus 0 and text_len. The resulting segments together cover [0, text_len).
shift_after_edit
Adjust every span’s range by a splice at byte at, to keep marks aligned after a user edit. Insertion: spans at/after at shift right, straddling spans extend right. Deletion of [at, at+removed_len): spans entirely inside are dropped, straddling spans are clipped.
toggle_mark_range
Apply a toggle of mark over range: if fully covered by same-kind spans, remove the coverage (clip/split); otherwise add a new span and merge touching same-kind spans into one contiguous run.

Type Aliases§

MentionPaint
The colours a mention of the participant with this id is painted in, supplied by the owning model (it knows who the participant is).
PageId
Stable identifier for a page link target. RichTextLine doesn’t own page identity — that’s the notes app’s concern — so a UUID is used here; the notes app’s PageId is itself a uuid::Uuid, so Mark::Link(PageId) round-trips through the markdown layer.