[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Re: Programming challenge: Undo
- Subject: Re: Programming challenge: Undo
- From: Carl Distefano cld@xxxxxxxx
- Date: Wed, 18 Jun 2008 13:16:07 -0400
Reply to note from Harry Binswanger Wed, 18 Jun
2008 00:42:59 -0400
> Of course, that could be accomplished by modifying the kbd file
> to call SAVEBAK or AUTOFILE before each CI.
Or before any operation that changes the file in any hard-to-restore
way. You don't even have to modify the KBD file. SAB is an
engrained habit with me (at least, when I'm working on critical
documents); I recommend it. I have a similar macro for WordPerfect,
which I use at work.
A step-by-step Undo is actually an interesting programming exercise.
It could be implemented, via XPL, for certain discrete procedures;
for example, block deletions and MoVes. For each procedure, you'd
have to write a routine that not only carries out the primary
procedure, but also, first, writes (prepends to a file, presumably)
the code to undo that procedure -- a kind of reverse macro recorder.
A separate PM would run the most recently saved Undo code on demand
(and remove it from the Undo stack). That much is relatively
straight-forward.
But things quickly get complicated, for example, when the user has
typed intervening keystrokes that can't be undone. If you restore a
deleted block at a stored cursor location, but the surrounding text
has changed, you haven't got very far. That's why a useful Undo is
really an all-or-nothing proposition, and "all" is a lot to chew.
(And block operations are only one of many that you'd want to be
able to undo.)
All things considered, the file-based expedients are good enough for
me.
--
Carl Distefano
cld@xxxxxxxx