[comp.sys.mac.programmer] Two Windows, Same Text, Howtodoit?

yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) (02/19/90)

(Don't think my 1st post on this took, so'll try again...)
I'm working on an app that will sometimes have two different
windows contain the same text. I want both windows to be editable,
with changes in one reflected instantaneously in the other, sort
of like the split-screen effect in MS-Word or Nisus.

Using standard TE calls, what's a good way to do this? Should I
declare a seperate TEHandle for each window and keep the text
within in synch by sending TEKey's to both? Or should I just
have 1 TEHandle?

Have tried the 2 TEHandle method and I get a glitchy problem when
I TEKey a cursor key to the inactive window, a caret (insertion
point) is drawn and remains. I can't filter out the cursor keys
cuz then the inactive TEHandle will lose track of where the
insertion point is s'posed to be. Maybe I should dicker with the
caretState or caretTime fields, but they're undocumented so I
don't know what to do... If it weren't for this caret problem, I'd
use this method as it otherwise looks good.

The 1 TEHandle method would seem to have a problem, too, in that
I'd have to do a EraseRect; TEUpdate combo to keep the inactive
window properly updated, and the ensuing flashing would look bogus.

Any Hints? Thanks! - Ross
>>>      Internet: yahnke@macc.wisc.edu        <<<
>>>   Mille voix chuchottent <<c'est vrai>>    <<<

bochner@babbage.harvard.edu (Harry Bochner) (02/22/90)

In article <3210@dogie.macc.wisc.edu>
yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) writes:
   I'm working on an app that will sometimes have two different
   windows contain the same text. I want both windows to be editable,
   with changes in one reflected instantaneously in the other, sort
   of like the split-screen effect in MS-Word or Nisus.

   Using standard TE calls, what's a good way to do this? Should I
   declare a seperate TEHandle for each window and keep the text
   within in synch by sending TEKey's to both? Or should I just
   have 1 TEHandle?

Here's a variation on the 2 TEHandle idea that might be worth trying:
Instead of passing a duplicate of each TEKey, TEClick, etc. to the
inactive handle, use the lower level routines TEInsert, TEDelete, etc.
The code will be trickier to write, but I suspect it will be less
kludgy.  You probably don't even have to keep the insertion points the
same; in fact I expect most applications with independent windows
would want the insertion points to be independent. Instead you figure
out where to do the TEInsert by looking at the value of TEselStart in
the active Handle. That way you don't have to pass on arrow keys at
all, eliminating the specific problem you mentioned.

Again, each approach has its headaches, and I'm not sure how they'll
balance out, but it might be worth a try.
--
Harry Bochner
bochner@endor.harvard.edu