The only discussion I have seen of this feature is the Gang of Four book on Design Patterns. They call it the "Action Pattern" there, and the idea is quite simple :

In your program, you have (named) actions, that the user can execute, for example in Word, insert a character, insert a word, insert a range, delete a character, delete a word, delete a range. Cutting and pasting text can be modeled as deleting and inserting of several words and characters. Every Action is put into a list, which will be called the "undo list" for obvious reasons. Now, inverting an action is very simple for insert and delete actions, and if you take an object oriented approach, you can simply make it that every action knows how to undo itself.

These actions must be wedged inbetween the model and the controler if you have an MVC approach. If you don't have an MVC approach, I have no idea how you will find all the possible locations where you need to put special registering code.

Note that the undo list and the code needed for it also makes your application very easily scriptable, as a script is nothing more than a saved "do"-list - you just need a way to tell your actions whether they should do or undo themselves.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

In reply to Re: Undo Operations by Corion
in thread Undo Operations by artist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.