SQLite Forum

Can BLOB incremental I/O be employed to manage edits to a block of text?
Login
Thank you very much. This is what I was trying to find and didn't know enough about the subject to have the right search terms.  It appears that piece tables made all the difference for Word 1.0 and 1.1 when machines were not so powerful and quick. I don't want to spend a year trying to build something complicated because I'm not capable of it and building a text editor isn't the objective. But I hate to do something poorly regardless, even if no one really notices a delay. Anyway, pointing me to this as a start is very helpful. Thank you.

I wanted to add that, if I'm understanding the piece table correctly, one issue is that once it is applied to build the new document from the original and the append buffer, the undo/redo chain is useless because the data for any deletions is permanently lost, at least from the original.  Thus, the undo/redo chain cannot be restored between sessions if the append buffer is applied and the piece table reset upon open or close.

I thought I had a method figured out that would hold each change event as a table row, passing only additions and no deletions data.  Then those rows could be used to build a piece table only when the original is to be updated and overwritten to reflect the changes. I thought building the piece table once at that time would make updating the original more efficient than attempting to apply all the recorded changes. Then realized that the deletion data required for preserving undo/redo between sessions would be lost. 

I think the method can still be used in a database set up but the deletions will need to be passed with each event also; and am still working through that.  It appears that the method is/was made for an in-RAM only process, apart from the quick save, that didn't preserve undo/redo between sessions.  

Thanks again for pointing me to it.  It was interesting but all the documents I came across give the method and leave out how to handle the actual splitting of the piece table ranges as edits take place.