Re: Undo and the text widget



on 11/28/00 12:53 PM, Havoc Pennington at hp redhat com wrote:

> An alternative to the flag indicating whether an insertion or deletion
> is interactive might be:
> 
> void gtk_text_buffer_begin_user_action      (GtkTextBuffer *buffer);
> void gtk_text_buffer_end_user_action        (GtkTextBuffer *buffer);
> int  gtk_text_buffer_get_user_action_serial (GtkTextBuffer *buffer);
> 
> [...]
>
> So, to implement undo, in your insert_text or delete_text signal
> handler, you'd see whether the current user action serial is
> nonzero. If the current serial matches the serial of the topmost
> item on the undo stack, you add the insert or delete to the topmost
> undo item. If it's different, you create a new undo item and push it
> on the undo stack.

I think you should get rid of the _get_user_action_serial from your public
interface, and simply emit a signal at the start and end of each user action
(the outermost calls to _begin_user_action and _end_user_action).

(I may have other feedback later with a bit more time to think on it.)

    -- Darin





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]