Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.programming    |    Programming issues that transcend langua    |    57,431 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 55,657 of 57,431    |
|    Malcolm McLean to oot...@hot.ee    |
|    Re: Undo / Redo design pattern.    |
|    03 Apr 22 13:32:07    |
      From: malcolm.arthur.mclean@gmail.com              On Sunday, 3 April 2022 at 14:26:22 UTC+1, oot...@hot.ee wrote:       >       > Storing whole program state is pointlessly memory consuming and diffing       whole program state is pointlessly expensive.       > More usual is to make all actions to be required to record their reverse       actions.       >       > So when action is done then reverse action is stored to undo stack and redo       stack is cleaned.       > Undo then means that reverse action is done and removed from undo stack and       action is stored to redo stack.       > Redo then means that action is done and removed from redo stack and reverse       action is stored to undo stack.       >       > That takes designing (and testing) your commands/actions/operations more       carefully.       > But that is anyway not bad at all in the long run.       >       I decided to knock something up anyway.       I just diff by finding the changed section. It will be inefficient if the user       makes an edit which moves       an item from the start of the string to the end, which is the most likely       bad-case scenario. But it's       O(N) in text size.       The other question is whether there will be many applications which can       cheaply stringify their       state. This approach makes sense for Crossword Designer, because the program       state is just       a crossword, which is 15x15 bytes for the grid and up to about a hundred short       strings for the clues.       But how many other programs have those characteristics I don't know.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca