Hey Klaus, To make it undo-able you should not use the page object at all. If you just use the TextBuffer API, all changes will be undo-able.
There is a "foreach_line()" which you could use to determining what lines you want to re-align. Just replace text with the "delete()" and "insert_text()" methods. Unfortunately you can not get all text, parse it, and replace at once, because you will loose all formatting. So will need to modify your current functions a bit to work line by line on the buffer. Regards, Jaap On Wed, Jul 10, 2013 at 6:00 PM, Klaus-Dieter Bauer < [email protected]> wrote: > I have largely overhauled my table plugin with a new format (less boundary > cases for better stability, cleaner functions, a bit of documentation). > > The problem of preserving Undo information persists. > > > > 2013/7/8 Klaus-Dieter Bauer <[email protected]> > >> Hello! >> >> I have written a make-shift table plugin, that just helps managing tables >> made from verbatim text (though images and links are possible, but >> currently break the formatting). Basically it looks for a line starting >> with {{| and the earliest line afterwards ending with ||} and realigns >> table contents in between. >> >> However, I found this extremely difficult to do on the level of the >> parsetree and instead extract the source code through >> "page.dump(zim.formats.wiki)", modify the source and write it back with >> "page.parse(...)". >> >> Sadly though, afterwards Undo is not possible. >> >> Is there some way that I can modify the contents of a page without >> breaking Undo? >> >> I have attached the experimental source and a file with example tables >> for reference. (Note: High risk of data loss, it's still pretty buggy). >> >> kind regards, Klaus >> > > > _______________________________________________ > Mailing list: https://launchpad.net/~zim-wiki > Post to : [email protected] > Unsubscribe : https://launchpad.net/~zim-wiki > More help : https://help.launchpad.net/ListHelp > >
_______________________________________________ Mailing list: https://launchpad.net/~zim-wiki Post to : [email protected] Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp

