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.

What would be really nice is if Rev had a feature where I could either mark ranges of text, and then say "put section 1 of myText into section 3 of myText" and then "select section 1 of myText". But it doesn't (that I know of)..

I suppose I could also just store the sections of text in an array, and then use matchChunk on each element of that array (after the first function that changed) to get the start and end points. But this is O(n) and invokes matchChunk every time (I do this to originally process the file and it takes about 3 seconds to do it)

Another possibility would be to use matchChunk to find the start and end positions on the fly whenever I want to select a function.

Any better ideas than these?

Jim

_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to