The way I like to explain MARK vs POINT is by representing them as square brackets at whatever offset they exist in a range of text. The direction the bracket is pointing shows the character that the mark or point is "attached" to.
So for a POINT, you would use the open bracket - it's attached to the character following it. And for a MARK, you would use the close bracket - it's attached to the character preceding it.
Let's look at some examples of each type:
SPAN_MARK_MARK
Inserting at the offset of a 0-length span: The marks remain fixed.
Before: Lorem ]]ipsum dolor sit.
After: Lorem ]]INSERTipsum dolor sit.
Inserting at the start of a non-0-length span: The inserted text is included in the range of the span.
Before: Lorem ]ipsum] dolor sit.
After: Lorem ]INSERTipsum] dolor sit.
Inserting at the end of a non-0-length span: The inserted text is excluded from the range of the span.
Before: Lorem ]ipsum] dolor sit.
After: Lorem ]ipsum]INSERT dolor sit.
You can see from the last two examples, why the SPAN_MARK_MARK
flag is synonymous with the SPAN_INCLUSIVE_EXCLUSIVE
flag. Text inserted at the start of the span is included in the range, while text inserted at the end is excluded.
SPAN_POINT_POINT
Inserting at the offset of a 0-length span: The points are pushed forward.
Before: Lorem [[ipsum dolor sit.
After: Lorem INSERT[[ipsum dolor sit.
Inserting at the start of a non-0-length span: The inserted text is excluded from the range of the span.
Before: Lorem [ipsum[ dolor sit.
After: Lorem INSERT[ipsum[ dolor sit.
Inserting at the end of a non-0-length span: The inserted text is included in the range of the span.
Before: Lorem [ipsum[ dolor sit.
After: Lorem [ipsumINSERT[ dolor sit.
Again you can see from the last two examples why the SPAN_POINT_POINT
flag is synonymous with the SPAN_EXCLUSIVE_INCLUSIVE
flag. Text inserted at the start of the span is excluded from the range, while text inserted at the end is included.
SPAN_MARK_POINT
Inserting at the start of the span: The inserted text is included in the range.
Before: Lorem ]ipsum[ dolor sit.
After: Lorem ]INSERTipsum[ dolor sit.
Inserting at the end of the span: The inserted text is still included in the range.
Before: Lorem ]ipsum[ dolor sit.
After: Lorem ]ipsumINSERT[ dolor sit.
And thus it has the synonym SPAN_INCLUSIVE_INCLUSIVE
- the inserted text is always included in the range of the span.
SPAN_POINT_MARK
Inserting at the start of the span: The inserted text is excluded from the range.
Before: Lorem [ipsum] dolor sit.
After: Lorem INSERT[ipsum] dolor sit.
Inserting at the end of the span: The inserted text is still excluded from the range.
Before: Lorem [ipsum] dolor sit.
After: Lorem [ipsum]INSERT dolor sit.
And thus it has the synonym SPAN_EXCLUSIVE_EXCLUSIVE
- the inserted text is always excluded from the range of the span.
I think the documentation confuses things by splitting the definitions of some of the synonyms. For example, when describing SPAN_MARK_MARK
, they only define its usage in terms of a 0-length span. Then when defining SPAN_INCLUSIVE_EXCLUSIVE
(which is a synonym) they only define its usage in terms of non-0-length spans. I think it would have been a lot clearer if they stated up front that they were synonyms, and had a single definition shared by both terms.
SPAN_MARK_MARK
andSPAN_POINT_POINT
represent 0 length strings? – Harem