A Thousand Newbie Questions...
A Thousand Newbie Questions...
- Subject: A Thousand Newbie Questions...
- From: email@hidden
- Date: Sun, 7 Oct 2001 23:56:01 -0500
Hey List -
First, let me thank you guys for the response to my previous inquiry.
The solution worked great, and has lead me on to a thousand other
questions....which I guess I'll ask now.
I'm trying to build a very simple code-editor, mostly to see if this is
possible. I've been wondering for the last few months about syntax
coloring, and how it's implemented. And in that. I've been trying to
think of a way to implement that would make it multi-purpose, and
infinetly expandable. After a whole three minutes of thinking, I
realized that I should use XML.
So, I sit down with my goals in mind. The application needs to be able
to do that following:
1.) Scan a folder for XML files that meet the basic criteria of a
pre-defined DTD.
2.) Parse above files into some sort of an array or, whatever, grabbing
the words to be highlighted.
3.) Have a text view the user can type into, with highlighted words
enabled, and save out as ASCII or RTF.
Simple right?
Well, I've figured out WHAT I need to do, but the HOW is bogging me
down. From reading through the useless Learning Cocoa, and Garfinkel's
excellent NeXTStep Programming, I'm thinking, and tell me if I'm wrong
here, that I should just parse the XML into an NSDictionary, using the
word itself as the key, and the color as the value. Then, I should be
able to build a simple method from which I can send a word to, and have
it return the color and format.
Okay, but HOW do you parse XML into an NSDictionary?
Next, I figured I could just subclass NSTextView, and override some it's
methods, creating, in effect an NSCodeView, that could be re-used by
anyone ( god love open-source ). I've created several of those stupid
text editors described in a hundred tutorials, but I'm failing to see a
way to send the NSTextView a formatting command. I looked at
ProjectCenter ( a GNUStep application) source, and they seem to be doing
something really strange with NSScanner and a textView, but this doesn't
seem like it would be the way to go.
Okay, so how do you send a format color command to NSTextView?
I really just want to be something that would be useful, and, I think
this would be, considering one could extend the DTD to include
documentation, attributes, and examples...making it a universally cool
code editor, open-sourced and free to the world. This seems like would
take a maximum of 50-or-so lines of code initially, but, god, Cocoa docs
are really sparse, and all the tutorials right now are fairly entry
level...
Anyway, any help is greatly appreciated, and I promise to sing a
heartfelt rendition of Amy Grant's 'Baby Baby' to all good knights who
could help.
Thanks In Advance,
Jack Shedd