v02i048: SBBS "edit" update

Rob DeMarco robertd at ncoast.UUCP
Sat Feb 6 11:31:50 AEST 1988


Comp.sources.misc: Volume 2, Issue 48

Submitted-By: "Rob DeMarco" <robertd at ncoast.UUCP>

Archive-Name: sbbs-editor


Comp.sources.misc: Volume 2, Issue 48
Submitted-By: "Rob DeMarco" <robertd at ncoast.UUCP>
Archive-Name: sbbs-editor

[Now I know why he's been ragging me about *my* editor....  ++bsa]

Ok, this is a MUCH needed upgrade to the SBBS editor. Some bugs were fixed.
Make sure that the resulting file help.editor is moved in the sbbs "misc"
directory. This is used with the "?" command. Also make sure you read
README.MOD1 and of course move "edit" to sbbs's "programs" directory.

All future modifications will be released to this news group. Do to some errors
and problems, an SBBS SYSII will be posted to comp.sources.unix at the end
of this year. But after then, any fixes and changes go to comp.source.misc.
The latest version will always be available by my bbs at (216)-781-6201 (login
"sbbs")
#--------------------------------CUT HERE-------------------------------------
#! /bin/sh
#
# This is a shell archive.  Save this into a file, edit it
# and delete all lines above this comment.  Then give this
# file to sh by executing the command "sh file".  The files
# will be extracted into the current directory owned by
# you with default permissions.
#
# The files contained herein are:
#
# -rw-r--r--   1 robertd  sbbs         231 Feb  4 21:28 README.MOD1
# -rw-rw-rw-   1 robertd  sbbs        1019 Feb  4 21:24 help.editor
# -rwxrwxrwx   1 robertd  sbbs        3376 Feb  4 21:23 edit
#
echo 'x - README.MOD1'
if test -f README.MOD1; then echo 'mkshar: not overwriting README.MOD1'; else
sed 's/^X//' << '________This_Is_The_END________' > README.MOD1
XThis shell archive create a new
Xeditor. This new editor is totally
Xcompatable with the old. Some 
Xbugs have been fix and arguments to
Xthe L, E, I, and D have been allowed.
X
XA new editor help file help.editor
Xreplaces the old ecom.
________This_Is_The_END________
if test `wc -l < README.MOD1` -ne 8; then
	echo 'mkshar: README.MOD1 was damaged during transit (should have been 8 bytes)'
fi
fi		; : end of overwriting check
echo 'x - help.editor'
if test -f help.editor; then echo 'mkshar: not overwriting help.editor'; else
sed 's/^X//' << '________This_Is_The_END________' > help.editor
X   (A)bort message                      (D)elete line
X   (E)dit a line                        (I)nsert at line
X   (C)ontinue entering message          (S)ave message
X   (P)roof read message(spell check)    (L)ist message
X   (R)ot 13 / DeRot 13 a message.
X
XValid Ranges:
X
X    With the E)dit and I)nsert commands, you may include a number AFTER the
Xletter command to stand for a line to apply that command. For instance,
Xto edit line 4 of the message, type
X         e4
X    To insert before line 6, type
X         i6
X
X    For the L)ist and D)elete commands, SBBS accepts a range. A range can be
Xa simple number or a range of lines. It can be used directly after the command
Xor in responce to a question.
X    Valid ranges are:
X
X    n1,n2 (Line n1 through line n2)
X    n1,$  (Line n1 through the end)
X    1,n1  (Line 1 through line n1)
X    1,$   (The entire message)
X    /s1/s2/
X          (The first line containing s1 through the first line containing s2)
X
X    You may also use - and + operators:
X
X    4-1,6+2  (3 though 8)
________This_Is_The_END________
if test `wc -l < help.editor` -ne 30; then
	echo 'mkshar: help.editor was damaged during transit (should have been 30 bytes)'
