[Openmcl-devel] string handling question

Pascal J.Bourguignon pjb at informatimago.com
Tue Nov 9 15:22:52 PST 2004


Andrew P. Lentvorski, Jr. writes:
> 
> On Nov 9, 2004, at 2:51 PM, Pascal J.Bourguignon wrote:
> 
> >
> > alex crain writes:
> >> COCOA is really unbright about inferring things and will often scan 
> >> the
> >> entire file for changes after
> >> I insert a single character, which means *lots* of string processing
> >> and good optimization or the
> >> system grinds to a halt.
> >
> > You don't have to use the high level text objects in Cocoa.  It would
> > be easier and faster to avoid cocoa text object and have hemlock
> > display the characters directly using cocoa graphic primitives.
> 
> Hmmm, is there an insert or redraw method you could override to 
> "smarten up the text object"?

Do you use -[NSText replaceCharactersInRange:withString:]?

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSText.html#//apple_ref/doc/uid/20000367/setDrawsBackground_

There's no documented hook. If it recomputes a lot each time you
replace a few characters, the only solution I see is a trick that was
used in MacOS (before it was named MacOS!):
 
    - put in the text object only the visible text plus a few lines
      before and after.

    - when scrolling is done, remove what disappears and add the
      newly visible characters to the text object.

http://developer.apple.com/documentation/Cocoa/Conceptual/TextArchitecture/index.html#//apple_ref/doc/uid/10000086i

http://developer.apple.com/documentation/Cocoa/Conceptual/TextArchitecture/Concepts/ArchitectureOverview.html#//apple_ref/doc/uid/20000839/CJBJHGAG

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSTypesetter.html#//apple_ref/doc/uid/20000389/BBCFGIII

Perhaps the heavy processing is done by the default layout manager. It
could be shortcircuited by a simplified custom  layout manager, or
perhaps only the type setter.  It must probably apply the same kerning
algorithm on non-proportional fonts than on any other font. Even in
Monaco (or was it in Apple's Courier), there was one character that
was wider: Copyright.


> Limitations in the high-level text object are real, but there often are 
> ways around them.  Apple does use these objects inside XCode, right?

I would not bet on it.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.




More information about the Openmcl-devel mailing list