The current setup for the minimap (where the minimap is a separate text view using a smaller font, but sharing an NSTextStorage with the main code view) has the inherent disadvantage that layout happens twice. This implies twice the work (where layout is the main performance bottleneck already anyway) and it means that we need to carefully set things up, such that the two layouts coincide (especially wrt to line breaks), which turns out to be a rather fragile affair.
A better code architecture would share the layout of the code view with the minimap. This requires the minimap to use a custom view (instead of being a subclass of {NS|UI}TextView). To this end, we need to do the following:
[ ] CodeView needs to use custom NSTextLineFragments that have a second draw method for drawing to the minimap.
[ ] The custom minimap view needs to scale everything down (as the layout is in terms of the coordinate system of the code view).
Two challenges are the following:
[ ] It seems hard to replace the view port manager in the standard {NS|UI}TextView set up (judging from earlier experiments, where it seemed to use some undocumented functionality), but that is necessary as the view port needs to include the entire region displayed by the minimap and not only the portion visible in the code view.
[ ] We want to be able to deviate from the layout of the code view in the minimap for things such as the documentation headers. Is that even possible in such a set up?
The current setup for the minimap (where the minimap is a separate text view using a smaller font, but sharing an
NSTextStorage
with the main code view) has the inherent disadvantage that layout happens twice. This implies twice the work (where layout is the main performance bottleneck already anyway) and it means that we need to carefully set things up, such that the two layouts coincide (especially wrt to line breaks), which turns out to be a rather fragile affair.A better code architecture would share the layout of the code view with the minimap. This requires the minimap to use a custom view (instead of being a subclass of
{NS|UI}TextView
). To this end, we need to do the following:CodeView
needs to use customNSTextLineFragment
s that have a seconddraw
method for drawing to the minimap.Two challenges are the following:
{NS|UI}TextView
set up (judging from earlier experiments, where it seemed to use some undocumented functionality), but that is necessary as the view port needs to include the entire region displayed by the minimap and not only the portion visible in the code view.