[WASTE-list] Assigning data to text ranges

Marco Piovanelli marco.piovanelli at pobox.com
Wed Mar 1 10:25:46 EST 2006


On Wed, 1 Mar 2006 16:20:23 +0700,
Brother Josef (thykeeper at nerdshack.com) wrote:



>First off excuse this message for being on the 3.0 list but the other

>list has repeatedly refused my request to join stating a confusing

>error...

>

>Are there any known methods for assigning data to a specified text

>range (as if you were calling WESetOneAttribute but with a custom

>tag)? I'm looking for a way to track the location of text ranges as a

>pose to using fixed value offsets which the text may or may be

>contained in (depending on the addition/removal of lines). thanks for

>your ideas.


WASTE 3.0 allows you to define your own custom attributes,
and to apply them to any text range just as if they were
built-in attributes: using WESetAttributes/WESetOneAttribute.

You define your own attributes using WERegisterCustomAttribute.
Here's a discussion of this API:

<http://six.pairlist.net/pipermail/waste-list/2005-December/000012.html>

If you're still using WASTE 2.x, you'll have to maintain your
own offset table, but you can install a so-called "flux" callback
that WASTE will invoke on any text insertion or deletion.
The "flux" callback was designed precisely as a mechanism to
help clients keep their own offsets in sync with the text.

A flux callback is declared like this:

pascal void MyFlux(SInt32 inOffset, SInt32 inDelta, WEReference inWE);

Where inOffset is the text offset where the insertion or deletion
occurred, and inDelta is the number of characters (actually, bytes
in the WASTE 2.x case) that were added (inDelta > 0) or removed
(inDelta < 0).

You install a flux callback using WESetInfo() with the weFluxProc
selector:

OSStatus MyInstallFluxProc(WEReferece inWE)
{
static WEFluxUPP fluxUPP = NewWEFluxUPP(MyFlux);

return WESetInfo(weFluxProc, &fluxUPP, inWE);
}

Hope this helps,


-- marco

--
It's not the data universe only, it's human conversation.
They want to turn it into a one-way flow that they have entirely
monetized. I look at the collective human mind as a kind of
ecosystem. They want to clear cut it. They want to go into the
rainforest of human thought and mow the thing down.



More information about the WASTE-list mailing list