[comp.sys.amiga] Macros to make "dme" look somewhat like Wordstar

kim@amdahl.uts.amdahl.com (Kim DeVaughn) (08/04/88)

[ Q: "What's the difference between a Design Rule and a Guideline?" ]
[ A: "Design Rules are violated  ...  Guidelines just get ignored." ]

Several people email'd that they'd like to see the Wordstar emulation
macros for "dme" that I mentioned in a previous posting, so here they
are.  I've source'd the file with dme v1.30 without getting any error
messages, and tried a few of the functions out, all of which seem to
work correctly (at least they do the same things that Wordstar does :-) ).

Also, thanks to Jim Blandy for his Turing Machine macro "hack" ... getting
some nifty macro coding examples for Matt's great editor!  Maybe the person
that mentioned they had "vi" macros for dme could post them also?

/kim


# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# dme-ws.edrc

echo x - dme-ws.edrc
cat > "dme-ws.edrc" << '//E*O*F dme-ws.edrc//'
# DME-WS version 1.0, copyright (C) 1988 by Bela Lubkin
# Permission granted for personal use and adaptation.  No commercial rights
# are granted.

# Developed for use with Matthew Dillon's programmable editor "DME".  I used
# DME version 1.29 and have no idea how this would work with other versions.
# I'd like to know if there is a later version...

# This is a set of macros for DME that give it a WordStar-like command set.
# Not all of WordStar's commands were possible or desirable; the subset chosen
# is that suitable for a programmer's editor.
#
# If you don't have WordStar commands burned into your circuits, I don't
# recommend you start now; it >is< an efficient editing system but it is not
# well represented on the Amiga and this implementation is kludgy at best.  I
# hear noise that MSS' Scribble! is WS-influenced, so if you're facile with
# Scribble! you might be able to make sense out of this.
#
# I'm providing no documentation beyond this bit of rambling at the beginning,
# some comments on weaknesses of various commands interspersed within the
# definitions, and the definitions themselves.  Another good reason not to
# jump in unless you're already a WordStar addict.
#
# The WordStar command set I've used is heavily influenced by Turbo
# Pascal, SideKick, EDWIN, and by my own personal preferences built up over
# 4 years of using those 3 WS-alike-but-reconfigurable editors.  Thus, for
# instance, most of the ^K-prefix commands (^KC=block copy) are duplicated as
# alt-command (^KC=alt-C); the function keys are elaborations of SideKick's;
# etc.
#
# DME's block commands are line-oriented; there was nothing I could do about
# this, so you'll have to bear with.  (WordStar's are stream-oriented).
#
# ALL TWO-CHARACTER COMMANDS MUST BE GIVEN AS TWO >CONTROL< CHARACTERS.
# WordStar will accept "control-Q R".  DME-WS wants "control-Q control-R".

# Contact me at:
#   XBBS     (408) 476-4946 (5-user)  (PC-Pursuit: CASJO node)
#   Pyrzqxgl (408) 476-4633                      "
#   FAUG BBS (415) 595-2479  (Whatever the San Fransisco node's called)
#   BBS-JC   (415) 961-7250                      "
#   My own BBS soon to come -- I think.




# Toggles used:
#   1=^J prefix (set but not used)
#   2=^K prefix
#   3=^O prefix
#   4=^P prefix (set but not used)
#   5=^Q prefix
#   6=search vs. replace
#   7=scratch used by backspace
#   8=auto-indent flag (alt-I)

pageset 99

map `ca-j' `resettoggle 1'
map `ca-k' `resettoggle 2'
map `ca-o' `resettoggle 3'
map `ca-p' `resettoggle 4'
map `ca-q' `resettoggle 5'
map `cas-esc' `ca-j ca-k ca-o ca-p ca-q'
map `a-esc' `cas-esc esc'
map `s-esc' `a-esc'
map `c-[' `a-esc'
map `esc' `a-esc'
map `c-esc' `cas-esc recall'

# ^A fails if there is whitespace to the left of the cursor and extending to
# the beginning of the line.
map `c-a' `ifelse 3 `s-f3' `ifelse 5 `ca-q settoggle 6 escimm `findstr ' escimm `repstr ' nextr' `c-left'''

map `c-b' `if 2 `a-b' if 3 `ca-o reformat' if 5 `ca-q goto block''
map `c-c' `ifelse 2 `a-c' `ifelse 5 `ca-q bottom last' `pagedown'''
map `c-d' `ifelse 2 `s-f2' `ifelse 5 `ca-q last' `right'''
map `c-e' `ifelse 5 `ca-q screentop' `up''

# ^F works correctly but causes disconcerting horizontal scrolling when moving
# from within last word on line to end of line, when line is longer than
# window width.
map `c-f' `ifelse 5 `ca-q resettoggle 6 escimm `find '' `c-right''

map `c-g' `del'
map `c-h' `ifelse 2 `a-h' `backspace''
map `c-i' `ifelse 3 `ca-o saveold iconify' `ifelse 5 `a-i' `tab'''
map `c-j' `settoggle 1'
map `c-k' `ifelse 2 `a-k' `ifelse 5 `ca-q goto end down' `settoggle 2'''
map `c-l' `ifelse 6 nextr next'
map `c-L' `ifelse 6 prevr prev'
map `c-m' `enter'
map `c-n' `ifelse b `split down down deline up' `split''
map `c-o' `settoggle 3'

