home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
disks
/
disk429.lzh
/
Uedit-Stuff
/
Delete.doc
< prev
next >
Wrap
Text File
|
1991-01-10
|
12KB
|
201 lines
PAUL KIENITZ'S UEDIT SCRATCH DELETE COMMANDS
Have you ever wished that you could paste back (undo) the delete before
last? Or the one before that? Have you ever wished the scratch delete
commands had more sense about when to merge consecutive deletes together, and
when not to? Have you ever wished it was easier to add new delete commands
that would know how to merge properly? The answer is here -- a complete
replacement set of scratch delete commands that remember the last eight
chunks of deleted text. I find them to be the most useful commands I have.
These commands replace the following commands from the standard config:
everything on kp0, kp7, and kp9; ctl-d, ctl-del, ctl-bs, and virtual-x; and
lAmiga-1. It also adds new commands, mostly lAmiga-kpX combinations. The
new commands have these properties:
The last eight chunks of text deleted are stored in a ring (a circular
stack). The most recently deleted chunk is what kp0 pastes back. The ring
can be rotated with two new commands: lAmiga-kp4 and lAmiga-kp6. If you view
the newest delete buffer in a split window with lAmiga-1, using the rotate
commands will let you see all eight chunks.
Consecutive deletes merge together in the right order when either end of
the piece being cut adjoins the location of the previous cut. But only if
the most recent cut was in this same buffer and there has been no paste since
the last cut. The location of the cursor doesn't matter. For instance, you
can delete the next line with ctl-bs, then delete this line with ctl-d, then
the previous line with ctl-del, and kp0 will restore all three lines together
in the correct order. If you want to prevent two deletes from merging, press
ctl-kp0 before making the second delete and they'll be kept separate. If
they don't join when you thought they would, no problem. Just rotate the
ring to get both pieces back.
Every delete command is very simple to write, since all the hard work is
done by a runkey. You just do this: first, equateLoc(curFile, mouseLoc,
locB). MouseLoc temporarily marks the spot where the previous delete in this
buffer happened. Then, mark the region to be deleted with locA at the start
and locB at the end. Then runKey(virtual-kp7). That's all.
The following are new commands:
ctl-kp0: Prevents the next delete from merging with the previous one,
even if at an adjoining location.
lAmiga-kp4: Makes the newest chunk of deleted text on the ring become the
"oldest"; the second-newest is now what kp0 pastes back.
Warning: if you delete again, the most recent delete before
that, being "oldest" now, is discarded.
lAmiga-kp6: Makes the oldest chunk "newest".
lAmiga-kp1: A shortcut for lAmiga-kp0 lAmiga-kp4 normal-kp0; it replaces
the last chunk you pasted back with the next older chunk.
This is often the most convenient way to paste back an older
chunk; first go kp0 and then repeat lAmiga-kp1 until you see
the chunk you want. (The next kp0 will paste that chunk you
ended up with, not the one it did originally.) The cursor
must be at the end of the last paste, just as for lAmiga-kp0.
lAmiga-kp0: Undoes the last paste; re-deletes the last chunk of text that
was inserted with kp0. This only works if there has been no
further cut since the last paste, and the cursor is at the
end of the chunk just inserted. It might not work properly
if you run other commands after the paste which use locA. If
you move the cursor, you can get back with:
lAmiga-kp5: Moves the cursor to the location of the last delete, or the
end of the last paste (locB).
These next few are strictly extras:
lAmiga-kp8: Moves the cursor to the start of the last paste (locA), if
there has been one since the last cut. If you run other
commands, this might end up anywhere.
lAmiga-kp7: Prompts for you to type a character, and then deletes from
the cursor back to most recent occurence of that character.
If the character is a letter, it ignores case if the
searchCaps flag is false. The character itself is not
deleted, and the character immediately to the left of the
cursor is not checked to see if it is the one specified.
lAmiga-kp9: Like lAmiga-kp7, but deletes forward. Does not look at the
character under the cursor.
lAmiga-kp3: Extends the last delete to the cursor in either direction.
That is, if you make any delete, you can merge another chunk
onto it on either side by simply putting the cursor at the
other end and pressing lAmiga-kp3. Or, it deletes from the
cursor to the end of the last paste, if that's what you did
most recently. This is handy for deleting odd shaped chunks.
shftAlt-kp7: Deletes from the cursor back to the first printable character
on the line, leaving the indentation intact. This won't work
without the ctl-[ command described in the Indent file.
shftCtl-kp7: Delete from the cursor back to the beginning of the
paragraph. Actually, this version just deletes back to the
nearest blank line (not counting blank lines at the cursor).
shftCtl-kp9: Delete from the cursor up to the end of the paragraph.
Actually, up to the next blank line (not counting blank lines
at the cursor). Maybe someday I'll do a version that looks
at the indentation of lines.
shftAltCtl-f7: Sets the search string using the last cut text as the default.
Like, you delete a few words, and then maybe paste them right
back, and then you can search for other copies of that phrase
with SAC-f7, possibly modifying them while in inputString.
The lAmiga-1 command, which views the newest delete buffer in a split
window, has been changed so that by default it leaves the window you were in
the active one. If you press lAmiga-1 again, that split becomes the active
window. If you don't want that feature (like because if you have two window
splits of the same file it might end up in the wrong one, or because the main
reason you want the split window is to modify the cut text) then there is a
simpler alternate version of the command, commented out, right after the
other one in the config file. Editing in the delete buffer is risky, because
thoughtlessly deleteing while in the delete buffer may cause the text you cut
to vanish entirely, or it may end up just dumping you into the next buffer in
the ring. The deleting engine virtual-kp7 is set up so that if a lAmiga-1
split window exists, it will be updated continually as you delete. If you
don't want that feature (which costs speed), remove the three lines in the
definition of virtual-kp7 that are marked with ** in a comment. To close the
split, press lAmiga-kp1 again to activate the split before pressing lAmiga-0.
Here is a quick summary of these commands, suitable for being put in your
Help! file:
DELETE & UNDO:
=============
kp0: Paste; undo latest scratch delete, inserting at cursor
C-d: Delete cursor line, storing it in Undo buffer
C-bs: Delete line below cursor line, save in undo buffer
C-del: Delete line above cursor line, save in undo buffer
kp7: Delete word left, storing it in Undo buffer
kp9: Delete word right, storing it in Undo buffer
S-kp7: Delete char to left of cursor, storing it in Undo buffer
S-kp9: Delete char under cursor, storing it in Undo buffer
A-kp7: Delete to start of line, storing it in Undo buffer
A-kp9: Delete to end of line, storing it in Undo buffer
C-kp7: Delete to top of window, storing it in Undo buffer
C-kp9: Delete to end of window, storing it in Undo buffer
L-kp7: Delete back to last occurence of given character, storing in Undo
L-kp9: Delete to next occurence of given character, storing it in Undo buffer
SC-kp7: Delete back to last blank line, storing it in Undo buffer
SC-kp9: Delete to next blank line, storing it in Undo buffer
SA-kp7: Delete back to end of indentation (first printable char on this line)
L-kp3: Extend last delete to cursor (merge with previous delete)
C-kp0: Prevent next delete in same place from merging with previous
L-kp0: Un-undo (re-delete) last paste, if cursor is at same place
L-kp1: Replace last paste with older deleted text (which is now "newest")
L-kp5: Go to location of last scratch delete or paste (bottom end)
L-kp8: Go to top end of last paste, or maybe who knows where
L-kp4: Make newest scratch delete "oldest"
L-kp6: Make oldest scratch delete "newest"
L-1: Show newest delete in split window (use L-kp4 & L-kp6 to see all)
SAC-f7: Set search string using text in Undo buffer
I know that's a lot of commands to incorporate into your stuff, but
since these are some of the most basic and heavily used commands in routine
editing, it makes sense to concentrate a lot of improvement here.
The following commands in the standard config trash locA:
shftAltCtl-buttonDown, ctl-tab, ctl-j, alt-1, alt-5, ctl-3, ctl-4, alt-s,
lAmiga-r, lAmiga-d, and lAmiga-p, and the spelling commands rAmiga-4,
rAmiga-5 and rAmiga-6. My indent commands alt-[ and alt-] do too, and so
does my replacement normal-tab when it runs alt-] (see Indent.doc).
Technical notes: The range of buffers used to store the cut chunks is 80
through 87. This can be changed quite easily, since only the three commands
lAmiga-kp4, lAmiga-kp6, and virtual-kp7 have any knowledge of which buffers
(or how many) are in use. The lines to change are marked with the word
"Bounds" in a comment. The n-variables used are n27 and n28. Changing these
are less easy, because more commands mention them, such as all the kp0
commands, lAmiga-kp8, and virtual-kp4, which is used to change the split
window display to a different buffer when the "top" position moves. Like the
standard commands, these require that locB not be changed by other commands
if you want merging to work right, but locA can be trashed. As mentioned,
these commands trash mouseLoc. They won't require any initialization, if you
trust the n-variables to all contain zero at startup. If you want to
explicitly initialize them, put -2 in n27 and 80 in n28, or zero in both.
Since the startup key doesn't seem to ever run equateNum as advertised, the
only way to do this is to have it runKey something that puts a magic number
in some n-variable to tell it that it's already been run if it gets run
again. If you're working with tight memory, storing eight pieces might be
trouble; unfortunately there's no way with this version of Uedit for a CL
function to tell when memory is low, and even more unfortunately, insertRgn
with no memory can basically wedge the whole system and may cause a crash
somewhere else; abort has been observed not to work at such times.
Hope all this is useful.
Feedback is appreciated.
email: none Paul Kienitz
bbses: 415-845-4812 6430 San Pablo ave.
415-222-9416 Oakland, CA, 94608
USA