|
|
How to realize syntax highlighting in Cocoa?
|
|
|
|
Junior Member
Join Date: Oct 2001
Location: Osnabrueck, North Germany
Status:
Offline
|
|
Hi,
i try to program some nice text editor. But how to realize syntax highlighting with a normal text field? Should i have to subclass it?
In which function should i do the highlighting?
Greetings
Vax
|
--:: Insanity is also a state of mind ::--
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status:
Offline
|
|
I guess you're German, since you misused the word "realize"
Well, get the TeXShop-source, this app does exactly what you want.
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Oct 2000
Location: Portland, OR USA
Status:
Offline
|
|
Originally posted by amonitzer:
<STRONG>I guess you're German, since you misused the word "realize"
Well, get the TeXShop-source, this app does exactly what you want.</STRONG>
That's not a misuse of realize, just not a common use (in the US, at least).
I have been curious about this as well, but more importantly, I've been wondering about spell checking in code. How do you get it to spell check code and comments differently, and how do you get it to spell check code properly?
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Sep 2000
Location: Calgary, Alberta, Canada
Status:
Offline
|
|
You will have to subclass NSTextField (or whichever view you choose) to achieve this, then implement your parsing/highlighting techniques in that subclass.
|
"The pool on the roof must have a leak"
|
|
|
|
|
|
|
|
Junior Member
Join Date: Mar 2001
Status:
Offline
|
|
I do not think it's possible to display more than one style in an NSTextField (e.g. the text has to be all blue, or all red; it can't be blue in some parts and red in the rest). You'll want to use an NSTextView.
-Peter
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
If you want to do syntax highlighting in an NSTextView (i.e. the large scrollable text widget that's like a TextEdit document window), you'll want to subclass NSTextView and/or NSTextStorage.
I don't think the original poster meant to ask about NSTextField (the little fields you can tab between, most often found in preferences dialogs and such), but I'll answer for that, too: That's probably much easier -- NSFormatter's attributedStringForObjectValue:defaultAttributes: method should help you there.
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Oct 2001
Location: Osnabrueck, North Germany
Status:
Offline
|
|
Hi,
for people curious about syntax highlighting in NSTextViews, visit http://www.cocoadev.com . Nice site with a lot of program examples and such things.
Greetings
Vax
|
--:: Insanity is also a state of mind ::--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|