fi
fi		; : end of overwriting check
echo 'x - edit'
if test -f edit; then echo 'mkshar: not overwriting edit'; else
sed 's/^X//' << '________This_Is_The_END________' > edit
X#! /bin/sh
X# Editor
X
Xwhile : ; do
Xarg=
Xecho "SBBS Editor) \c"
Xcmd=`line | tr -d "!" -d " "`
Xarg="`echo \"$cmd\" | cut -c2-`"
Xcmd="`echo \"$cmd\" | cut -c1`"
X
Xif [ "$cmd" = "" ];then
X  continue
Xfi
X
Xif [ "$cmd" = "?" ] ; then
X  cat $dir/misc/help.editor
X  continue
Xfi
X
Xif [ $cmd = C -o $cmd = c ];then
X  echo "(continue)"
X  exit 1
Xfi
X
Xif [ $cmd = P -o $cmd = p ];then
X  echo "UNIX spell checker. Is not 100% accurate."
X  echo "---------------{spelling errors}------"
X  echo `sed -n '6,$p' $1|spell`
X  continue
Xfi
X
Xif [ $cmd = A -o $cmd = a ];then
X  echo "---------ABORT---------"
X  echo "Do you realy want to do this?"
X  echo "<N>: \c"
X  read yn
X  yn=`echo $yn | cut -c1`
X  if [ "$yn" = Y -o "$yn" = y ];then
X    echo "-<ABORT>-"
X    rm $1
X    exit 2
X  fi
X  echo "ABORT was aborted."
X  continue
Xfi
X
Xif [ $cmd = S -o $cmd = s ];then
X  echo "Saving message..."
X  if [ "$2" != "" ];then
X    $dir/programs/lock /tmp/sbbs.pst.lock
X    ml=`ls $dir/bbs/$basen|wc -l`
X    ml=`expr $ml + 1`
X    cat $1 > $dir/bbs/$basen/$ml 
X    rm $1
X    rm /tmp/sbbs.pst.lock
X  else
X    exit 3
X  fi
X  echo "Message saved..."
X  exit 
Xfi
X
Xif [ $cmd = L -o $cmd = l ];then
X  l=`cat $1|wc -l`
X  l=`expr $l - 5`
X  if [ $l -eq 0 ];then
X    continue
X  fi
X  if [ -z "$arg" ] ; then
X     arg='1,$'
X  fi
X
X  file=/tmp/sbbs.tmp.$$
Xed - $1 << 'EOS' >$file
X6,$p
XEOS
Xed - $file << EOS
X$arg n
XEOS
X  if [ $? -ne 0 ]; then
X     echo "Can't understand range. Type \"?\" for help."
X  fi
X  rm $file
X  continue
Xfi
X
Xif [ $cmd = E -o $cmd = e ];then
X  if [ -z "$arg" ]; then
X     echo "Edit what line? \c"
X     read l
X     l=`echo $l`
X     if [ "$l" = "" ];then
X        continue
X     fi
X  else
X     l=$arg
X  fi
X  l=`expr $l + 5 2> /dev/null`
X  if [ $? -ne 0 ];then
X     echo "Can't understand range. Type \"?\" for help."
X     continue
X  fi
X  wc=`cat $1|wc -l`
X  if [ $l -gt $wc ];then
X     echo "A number 1 through `expr $wc - 5`, please."
X     continue
X  elif [ $l -lt 6 ];then
X     echo "A number 1 through `expr $wc - 5`, please."
X     continue
X  fi
X  echo "Old line reads"
X  sed -n "${l}p" $1
X  echo "Enter new line"
X  qr=`line`
X  ed - $1 <<- EOS
X${l}a
X$qr
X.
X${l}d
Xw
XEOS
X     continue
Xfi
X
Xif [ $cmd = D -o $cmd = d ];then
X  if [ -z "$arg" ] ; then
X     echo "Delete what line(s)? \c"
X     read l
X  else
X     l=$arg
X  fi
X  sed -n '6,$p' $1 > /tmp/sbbs.tmp.$$
Xed - $1 << \EOS
X6,$d
Xw
XEOS
X  sed "${l}d" /tmp/sbbs.tmp.$$ >> $1
X  rm /tmp/sbbs.tmp.$$
X  continue
Xfi
X
Xif [ $cmd = I -o $cmd = i ] ; then
X  if [ -z "$arg" ] ; then
X     echo "Insert at what line? \c"
X     read insert
X  else
X     insert=$arg
X  fi
X  insert=`expr $insert + 0 2> /dev/null`
X  if [ $? -ne 0 ] ; then
X    echo "A number 1 through `expr \`cat $1|wc -l\` - 5`, please."
X    continue
X  fi
X  insert_limit=`cat $1 | wc -l`
X  insert_limit=`expr $insert_limit - 5`
X
X  if [ $insert -gt $insert_limit -o $insert -lt 1 ];then
X    echo "A number 1 through $insert_limit, please."
X    continue
X  fi
X  echo "Start inserting now. Type CTRL-D on a\nblank line to get to editor."
X  file=/tmp/sbbs.tpi.$$
X  cat > $file
X  {
X   ed - $1 << EOS
X   $insert+5,\$p
X   $insert+5,\$d
X   w
XEOS
X  } >> $file
X  cat $file >> $1
X  rm $file
X  continue
Xfi
X
Xif [ $cmd = R -o $cmd = r ] ; then
X   file=/tmp/sbbs.rot.$$
X   sed -n '1,5p' $1 > $file
X   sed -n '6,$p' $1 | tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]" >> $file
X   mv $file $1
X   continue
Xfi   
Xecho "Illegal command."
Xdone
________This_Is_The_END________
if test `wc -l < edit` -ne 184; then
	echo 'mkshar: edit was damaged during transit (should have been 184 bytes)'
fi
fi		; : end of overwriting check
exit 0
-- 
North Coast Computer Resources(ncoast) - 216-781-6201 (or 781-6202)

UUCP: ...uunet!amdahl!sun!mandrill!ncoast!robertd

Ever notice when you say "Pittsburgh",
you can't help to add that silly
",P.A." at the end of it?



More information about the Comp.sources.misc mailing list