Question

I'm trying to implement undo/redo feature in my custom application that displays code using ICSharpCode.TextEditor.

TextEditor fully supports undo and redo. But unfortunately, the control is poorly documented. It's not clear how to detect change of the undo state, so the program can gray out and re-enable the undo and redo buttons on the toolbar.

Is there any suitable event I can subscribe to? Should I then use EnableUndo and EnableRedo properties?

Was it helpful?

Solution

Check out the IDocument being edited, not the TextEditor. Make sure that you are editing the document using the IDocument methods. You can group actions together using IDocument.UndoStack.StartUndoGroup and IDocument.UndoStack.EndUndoGroup. To see if there are undos possible, you can check if the IDocument.UndoStack is empty.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top