Easier way to do text-movement algorithm?
Sarah
sarahr at genesearch.com.au
Thu Aug 14 19:35:00 EDT 2003
> I'm making an source code rearrangement application where I need to
> rearrange different sections of a long piece of text. I've basically
> got a structure that looks like
>
> 1: A
> 2: --
> 3: --
> 4: --
> 5: B
> 6: --
> 7: --
> 8: C
> 9: --
> 10: D
>
> and I'd want to for instance move the 'A' section (lines 1-4
> inclusive) to where the 'C' section is now (after the current line 7,
> pushing everything else out of the way. I also want to keep track of
> the beginning and ending characters of the sections, so I can select
> any of them at will.
>
> Moving the sections around isn't much of a problem - I just copy a
> character range A and put it at point C, then delete the original
> range (so I don't have to keep track of what C becomes after I delete
> range A). But then I'd have to recalculate all the values of the
> start and end points of the sections.
How about creating a new variable, and putting all the chunks into it
in their new order. That way you only have to calculate the start & end
points once. Then you can record the new start & end points as you move
and when you have finished, copy the new variable back to the old one
and the new start-end points list back to the original list.
Cheers,
Sarah
sarahr at genesearch.com.au
http://www.troz.net/Rev/
More information about the use-livecode
mailing list