home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
epmsmp.zip
/
UNDOREDO.E
< prev
next >
Wrap
Text File
|
1996-03-15
|
3KB
|
66 lines
/* The following code defines a couple of keys that let you step backwards
and forwards through the undo states. For the sake of example, I've
defined the Undo key as Ctrl+U and the Redo key as Ctrl+R. You might
prefer to select other keys that don't conflict with standard EPM key
definitions. One important note - the way that the keys determine if
you're still in an undo/redo sequence is checking if the previous key
pressed was also Ctrl+U or Ctrl+R. Because of the way keys are handled,
you must press and hold the Ctrl key for as long as you're stepping back
and forth (by pressing U and R) - once you release the Ctrl key, the next
time you press Ctrl+U or Ctrl+R, they will see the previously-pressed key
as being the Ctrl key, not Ctrl+U or Ctrl+R. The same is true if you
define the keys to be a Shift or Alt combination (which implies that they
both have to have the same shift state - both start with s_, both with c_,
both with a_, or both unshifted).
Note also that this assumes the user has not enabled undo-state recording
on *every* keystroke. If you did, then you might have to add code here
to stop recording changes on keystrokes, and it's not clear how you'd
figure out when to turn it back on.
by: Larry Margolis */
define
undo_key = 'c_U' -- (Ctrl+U normally pops the Undo dialog)
redo_key = 'c_R' -- (Ctrl+R normally starts recording keystrokes)
def $undo_key =
universal current_undo_state
lk = lastkey(1)
if lk = $undo_key | lk = $redo_key then -- last key was undo or redo
parse value current_undo_state with presentstate oldeststate neweststate
if presentstate > oldeststate then
presentstate = presentstate - 1
undoaction 7, presentstate
current_undo_state = presentstate oldeststate neweststate
else
call beep(800, 500)
endif
sayerror 'Now at state' presentstate 'of' neweststate
return
endif
-- Need to get new state information
undoaction 1, starting_state -- Do to fix range and for value.
undoaction 6, StateRange -- query range
parse value staterange with oldeststate neweststate
presentstate = neweststate - 1
undoaction 7, presentstate
current_undo_state = presentstate oldeststate neweststate
sayerror 'Initialized: at state' presentstate 'of' neweststate
def $redo_key =
universal current_undo_state
lk = lastkey(1)
if lk = $undo_key | lk = $redo_key then -- last key was undo or redo
parse value current_undo_state with presentstate oldeststate neweststate
if presentstate < neweststate then
presentstate = presentstate + 1
undoaction 7, presentstate
current_undo_state = presentstate oldeststate neweststate
sayerror 'Now at state' presentstate 'of' neweststate
return
endif
sayerror 'Already at state' presentstate 'of' neweststate
endif
call beep(800, 500)