redDragonzz
redDragonzz

Reputation: 1571

Handling Undo and redo in a rich text box

I extended a rich text box to do syntax highlighting, making use of selection functions available from the Rich text box class. However, in the process, I have lost, the ability to handle undo and redo on the text box. When i do undo, all it does is to selects the last word that I had selected and highlighted programmatically.

Is there a solution for handling this sort of scenario, I want the undo/redo functionality along with the ability to select chunks of text and change their background color etc?

cheers

redDragon

Upvotes: 0

Views: 726

Answers (1)

David Heffernan
David Heffernan

Reputation: 612914

It sounds to me like your design is flawed.

For syntax highlighting it is better to keep the text and the formatting separate. By mixing them up as you have done you have made implementing undo very difficult. You can no longer rely on the control to do it because you are conflating the text edits with your formatting edits.

Have you considered using something like Scintilla rather than trying to solve this problem again?

Upvotes: 1

Related Questions