[plt-scheme] How to store extra data in text% editor

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue May 23 08:42:23 EDT 2006

At Tue, 23 May 2006 05:51:07 +0200, "pascal.delcombel" wrote:
> Now, here is where I'm troubled: imagine I want to add a snip (whatever, 
> text or picture) in a text with a hyperlink somewhere, then imagine I want 
> to add text (or picture), before this hyperlink: if the data is not stored 
> within the snip (or data region), my hyperlink references (begin and end 
> positions) won't be correct after the insert.
> Alternatively, I should have coded the hyperlinks reference update using the 
> after-delete and after-insert events. 

That's what I would do.

> Well, I'm forecasting a bad response 
> time for that solution, but I could be wrong.

O(log n) operations in `after-delete' and `after-insert' should keep
the editor responsive enough. My favorite data structure for this task
is a red-black tree where offsets are stored relative to "right"


Posted on the users mailing list.