undo-redo

How to design undo & redo in text editor?

孤街浪徒 提交于 2019-11-27 04:30:46
问题 Part of my project is to write a text editor that is used for typing some rules, compiling my application and running it. Writing compiler was end and release beta version. In the final version we must add undo and redo to the text editor. I use a file and save it periodically for the text editor. How to design undo and redo to my text editor? What is changed in the structure of persistent of file? 回答1: You can model your actions as commands, that you keep in two stacks. One for undo, another

How to implement good and efficient undo/redo functionality for a TextBox

老子叫甜甜 提交于 2019-11-27 00:22:16
问题 I have a TextBox which I would like to implement undo/redo functionality for. I have read that it might have some slight undo functionality already, but that it is buggy? Anyways, I would like to implement both undo and redo functionality also just to learn how you would go ahead and do that. I have read about the Memento Pattern and looked some on a Generic Undo/Redo example on CodeProject. And the pattern kiiind of makes sense. I just can't seem to wrap my head around how to implement it.

How to implement 'undo' operation in .net windows application?

為{幸葍}努か 提交于 2019-11-26 22:42:21
问题 Assume that, a win form has certain input fields and user enters/re-enters some data. How to retain data previously entered by 'undo' operation? Just I want to know the best way to accomplish it. 回答1: There are a few options. The important thing is that you start designing it in early in the project. Trying to add it to an existing project can be very expensive if it wasn't designed with this capability in mind. There are a few fundamental patterns that you'll want to take advantage of: MVC

“Undo” history button clear after run macro excel

早过忘川 提交于 2019-11-26 21:49:29
问题 I have a macro that fires on the "Worksheet_SelectionChange" event. The macro validate data of one column, it changes the background color of the cell if its wrong. The problem is after run the macro, it clears the history of changes (Ctrl Z) of all the document, even the history changes of other cells that I didnt validate. How can I solve this problem? Thanks. 回答1: As the others have stated, there is not way to stop a worksheet-changing macro from clearing the undo stack. As another side

Undo with multitouch drawing in iOS

独自空忆成欢 提交于 2019-11-26 18:36:25
问题 I am working with multitouch while writing, So basically what I am doing is, I am writing with hand support, because typically, its how user rights, I followed this link How to ignore certain UITouch Points in multitouch sequence Everything is working fine, but their is some problem with undo when I write with my hand touching the screen, otherwise it works fine. Below is my code -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* topmostTouch = self.trackingTouch; for

data structure used to implement UNDO and REDO option

萝らか妹 提交于 2019-11-26 15:08:41
问题 I want to implement UNDO and REDO option(as we see in MS word etc). Can you suggest me a data structure for it, and how can i implement it.? 回答1: It isn't a data structure but a design pattern. You're looking for the Command Pattern. The standard is to keep the Command objects in a stack to support multi level undo. In order to support redo, a second stack keeps all the commands you've Undone. So when you pop the undo stack to undo a command, you push the same command you popped into the redo

NSInvocation for Dummies?

你说的曾经没有我的故事 提交于 2019-11-26 11:01:11
How exactly does NSInvocation work? Is there a good introduction? I’m specifically having issues understanding how the following code (from Cocoa Programming for Mac OS X, 3rd Edition ) works, but then also be able to apply the concepts independently of the tutorial sample. The code: - (void)insertObject:(Person *)p inEmployeesAtIndex:(int)index { NSLog(@"adding %@ to %@", p, employees); // Add inverse of this operation to undo stack NSUndoManager *undo = [self undoManager]; [[undo prepareWithInvocationTarget:self] removeObjectFromEmployeesAtIndex:index]; if (![undo isUndoing]) [undo