# ^P doesn't do anything; I could see no reasonable way to implement it and it
# didn't seem important in context anyway.  It could probably be implemented
# by prefixing each control-character definition with something like
#    ifelse 4 `ca-p `A' left tlate -64' `rest-of-definition'
# or
#    ifelse 4 ``A' ca-p' `rest-of-definition'
# if ca-p were defined as
#    map ca-p `resettoggle 4 left tlate -64 right'
# but either choice seemed >too< obscene... (both examples insert a ^A).
# Alternatively, enable the following definition:
#    map `c-p' `while c>32 `tlate -32' right'
# which defines ^P as "convert the character under the cursor to a control
# character, then go right".
map `c-p' `settoggle 4'

map `c-q' `ifelse 2 `a-q' `settoggle 5''
map `c-r' `ifelse 2 `a-r' `ifelse 5 `ca-q top first' pageup'''
map `c-s' `ifelse 2 `f2' `ifelse 5 `ca-q first' `left'''

# ^T works correctly but resorts to tricks that may appear disconcerting on
# screen.
map `c-t' `ifelse r `join if !l del' `split `!' down first wright ifelse l `up deline up last bs' `split deline up last join del bs'''

map `c-u' `unblock'
map `c-v' `ifelse 2 `a-v' `insertmode toggle''

# ^W scrolls the screen but cannot place the cursor correctly; different
# scroll primitives or a conditional to test whether the cursor is at the
# bottom of the window would be necessary.
map `c-w' `ifelse 2 `a-w' `ifelse 3 `ca-o wordwrap toggle' `c-up'''

map `c-x' `ifelse 2 `c-f2' `ifelse 5 `ca-q screenbottom' `down'''
map `c-y' `ifelse 2 `a-y' `ifelse 5 `ca-q remeol' s-del''

# ^Z scrolls the screen but cannot place the cursor correctly; different
# scroll primitives or a conditional to test whether the cursor is at the top
# of the window would be necessary.
map `c-z' `c-down'

map `c-]' `ref'

map `backspace' `ifelse !l bs `if !t `resettoggle 7 if b `toggle 7' `!' up last join if 7 down del if !l del'''
map `s-backspace' `backspace'
map `c-backspace' `backspace'
map `a-backspace' `backspace'
map `enter' `ifelse b `split down first down deline' `split down first' if 8 `up ifelse c<>32 `down' `down `!' first split up firstnb down join del'''
map `s-enter' `enter'
map `c-enter' `enter'
map `a-enter' `enter'
map `return' `enter'
map `s-return' `enter'
map `c-return' `enter'
map `a-return' `enter'
map `help' `iconify'
map `c-help' `source s:ws.edrc'
map `L-lmb' `tomouse'
map `L-mmove' `tomouse'
map `aA-lmb' `tomouse'
map `aA-mmove' `tomouse'
map `saA-mmove' `tomouse'
map `R-rmb' `iconify'
map `aA-rmb' `iconify'
map `c-up' `scrollup'
map `c-down' `scrolldown'
map `c-left' `ifelse l `up last' `wleft''
map `c-right' `ifelse r `down first' `wright if l `up if r up last'''
map `a-up' `repeat 5 up'
map `a-down' `repeat 5 down'
map `a-left' `repeat 10 left'
map `a-right' `repeat 10 right'
map `s-up' `top'
map `s-down' `bottom'
map `s-left' `first'
map `s-right' `last'
map `s-del' `if b `downadd up' deline first'
map `c-del' `remeol'
map `s- ' `` ''
map `c- ' `` ''
map `a- ' `` ''
map `s-tab' `backtab'
map `a-b' `ca-k block'
map `a-c' `ca-k bcopy'
map `a-h' `ca-k unblock'
map `a-i' `ca-q toggle 8 ifelse 8 `escimm `Autoindent ON, press ESC...'' `escimm `Autoindent OFF, press ESC...'''
map `a-k' `ca-k up block down'
map `a-q' `ca-k quit'
map `a-r' `ca-k escimm `insfile ''
map `a-s' `bsource'
map `a-v' `ca-k bmove'
map `a-w' `ca-k escimm `bsave ''
map `a-y' `ca-k bdelete'
map `as-s' `unblock block block bsource'
map `f2' `ca-k saveold'
map `c-f2' `ca-k saveold quit'
map `s-f2' `ca-k saveold escimm `newfile ''
map `f3' `escimm `newfile ''
map `s-f3' `ca-o escimm `newwindow newfile ''

map `del' `del'
map `down' `down'
map `left' `left'
map `right' `right'
map `tab' `tab'
map `up' `up'

# Some hardwired DME commands that I trash..
unmap `a-d'
unmap `a-l'
unmap `a-m'
unmap `a-u'
unmap `c-/'
unmap `c-1'
unmap `f1'
unmap `f6'
unmap `f7'
unmap `f8'
unmap `f9'
unmap `f10'

//E*O*F dme-ws.edrc//

echo Possible errors detected by \'wc\' [hopefully none]:
temp=/tmp/shar$$
trap "rm -f $temp; exit" 0 1 2 3 15
cat > $temp <<\!!!
 214  1283  7645  dme-ws.edrc
!!!
wc  dme-ws.edrc | sed 's=[^ ]*/==' | diff -bw $temp -
exit 0

-- 
UUCP:  kim@amdahl.amdahl.com
  or:  {sun,decwrl,hplabs,pyramid,uunet,oliveb,ames}!amdahl!kim
DDD:   408-746-8462
USPS:  Amdahl Corp.  M/S 249,  1250 E. Arques Av,  Sunnyvale, CA 94086
CIS:   76535,25