Text Processing in NSTextView
Text Processing in NSTextView
- Subject: Text Processing in NSTextView
- From: Ronnie O <email@hidden>
- Date: Thu, 30 Jun 2005 14:14:28 -0400
I recently wrote an app that uses an NSTextView to display text. I
had been performing operations on the text by grabbing it from the
NSTextView via the method:
[[textView textStorage] string]
I scanned for only letter characters, appended each one found to a
variable dataString. This variable served as my raw text without any
formatting. I subsequently reformatted the text and spat it back out
onto the NSTextView with tabs, spaces. etc. So everytime the
NSTextView was altered, a textDidChange notification was received, and
this process was repeated.
I have found this to be quite inefficient and has cornered me in many
ways programatically. I imagine this method is also not the most
computationally efficient also.
Can anyone recommend an alternative that would allow me to grab the
keyDown event (in the case of character input, removal etc.) and
directly alter my dataString variable? Then I could just format that
for display. Then I would not need to de-format the data in the view.
I see in the docs that I can capture the NSEvent and send it a
characters message to obtain the characters. But, for instance, how
would I find the location in my dataString to insert characters.
remove characters? How would I derive this information from the
formatted string that is in the textView? Sorry if this is sorted or
too general, but if anyone can at least recommend reading for this
issue, it would be great, thanks!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden