home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
disks
/
disk429.lzh
/
Uedit-Stuff
/
Indent.doc
< prev
next >
Wrap
Text File
|
1991-01-10
|
10KB
|
185 lines
PAUL KIENITZ'S UEDIT INDENTATION COMMANDS
Have you ever wished that you could leave your tab ruler with stops every
eight spaces (because that's what most other software uses) but still conven-
iently indent things by multiples of four spaces, or three or five? Here is
a new set of indent related commands for that purpose. And there are a few
other miscellaneous goodies floating around in this stuff too.
The basic commands are alt-], which indents the present line by more
spaces, and alt-[ which indents it by less. They both use the optimum
combination of tabs and spaces according to your present tab table for the
new indentation, if trueTabs is on. The size of the increment they indent by
is set by the command shftAlt-], which prompts you to press a digit key to
specify the indent size from one to ten spaces (press a zero for ten). It
can be changed to accept any number; see the comments in SA-]. If you do not
set the distance, it defaults to four spaces. To change this default, search
for places in the Indent file marked with the string "default @@". You'll
need to change 4 to the new value in alt-[, alt-], and lAmiga-[.
There is also another pair of commands which were not present in the earlier
version of this file: lAmiga-[ and lAmiga-]. LAmiga-[ looks back at several
previous lines (currently it looks at the last six; this is easily changed)
until it finds one that is indented less than the present line, but not
completely unindented, and then matches the indentation of the present line
to that one. Here's an example of what it does:
BEFORE PRESSING LAMIGA-[
third line above the cursor
second line which it ignores because it's not indented at all
first line above the cursor
the line the cursor is on
AFTER PRESSING LAMIGA-[ ONCE
third line above the cursor
second line which it ignores because it's not indented at all
first line above the cursor
the line the cursor is on
AFTER PRESSING LAMIGA-[ AGAIN
third line above the cursor
second line which it ignores because it's not indented at all
one line above the cursor
the line the cursor is on
If it doesn't find a line above to give guidance, it outdents by the
distance that alt-] indents. There is also a function lAmiga-] which
outdents the current line to match up with the next text after whitespace in
the line immediately above. (Actually if the line(s) directly above are
blank it looks further up for a non-blank line. Example:
BEFORE PRESSING LAMIGA-]
the_line: above ; the cursor
line the cursor is on
AFTER PRESSING LAMIGA-]
the_line: above ; the cursor
line the cursor is on
AFTER PRESSING LAMIGA-] AGAIN
the_line: above ; the cursor
line the cursor is on
and so on. As you might be able to tell from the example, I intended this to
be useful for assembly language programmers. When it reaches the last word
of the line above it aligns with the end of that line. (Maybe I should have
made lAmiga-[ do this the opposite direction and used some other key for what
it does now.)
Also included is a new version of normal-tab which runs alt-] if it is in
the leading indent of the line, and just inserts a tab normally (or equiva-
lent spaces if trueTabs is off) if it's elsewhere. This gives the effect of
tab stops every howevermany spaces at the beginning of the line. And there's
a version of backspace that runs alt-[ when it's in the leading indent, but
it's commented out because of slowness. (This slowness is apparently in the
display updater, not the command itself. The command itself runs in ten
milliseconds or so in those cases when it doesn't run alt-[.)
This file also includes replacements for the fairly useless alt-l and
alt-r commands, which in the standard config move the hilite region one space
left or right, but don't work if the line has leading tabs. The new versions
move the lines left or right several spaces using alt-[ and alt-], and don't
move any lines that aren't visibly hilited (lines with the hilite marker at
one end). These commands are noticeably slow, since each alt-[ or alt-]
takes an unfortunately large fraction of a second.
To move a line, or a hilited group of lines, left or right by only one
space, use altCtl-[, altCtl-], altCtl-l, or altCtl-r. Think of the control
key as "shortening" whichever other key it's applied to. And shftAltCtl-r
asks for a number, positive or negative, and indents (or outdents if
negative) the hilite region by that many spaces.
Another key provided is ctl-[ which moves the cursor to the end of the
indent; that is, to the first visible character on the line. Be careful
about moving this to another key, because all the others runKey this one.
Also thrown in is shftAlt-[ ( think of it as alt-{ ) which creates a pair
of C braces with an indented line between them. The amount of indentation is
the amount used by alt-]. Example:
Blah blah blah <- that's where the cursor is
becomes:
Blah blah blah {
<- that's where the cursor is
}
Here's a Help! file excerpt for these commands:
INDENT:
======
C-[: Move to first non-whitespace on line
A-]: Increase indentation by amount set with SA-] (default 4 spaces)
A-[: Decrease indentation by amount set with SA-[ (default 4 spaces)
A-r: Indent hilite region by amount set by SA-]
A-l: Un-indent hilite region by amount set by SA-]
AC-]: Increase indentation of this line by one space
AC-[: Decrease indentation of this line by one space
AC-r: Indent hilite region by one space more
AC-l: Indent hilite region by one space less
SAC-r: Ask how many spaces to indent or un-indent hilite region by
SA-]: Set indentation amount for alt-[ and alt-]
SA-[: Insert C braces with indented line between ( sort of alt-{ )
L-[: Reduce indentation to match nearest less indented line above
L-]: Indent to match next word after whitespace in line above
Also remember alt-4 which indents the current line to match the one before
it, and alt-1 which moves the line all the way to the left.
Technical notes: The useful thing about ctl-[ is that after you run it, the
number of spaces currently indented is in n50. The core of the system is
virtual-[ which indents the current line to the column in n54 (by temporarily
changing leftMargin), and then moves the cursor to locA, which it assumes you
have used to store the initial position of the cursor. Changing shftAlt-[ to
use inputNum (so that it's not limited to one digit values) should be
straightforward; there are hints there.
A FEW OTHER RANDOM GOODIES
Well lessee... Have you ever wished you knew WHAT JUST HAPPENED when the
cat walked on the keyboard and you couldn't regognize the mess on the screen?
There's a prekey and an alt-q which tell you what the last eight inputs were.
The prekey is commented out for the sake of those who might mass-compile the
whole file without looking at each command first. There are lines in the
prekey that cause normal-buttondown and normal-buttonup inputs to be left out
of the record, easily removed if you desire. There's a commented-out line
that would make it ignore all inputs that just insert characters. The alt-q
command may be a useful example for someone who wants to convert macronums to
readable key names. The n-variables used are n10 through n18 (easily
changeable).
There's a new'n'improved ctl-x Toggle Hex/Decimal which allows the cursor
to start in the middle of the number, allows a trailing L and doesn't
convert anything to 0X with no digits after it. (Personally, I swap this
with ctl-d.)
There's a command for ümlautïng the next vöwël, useful for writing in
German or reviewing heavy metal albums. It also makes some other odd
characters like ß © ¡ ¿ « » ñ. It's on alt-/. (These characters won't
display correctly if you have the last version of 2.4g before 2.4h.)
There are commands to uppercase and lowercase whole words (ctl-l and
ctl-u); the cursor can start in the middle. There's ctl-c which capitalizes
the letter the cursor is on (or the next letter if not on one) and lowercases
the rest of the word if the letter after the one capitalized was uppercase.
I recommend swapping the ctl-c Make Control Character command to ctl-q.
There's a command to save curFile with an icon, but not make icons with
later saves. It's on lAmiga-f2. It might not make an icon if you run it
while there are files in the save queue. There's a replacement for ctl-1
which shows your file size and your position in it in characters and lines
and as a percentage.
And a few other simple things that are self explanatory, like things to
move the cursor to either end of the hilite or invert region, and one to
reset the color permutation if you hit alt-help by mistake, and so on.
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