Access to the Undo list

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Kasper
Avatar
Hi,

In my application, I only have one instance of the SyntaxEditor. The user can of course have multiple open documents, so whenever the user changes between two documents, I simply take the relevant information from the SyntaxEditor, e.g. content, cursor position etc. and save it to an object, and then I load the other object into the SyntaxEditor. This works very well. However, I can't seem to do this with the Undo/Redo information of the SyntaxEditor. I thought I could simply save a copy of the UndoStack from SyntaxEditor.Document.UndoRedo, but it's readonly, so I can't assign the object from my document object. Do you have any idea how I can do this?

[Modified at 05/28/2006 01:26 PM]

Comments (3)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Kasper,

Unfortunately since the undo/redo data is tracked internally, it is a read-only collection on the Document.

However, we made the Document object so that it can be used independently from SyntaxEditor. Along with that design, it is portable, meaning you can retain a reference to the Document and then reassign it to the SyntaxEditor later. While it is detached from the SyntaxEditor, it will retain the Undo/Redo information. Could you do that?


Actipro Software Support

Posted 18 years ago by Kasper
Avatar
>Unfortunately since the undo/redo data is tracked internally, it is a read-only collection on the Document.

Okay, I'm not trying to be clever or anything, but if you allowed access to it, and I did not try to remove or add items directly to it, but simply assigned it to the SyntaxEditor - would this cause problems?

>However, we made the Document object so that it can be used independently from SyntaxEditor. Along with that design, it is portable, meaning you can retain a reference to the Document and then reassign it to the SyntaxEditor later. While it is detached from the SyntaxEditor, it will retain the Undo/Redo information. Could you do that?

Yeah, it seems to work, but won't this require a bunch of extra memory, for each open document I have? I'm using only one instance of SyntaxEditor because it seems to save some memory when multiple documents are open. However, the Document seems to be a big part of the memory usage, including the SyntaxLanguage - or am I wrong here? :)

[Modified at 05/31/2006 10:42 AM]
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Since it is an internal class that stores the undo info, we can't allow it to be persisted externally. So our recommendation is to save the Document.

The Document stores data for text, document lines, undo/redo, indicators, and tokens. You want the undo/redo. If you aren't using indicators, that won't take up anything. So that leaves the memory taken up for text, document lines and tokens.

In the work we've done on v4.0, the document line memory usage has been reduced dramatically. It scales up though as needed if you start using extra features like background colors, etc. Also in v4.0 we allow you to turn off lexical parsing, meaning it clears the tokens. Therefore when you are storing a Document in memory, you could turn off the lexical parsing until you want to plug it back into a SyntaxEditor. Those things will really cut down the memory footprint.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.