[comp.sys.mac.programmer] MacApp question on TTEView

kn@doc.ic.ac.uk (Keng Ng) (06/21/91)

I need to keep track of the number of changes that have been applied to the
text in a TTEView. (Similar to the fChangeCount field of TDocument). My
first idea was to override the DoKeyCommand method to increment a field
within the view, but this won't work if the text was changed though cut and
paste.

I then thought of overriding the methods of TTECommand or its subclasses.
Before I spent too much time figuring out how these work (I've had a look
but am a little confused), can someone tell me whether I'm heading in the
right direction ? Larry, Keith, Kent, anyone ?

Thanks in advance.

--- Keng

-----------------------------------------------------------------

Keng T. Ng              DARPA: kn@doc.ic.ac.uk
Imperial College,              kn%uk.ac.ic.doc@nsfnet-relay.ac.uk
Dept. of Computing,     UUCP:  kn@icdoc.UUCP
180 Queen's Gate,
London SW7 2BZ,
United Kingdom.

ksand@apple.com (Kent Sandvik) (06/23/91)

In article <1991Jun20.173035.29174@doc.ic.ac.uk>, kn@doc.ic.ac.uk (Keng Ng) writes:
> 
> I need to keep track of the number of changes that have been applied to the
> text in a TTEView. (Similar to the fChangeCount field of TDocument). My
> first idea was to override the DoKeyCommand method to increment a field
> within the view, but this won't work if the text was changed though cut and
> paste.
> 
> I then thought of overriding the methods of TTECommand or its subclasses.
> Before I spent too much time figuring out how these work (I've had a look
> but am a little confused), can someone tell me whether I'm heading in the
> right direction ? Larry, Keith, Kent, anyone ?

I checked the MacApp sources, and yes the TTECommand should handle both typing
(TTETypingCommand) cut/copy (TTECutcopyCommand) and pasting (TTEPasteCommand).
Now depending on the actual need of logging (typing, paste only, or also cut/copy)
one could overrided either the TTECommand.ITECommand and keep track of changes in
the actual view, or separate this into various sub TECommand objects. So you could
subclass these and keep track of changes - maybe there's a better way. I checked for
the fSpecsChanged field, but it does not seem to be updated in every case.

..Saturday evening, so I guess I should go home.

Kent

sgrae@megatest.UUCP (Steve Graesser) (06/24/91)

I would like to change the text in the TTEView between
three different text Handles (text1, text2, text3)
using a pull down menu.  I was able to add the menu
to the menu bar, select the proper text to display,
but when trying to update the TEView Handle to
the new text, it either comes a out with the wrong
format or is trashed because of the repeated
calls to StuffText.

Let's assume fTEView is a valid TEView* in TDocument.

case cText1:
	fTEView->StuffText(text1);
	fTEView->ForceRedraw();
	break;

case cText2:
	fTEView->StuffText(text2);
	fTEView->ForceRedraw();
	break;

case cText3:
	fTEView->StuffText(text3);
	fTEView->ForceRedraw();
	break;

After looking at the MacApp libraries for
StuffText, SetText, etc. - I wasn't able to
find a routine that just changed the fTEH (sp?)
or fText handle to point the new Text Handle.

The MacApp Methods stack on ETO#3, doesn't
mention the destuctive behavior of StuffText
or of SetText (BTW how do you get SetText
to display more than 255 characters?)
and MacApp411 doesn't have an entry for StuffText.

Before I spent too much time figuring out how these work (I've had a look
but am a little confused), can someone tell me whether I'm heading in the
right direction ? Larry, Keith, Kent, anyone ?
-- 
Steve Graesser		{decwrl | amdcad}!megatest.uucp!sgrae
Megatest Corp.
880 Fox Lane
San Jose, CA 95131	|	(408) 441-3077