NSTextView: displaying "virtual" symbols?


David Young
 

[I'd sent this to cocoa-dev@..., but ISTR that list is
deprecated. Resending here.]

I am working on a document storage format that consists of logical zones
that nest. You can think of them sort of like <div> elements from
(X)HTML:

<div id="foo"><div id="bar">All work and no play.</div></div>

Ordinarily, I would like for the zone boundaries marked by <div> and
</div> to be invisible to the user. Ordinary cursor motion commands
should step from character to character, ignoring the <div> boundaries.

However, I also want to offer a display & editing mode to the user where
they can see the boundaries and use special cursor motion commands to
"creep" the cursor across the boundaries. In this mode, there are
additional locations addressable by the cursor. I have marked those
locations with a pipe (|):

|<div id="foo">|<div id="bar">All work and no play.</div>|</div>|

I took the attached screenshot in Numbers. It shows roughly the visual
effect I'm looking for. Incidentally, it's possible to move the cursor
back and forth over the crescent that "closes" the AVERAGE function
cell. That's good. It is also possible to delete the crescent, which
is neither necessary nor desirable for my purposes, but I guess that I
could accept it.

It would be nice if I could accomplish this effect without introducing
characters to my NSTextStorage.

It looks like TextKit 2 lets one do something like this rather easily,
but I'm leary of adopting it while it's so green.

Is anyone aware of a "worked example" I can read for TextKit 1?

Dave

--
David Young
dyoung@... Urbana, IL (217) 721-9981

Join cocoa@apple-dev.groups.io to automatically receive all group messages.