AutoHotkey Community

It is currently May 27th, 2012, 4:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: September 26th, 2005, 5:05 pm 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
How are undo actions handled in text editors? Most editors have unlimited undos, but what happens when the RAM is full? Are temp files created? Can someone explain how this process works?

_________________
my lame sig :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 7th, 2005, 7:07 pm 
Offline

Joined: October 6th, 2005, 7:25 am
Posts: 24
Text doesnt take up much RAM so I doubt that filling it up is much of an issue.
But in the event that RAM was full, it would probably be written to virtual memory(on the hard drive). This is handled internally by windows, and you shouldn't really have to worry about it when writing scripts or programs.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 7th, 2005, 7:58 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
There could be many ways implementing unlimited undo's. When I wrote a math text editor many years ago I chose a very simple way: keep a copy of the original file on disk, not changed at file saves, and record all the user input. At an undo request the editor replayed all the user actions from the original file until the requested undo point. It allowed re-do's, too, but when slow operations were executed, like millions of replaces, or rectangular cut over thousands of lines, it was painfully slow. To speed this up, further temporary copies of the files had to be saved after a certain cumulative time the sequence of redo operations would take. (Simple typing is very fast to redo, so thousands of keystrokes are allowed between temporary file creations.) In this way you could start the replay from the last saved file prior to the undo point. Obsolete temp files have to be deleted and a cleanup is needed at the end.

This approach is still slow when you want to go back with single step undo's, so it ought to be complemented with backward action steps, whenever feasible. Simple typing can be undone by backspaces, but undoing large search and replace operations have to load a temporary file.

This way the undo buffer is never too large. Even if you type 100 keystrokes a minute you cannot type more than 150K keys a day.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot] and 75 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group