开发者

Handling Undo and redo in a rich text box

开发者 https://www.devze.com 2023-03-06 18:25 出处:网络
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 red

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开发者_如何学Go chunks of text and change their background color etc?

cheers

redDragon


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号