What kinds of process can be part of an undo group?

General TRichView support forum. Please post your questions here
Post Reply
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

What kinds of process can be part of an undo group?

Post by martindholmes »

I noticed from this post:

<http://www.trichview.com/forums/viewtop ... light=undo>

that "direct assignment to StyleNo cannot be undone". I'm trying to create systems for undoing complex sequences of actions, so I'd like to know exactly what actions can be part of an UndoGroup, and which can't. For instance, I have an action which:
  • deletes an item in a TRichViewEdit
    creates a new style for another item, and applies it (by directly assigning the style number)
    repeats the above step for zero or more preceding items
I'd really like to undo this action with a GroupUndo, but it doesn't seem to be working, and I think it's because some of the actions above can't be part of an undo group. Is there any way I could make undo work in this situation?

Cheers,
Martin[/code]
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

May be the simplest way is to use standard editing operation? To select item and delete selection, to select items and apply new style?
These operations can be undone (except for adding new style to the collection, this operation is not undoable yet)
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Post by martindholmes »

Unfortunately, this almost always involves adding new styles to the collection.

Undo is such a messy business, eh?

I guess I'll have to try and store enough information to re-create the previous state of the document, by taking actions instead of undoing them. If I intercept the Undo command when I see that it's rvutCustom, and undertake my own undo actions, how do I remove that undo item from the undo list?

Cheers,
Martin
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It's possible to create undo class for addition in style collections.
But, other operations may add styles as well, and it would be not simple to remove styles added only be certain operations.
I do not think this is a big problem, because unused styles can be deleted by DeleteUnusedStyles method.
Post Reply