[comp.sys.apple2] TextEdit toolbox question

jason@madnix.UUCP (Jason Blochowiak) (05/24/90)

In article <9005211536.AA13364@apple.com> JWANKERL@UTCVM.BITNET ("Josef W. Wankerl") writes:
> [I nuked the references to Scott Lindsey's article]
>WOW!  Just off the top of your head, eh?  Well yeah, I had considered
>going deep down through the bowels of TE's data structures and such, but
>I really didn't look forward to coding it.  So what I did was re-think
>my problem.  It turns out that I didn't have to actually get that text
>for this project.  :-)  But I might in a future project when I want to
>do a "Find/Replace" option.  Any tips for that?

	In an application that I'm writing, I'm planning on using a TEGetText()
call to grab the entire thing. I figure that life is going to be interesting
enough writing or porting a grep engine for the first time without having to
worry about mucking with TE's data structures (scanning & parsing - no problem!
running a FA on something like that? Ick!!!), not to mention speed concerns.

	It would be really nice to have a TEGetSelectionText() or something
similar. Or, hey, how about built-in MPW style selections & regular
expressions? Sure, the average user would have a seizure trying to understand
it, but it'd make my life easier ;)

	I figure that I can't complain too much, though, as I've got a fairly
complete set of support code for TE (including complete support for fonts,
sizes, and styles) in way under 2,000 lines of C...

	I do have a couple of questions: 1) Is there a simple, and clean, way
of telling if a TE record is dirty? I change the status of the Save item in
the File menu based on a call to IsDirty(window) - IsDirty(), in turn, looks at
(**refcon).dirty. (**refcon).dirty, in turn, gets set when there's a hit of any
sort on the TE control. Right now I'm planning on being quite a bit more
selective - I'll only mark the thing as dirty if it gets a key event, or a
special (cut, copy, etc.) or stylistic (font, style, size) menu selection. But
I'd rather have a call to TE to ask it if the thing is dirty. That might be
asking a bit much, but I'm lazy.

	2) What about supporting Undo in a TE record? I'm familiar with the
standard method of Undo/Redo (record the last N operations, with code to
reverse the action, or record an already reversed action), but it seems like
it'll be a relative pain to discern what's going on. Of course, the simple
stuff like the editing ops won't be a problem, but what about keypresses? If I
were using my own editor engine, then it'd have to figure out what to do with
a particular keystroke anyways, and I'd be tied to those keys no matter what.
But, it seems that I'm going to have to look at a keystroke, figure out what
TE is going to do with it, record the action, and _then_ let TE have at it
(and, of course, this means that I'll be giving up the relative safety of
TaskMaster()). This seems to needlessly tie my application to what TE will do
with a particular key...

	At this point I'm actually considering (ick) not providing Undo for the
TE windows - the user will just have to close the window, telling the app that
s/he doesn't want the changes saved, and then re-open it (which isn't too bad,
considering that the TE windows are derived from an already open window, which
means no SFGetFile2()).

	Anyone have any ideas?

>===> Josef W. Wankerl, college student | "I am a Viking"  -Y. Malmsteen
> ProLine:  jwankerl@pro-gsplus         | BITNET:  JWANKERL@UTCVM
>InterNet:  jwankerl@pro-gsplus.cts.com | UUCP:  ...crash!pro-gsplus!jwankerl
>ARPA/DDN:  ...crash!pro-gsplus!jwankerl@nosc.mil | I'm employed by EGO, GS+!


-- 
                      Jason Blochowiak - jason@madnix.UUCP
or, try:         astroatc!nicmad!madnix!jason@spool.cs.wisc.edu
       "Education, like neurosis, begins at home." - Milton R. Saperstein

JWANKERL@UTCVM.BITNET ("Josef W. Wankerl") (05/27/90)

On Thu, 24 May 90 10:47:34 GMT Jason Blochowiak said:
>In an application that I'm writing, I'm planning on using a TEGetText()
>call to grab the entire thing.

Yep, that's how I thought about doing it.  Afterall, you gotta do a
TEGetText() anyhow when the stuff is going to be saved so if you don't
have enough memory for a save it is probably reasonable not to allow
a search/replace.  I'd rather only work with one copy of the text
though.

>It would be really nice to have a TEGetSelectionText() or something
>similar.

Yep, that's what I was hoping for.  It'd make life much simpler.

>I do have a couple of questions: 1) Is there a simple, and clean, way
>of telling if a TE record is dirty?

I believe that TE automatically keeps track of a dirty flag for you.
I don't have a TBRefIII handy so I can't tell ya exactly where, but
there's one in there somewhere... look around where it defines the
TERecord structure.

>2) What about supporting Undo in a TE record?

Undo for a cut/paste/clear would be easy for TE to do automatically.
Heck, that's all I use undo for anyhow.  An undo typing would indeed
be more difficult.  I don't even want to begin thinking about it...

>--
>                      Jason Blochowiak - jason@madnix.UUCP
>or, try:         astroatc!nicmad!madnix!jason@spool.cs.wisc.edu
>       "Education, like neurosis, begins at home." - Milton R. Saperstein

--
===> Josef W. Wankerl, college student | "I am a Viking"  -Y. Malmsteen
 ProLine:  jwankerl@pro-gsplus         | BITNET:  JWANKERL@UTCVM
InterNet:  jwankerl@pro-gsplus.cts.com | UUCP:  ...crash!pro-gsplus!jwankerl
ARPA/DDN:  ...crash!pro-gsplus!jwankerl@nosc.mil | I'm employed by EGO, GS+!