Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

v37i001: vim - Vi IMitation editor v1.27, Part01/24

62 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 23, 1993, 1:17:16 PM4/23/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 1
Archive-name: vim/part01
Environment: UNIX, AMIGA, MS-DOS

Vim - Vi IMitation. A clone of the UNIX text editor Vi. Very useful for
editing programs and other plain ASCII text. Full Vi compatibility (except Q
command) and includes most Ex commands.

Extra features above Vi: Multilevel undo, command line history, improved
command line editing, command typeahead display, command to display yank
buffers, possibility to edit binary files, file name stack, support for Manx
QuickFix, shows current file name in window title, on-line help, etc.

Version 1.27, update to 1.24. Most important changes:
- 'ignorecase' did not work with UNIX, fixed
- ":s/a/b/ did not work with MSDOS, fixed
- all other reported bugs fixed
- portability for UNIX improved for linux, hpux, pyramid, SCO Xenix, etc.
- improved security for .exrc and .vimrc in current directory
- a few Ex commands added and a few compatibility problems fixed
- added 'compatible' option to switch off a few vi incompatible extentions
- Vim now works on more terminals (e.g. Sun cmdtool)
- with Amiga DOS 2.0 arp.library is no longer needed
- help file is now displayed using terminal codes
- support for locale() with UNIX

Portability: Runs on Amiga, MSDOS and several UNIX versions.

Distribution:
comp.sources.misc: Sources and documentation (shell archive)
comp.binaries.amiga: AMIGA binaries and documentation (lha archive)
comp.binaries.ibm.pc: MSDOS binaries and documentation (lha archive)
(Sorry to post the documentation three times. It is the only way to guarantee
that everybody gets it. Otherwise people will start asking me for it).

The shell archive contains a few uuencoded files and the reference.doc file
is split up in three. To get the original files back you can use the
"execute.me" script.

Vim is public domain. You are encouraged to put it on ftp servers. It has
already been put on "Aminet". I will ask Fred Fish to put it on one of his
disks.

-------------8<----------------8<----------------8<---------------8<--------
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 1 (of 23)."
# Contents: vim vim/.exrc vim/doc vim/doc/unix.doc vim/doc/vim132.uue
# vim/execute.me vim/macros vim/macros/center.uue vim/macros/hanoi
# vim/macros/hanoi/click.me vim/macros/hanoi/hanoi.mac.uue
# vim/macros/hanoi/poster vim/macros/maze vim/macros/maze/README
# vim/macros/maze/makefile vim/macros/maze/maze.c
# vim/macros/maze/maze_5.78 vim/macros/maze/maze_ansi.c
# vim/macros/maze/poster vim/macros/readme vim/src vim/src/addcr.c
# vim/src/ascii.h vim/src/debug.h vim/src/keymap.h vim/src/macros.h
# vim/src/mark.h vim/src/proto vim/src/proto.h
# vim/src/proto/alloc.pro vim/src/proto/amiga.pro
# vim/src/proto/buffers.pro vim/src/proto/charset.pro
# vim/src/proto/cmdline.pro vim/src/proto/csearch.pro
# vim/src/proto/digraph.pro vim/src/proto/edit.pro
# vim/src/proto/fileio.pro vim/src/proto/help.pro
# vim/src/proto/linefunc.pro vim/src/proto/main.pro
# vim/src/proto/mark.pro vim/src/proto/message.pro
# vim/src/proto/misccmds.pro vim/src/proto/normal.pro
# vim/src/proto/ops.pro vim/src/proto/param.pro
# vim/src/proto/quickfix.pro vim/src/proto/regexp.pro
# vim/src/proto/regsub.pro vim/src/proto/screen.pro
# vim/src/proto/script.pro vim/src/proto/search.pro
# vim/src/proto/storage.pro vim/src/proto/tag.pro
# vim/src/proto/term.pro vim/src/proto/termlib.pro
# vim/src/proto/undo.pro vim/src/ptx_stdlib.h vim/src/regexp.h
# vim/src/regmagic.h vim/src/termlib.fix.uue vim/src/vim.prj
# vim/src/vimresp vim/todo vim/tutor vim/tutor/Readme
# vim/tutor/poster
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:03 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d 'vim' ; then
echo shar: Creating directory \"'vim'\"
mkdir 'vim'
fi
if test -f 'vim/.exrc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/.exrc'\"
else
echo shar: Extracting \"'vim/.exrc'\" \(35 characters\)
sed "s/^X//" >'vim/.exrc' <<'END_OF_FILE'
Xset ai bs=2 shell=csh nojs nord ru
END_OF_FILE
if test 35 -ne `wc -c <'vim/.exrc'`; then
echo shar: \"'vim/.exrc'\" unpacked with wrong size!
fi
# end of 'vim/.exrc'
fi
if test ! -d 'vim/doc' ; then
echo shar: Creating directory \"'vim/doc'\"
mkdir 'vim/doc'
fi
if test -f 'vim/doc/unix.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/unix.doc'\"
else
echo shar: Extracting \"'vim/doc/unix.doc'\" \(1300 characters\)
sed "s/^X//" >'vim/doc/unix.doc' <<'END_OF_FILE'
XThis file contains the particularities for the UNIX version of Vim.
X
XThe default help filename is "/usr/local/doc/vim.hlp"
XThe files "$HOME/.vimrc" and "$HOME/.exrc" are used instead of "s:.vimrc" and
X"s:.exrc". Additionally "/usr/etc/.vimrc" is used first.
X
XTemporary files (for filtering) are put in "/tmp".
X
XIn some rare cases the terminal may have a problem with CTRL-Q or CTRL-S. To
Xget around this you can map another key to CTRL-Q and CTRL-S, and remap
XCTRL-Q and CTRL-S to nothing. You could use CTRL-W and CTRL-X:
X :noremap! ^W ^V017
X :noremap! ^X ^V019
X :noremap! ^V017 ^V^V
X :noremap! ^V019 ^V^V
X :noremap ^W ^V017
X :noremap ^X ^V019
X :noremap ^V017 ^V^V
X :noremap ^V019 ^V^V
X(^V is the single character CTRL-V. Do not use the '^' character. You have to
Xtype CTRL-V twice to get one. What is shown above is what you have to type,
Xit will look different on the screen or in the .exrc file.)
X
XWith wildcard expansion you can use <~> (home directory) and <$>
X(environment variable).
X
XIf terminal updating is slow, try resetting the 'showcommand' and the
X'ruler' option (e.g. in a shell window in suntools).
X
XThe file Vim132 is a shell script that can be used to put Vim in 132 column
Xmode on a vt100 and lookalikes.
X
XThe *.info files are for the Amiga. You don't need them with unix.
END_OF_FILE
if test 1300 -ne `wc -c <'vim/doc/unix.doc'`; then
echo shar: \"'vim/doc/unix.doc'\" unpacked with wrong size!
fi
# end of 'vim/doc/unix.doc'
fi
if test -f 'vim/doc/vim132.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/vim132.uue'\"
else
echo shar: Extracting \"'vim/doc/vim132.uue'\" \(372 characters\)
sed "s/^X//" >'vim/doc/vim132.uue' <<'END_OF_FILE'
X
Xbegin 644 vim132
XM(R$@+V)I;B]C<V@*(R!3:&5L;"!S8W)I<'0@9F]R('5S92!W:71H(%5.25@*1
XM(R!3=&%R=',@=7`@5FEM('=I=&@@=&AE('1E<FUI;F%L(&EN(#$S,B!C;VQU.
XM;6X@;6]D90HC($]N;'D@=V]R:W,@;VX@5E0M,3`P('1E<FUI;F%L<R!A;F0@,
XM;&]O:V%L:6ME<PHC"G-E="!O;&1T97)M/21T97)M"F5C:&\@(AM;/S-H(@IS[
XM971E;G8@5$5232!V=#$P,"UW(`IV:6T@)"H*<V5T('1E<FT])&]L9'1E<FT*M
X-96-H;R`B&UL_,VPB"C$P"
X``
Xend
Xsize 238
END_OF_FILE
if test 372 -ne `wc -c <'vim/doc/vim132.uue'`; then
echo shar: \"'vim/doc/vim132.uue'\" unpacked with wrong size!
fi
# end of 'vim/doc/vim132.uue'
fi
if test -f 'vim/execute.me' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/execute.me'\"
else
echo shar: Extracting \"'vim/execute.me'\" \(599 characters\)
sed "s/^X//" >'vim/execute.me' <<'END_OF_FILE'
X#execute this script while standing in the 'vim' directory
Xcd macros
Xuudecode center.uue
Xrm center.uue
Xcd maze
Xuudecode maze.mac.uue
Xrm maze.mac.uue
Xcd ../hanoi
Xuudecode hanoi.mac.uue
Xrm hanoi.mac.uue
Xcd ../../src
Xuudecode digraph.c.uue
Xuudecode tcconfig.tc.uue
Xuudecode termlib.fix.uue
Xrm digraph.c.uue tcconfig.tc.uue termlib.fix.uue
Xcd ../doc
Xuudecode vim.hlp.uue
Xuudecode digraph.doc.uue
Xuudecode vim.man.uue
Xuudecode vim132.uue
Xrm vim.hlp.uue digraph.doc.uue vim.man.uue vim132.uue
Xcat reference.doc1 reference.doc2 reference.doc3 >reference.doc
Xrm reference.doc1 reference.doc2 reference.doc3
END_OF_FILE
if test 599 -ne `wc -c <'vim/execute.me'`; then
echo shar: \"'vim/execute.me'\" unpacked with wrong size!
fi
chmod +x 'vim/execute.me'
# end of 'vim/execute.me'
fi
if test ! -d 'vim/macros' ; then
echo shar: Creating directory \"'vim/macros'\"
mkdir 'vim/macros'
fi
if test -f 'vim/macros/center.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/center.uue'\"
else
echo shar: Extracting \"'vim/macros/center.uue'\" \(274 characters\)
sed "s/^X//" >'vim/macros/center.uue' <<'END_OF_FILE'
X
Xbegin 644 center
XM(E1H:7,@;6%C<F\@8V5N=&5R<R!A(&QI;F4@:6X@86X@.#`@8VAA<F%C=&5R$
XM('-P86-E+@HB0V%R969U;#H@;&EN97,@;&]N9V5R('1H86X@.#`@8VAA<F%CY
XM=&5R<R!W:6QL(&)E('1R=6YC871E9`IM87`@.V-E(#IS+UY;(`E=*B\O#21MS
XB83@Q82`;.#$6?$1@86QL9#`Z<R\@("\@+V<-)'`-:R1X"EY;+
X``
Xend
Xsize 169
END_OF_FILE
if test 274 -ne `wc -c <'vim/macros/center.uue'`; then
echo shar: \"'vim/macros/center.uue'\" unpacked with wrong size!
fi
# end of 'vim/macros/center.uue'
fi
if test ! -d 'vim/macros/hanoi' ; then
echo shar: Creating directory \"'vim/macros/hanoi'\"
mkdir 'vim/macros/hanoi'
fi
if test -f 'vim/macros/hanoi/click.me' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/hanoi/click.me'\"
else
echo shar: Extracting \"'vim/macros/hanoi/click.me'\" \(255 characters\)
sed "s/^X//" >'vim/macros/hanoi/click.me' <<'END_OF_FILE'
X
X
XSee Vim solve the towers of Hanoi!
X
XInstructions:
X type ":so hanoi.mac<RETURN>" to load the macros
X type "g" to start it
X
Xand watch it go.
X
X to quit type ":q!<RETURN>"
Xto interrupt type CTRL-C
X
X(This text will disappear as soon as you type "g")
END_OF_FILE
if test 255 -ne `wc -c <'vim/macros/hanoi/click.me'`; then
echo shar: \"'vim/macros/hanoi/click.me'\" unpacked with wrong size!
fi
# end of 'vim/macros/hanoi/click.me'
fi
if test -f 'vim/macros/hanoi/hanoi.mac.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/hanoi/hanoi.mac.uue'\"
else
echo shar: Extracting \"'vim/macros/hanoi/hanoi.mac.uue'\" \(1577 characters\)
sed "s/^X//" >'vim/macros/hanoi/hanoi.mac.uue' <<'END_OF_FILE'
X
Xbegin 644 hanoi.mac
XM<V5T(')E;6%P"G-E="!N;W1E<G-E"G-E="!W<F%P<V-A;@HB('1O('-E="!T[
XM:&4@:&5I9VAT(&]F('1H92!T;W=E<BP@8VAA;F=E('1H92!D:6=I="!I;B!T<
XM:&4@9F]L;&]W:6YG"B(@='=O(&QI;F5S('1O('1H92!H96EG:'0@>6]U('=A1
XM;G0@*'-E;&5C="!F<F]M(#$@=&\@.2D*;6%P('0@-PIM87`A('0@-PIM87`@#
XM3"`Q1R]T#5@O7C`-)%`Q1THD06XD0D=#,&4D6#!%,$8D6"]4#4!F#4!H#21!$
XM,4=*0&8P;"18;B1050IM87`@9R!)3`H*;6%P($H@+UXP6UYT72HD#0IM87`@A
XM6"!X"FUA<"!0('`*;6%P(%4@3`IM87`@02`B9GEL"FUA<"!"(")H>6P*;6%P8
XM($,@(F9P"FUA<"!E(")F>3)L"FUA<"!%(")H<`IM87`@1B`B:'DR;`H*(B!I\
XM;FET:6%L:7-A=&EO;G,Z"B(@2TT)8VQE86YU<"!B=69F97(*(B!9"6-R96%T1
XM92!T;W=E<B!O9B!D97-I<F5D(&AE:6=H=`HB($Y/40EC;W!Y(&ET(&%N9"!I;
XM;G-T97(@82!4"B(@3D\)8V]P>2!T:&ES(&]N90HB(%,)8VAA;F=E(&QA<W0@*
XM8VAA<B!I;G1O(&$@)`HB(%()8VAA;F=E(&QA<W0@8VAA<B!I;B!P<F5V:6]U]
XM<R!L:6YE(&EN=&\@82!N"B(@5`EI;G-E<G0@='=O(&QI;F5S(&-O;G1A:6YI,
XM;F<@82!Z97)O"B(@5@EA9&0@82!L87-T(&QI;F4@8V]N=&%I;FEN9R!A(&)A5
XM8VMS;&%S:`IM87`@22!+35E.3U%.3U-K4E16"@HB8W)E871E(&5M<'1Y(&QI>
XM;F4*;6%P($L@,4=O&PH*(F1E;&5T92!T;R!E;F0@;V8@9FEL90IM87`@32!D9
XM1PH*(GEA;FL@;VYE(&QI;F4*;6%P($X@>7D*"B)P=70*;6%P($\@<`H*(F1EW
XM;&5T92!M;W)E('1H86X@:&5I9VAT+6]F+71O=V5R(&-H87)A8W1E<G,*;6%P)
XM('$@=&QL1`H*(F-R96%T92!A('1O=V5R(&]F(&1E<VER960@:&5I9VAT"FUAC
XM<"!9(&\P,3(S-#4V-S@Y6ALP<0H*(FEN<V5R="!A(%0@:6X@8V]L=6UN(#$*;
XM;6%P(%$@,&E4&PH*(G-U8G-T:71U=&4@;&%S="!C:&%R86-T97(@=VET:"!AG
XM(&X*;6%P(%(@)')N"@HB<W5B<W1I='5T92!L87-T(&-H87)A8W1E<B!W:71H[
XM(&$@)`IM87`@4R`D<B0*"B)I;G-E<G0@='=O(&QI;F5S(&-O;G1A:6YI;F<@$
XM82!Z97)O"FUA<"!4(&MO,`TP#0T;"@HB861D(&$@8F%C:W-L87-H(&%T('1HV
X192!E;F0*;6%P(%8@1V\O&PHP4
X``
Xend
Xsize 1097
END_OF_FILE
if test 1577 -ne `wc -c <'vim/macros/hanoi/hanoi.mac.uue'`; then
echo shar: \"'vim/macros/hanoi/hanoi.mac.uue'\" unpacked with wrong size!
fi
# end of 'vim/macros/hanoi/hanoi.mac.uue'
fi
if test -f 'vim/macros/hanoi/poster' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/hanoi/poster'\"
else
echo shar: Extracting \"'vim/macros/hanoi/poster'\" \(1259 characters\)
sed "s/^X//" >'vim/macros/hanoi/poster' <<'END_OF_FILE'
XArticle 2913 of alt.sources:
XPath: oce-rd1!hp4nl!mcsun!uunet!munnari.oz.au!metro!cluster!swift!softway!otc!gregm
XFrom: gr...@otc.otca.oz.au (Greg McFarlane)
XNewsgroups: comp.sources.d,alt.sources,comp.editors
XSubject: VI SOLVES HANOI
XMessage-ID: <23...@otc.otca.oz>
XDate: 19 Feb 91 01:32:14 GMT
XSender: ne...@otc.otca.oz
XReply-To: gr...@otc.otca.oz.au (Greg McFarlane)
XOrganization: OTC Development Unit, Australia
XLines: 80
XXref: oce-rd1 comp.sources.d:5702 alt.sources:2913 comp.editors:2313
X
XSubmitted-by: gr...@otc.otca.oz.au
XArchive-name: hanoi.vi.macros/part01
X
XEveryone seems to be writing stupid Tower of Hanoi programs.
XWell, here is the stupidest of them all: the hanoi solving vi macros.
X
XSave this article, unshar it, and run uudecode on hanoi.vi.macros.uu.
XThis will give you the macro file hanoi.vi.macros.
XThen run vi (with no file: just type "vi") and type:
X :so hanoi.vi.macros
X g
Xand watch it go.
X
XThe default height of the tower is 7 but can be easily changed by editing
Xthe macro file.
X
XThe disks aren't actually shown in this version, only numbers representing
Xeach disk, but I believe it is possible to write some macros to show the
Xdisks moving about as well. Any takers?
X
X(For maze solving macros, see alt.sources or comp.editors)
X
XGreg
END_OF_FILE
if test 1259 -ne `wc -c <'vim/macros/hanoi/poster'`; then
echo shar: \"'vim/macros/hanoi/poster'\" unpacked with wrong size!
fi
# end of 'vim/macros/hanoi/poster'
fi
if test ! -d 'vim/macros/maze' ; then
echo shar: Creating directory \"'vim/macros/maze'\"
mkdir 'vim/macros/maze'
fi
if test -f 'vim/macros/maze/README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/maze/README'\"
else
echo shar: Extracting \"'vim/macros/maze/README'\" \(1666 characters\)
sed "s/^X//" >'vim/macros/maze/README' <<'END_OF_FILE'
XTo prove that you can do anything in vi, I wrote a couple of macros that
Xallows vi to solve mazes. It will solve any maze produced by maze.c
Xthat was posted to the net recently.
X
XJust follow this recipe and SEE FOR YOURSELF.
X 1. run uudecode on the file "maze.vi.macros.uu" to
X produce the file "maze.vi.macros"
X (If you can't wait to see the action, jump to step 4)
X 2. compile maze.c with "cc -o maze maze.c"
X 3. run maze > maze.out and input a small number (for example 10 if
X you are on a fast machine, 3-5 if slow) which
X is the size of the maze to produce
X 4. edit the maze (vi maze.out)
X 5. include the macros with the vi command:
X :so maze.vi.macros
X 6. type the letter "g" (for "go") and watch vi solve the maze
X 7. when vi solves the maze, you will see why it lies
X 8. now look at maze.vi.macros and all will be revealed
X
XTested on a sparc, a sun and a pyramid (although maze.c will not compile
Xon the pyramid).
X
XAnyone who can't get the maze.c file to compile, get a new compiler,
Xtry maze.ansi.c which was also posted to the net.
XIf you can get it to compile but the maze comes out looking like a fence
Xand not a maze and you are using SysV or DOS replace the "27" on the
Xlast line of maze.c by "11"
XThanks to John Tromp (tr...@piring.cwi.nl) for maze.c.
XThanks to ant...@nntp-server.caltech.edu (Bill T. Cat) for maze.ansi.c.
X
XAny donations should be in unmarked small denomination bills :^)=.
X
X ACSnet: gr...@otc.otca.oz.au
XGreg McFarlane UUCP: {uunet,mcvax}!otc.otca.oz.au!gregm
X|||| OTC || Snail: OTC R&D GPO Box 7000, Sydney 2001, Australia
X Phone: +61 2 287 3139 Fax: +61 2 287 3299
X
X
END_OF_FILE
if test 1666 -ne `wc -c <'vim/macros/maze/README'`; then
echo shar: \"'vim/macros/maze/README'\" unpacked with wrong size!
fi
# end of 'vim/macros/maze/README'
fi
if test -f 'vim/macros/maze/makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/maze/makefile'\"
else
echo shar: Extracting \"'vim/macros/maze/makefile'\" \(104 characters\)
sed "s/^X//" >'vim/macros/maze/makefile' <<'END_OF_FILE'
X#On the amiga with manx C 5.0 we have to use maze.ansi.c
X
Xmaze: maze.ansi.o
X ln maze.ansi.o -o maze -lc
END_OF_FILE
if test 104 -ne `wc -c <'vim/macros/maze/makefile'`; then
echo shar: \"'vim/macros/maze/makefile'\" unpacked with wrong size!
fi
# end of 'vim/macros/maze/makefile'
fi
if test -f 'vim/macros/maze/maze.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/maze/maze.c'\"
else
echo shar: Extracting \"'vim/macros/maze/maze.c'\" \(441 characters\)
sed "s/^X//" >'vim/macros/maze/maze.c' <<'END_OF_FILE'
Xchar*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C);
X-- E; J[ E] =T
X[E ]= E) printf("._"); for(;(A-=Z=!Z) || (printf("\n|"
X) , A = 39 ,C --
X) ; Z || printf (M ))M[Z]=Z[A-(E =A[J-Z])&&!C
X& A == T[ A]
X|6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];}
END_OF_FILE
if test 441 -ne `wc -c <'vim/macros/maze/maze.c'`; then
echo shar: \"'vim/macros/maze/maze.c'\" unpacked with wrong size!
fi
# end of 'vim/macros/maze/maze.c'
fi
if test -f 'vim/macros/maze/maze_5.78' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/maze/maze_5.78'\"
else
echo shar: Extracting \"'vim/macros/maze/maze_5.78'\" \(758 characters\)
sed "s/^X//" >'vim/macros/maze/maze_5.78' <<'END_OF_FILE'
X._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
X| ._| . . ._| | |_._._. . ._|_._._._._. ._|_. ._|_._. ._| . ._|_. | . ._._. |
X| ._|_| |_. | | | | ._._|_._|_._. . |_. | | | ._._| |_._._| | ._. ._| . . |_|
X|_._._._. | ._|_. ._._._. | | ._. |_._. . | ._._| |_. | ._._._. |_. | |_|_| |
X| | . |_._| . ._._._| ._._. ._._| | | |_| . | |_. . ._|_| ._._. |_._|_| . | |
X|_._|_._._._|_._._._|_|_._._._|_._|_._._._|_._._._|_._._._|_._._._._._._|_._|
X
XSee Vim solve a maze!
X
X type ":so maze<DOT>mac<RETURN>" to load the macros
X (replace <DOT> by a real dot; can't type it here because the
X macros use the last dot in the file as the goal in the maze)
X type "g" to start
X
Xto interrupt type "<CTRL-C>"
X to quit type ":q!<RETURN>"
X
END_OF_FILE
if test 758 -ne `wc -c <'vim/macros/maze/maze_5.78'`; then
echo shar: \"'vim/macros/maze/maze_5.78'\" unpacked with wrong size!
fi
# end of 'vim/macros/maze/maze_5.78'
fi
if test -f 'vim/macros/maze/maze_ansi.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/maze/maze_ansi.c'\"
else
echo shar: Extracting \"'vim/macros/maze/maze_ansi.c'\" \(441 characters\)
sed "s/^X//" >'vim/macros/maze/maze_ansi.c' <<'END_OF_FILE'
Xchar*M,A,Z,E=40,J[80],T[3];main(C){for(M=J+E,*J=A=scanf("%d",&
XC) ;-- E;J [E ]=M
X[E ]= E) printf("._"); for(;(A-=Z=!Z) || (printf("\n|"
X) , A = 39 ,C --
X) ; Z || printf (T ))T[Z]=Z[A-(E =A[J-Z])&&!C
X& A == M[ A]
X|6<<11<rand()||!C&!Z?J[M[E]=M[A]]=E,J[M[A]=A-Z]=A,"_.":" |"];}
END_OF_FILE
if test 441 -ne `wc -c <'vim/macros/maze/maze_ansi.c'`; then
echo shar: \"'vim/macros/maze/maze_ansi.c'\" unpacked with wrong size!
fi
# end of 'vim/macros/maze/maze_ansi.c'
fi
if test -f 'vim/macros/maze/poster' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/maze/poster'\"
else
echo shar: Extracting \"'vim/macros/maze/poster'\" \(1562 characters\)
sed "s/^X//" >'vim/macros/maze/poster' <<'END_OF_FILE'
XArticle 2846 of alt.sources:
XPath: oce-rd1!hp4nl!mcsun!uunet!munnari.oz.au!metro!otc!gregm
XFrom: gr...@otc.otca.oz.au (Greg McFarlane)
XNewsgroups: alt.sources
XSubject: VI SOLVES MAZE (commented macros)
XMessage-ID: <22...@otc.otca.oz>
XDate: 10 Feb 91 23:31:02 GMT
XSender: ne...@otc.otca.oz
XReply-To: gr...@otc.otca.oz.au (Greg McFarlane)
XOrganization: OTC Development Unit, Australia
XLines: 464
X
XSubmitted-by: gr...@otc.otca.oz.au
XArchive-name: maze_solving_vi_macros
X
XA real working model. See it walk the maze in front of your very own eyes.
X
XTo prove that you can do anything in vi, I wrote a couple of macros that
Xallows vi to solve mazes. It will solve any maze produced by maze.c
Xthat was posted to the alt.sources last month. (Maze.c is also included
Xin this posting as well as an example of its output.)
X
XThe uncommented version of the macros was sent to alt.sources last month.
XHowever, so many people mailed me requesting the commented version of the
Xmacros that I decided to post it. I have made some modifications to the
Xoriginal macros to make them easier to follow and also after I learnt
Xthat you can escape the special meaning of '|' in macros by using '^V|'.
X
XSave this article and unshar it. Then read maze.README.
X
XAfter studying these macros, anyone who cannot write an emacs emulator
Xin vi macros should just curl up and :q!.
X
XComing soon to a newsgroup near you: "Vi macros solve Tower of Hanoi",
Xand a repost of the original "Turing Machine implemented in Vi macros"
X
XAnyone who has a version of these macros for edlin or nroff, please post.
END_OF_FILE
if test 1562 -ne `wc -c <'vim/macros/maze/poster'`; then
echo shar: \"'vim/macros/maze/poster'\" unpacked with wrong size!
fi
# end of 'vim/macros/maze/poster'
fi
if test -f 'vim/macros/readme' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/readme'\"
else
echo shar: Extracting \"'vim/macros/readme'\" \(271 characters\)
sed "s/^X//" >'vim/macros/readme' <<'END_OF_FILE'
XThe macros in these directories can be used to test Vim for vi compatibility.
XThey have been written for vi to show its unlimited possibilities.
X
XHANOI are macros that solve the tower of hanoi problem.
XMAZE are macros that solve a maze (amazing!).
X
XThey are unmodified.
END_OF_FILE
if test 271 -ne `wc -c <'vim/macros/readme'`; then
echo shar: \"'vim/macros/readme'\" unpacked with wrong size!
fi
# end of 'vim/macros/readme'
fi
if test ! -d 'vim/src' ; then
echo shar: Creating directory \"'vim/src'\"
mkdir 'vim/src'
fi
if test -f 'vim/src/addcr.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/addcr.c'\"
else
echo shar: Extracting \"'vim/src/addcr.c'\" \(413 characters\)
sed "s/^X//" >'vim/src/addcr.c' <<'END_OF_FILE'
X/*
X * This program, when compiled with Turbo-C, will make <LF> into <CR><LF>
X */
X
X#include <stdio.h>
X
Xmain(argc, argv)
X int argc;
X char **argv;
X{
X char buffer[1024];
X int len;
X
X while ((len = fread(buffer, 1, 1024, stdin)) > 0)
X fwrite(buffer, 1, len, stdout);
X if (ferror(stdin))
X fprintf(stderr, "Error while reading\n");
X if (ferror(stdout))
X fprintf(stderr, "Error while writing\n");
X}
END_OF_FILE
if test 413 -ne `wc -c <'vim/src/addcr.c'`; then
echo shar: \"'vim/src/addcr.c'\" unpacked with wrong size!
fi
# end of 'vim/src/addcr.c'
fi
if test -f 'vim/src/ascii.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/ascii.h'\"
else
echo shar: Extracting \"'vim/src/ascii.h'\" \(766 characters\)
sed "s/^X//" >'vim/src/ascii.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*
X * Definitions of various common control characters
X */
X
X#define NUL '\000'
X#define BS '\010'
X#define BS_STR "\010"
X#define TAB '\011'
X#define NL '\012'
X#define NL_STR "\012"
X#define CR '\015'
X#define ESC '\033'
X#define ESC_STR "\033"
X#define DEL 0x7f
X#define CSI 0x9b
X
X#define Ctrl(x) ((x) & 0x1f)
X
X/*
X * character that separates dir names in a path
X */
X#ifdef MSDOS
X# define PATHSEP '\\'
X# define PATHSEPSTR "\\"
X#else
X# define PATHSEP '/'
X# define PATHSEPSTR "/"
X#endif
END_OF_FILE
if test 766 -ne `wc -c <'vim/src/ascii.h'`; then
echo shar: \"'vim/src/ascii.h'\" unpacked with wrong size!
fi
# end of 'vim/src/ascii.h'
fi
if test -f 'vim/src/debug.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/debug.h'\"
else
echo shar: Extracting \"'vim/src/debug.h'\" \(865 characters\)
sed "s/^X//" >'vim/src/debug.h' <<'END_OF_FILE'
X/*
X * debug.h -- my debug header for just any program.
X * use:
X * place the statement OPENDEBUG("/tmp/programdebug"); inside main.
X * Nothing will happen, unless you compile the source with -DDEBUG.
X *
X * jw. 13.4.91.
X */
X#ifndef FILE
X# include <stdio.h>
X#endif
X
X#ifdef DEBUG
X# define debug(x) {fprintf(debugfp,x);fflush(debugfp);}
X# define debug1(x,a) {fprintf(debugfp,x,a);fflush(debugfp);}
X# define debug2(x,a,b) {fprintf(debugfp,x,a,b);fflush(debugfp);}
X# define debug3(x,a,b,c) {fprintf(debugfp,x,a,b,c);fflush(debugfp);}
X# define OPENDEBUG(file)\
X if ((debugfp = fopen(file,"w")) == NULL)\
X { debugfp = stderr;\
X debug1("OPENDEBUG: sorry, cannot open '%s'\n", file);\
X debug(" beware, using stderr!\n");\
X sleep(3);\
X }
X#else
X# define debug(x)
X# define debug1(x,a)
X# define debug2(x,a,b)
X# define debug3(x,a,b,c)
X# define OPENDEBUG(file)
X#endif
END_OF_FILE
if test 865 -ne `wc -c <'vim/src/debug.h'`; then
echo shar: \"'vim/src/debug.h'\" unpacked with wrong size!
fi
# end of 'vim/src/debug.h'
fi
if test -f 'vim/src/keymap.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/keymap.h'\"
else
echo shar: Extracting \"'vim/src/keymap.h'\" \(1576 characters\)
sed "s/^X//" >'vim/src/keymap.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*
X * Keycode definitions for special keys
X *
X * On systems that have any of these keys, the routine 'inchar' in the
X * machine-dependent code should return one of the codes here.
X */
X
X#define K_CCIRCM 0x1e /* control circumflex */
X
X/*
X * careful: the next entries must be in the same order as the termcap strings
X * in term.h and the numbers must be consecutive (used by inchar()).
X */
X#define K_UARROW 0x80
X#define K_DARROW 0x81
X#define K_LARROW 0x82
X#define K_RARROW 0x83
X#define K_SUARROW 0x84
X#define K_SDARROW 0x85
X#define K_SLARROW 0x86
X#define K_SRARROW 0x87
X
X#define K_F1 0x88 /* function keys */
X#define K_F2 0x89
X#define K_F3 0x8a
X#define K_F4 0x8b
X#define K_F5 0x8c
X#define K_F6 0x8d
X#define K_F7 0x8e
X#define K_F8 0x8f
X#define K_F9 0x90
X#define K_F10 0x91
X
X#define K_SF1 0x92 /* shifted function keys */
X#define K_SF2 0x93
X#define K_SF3 0x94
X#define K_SF4 0x95
X#define K_SF5 0x96
X#define K_SF6 0x97
X#define K_SF7 0x98
X#define K_SF8 0x99
X#define K_SF9 0x9a
X#define K_SF10 0x9b
X
X#define K_HELP 0x9c
X#define K_UNDO 0x9d
X
X/*
X * NULs cannot be in the input string, therefore CTRL-@ is replaced by K_ZERO.
X * K_NUL is used for MSDOS extended keys (same value used in term.h).
X */
X#define K_NUL 0x9e /* for MSDOS: special key follows */
X#define K_ZERO 0x9f /* replaces ^@ */
END_OF_FILE
if test 1576 -ne `wc -c <'vim/src/keymap.h'`; then
echo shar: \"'vim/src/keymap.h'\" unpacked with wrong size!
fi
# end of 'vim/src/keymap.h'
fi
if test -f 'vim/src/macros.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/macros.h'\"
else
echo shar: Extracting \"'vim/src/macros.h'\" \(1055 characters\)
sed "s/^X//" >'vim/src/macros.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*
X * macros.h: macro definitions for often used code
X */
X
X/*
X * pchar(lp, c) - put character 'c' at position 'lp'
X */
X#define pchar(lp, c) (*(nr2ptr((lp).lnum) + (lp).col) = (c))
X
X/*
X * Position comparisons
X */
X#define lt(a, b) (((a).lnum != (b).lnum) \
X ? ((a).lnum < (b).lnum) : ((a).col < (b).col))
X
X#define ltoreq(a, b) (((a).lnum != (b).lnum) \
X ? ((a).lnum < (b).lnum) : ((a).col <= (b).col))
X
X#define equal(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col))
X
X/*
X * buf1line() - return TRUE if there is only one line in file buffer
X */
X#define buf1line() (line_count == 1)
X
X/*
X * lineempty() - return TRUE if the line is empty
X */
X#define lineempty(p) (*nr2ptr(p) == NUL)
X
X/*
X * bufempty() - return TRUE if the file buffer is empty
X */
X#define bufempty() (buf1line() && lineempty((linenr_t)1))
END_OF_FILE
if test 1055 -ne `wc -c <'vim/src/macros.h'`; then
echo shar: \"'vim/src/macros.h'\" unpacked with wrong size!
fi
# end of 'vim/src/macros.h'
fi
if test -f 'vim/src/mark.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/mark.h'\"
else
echo shar: Extracting \"'vim/src/mark.h'\" \(546 characters\)
sed "s/^X//" >'vim/src/mark.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*
X * mark.h: definitions shared between tag.c and mark.c
X */
X
Xstruct mark
X{
X char *ptr;
X colnr_t col;
X};
X
Xstruct filemark
X{
X struct mark mark; /* cursor position */
X linenr_t lnum; /* last known line number */
X int fnum; /* file number */
X};
X
Xchar *fm_getname __ARGS((struct filemark *));
END_OF_FILE
if test 546 -ne `wc -c <'vim/src/mark.h'`; then
echo shar: \"'vim/src/mark.h'\" unpacked with wrong size!
fi
# end of 'vim/src/mark.h'
fi
if test ! -d 'vim/src/proto' ; then
echo shar: Creating directory \"'vim/src/proto'\"
mkdir 'vim/src/proto'
fi
if test -f 'vim/src/proto.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto.h'\"
else
echo shar: Extracting \"'vim/src/proto.h'\" \(1269 characters\)
sed "s/^X//" >'vim/src/proto.h' <<'END_OF_FILE'
X/*
X * proto.h: include the (automatically generated) function prototypes
X *
X * the proto/xxx.pro files are automatically generated when using Manx/Aztec C.
X * For other compilers you will have to edit them.
X */
X
X#include "regexp.h" /* for struct regexp */
X
X/*
X * Machine-dependent routines.
X */
X#ifdef AMIGA
X# include "proto/amiga.pro"
X#endif
X#ifdef UNIX
X# include "unix.h"
X#endif
X#ifdef MSDOS
X# include "msdos.h"
X#endif
X
X#include "proto/alloc.pro"
X#include "proto/buffers.pro"
X#include "proto/charset.pro"
X#include "proto/cmdline.pro"
X#include "proto/csearch.pro"
X#include "proto/digraph.pro"
X#include "proto/edit.pro"
X#include "proto/fileio.pro"
X#include "proto/help.pro"
X#include "proto/linefunc.pro"
X#include "proto/main.pro"
X#include "proto/mark.pro"
X
X#ifndef MESSAGE
Xvoid smsg __PARMS((char *, ...)); /* cannot be produced automatically */
X#endif
X#include "proto/message.pro"
X#include "proto/misccmds.pro"
X#include "proto/normal.pro"
X#include "proto/ops.pro"
X#include "proto/param.pro"
X#include "proto/quickfix.pro"
X#include "proto/regexp.pro"
X#include "proto/regsub.pro"
X#include "proto/screen.pro"
X#include "proto/script.pro"
X#include "proto/search.pro"
X#include "proto/storage.pro"
X#include "proto/tag.pro"
X#include "proto/term.pro"
X#include "proto/undo.pro"
END_OF_FILE
if test 1269 -ne `wc -c <'vim/src/proto.h'`; then
echo shar: \"'vim/src/proto.h'\" unpacked with wrong size!
fi
# end of 'vim/src/proto.h'
fi
if test -f 'vim/src/proto/alloc.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/alloc.pro'\"
else
echo shar: Extracting \"'vim/src/proto/alloc.pro'\" \(300 characters\)
sed "s/^X//" >'vim/src/proto/alloc.pro' <<'END_OF_FILE'
X/* alloc.c */
Xchar *alloc __PARMS((unsigned int size));
Xchar *lalloc __PARMS((unsigned long size, int message));
Xchar *strsave __PARMS((char *string));
Xchar *strnsave __PARMS((char *string, int len));
Xvoid copy_spaces __PARMS((char *ptr, unsigned long count));
Xchar *mkstr __PARMS((unsigned int c));
END_OF_FILE
if test 300 -ne `wc -c <'vim/src/proto/alloc.pro'`; then
echo shar: \"'vim/src/proto/alloc.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/alloc.pro'
fi
if test -f 'vim/src/proto/amiga.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/amiga.pro'\"
else
echo shar: Extracting \"'vim/src/proto/amiga.pro'\" \(1222 characters\)
sed "s/^X//" >'vim/src/proto/amiga.pro' <<'END_OF_FILE'
X/* amiga.c */
Xvoid win_resize_on __PARMS((void));
Xvoid win_resize_off __PARMS((void));
Xvoid flushbuf __PARMS((void));
Xvoid outchar __PARMS((unsigned int c));
Xint GetChars __PARMS((char *buf, int maxlen, int type));
Xvoid sleep __PARMS((int n));
Xvoid vim_delay __PARMS((void));
Xvoid mch_suspend __PARMS((void));
Xvoid mch_windinit __PARMS((void));
Xvoid check_win __PARMS((int argc, char **argv));
Xvoid fname_case __PARMS((char *name));
Xvoid settitle __PARMS((char *str));
Xvoid resettitle __PARMS((void));
Xint dirname __PARMS((char *buf, int len));
Xint FullName __PARMS((char *fname, char *buf, int len));
Xlong getperm __PARMS((char *name));
Xint setperm __PARMS((char *name, long perm));
Xint isdir __PARMS((char *name));
Xvoid mch_windexit __PARMS((int r));
Xvoid mch_settmode __PARMS((int raw));
Xint mch_get_winsize __PARMS((void));
Xvoid mch_set_winsize __PARMS((void));
Xint call_shell __PARMS((char *cmd, int filter));
Xvoid breakcheck __PARMS((void));
Xlong Chk_Abort __PARMS((void));
Xint ExpandWildCards __PARMS((int num_pat, char **pat, int *num_file, char ***file, int files_only, int list_notfound));
Xvoid FreeWild __PARMS((int num, char **file));
Xint has_wildcard __PARMS((char *p));
Xchar *vimgetenv __PARMS((char *var));
END_OF_FILE
if test 1222 -ne `wc -c <'vim/src/proto/amiga.pro'`; then
echo shar: \"'vim/src/proto/amiga.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/amiga.pro'
fi
if test -f 'vim/src/proto/buffers.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/buffers.pro'\"
else
echo shar: Extracting \"'vim/src/proto/buffers.pro'\" \(832 characters\)
sed "s/^X//" >'vim/src/proto/buffers.pro' <<'END_OF_FILE'
X/* buffers.c */
Xunsigned char *get_bufcont __PARMS((struct buffheader *buffer));
Xunsigned char *get_recorded __PARMS((void));
Xunsigned char *get_inserted __PARMS((void));
Xint stuff_empty __PARMS((void));
Xvoid flush_buffers __PARMS((void));
Xvoid ResetBuffers __PARMS((void));
Xvoid AppendToRedobuff __PARMS((char *s));
Xvoid AppendNumberToRedobuff __PARMS((long n));
Xvoid stuffReadbuff __PARMS((char *s));
Xvoid stuffnumReadbuff __PARMS((long n));
Xvoid copy_redo __PARMS((void));
Xint start_redo __PARMS((long count));
Xint start_redo_ins __PARMS((void));
Xvoid set_redo_ins __PARMS((void));
Xvoid stop_redo_ins __PARMS((void));
Xint ins_mapbuf __PARMS((char *str));
Xunsigned char vgetc __PARMS((void));
Xunsigned char vpeekc __PARMS((void));
Xint domap __PARMS((int maptype, char *keys, int mode));
Xint makemap __PARMS((struct __stdio *fd));
END_OF_FILE
if test 832 -ne `wc -c <'vim/src/proto/buffers.pro'`; then
echo shar: \"'vim/src/proto/buffers.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/buffers.pro'
fi
if test -f 'vim/src/proto/charset.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/charset.pro'\"
else
echo shar: Extracting \"'vim/src/proto/charset.pro'\" \(240 characters\)
sed "s/^X//" >'vim/src/proto/charset.pro' <<'END_OF_FILE'
X/* charset.c */
Xchar *transchar __PARMS((unsigned int c));
Xint outtrans __PARMS((char *str, int len));
Xint charsize __PARMS((int c));
Xint strsize __PARMS((char *s));
Xint chartabsize __PARMS((int c, int col));
Xint isidchar __PARMS((int c));
END_OF_FILE
if test 240 -ne `wc -c <'vim/src/proto/charset.pro'`; then
echo shar: \"'vim/src/proto/charset.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/charset.pro'
fi
if test -f 'vim/src/proto/cmdline.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/cmdline.pro'\"
else
echo shar: Extracting \"'vim/src/proto/cmdline.pro'\" \(487 characters\)
sed "s/^X//" >'vim/src/proto/cmdline.pro' <<'END_OF_FILE'
X/* cmdline.c */
Xint getcmdline __PARMS((int firstc, unsigned char *buff));
Xvoid redrawcmdline __PARMS((void));
Xvoid redrawcmd __PARMS((void));
Xvoid docmdline __PARMS((unsigned char *cmdline));
Xint doarglist __PARMS((char *str));
Xvoid gotocmdline __PARMS((int clr, int firstc));
Xint getfile __PARMS((char *fname, int setpm));
Xint samealtfile __PARMS((int n));
Xint getaltfile __PARMS((int n, long lnum, int setpm));
Xchar *getaltfname __PARMS((int n));
Xint dosource __PARMS((char *fname));
END_OF_FILE
if test 487 -ne `wc -c <'vim/src/proto/cmdline.pro'`; then
echo shar: \"'vim/src/proto/cmdline.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/cmdline.pro'
fi
if test -f 'vim/src/proto/csearch.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/csearch.pro'\"
else
echo shar: Extracting \"'vim/src/proto/csearch.pro'\" \(158 characters\)
sed "s/^X//" >'vim/src/proto/csearch.pro' <<'END_OF_FILE'
X/* csearch.c */
Xvoid dosub __PARMS((long lp, long up, char *cmd, unsigned char **nextcommand));
Xvoid doglob __PARMS((int type, long lp, long up, char *cmd));
END_OF_FILE
if test 158 -ne `wc -c <'vim/src/proto/csearch.pro'`; then
echo shar: \"'vim/src/proto/csearch.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/csearch.pro'
fi
if test -f 'vim/src/proto/digraph.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/digraph.pro'\"
else
echo shar: Extracting \"'vim/src/proto/digraph.pro'\" \(137 characters\)
sed "s/^X//" >'vim/src/proto/digraph.pro' <<'END_OF_FILE'
X/* digraph.c */
Xint getdigraph __PARMS((int char1, int char2));
Xvoid putdigraph __PARMS((char *str));
Xvoid listdigraphs __PARMS((void));
END_OF_FILE
if test 137 -ne `wc -c <'vim/src/proto/digraph.pro'`; then
echo shar: \"'vim/src/proto/digraph.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/digraph.pro'
fi
if test -f 'vim/src/proto/edit.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/edit.pro'\"
else
echo shar: Extracting \"'vim/src/proto/edit.pro'\" \(389 characters\)
sed "s/^X//" >'vim/src/proto/edit.pro' <<'END_OF_FILE'
X/* edit.c */
Xvoid edit __PARMS((long count));
Xint get_literal __PARMS((int *nextc));
Xvoid insertchar __PARMS((unsigned int c));
Xint oneright __PARMS((void));
Xint oneleft __PARMS((void));
Xvoid beginline __PARMS((int flag));
Xint oneup __PARMS((long n));
Xint onedown __PARMS((long n));
Xint onepage __PARMS((int dir, long count));
Xvoid stuff_inserted __PARMS((int c, long count, int no_esc));
END_OF_FILE
if test 389 -ne `wc -c <'vim/src/proto/edit.pro'`; then
echo shar: \"'vim/src/proto/edit.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/edit.pro'
fi
if test -f 'vim/src/proto/fileio.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/fileio.pro'\"
else
echo shar: Extracting \"'vim/src/proto/fileio.pro'\" \(205 characters\)
sed "s/^X//" >'vim/src/proto/fileio.pro' <<'END_OF_FILE'
X/* fileio.c */
Xvoid filemess __PARMS((char *name, char *s));
Xint readfile __PARMS((char *fname, long from, int newfile));
Xint writeit __PARMS((char *fname, long start, long end, int append, int forceit));
END_OF_FILE
if test 205 -ne `wc -c <'vim/src/proto/fileio.pro'`; then
echo shar: \"'vim/src/proto/fileio.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/fileio.pro'
fi
if test -f 'vim/src/proto/help.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/help.pro'\"
else
echo shar: Extracting \"'vim/src/proto/help.pro'\" \(72 characters\)
sed "s/^X//" >'vim/src/proto/help.pro' <<'END_OF_FILE'
X/* help.c */
Xvoid help __PARMS((void));
Xint redrawhelp __PARMS((void));
END_OF_FILE
if test 72 -ne `wc -c <'vim/src/proto/help.pro'`; then
echo shar: \"'vim/src/proto/help.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/help.pro'
fi
if test -f 'vim/src/proto/linefunc.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/linefunc.pro'\"
else
echo shar: Extracting \"'vim/src/proto/linefunc.pro'\" \(306 characters\)
sed "s/^X//" >'vim/src/proto/linefunc.pro' <<'END_OF_FILE'
X/* linefunc.c */
Xvoid coladvance __PARMS((unsigned int wcol));
Xint inc __PARMS((struct fpos *lp));
Xint incCurpos __PARMS((void));
Xint incl __PARMS((struct fpos *lp));
Xint dec __PARMS((struct fpos *lp));
Xint decCurpos __PARMS((void));
Xint decl __PARMS((struct fpos *lp));
Xvoid adjustCurpos __PARMS((void));
END_OF_FILE
if test 306 -ne `wc -c <'vim/src/proto/linefunc.pro'`; then
echo shar: \"'vim/src/proto/linefunc.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/linefunc.pro'
fi
if test -f 'vim/src/proto/main.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/main.pro'\"
else
echo shar: Extracting \"'vim/src/proto/main.pro'\" \(87 characters\)
sed "s/^X//" >'vim/src/proto/main.pro' <<'END_OF_FILE'
X/* main.c */
Xvoid main __PARMS((int argc, char **argv));
Xvoid getout __PARMS((int r));
END_OF_FILE
if test 87 -ne `wc -c <'vim/src/proto/main.pro'`; then
echo shar: \"'vim/src/proto/main.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/main.pro'
fi
if test -f 'vim/src/proto/mark.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/mark.pro'\"
else
echo shar: Extracting \"'vim/src/proto/mark.pro'\" \(433 characters\)
sed "s/^X//" >'vim/src/proto/mark.pro' <<'END_OF_FILE'
X/* mark.c */
Xint setmark __PARMS((int c));
Xvoid setpcmark __PARMS((void));
Xstruct fpos *movemark __PARMS((int count));
Xstruct fpos *getmark __PARMS((int c, int changefile));
Xvoid clrallmarks __PARMS((void));
Xvoid incrmarks __PARMS((void));
Xvoid decrmarks __PARMS((void));
Xvoid adjustmark __PARMS((char *old, char *new));
Xchar *fm_getname __PARMS((struct filemark *fmark));
Xvoid domarks __PARMS((void));
Xvoid dojumps __PARMS((void));
END_OF_FILE
if test 433 -ne `wc -c <'vim/src/proto/mark.pro'`; then
echo shar: \"'vim/src/proto/mark.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/mark.pro'
fi
if test -f 'vim/src/proto/message.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/message.pro'\"
else
echo shar: Extracting \"'vim/src/proto/message.pro'\" \(115 characters\)
sed "s/^X//" >'vim/src/proto/message.pro' <<'END_OF_FILE'
X/* message.c */
Xvoid msg __PARMS((char *s));
Xvoid emsg __PARMS((char *s));
Xvoid wait_return __PARMS((int redraw));
END_OF_FILE
if test 115 -ne `wc -c <'vim/src/proto/message.pro'`; then
echo shar: \"'vim/src/proto/message.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/message.pro'
fi
if test -f 'vim/src/proto/misccmds.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/misccmds.pro'\"
else
echo shar: Extracting \"'vim/src/proto/misccmds.pro'\" \(986 characters\)
sed "s/^X//" >'vim/src/proto/misccmds.pro' <<'END_OF_FILE'
X/* misccmds.c */
Xint get_indent __PARMS((void));
Xvoid set_indent __PARMS((int size, int delete));
Xint Opencmd __PARMS((int dir, int redraw));
Xint plines __PARMS((long p));
Xint plines_m __PARMS((long first, long last));
Xvoid fileinfo __PARMS((void));
Xvoid setfname __PARMS((char *s));
Xint otherfile __PARMS((char *s));
Xvoid maketitle __PARMS((void));
Xvoid inschar __PARMS((int c));
Xvoid insstr __PARMS((char *s));
Xint delchar __PARMS((int fixpos));
Xvoid dellines __PARMS((long nlines, int can_update));
Xint gchar __PARMS((struct fpos *pos));
Xint gcharCurpos __PARMS((void));
Xint inindent __PARMS((void));
Xvoid skipspace __PARMS((char **pp));
Xvoid skiptospace __PARMS((char **pp));
Xlong getdigits __PARMS((char **pp));
Xchar *plural __PARMS((long n));
Xvoid set_Changed __PARMS((void));
Xint ask_yesno __PARMS((char *str));
Xvoid msgmore __PARMS((long n));
Xvoid beep __PARMS((void));
Xvoid expand_env __PARMS((char *src, char *dst, int dstlen));
Xint fullpathcmp __PARMS((char *s1, char *s2));
END_OF_FILE
if test 986 -ne `wc -c <'vim/src/proto/misccmds.pro'`; then
echo shar: \"'vim/src/proto/misccmds.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/misccmds.pro'
fi
if test -f 'vim/src/proto/normal.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/normal.pro'\"
else
echo shar: Extracting \"'vim/src/proto/normal.pro'\" \(44 characters\)
sed "s/^X//" >'vim/src/proto/normal.pro' <<'END_OF_FILE'
X/* normal.c */
Xvoid normal __PARMS((void));
END_OF_FILE
if test 44 -ne `wc -c <'vim/src/proto/normal.pro'`; then
echo shar: \"'vim/src/proto/normal.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/normal.pro'
fi
if test -f 'vim/src/proto/ops.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/ops.pro'\"
else
echo shar: Extracting \"'vim/src/proto/ops.pro'\" \(691 characters\)
sed "s/^X//" >'vim/src/proto/ops.pro' <<'END_OF_FILE'
X/* ops.c */
Xvoid doshift __PARMS((int op));
Xvoid shift_line __PARMS((int left));
Xint dorecord __PARMS((int c));
Xint doexecbuf __PARMS((int c));
Xint insertbuf __PARMS((int c));
Xvoid dodelete __PARMS((void));
Xvoid dotilde __PARMS((void));
Xvoid swapchar __PARMS((struct fpos *pos));
Xvoid dochange __PARMS((void));
Xvoid init_yank __PARMS((void));
Xint doyank __PARMS((int deleting));
Xvoid doput __PARMS((int dir, long count));
Xvoid dodis __PARMS((void));
Xvoid dodojoin __PARMS((long count, int flag, int redraw));
Xint dojoin __PARMS((int insert_space));
Xvoid doformat __PARMS((void));
Xvoid startinsert __PARMS((int initstr, int startln, long count));
Xint doaddsub __PARMS((int c, long Prenum1));
END_OF_FILE
if test 691 -ne `wc -c <'vim/src/proto/ops.pro'`; then
echo shar: \"'vim/src/proto/ops.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/ops.pro'
fi
if test -f 'vim/src/proto/param.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/param.pro'\"
else
echo shar: Extracting \"'vim/src/proto/param.pro'\" \(159 characters\)
sed "s/^X//" >'vim/src/proto/param.pro' <<'END_OF_FILE'
X/* param.c */
Xvoid set_init __PARMS((void));
Xvoid doset __PARMS((char *arg));
Xint makeset __PARMS((struct __stdio *fd));
Xvoid clear_termparam __PARMS((void));
END_OF_FILE
if test 159 -ne `wc -c <'vim/src/proto/param.pro'`; then
echo shar: \"'vim/src/proto/param.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/param.pro'
fi
if test -f 'vim/src/proto/quickfix.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/quickfix.pro'\"
else
echo shar: Extracting \"'vim/src/proto/quickfix.pro'\" \(209 characters\)
sed "s/^X//" >'vim/src/proto/quickfix.pro' <<'END_OF_FILE'
X/* quickfix.c */
Xint qf_init __PARMS((char *fname));
Xvoid qf_jump __PARMS((int errornr));
Xvoid qf_list __PARMS((void));
Xvoid qf_clrallmarks __PARMS((void));
Xvoid qf_adjustmark __PARMS((char *old, char *new));
END_OF_FILE
if test 209 -ne `wc -c <'vim/src/proto/quickfix.pro'`; then
echo shar: \"'vim/src/proto/quickfix.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/quickfix.pro'
fi
if test -f 'vim/src/proto/regexp.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/regexp.pro'\"
else
echo shar: Extracting \"'vim/src/proto/regexp.pro'\" \(171 characters\)
sed "s/^X//" >'vim/src/proto/regexp.pro' <<'END_OF_FILE'
X/* regexp.c */
Xstruct regexp *regcomp __PARMS((char *exp));
Xint regexec __PARMS((struct regexp *prog, char *string, int at_bol));
Xchar *cstrchr __PARMS((char *s, int c));
END_OF_FILE
if test 171 -ne `wc -c <'vim/src/proto/regexp.pro'`; then
echo shar: \"'vim/src/proto/regexp.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/regexp.pro'
fi
if test -f 'vim/src/proto/regsub.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/regsub.pro'\"
else
echo shar: Extracting \"'vim/src/proto/regsub.pro'\" \(105 characters\)
sed "s/^X//" >'vim/src/proto/regsub.pro' <<'END_OF_FILE'
X/* regsub.c */
Xint regsub __PARMS((struct regexp *prog, char *source, char *dest, int copy, int magic));
END_OF_FILE
if test 105 -ne `wc -c <'vim/src/proto/regsub.pro'`; then
echo shar: \"'vim/src/proto/regsub.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/regsub.pro'
fi
if test -f 'vim/src/proto/screen.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/screen.pro'\"
else
echo shar: Extracting \"'vim/src/proto/screen.pro'\" \(662 characters\)
sed "s/^X//" >'vim/src/proto/screen.pro' <<'END_OF_FILE'
X/* screen.c */
Xvoid updateline __PARMS((void));
Xvoid updateScreen __PARMS((int type));
Xvoid comp_Botline __PARMS((void));
Xint prt_line __PARMS((char *s));
Xvoid screenalloc __PARMS((void));
Xvoid screenclear __PARMS((void));
Xvoid cursupdate __PARMS((void));
Xvoid curs_columns __PARMS((void));
Xint getvcol __PARMS((struct fpos *pos, int type));
Xvoid scrolldown __PARMS((long nlines));
Xvoid scrollup __PARMS((long nlines));
Xint s_ins __PARMS((int row, int nlines, int invalid));
Xint s_del __PARMS((int row, int nlines, int invalid));
Xvoid showmode __PARMS((void));
Xvoid delmode __PARMS((void));
Xvoid showruler __PARMS((int always));
Xvoid clear_line __PARMS((void));
END_OF_FILE
if test 662 -ne `wc -c <'vim/src/proto/screen.pro'`; then
echo shar: \"'vim/src/proto/screen.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/screen.pro'
fi
if test -f 'vim/src/proto/script.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/script.pro'\"
else
echo shar: Extracting \"'vim/src/proto/script.pro'\" \(315 characters\)
sed "s/^X//" >'vim/src/proto/script.pro' <<'END_OF_FILE'
X/* script.c */
Xvoid startscript __PARMS((void));
Xint stopscript __PARMS((void));
Xint openscript __PARMS((char *name));
Xvoid updatescript __PARMS((int c));
Xvoid openrecover __PARMS((void));
Xchar *modname __PARMS((char *fname, char *ext));
Xvoid script_winsize __PARMS((void));
Xvoid script_winsize_pp __PARMS((void));
END_OF_FILE
if test 315 -ne `wc -c <'vim/src/proto/script.pro'`; then
echo shar: \"'vim/src/proto/script.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/script.pro'
fi
if test -f 'vim/src/proto/search.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/search.pro'\"
else
echo shar: Extracting \"'vim/src/proto/search.pro'\" \(717 characters\)
sed "s/^X//" >'vim/src/proto/search.pro' <<'END_OF_FILE'
X/* search.c */
Xstruct regexp *myregcomp __PARMS((char *pat));
Xint searchit __PARMS((struct fpos *pos, int dir, char *str, long count, int end));
Xint dosearch __PARMS((int dir, char *str, int reverse, long count, int echo));
Xint searchc __PARMS((int c, int dir, int type, long count));
Xstruct fpos *showmatch __PARMS((void));
Xint findfunc __PARMS((int dir, int what, long count));
Xint findsent __PARMS((int dir, long count));
Xint findpar __PARMS((int dir, long count, int what));
Xint startPS __PARMS((long lnum, int para));
Xint fwd_word __PARMS((long count, int type));
Xint bck_word __PARMS((long count, int type));
Xint end_word __PARMS((long count, int type, int stop));
Xint skip_chars __PARMS((int class, int dir));
END_OF_FILE
if test 717 -ne `wc -c <'vim/src/proto/search.pro'`; then
echo shar: \"'vim/src/proto/search.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/search.pro'
fi
if test -f 'vim/src/proto/storage.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/storage.pro'\"
else
echo shar: Extracting \"'vim/src/proto/storage.pro'\" \(705 characters\)
sed "s/^X//" >'vim/src/proto/storage.pro' <<'END_OF_FILE'
X/* storage.c */
Xchar *m_blockalloc __PARMS((unsigned long size, int message));
Xvoid m_blockfree __PARMS((void));
Xvoid free_line __PARMS((char *ptr));
Xchar *alloc_line __PARMS((unsigned int size));
Xchar *save_line __PARMS((char *src));
Xvoid filealloc __PARMS((void));
Xvoid freeall __PARMS((void));
Xchar *nr2ptr __PARMS((long nr));
Xchar *pos2ptr __PARMS((struct fpos *pos));
Xvoid setmarked __PARMS((long lnum));
Xlong firstmarked __PARMS((void));
Xvoid clearmarked __PARMS((void));
Xlong ptr2nr __PARMS((char *ptr, long start));
Xint appendline __PARMS((long after, char *s));
Xchar *delsline __PARMS((long nr, int delmarks));
Xchar *replaceline __PARMS((long lnum, char *new));
Xint canincrease __PARMS((int n));
END_OF_FILE
if test 705 -ne `wc -c <'vim/src/proto/storage.pro'`; then
echo shar: \"'vim/src/proto/storage.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/storage.pro'
fi
if test -f 'vim/src/proto/tag.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/tag.pro'\"
else
echo shar: Extracting \"'vim/src/proto/tag.pro'\" \(187 characters\)
sed "s/^X//" >'vim/src/proto/tag.pro' <<'END_OF_FILE'
X/* tag.c */
Xvoid dotag __PARMS((char *tag, int type, int count));
Xvoid clrtags __PARMS((void));
Xvoid incrtags __PARMS((void));
Xvoid decrtags __PARMS((void));
Xvoid dotags __PARMS((void));
END_OF_FILE
if test 187 -ne `wc -c <'vim/src/proto/tag.pro'`; then
echo shar: \"'vim/src/proto/tag.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/tag.pro'
fi
if test -f 'vim/src/proto/term.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/term.pro'\"
else
echo shar: Extracting \"'vim/src/proto/term.pro'\" \(594 characters\)
sed "s/^X//" >'vim/src/proto/term.pro' <<'END_OF_FILE'
X/* term.c */
Xvoid set_term __PARMS((char *term));
Xchar *tgoto __PARMS((char *cm, int x, int y));
Xvoid termcapinit __PARMS((char *term));
Xvoid outstrn __PARMS((char *s));
Xvoid outstr __PARMS((char *s));
Xvoid windgoto __PARMS((int row, int col));
Xvoid setcursor __PARMS((void));
Xvoid ttest __PARMS((int pairs));
Xint inchar __PARMS((int async, int waitforever));
Xvoid outnum __PARMS((long n));
Xvoid check_winsize __PARMS((void));
Xvoid set_winsize __PARMS((int width, int height, int mustset));
Xvoid settmode __PARMS((int raw));
Xvoid starttermcap __PARMS((void));
Xvoid stoptermcap __PARMS((void));
END_OF_FILE
if test 594 -ne `wc -c <'vim/src/proto/term.pro'`; then
echo shar: \"'vim/src/proto/term.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/term.pro'
fi
if test -f 'vim/src/proto/termlib.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/termlib.pro'\"
else
echo shar: Extracting \"'vim/src/proto/termlib.pro'\" \(300 characters\)
sed "s/^X//" >'vim/src/proto/termlib.pro' <<'END_OF_FILE'
X/* termlib.c */
Xint tgetent __PARMS((char *tbuf, char *term));
Xint tgetflag __PARMS((char *id));
Xint tgetnum __PARMS((char *id));
Xchar *tgetstr __PARMS((char *id, char **buf));
Xchar *tgoto __PARMS((char *cm, int col, int line));
Xint tputs __PARMS((char *cp, int affcnt, void (*outc)(unsigned int)));
END_OF_FILE
if test 300 -ne `wc -c <'vim/src/proto/termlib.pro'`; then
echo shar: \"'vim/src/proto/termlib.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/termlib.pro'
fi
if test -f 'vim/src/proto/undo.pro' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/proto/undo.pro'\"
else
echo shar: Extracting \"'vim/src/proto/undo.pro'\" \(418 characters\)
sed "s/^X//" >'vim/src/proto/undo.pro' <<'END_OF_FILE'
X/* undo.c */
Xint u_saveCurpos __PARMS((void));
Xint u_save __PARMS((long top, long bot));
Xint u_savesub __PARMS((long lnum, char *ptr));
Xint u_savedel __PARMS((long lnum, char *ptr));
Xvoid u_undo __PARMS((int count));
Xvoid u_redo __PARMS((int count));
Xvoid u_sync __PARMS((void));
Xvoid u_clearall __PARMS((void));
Xvoid u_saveline __PARMS((long lnum));
Xvoid u_clearline __PARMS((void));
Xvoid u_undoline __PARMS((void));
END_OF_FILE
if test 418 -ne `wc -c <'vim/src/proto/undo.pro'`; then
echo shar: \"'vim/src/proto/undo.pro'\" unpacked with wrong size!
fi
# end of 'vim/src/proto/undo.pro'
fi
if test -f 'vim/src/ptx_stdlib.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/ptx_stdlib.h'\"
else
echo shar: Extracting \"'vim/src/ptx_stdlib.h'\" \(955 characters\)
sed "s/^X//" >'vim/src/ptx_stdlib.h' <<'END_OF_FILE'
X/*
X * ptx_stdlib.h: declarations which are needed for sequent
X */
X
Xextern void free(void *);
X#ifdef SIZE_T /* sys/types.h */
Xextern void *malloc(size_t);
Xextern off_t lseek(int, off_t, int);
X#else
Xextern void *malloc(unsigned);
Xextern int lseek(int, int, int);
X#endif
X
X#ifndef _FCNTL_H_
Xextern int open(char *, int, ...);
X#endif
Xextern int close(int);
Xextern int read(int, char *, unsigned);
Xextern int write(int, char *, unsigned);
Xextern int ioctl(int, int, ...);
Xextern int unlink(char *);
X
Xextern char *getenv(char *);
Xextern int getuid(void);
Xextern int getgid(void);
X
X#ifdef _NFILE /* stdio.h */
Xextern int _filbuf(FILE *);
Xextern int _flsbuf(unsigned char, FILE *);
X#endif
X
X#ifdef _POLL_H_
Xextern int poll(struct pollfd[], unsigned long, int);
X#endif /* _POLL_H_ */
X
Xextern char *getcwd(char *, int);
X
Xextern int chdir(char *);
X
Xextern int atoi (char *);
Xextern long atol(char *);
Xextern long strtol(char *, char **, int);
X
Xextern int isatty(int);
END_OF_FILE
if test 955 -ne `wc -c <'vim/src/ptx_stdlib.h'`; then
echo shar: \"'vim/src/ptx_stdlib.h'\" unpacked with wrong size!
fi
# end of 'vim/src/ptx_stdlib.h'
fi
if test -f 'vim/src/regexp.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/regexp.h'\"
else
echo shar: Extracting \"'vim/src/regexp.h'\" \(1541 characters\)
sed "s/^X//" >'vim/src/regexp.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *
X * This is NOT the original regular expression code as written by
X * Henry Spencer. This code has been modified specifically for use
X * with the VIM editor, and should not be used apart from compiling
X * VIM. If you want a good regular expression library, get the
X * original code. The copyright notice that follows is from the
X * original.
X *
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *
X * Definitions etc. for regexp(3) routines.
X *
X * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
X * not the System V one.
X */
X
X#ifndef _REGEXP_H
X#define _REGEXP_H
X
X#define NSUBEXP 10
Xtypedef struct regexp {
X char *startp[NSUBEXP];
X char *endp[NSUBEXP];
X char regstart; /* Internal use only. */
X char reganch; /* Internal use only. */
X char *regmust; /* Internal use only. */
X int regmlen; /* Internal use only. */
X char program[1]; /* Unwarranted chumminess with compiler. */
X} regexp;
X
X/* regexp.c */
Xregexp *regcomp __ARGS((char *));
Xint regexec __ARGS((regexp *, char *, int));
X/* int cstrncmp __ARGS((char *, char *, int)); */
Xchar *cstrchr __ARGS((char *, int));
X
X/* regsub.c */
Xint regsub __ARGS((regexp *, char *, char *, int, int));
X
X/* search.c */
Xextern void regerror __ARGS((char *));
X
X#ifndef ORIGINAL
Xextern int reg_ic; /* set non-zero to ignore case in searches */
Xextern int reg_magic; /* set zero to disable magicness of .*[~& */
X#endif
X#endif /* _REGEXP_H */
END_OF_FILE
if test 1541 -ne `wc -c <'vim/src/regexp.h'`; then
echo shar: \"'vim/src/regexp.h'\" unpacked with wrong size!
fi
# end of 'vim/src/regexp.h'
fi
if test -f 'vim/src/regmagic.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/regmagic.h'\"
else
echo shar: Extracting \"'vim/src/regmagic.h'\" \(663 characters\)
sed "s/^X//" >'vim/src/regmagic.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *
X * This is NOT the original regular expression code as written by
X * Henry Spencer. This code has been modified specifically for use
X * with the VIM editor, and should not be used apart from compiling
X * VIM. If you want a good regular expression library, get the
X * original code. The copyright notice that follows is from the
X * original.
X *
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *
X * The first byte of the regexp internal "program" is actually this magic
X * number; the start node begins in the second byte.
X */
X
X#define MAGIC 0234
END_OF_FILE
if test 663 -ne `wc -c <'vim/src/regmagic.h'`; then
echo shar: \"'vim/src/regmagic.h'\" unpacked with wrong size!
fi
# end of 'vim/src/regmagic.h'
fi
if test -f 'vim/src/termlib.fix.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/termlib.fix.uue'\"
else
echo shar: Extracting \"'vim/src/termlib.fix.uue'\" \(89 characters\)
sed "s/^X//" >'vim/src/termlib.fix.uue' <<'END_OF_FILE'
X
Xbegin 644 termlib.fix
XB#2]O=71C*2@I#6QL;&QL875N<VEG;F5D(&EN=!LZ=W$-"O__5
X``
Xend
Xsize 34
END_OF_FILE
if test 89 -ne `wc -c <'vim/src/termlib.fix.uue'`; then
echo shar: \"'vim/src/termlib.fix.uue'\" unpacked with wrong size!
fi
# end of 'vim/src/termlib.fix.uue'
fi
if test -f 'vim/src/vim.prj' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/vim.prj'\"
else
echo shar: Extracting \"'vim/src/vim.prj'\" \(283 characters\)
sed "s/^X//" >'vim/src/vim.prj' <<'END_OF_FILE'
XALLOC.C
XBUFFERS.C
XCHARSET.C
XCMDLINE.C
XCSEARCH.C
XEDIT.C
XDIGRAPH.C
XFILEIO.C
XHELP.C
XLINEFUNC.C
XMAIN.C
XMARK.C
XMESSAGE.C
XMISCCMDS.C
XMSDOS.C
XNORMAL.C
XOPS.C
XPARAM.C
XQUICKFIX.C
XREGEXP.C
XREGSUB.C
XSCREEN.C
XSCRIPT.C
XSEARCH.C
XSTORAGE.C
XTAG.C
XTERM.C
XUNDO.C
XVERSION.C
END_OF_FILE
if test 283 -ne `wc -c <'vim/src/vim.prj'`; then
echo shar: \"'vim/src/vim.prj'\" unpacked with wrong size!
fi
# end of 'vim/src/vim.prj'
fi
if test -f 'vim/src/vimresp' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/vimresp'\"
else
echo shar: Extracting \"'vim/src/vimresp'\" \(325 characters\)
sed "s/^X//" >'vim/src/vimresp' <<'END_OF_FILE'
Xalloc.obj msdos.obj buffers.obj charset.obj cmdline.obj csearch.obj +
Xdigraph.obj edit.obj fileio.obj help.obj linefunc.obj main.obj mark.obj +
Xmessage.obj misccmds.obj normal.obj ops.obj param.obj quickfix.obj +
Xregexp.obj regsub.obj screen.obj script.obj search.obj storage.obj +
Xtag.obj term.obj undo.obj version.obj
END_OF_FILE
if test 325 -ne `wc -c <'vim/src/vimresp'`; then
echo shar: \"'vim/src/vimresp'\" unpacked with wrong size!
fi
# end of 'vim/src/vimresp'
fi
if test -f 'vim/todo' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/todo'\"
else
echo shar: Extracting \"'vim/todo'\" \(1614 characters\)
sed "s/^X//" >'vim/todo' <<'END_OF_FILE'
XBugs, VI compatibility:
X
XSetting the size of the window does not always work as expected.
XWith quickfix we only get the first 25 errors. How do we get the rest?
XThe ":cq" command does not always abort the compiler.
XWhen editing multiple files, typing :q twice should exit Vim.
X
X
XFurther extentions:
X
XHistory stack for . command?
XWhen there are "Too many files", possibility to insert them all (CTRL-A).
XUse insert/delete char when terminal supports it.
X"edit" option: when off changing the buffer is not possible.
XAdd "-d null" for editing with a script file without a display.
XFor MSDOS use memory mapped screen output (ansi.sys not needed).
XFor MSDOS search for _exrc in the directory where the binary is, instead
X of using $VIM\_exrc.
XIn insert mode: Remember the characters that were removed with backspace and
X re-insert them one at a time with CTRL-x, all together with CTRL-x.
XAdd possibility to set a keymap. The code in amiga.c does not work yet.
XAdd recognition of CR-LF files and correctly write them automatically.
XAdd to quoting: Center, right-adjust, left-adjust, function (e.g. add).
XAdd possibility to re-select previously quoted part.
X
XFrom Elvis:
Xfontchanges recognized "\\fB" etc.
Xparse error messages from many compilers
X
X
XFar future extentions:
X
XOption verbose; when on keep the screen uptodate, when off only redisplay when
X input needed.
XRemember message line for redraw.
XUse disk swap file when editing very large files.
XMode to keep text formatted while inserting/deleting.
XMode to keep C-code formatted (sort of on-line indent)
XOption to choose between line wrap and horizontal scrolling
END_OF_FILE
if test 1614 -ne `wc -c <'vim/todo'`; then
echo shar: \"'vim/todo'\" unpacked with wrong size!
fi
# end of 'vim/todo'
fi
if test ! -d 'vim/tutor' ; then
echo shar: Creating directory \"'vim/tutor'\"
mkdir 'vim/tutor'
fi
if test -f 'vim/tutor/Readme' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/tutor/Readme'\"
else
echo shar: Extracting \"'vim/tutor/Readme'\" \(768 characters\)
sed "s/^X//" >'vim/tutor/Readme' <<'END_OF_FILE'
XVitutor is a "hands on" tutorial for new users of the Vim editor.
X
XMost new users can get through it in less than one hour. The result
Xis that you can do a simple editing task using the Vim editor.
X
XTutor is a file that contains the tutorial lessons. You can simply
Xexecute "vim tutor" and then follow the instructions in the lessons.
XThe lessons tell you to modify the file, so DON'T DO THIS ON YOUR
XORIGINAL COPY.
X
XI have considered adding more advanced lessons but have not found the
Xtime. Please let me know how you like it and send any improvements you
Xmake.
X
XBob Ware, Colorado School of Mines, Golden, Co 80401, USA
X(303) 273-3987
Xbw...@mines.colorado.edu bw...@slate.mines.colorado.edu bw...@mines.bitnet
X
X(This file was modified by Bram Moolenaar for Vim)
END_OF_FILE
if test 768 -ne `wc -c <'vim/tutor/Readme'`; then
echo shar: \"'vim/tutor/Readme'\" unpacked with wrong size!
fi
# end of 'vim/tutor/Readme'
fi
if test -f 'vim/tutor/poster' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/tutor/poster'\"
else
echo shar: Extracting \"'vim/tutor/poster'\" \(860 characters\)
sed "s/^X//" >'vim/tutor/poster' <<'END_OF_FILE'
XArticle 3390 of alt.sources:
XXref: oce-rd1 comp.editors:3231 alt.sources:3390
XPath: oce-rd1!venlo!hp4nl!mcsun!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!pikes!slate!bware
XFrom: bw...@slate.mines.colorado.edu (Ware Bob)
XNewsgroups: comp.editors,alt.sources
XSubject: hands on vi tutor
XKeywords: for new users
XMessage-ID: <1991Jul17.1...@slate.mines.colorado.edu>
XDate: 17 Jul 91 16:13:55 GMT
XSender: bw...@slate.mines.colorado.edu (Ware Bob)
XOrganization: Colorado School of Mines
XLines: 830
X
X
XI posted this a few weeks ago, but a number of people have munged
Xtheir copy, so I am reposting it with better instructions.
X
XThis is a "hand-on" tutor to help new users learn the vi editor.
X
XBob Ware, Colorado School of Mines, Golden, Co 80401, USA
X(303) 273-3987
Xbw...@mines.colorado.edu bw...@slate.mines.colorado.edu bw...@mines.bitnet
END_OF_FILE
if test 860 -ne `wc -c <'vim/tutor/poster'`; then
echo shar: \"'vim/tutor/poster'\" unpacked with wrong size!
fi
# end of 'vim/tutor/poster'
fi
echo shar: End of archive 1 \(of 23\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 23 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
-------------8<----------------8<----------------8<---------------8<--------
Bram Moolenaar | DISCLAIMER: This note does not
Oce Nederland B.V., Research & Development | necessarily represent the position
p.o. box 101, 5900 MA Venlo | of Oce-Nederland B.V. Therefore
The Netherlands phone +31 77 594077 | no liability or responsibility for
UUCP: mo...@oce.nl fax +31 77 595450 | whatever will be accepted.

exit 0 # Just in case...

Bram Moolenaar

unread,
Apr 23, 1993, 1:27:33 PM4/23/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 2
Archive-name: vim/part02
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 2 (of 23)."
# Contents: vim/README vim/doc/digraph.doc.uue vim/doc/msdos.doc
# vim/src/addcr.bat vim/src/alloc.c vim/src/charset.c vim/src/help.c
# vim/src/linefunc.c vim/src/makefile.dice vim/src/makefile.dos
# vim/src/message.c vim/src/mkcmdtab.c vim/src/msdos.h vim/src/ops.h
# vim/src/sun_stdlib.h vim/src/tcconfig.tc.uue vim/src/unix.h
# vim/termcap
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:05 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/README'\"
else
echo shar: Extracting \"'vim/README'\" \(2167 characters\)
sed "s/^X//" >'vim/README' <<'END_OF_FILE'
XREADME for version 1.27 of Vim: Vi IMitation.
X
XVim is an almost compatible version of the UNIX editor vi. Only the 'Q'
Xcommand is missing. Many new features have been added: multi level undo,
Xcommand line history, filename completion, quoting, etc. See difference.doc.
X
XThis editor is very useful for editing programs and other plain ASCII files.
XAll commands are given with normal keyboard characters, so those who can type
Xwith ten fingers can work very fast. Function keys can be used for macros.
X
XVim currently runs under Amiga DOS, MSDOS and UNIX. Porting to other systems
Xshould not be very difficult.
X
XDocumentation:
X tutor/readme - one hour training course for beginners
X reference.doc - complete reference of all Vim commands
X difference.doc - summarizes the differences with UNIX vi
X index - alfabetical list of commands
X unix.doc - remarks for unix
X msdos.doc - remarks for MSDOS
X
XVim is Public Domain. You can copy it as much as you like. If you want to
Xdistribute a modified version of the source code please contact me first.
X
XInstallation on the Amiga:
X- Put "arp.library" in "libs:" (not required for Amiga DOS 2.0 and later)
X- Assign "vim:" to the directory where the vim.hlp file is (for the help
X command).
X- With DOS 1.3 or earlier: make sure that newcli and run are in "c:" (for
X executing external commands).
X- Put a shell that accepts a command with "-c" (e.g. "Csh" from Fish disk
X 624) in "c:" or in any other directory that is in your search path (for
X executing external commands).
X
XIf you have sufficient memory you can avoid startup delays by making Vim and
Xcsh resident with the command "rez csh vim". You will have to put
X"rezlib.library" in your "libs:" directory. Under 2.0 you will need rez
Xversion 0.5.
X
XIf you do not use digraphs, you can save some memory by recompiling without
Xthe DIGRAPHS option. If you want to use Vim with other terminals you can
Xrecompile with the TERMCAP option. Vim compiles with Manx 5.x and SAS 6.x.
XSee the makefiles.
X
XPlease send comments, bug reports and suggestions to:
X
X Bram Moolenaar
X Clematisstraat 30
X 5925 BE Venlo
X The Netherlands
X
XUUCP E-mail: mo...@oce.nl
END_OF_FILE
if test 2167 -ne `wc -c <'vim/README'`; then
echo shar: \"'vim/README'\" unpacked with wrong size!
fi
# end of 'vim/README'
fi
if test -f 'vim/doc/digraph.doc.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/digraph.doc.uue'\"
else
echo shar: Extracting \"'vim/doc/digraph.doc.uue'\" \(1961 characters\)
sed "s/^X//" >'vim/doc/digraph.doc.uue' <<'END_OF_FILE'
X
Xbegin 644 digraph.doc
XM5&AE<V4@87)E('1H92!D969A=6QT(&1I9W)A<&@@8VAA<F%C=&5R<R!F;W(@]
XM5FEM+B!4:&4@9FER<W0@='=O(&-H87)A8W1E<G,@:6X@"F5A8V@@8V]L=6UN]
XM(&%R92!T:&4@8VAA<F%C=&5R<R!Y;W4@:&%V92!T;R!T>7!E('1O(&5N=&5R@
XM(&$@9&EG<F%P:"X@26X@=&AE(`IM:61D;&4@;V8@96%C:"!C;VQU;6X@:7,@O
XM=&AE(')E<W5L=&EN9R!C:&%R86-T97(N(%1H:7,@;6%Y(&)E(&UA;F=L960@7
XM:68@>6]U(`IL;V]K(&%T('1H:7,@9FEL92!O;B!S;VUE=&AI;F<@96QS92!T`
XM:&%N(&%N($%M:6=A(&]R('=H96X@>6]U('!R:6YT(&ET+B!4:&4@"F1E8VEM:
XM86P@;G5M8F5R(&ES('1H92!!4T-)22!C;V1E(&9O<B!T:&4@8VAA<F%C=&5RL
XM+@H*?B$@H2`Q-C$@("!C?""B(#$V,B`@("0D(*,@,38S("`@;W@@I"`Q-C0@?
XM("!9+2"E(#$V-2`@('Q\(*8@,38V("`@<&$@IR`Q-C<*(B(@J"`Q-C@@("!CP
XM3R"I(#$V.2`@(&$M(*H@,3<P("`@/#P@JR`Q-S$@("`M+2"M(#$W,R`@(')/'
XM(*X@,3<T("`@+3T@KR`Q-S4*?F\@L"`Q-S8@("`K+2"Q(#$W-R`@(#(R(+(@C
XM,3<X("`@,S,@LR`Q-SD@("`G)R"T(#$X,"`@(&IU(+4@,3@Q("`@<'`@MB`QJ
XM.#(*?BX@MR`Q.#,@("`L+""X(#$X-"`@(#$Q(+D@,3@U("`@;RT@NB`Q.#8@.
XM("`^/B"[(#$X-R`@(#$T(+P@,3@X("`@,3(@O2`Q.#D*,S0@OB`Q.3`@("!^"
XM/R"_(#$Y,2`@($%@(,`@,3DR("`@02<@P2`Q.3,@("!!7B#"(#$Y-"`@($%^:
XM(,,@,3DU("`@02(@Q"`Q.38*04`@Q2`Q.3<@("!!12#&(#$Y."`@($,L(,<@>
XM,3DY("`@16`@R"`R,#`@("!%)R#)(#(P,2`@($5>(,H@,C`R("`@12(@RR`R/
XM,#,*26`@S"`R,#0@("!))R#-(#(P-2`@($E>(,X@,C`V("`@22(@SR`R,#<@L
XM("`M1"#0(#(P."`@($Y^(-$@,C`Y("`@3V`@TB`R,3`*3R<@TR`R,3$@("!/]
XM7B#4(#(Q,B`@($]^(-4@,C$S("`@3R(@UB`R,30@("`O7"#7(#(Q-2`@($\O5
XM(-@@,C$V("`@56`@V2`R,3<*52<@VB`R,3@@("!57B#;(#(Q.2`@(%4B(-P@Q
XM,C(P("`@62<@W2`R,C$@("!)<"#>(#(R,B`@('-S(-\@,C(S("`@86`@X"`RB
XM,C0*82<@X2`R,C4@("!A7B#B(#(R-B`@(&%^(.,@,C(W("`@82(@Y"`R,C@@-
XM("!A0"#E(#(R.2`@(&%E(.8@,C,P("`@8RP@YR`R,S$*96`@Z"`R,S(@("!E#
XM)R#I(#(S,R`@(&5>(.H@,C,T("`@92(@ZR`R,S4@("!I8"#L(#(S-B`@(&DG:
XM(.T@,C,W("`@:5X@[B`R,S@*:2(@[R`R,SD@("`M9"#P(#(T,"`@(&Y^(/$@1
XM,C0Q("`@;V`@\B`R-#(@("!O)R#S(#(T,R`@(&]>(/0@,C0T("`@;WX@]2`R!
XM-#4*;R(@]B`R-#8@("`Z+2#W(#(T-R`@(&\O(/@@,C0X("`@=6`@^2`R-#D@R
XM("!U)R#Z(#(U,"`@('5>(/L@,C4Q("`@=2(@_"`R-3(*>2<@_2`R-3,@("!I)
X3<"#^(#(U-"`@('DB(/\@,C4U"C4Q/
X``
Xend
Xsize 1369
END_OF_FILE
if test 1961 -ne `wc -c <'vim/doc/digraph.doc.uue'`; then
echo shar: \"'vim/doc/digraph.doc.uue'\" unpacked with wrong size!
fi
# end of 'vim/doc/digraph.doc.uue'
fi
if test -f 'vim/doc/msdos.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/msdos.doc'\"
else
echo shar: Extracting \"'vim/doc/msdos.doc'\" \(2942 characters\)
sed "s/^X//" >'vim/doc/msdos.doc' <<'END_OF_FILE'
XThis file contains the particularities for the MSDOS version of Vim.
X
XIf Vim produces all kinds of garbage on the screen you need to install
Xansi.sys (or equivalent).
X
XIf the "tx" (textmode) option is set (which is the default), Vim will accept a
Xsingle <LF> or a <CR><LF> pair for end-of-line. When writing a file Vim will
Xuse <CR><LF>. Thus if you edit a file and write it, <LF> is replaced with
X<CR><LF>. Single <CR> characters are lost. If the "tx" option is not set the
Xsingle <LF> will be used for end-of-line. A <CR> will be shown as ^M.
XYou can use Vim to replace <LF> by <CR><LF> by reading in any mode and
Xwriting in text mode. You can use Vim to replace <CR><LF> by <LF> by reading
Xin text mode and writing in non-text mode.
X
XScript files contain single <CR> characters. If you want to edit a script file
Xyou should reset the textmode option before loading the file.
X
XThe default help filename is "$VIM\vim.hlp". If the environment variable $VIM
Xis not defined or the file is not found, the DOS search path is used to
Xsearch for the file "vim.hlp". If you do not want to put "vim.hlp" in your
Xsearch path, use the command ":set helpfile=pathname" to tell Vim where the
Xhelp file is.
X
XThe files "_vimrc" and "_exrc" are used instead of ".vimrc" and ".exrc".
XThe files "$VIM\_vimrc" and "$VIM\_exrc" are used instead of "s:.vimrc" and
X"s:.exrc".
X
XUse CTRL-break instead of CTRL-C to interrupt searches. The CTRL-C is not
Xdetected until a key is read.
X
XUse CTRL-arrow-left and CTRL-arrow-right instead of SHIFT-arrow-left and
XSHIFT-arrow-right. The arrow-up and arrow-down cannot be used with SHIFT or
XCTRL.
X
XTemporary files (for filtering) are put in the current directory.
X
XThe default for the sh (shell) option is "command". External commands are
Xstarted with "command /c <command_name>". Typing CTRL-Z starts a new command
Xshell. Return to Vim with "exit".
X
X
XMS-DOS allows for only one filename extention. Therefore, in the original
Xfilename the '.' is replaced by a '_', the name is truncated to 8 characters
Xand the new extention ".vim" or ".bak" is appended. Two examples: "test.c"
Xbecomes "test_c.bak", "ditiseen.tst" becomes "ditiseen.bak". The 'shortname'
Xoption is not available.
X
XThe MS-DOS binary was compiled with Turbo-C version 2.0 (yes, it's old). You
Xmay get some "argument never used" warning messages. They can be ignored. If
Xyou get all kinds of strange error messages when compiling, you have to add
X<CR> characters at the end of each line. This can be done with the addcr
Xprogram: "make addcr". This will compile addcr.c to addcr.exe and execute
Xthe addcr.bat file.
X
XAll text is kept in memory. This limits the size of the file you can edit,
Xthe number of undo levels that can be remembered, etc.. If Vim gives an "Out
Xof memory" warning you should stop editing. Result of further editing actions
Xis unpredictable.
X
XThe *.info files are for the Amiga. You don't need them with MSDOS.
END_OF_FILE
if test 2942 -ne `wc -c <'vim/doc/msdos.doc'`; then
echo shar: \"'vim/doc/msdos.doc'\" unpacked with wrong size!
fi
# end of 'vim/doc/msdos.doc'
fi
if test -f 'vim/src/addcr.bat' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/addcr.bat'\"
else
echo shar: Extracting \"'vim/src/addcr.bat'\" \(3795 characters\)
sed "s/^X//" >'vim/src/addcr.bat' <<'END_OF_FILE'
Xaddcr <addcr.c >tmp
Xcp tmp addcr.c
Xaddcr <alloc.c >tmp
Xcp tmp alloc.c
Xaddcr <ascii.h >tmp
Xcp tmp ascii.h
Xaddcr <buffers.c >tmp
Xcp tmp buffers.c
Xaddcr <charset.c >tmp
Xcp tmp charset.c
Xaddcr <cmdline.c >tmp
Xcp tmp cmdline.c
Xaddcr <cmdtab.h >tmp
Xcp tmp cmdtab.h
Xaddcr <cmdtab.tab >tmp
Xcp tmp cmdtab.tab
Xaddcr <csearch.c >tmp
Xcp tmp csearch.c
Xaddcr <debug.h >tmp
Xcp tmp debug.h
Xaddcr <digraph.c >tmp
Xcp tmp digraph.c
Xaddcr <edit.c >tmp
Xcp tmp edit.c
Xaddcr <env.h >tmp
Xcp tmp env.h
Xaddcr <fileio.c >tmp
Xcp tmp fileio.c
Xaddcr <globals.h >tmp
Xcp tmp globals.h
Xaddcr <help.c >tmp
Xcp tmp help.c
Xaddcr <keymap.h >tmp
Xcp tmp keymap.h
Xaddcr <linefunc.c >tmp
Xcp tmp linefunc.c
Xaddcr <macros.h >tmp
Xcp tmp macros.h
Xaddcr <main.c >tmp
Xcp tmp main.c
Xaddcr <makefile >tmp
Xcp tmp makefile
Xaddcr <mark.c >tmp
Xcp tmp mark.c
Xaddcr <mark.h >tmp
Xcp tmp mark.h
Xaddcr <message.c >tmp
Xcp tmp message.c
Xaddcr <misccmds.c >tmp
Xcp tmp misccmds.c
Xaddcr <mkcmdtab.c >tmp
Xcp tmp mkcmdtab.c
Xaddcr <msdos.c >tmp
Xcp tmp msdos.c
Xaddcr <msdos.h >tmp
Xcp tmp msdos.h
Xaddcr <normal.c >tmp
Xcp tmp normal.c
Xaddcr <ops.c >tmp
Xcp tmp ops.c
Xaddcr <ops.h >tmp
Xcp tmp ops.h
Xaddcr <param.c >tmp
Xcp tmp param.c
Xaddcr <param.h >tmp
Xcp tmp param.h
Xaddcr <proto.h >tmp
Xcp tmp proto.h
Xaddcr <quickfix.c >tmp
Xcp tmp quickfix.c
Xaddcr <regexp.c >tmp
Xcp tmp regexp.c
Xaddcr <regexp.h >tmp
Xcp tmp regexp.h
Xaddcr <regmagic.h >tmp
Xcp tmp regmagic.h
Xaddcr <regsub.c >tmp
Xcp tmp regsub.c
Xaddcr <screen.c >tmp
Xcp tmp screen.c
Xaddcr <script.c >tmp
Xcp tmp script.c
Xaddcr <search.c >tmp
Xcp tmp search.c
Xaddcr <storage.c >tmp
Xcp tmp storage.c
Xaddcr <tag.c >tmp
Xcp tmp tag.c
Xaddcr <tags >tmp
Xcp tmp tags
Xaddcr <term.c >tmp
Xcp tmp term.c
Xaddcr <term.h >tmp
Xcp tmp term.h
Xaddcr <termlib.c >tmp
Xcp tmp termlib.c
Xaddcr <termlib.fix >tmp
Xcp tmp termlib.fix
Xaddcr <undo.c >tmp
Xcp tmp undo.c
Xaddcr <version.c >tmp
Xcp tmp version.c
Xaddcr <vim.h >tmp
Xcp tmp vim.h
Xaddcr <vim.prj >tmp
Xcp tmp vim.prj
Xaddcr <vimresp >tmp
Xcp tmp vimresp
Xaddcr <proto\alloc.pro >tmp
Xcp tmp proto\alloc.pro
Xaddcr <proto\amiga.pro >tmp
Xcp tmp proto\amiga.pro
Xaddcr <proto\buffers.pro >tmp
Xcp tmp proto\buffers.pro
Xaddcr <proto\charset.pro >tmp
Xcp tmp proto\charset.pro
Xaddcr <proto\cmdline.pro >tmp
Xcp tmp proto\cmdline.pro
Xaddcr <proto\csearch.pro >tmp
Xcp tmp proto\csearch.pro
Xaddcr <proto\digraph.pro >tmp
Xcp tmp proto\digraph.pro
Xaddcr <proto\edit.pro >tmp
Xcp tmp proto\edit.pro
Xaddcr <proto\fileio.pro >tmp
Xcp tmp proto\fileio.pro
Xaddcr <proto\help.pro >tmp
Xcp tmp proto\help.pro
Xaddcr <proto\linefunc.pro >tmp
Xcp tmp proto\linefunc.pro
Xaddcr <proto\main.pro >tmp
Xcp tmp proto\main.pro
Xaddcr <proto\mark.pro >tmp
Xcp tmp proto\mark.pro
Xaddcr <proto\message.pro >tmp
Xcp tmp proto\message.pro
Xaddcr <proto\misccmds.pro >tmp
Xcp tmp proto\misccmds.pro
Xaddcr <proto\normal.pro >tmp
Xcp tmp proto\normal.pro
Xaddcr <proto\ops.pro >tmp
Xcp tmp proto\ops.pro
Xaddcr <proto\param.pro >tmp
Xcp tmp proto\param.pro
Xaddcr <proto\quickfix.pro >tmp
Xcp tmp proto\quickfix.pro
Xaddcr <proto\regexp.pro >tmp
Xcp tmp proto\regexp.pro
Xaddcr <proto\regsub.pro >tmp
Xcp tmp proto\regsub.pro
Xaddcr <proto\screen.pro >tmp
Xcp tmp proto\screen.pro
Xaddcr <proto\script.pro >tmp
Xcp tmp proto\script.pro
Xaddcr <proto\search.pro >tmp
Xcp tmp proto\search.pro
Xaddcr <proto\storage.pro >tmp
Xcp tmp proto\storage.pro
Xaddcr <proto\tag.pro >tmp
Xcp tmp proto\tag.pro
Xaddcr <proto\term.pro >tmp
Xcp tmp proto\term.pro
Xaddcr <proto\termlib.pro >tmp
Xcp tmp proto\termlib.pro
Xaddcr <proto\undo.pro >tmp
Xcp tmp proto\undo.pro
Xaddcr <proto\version.pro >tmp
Xcp tmp proto\version.pro
Xdel tmp
END_OF_FILE
if test 3795 -ne `wc -c <'vim/src/addcr.bat'`; then
echo shar: \"'vim/src/addcr.bat'\" unpacked with wrong size!
fi
# end of 'vim/src/addcr.bat'
fi
if test -f 'vim/src/alloc.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/alloc.c'\"
else
echo shar: Extracting \"'vim/src/alloc.c'\" \(2444 characters\)
sed "s/^X//" >'vim/src/alloc.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * alloc.c
X *
X * This file contains various routines dealing with allocation and
X * deallocation of data structures.
X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X
X#ifdef AMIGA
X# undef FALSE /* these are redefined in exec/types.h */
X# undef TRUE
X# include <exec/types.h>
X# include <exec/memory.h>
X# undef FALSE
X# define FALSE 0 /* define FALSE and TRUE as ints instead of longs */
X# undef TRUE
X# define TRUE 1
X#endif /* AMIGA */
X
X#ifdef MSDOS
X# include <alloc.h>
X#endif /* MSDOS */
X
X#define PANIC_FACTOR_CHIP 8192L
X
X char *
Xalloc(size)
X unsigned size;
X{
X return (lalloc((u_long)size, TRUE));
X}
X
X char *
Xlalloc(size, message)
X u_long size;
X int message;
X{
X register char *p; /* pointer to new storage space */
X
X if ((p = (char *)malloc(size)) != NULL)
X {
X#ifdef AMIGA
X if (AvailMem((long)MEMF_CHIP) < PANIC_FACTOR_CHIP)
X { /* System is low... no go! */
X free(p);
X p = NULL;
X }
X#endif
X#ifdef MSDOS
X if (coreleft() < PANIC_FACTOR_CHIP)
X { /* System is low... no go! */
X free(p);
X p = NULL;
X }
X#endif
X }
X if (message && p == NULL)
X emsg(e_outofmem);
X return (p);
X}
X
X/*
X * copy a string into newly allocated memory
X */
X char *
Xstrsave(string)
X char *string;
X{
X char *p;
X
X p = alloc((unsigned) (strlen(string) + 1));
X if (p != NULL)
X strcpy(p, string);
X return p;
X}
X
X char *
Xstrnsave(string, len)
X char *string;
X int len;
X{
X char *p;
X
X p = alloc((unsigned) (len + 1));
X if (p != NULL)
X {
X strncpy(p, string, (size_t)len);
X p[len] = NUL;
X }
X return p;
X}
X
X/*
X * copy a number of spaces
X */
X void
Xcopy_spaces(ptr, count)
X char *ptr;
X size_t count;
X{
X register size_t j;
X
X while (count) /* copy 15 spaces at a time */
X {
X j = count;
X if (j > 15)
X j = 15;
X memmove(ptr, spaces, j);
X ptr += j;
X count -= j;
X }
X}
X
X char *
Xmkstr(c)
X unsigned c;
X{
X static char s[2];
X
X s[0] = c;
X s[1] = NUL;
X
X return s;
X}
X
X#ifdef NO_FREE_NULL
X#undef free
X/*
X * replacement for free() that cannot handle NULL pointers
X */
X void
XnofreeNULL(x)
X void *x;
X{
X if (x != NULL)
X free(x);
X}
X#endif
X
X#ifdef BSD
X char *
Xbsdmemset(ptr, c, size)
X char *ptr;
X int c;
X long size;
X{
X register char *p = ptr;
X
X while (size-- > 0)
X *p++ = c;
X return ptr;
X}
X#endif
END_OF_FILE
if test 2444 -ne `wc -c <'vim/src/alloc.c'`; then
echo shar: \"'vim/src/alloc.c'\" unpacked with wrong size!
fi
# end of 'vim/src/alloc.c'
fi
if test -f 'vim/src/charset.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/charset.c'\"
else
echo shar: Extracting \"'vim/src/charset.c'\" \(1994 characters\)
sed "s/^X//" >'vim/src/charset.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X

X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X
X
X char *
Xtranschar(c)
X unsigned c;
X{
X static char buf[3];
X
X if (c < ' ')
X {
X if (c == NL)
X c = NUL; /* we use newline in place of a NUL */
X buf[0] = '^';
X buf[1] = '@' + c;
X buf[2] = NUL;
X }
X else if (c <= '~' || c > 0xa0 || p_gr)
X {
X buf[0] = c;
X buf[1] = NUL;
X }
X else
X {
X buf[0] = '~';
X buf[1] = c - 0x80 + '@';
X buf[2] = NUL;
X }
X return buf;
X}
X
X/*
X * output 'len' characters in 'str' (including NULs) with translation
X * if 'len' is -1, output upto a NUL character
X * return the number of characters it takes on the screen
X */
X int
Xouttrans(str, len)
X register char *str;
X register int len;
X{
X int retval = 0;
X
X if (len == -1)
X len = strlen(str);
X while (--len >= 0)
X {
X outstrn(transchar(*(u_char *)str));
X retval += charsize(*(u_char *)str);
X ++str;
X }
X return retval;
X}
X
X/*
X * return the number of characters 'c' will take on the screen
X */
X int
Xcharsize(c)
X int c;
X{
X return ((c >= ' ' && (p_gr || c <= '~')) || c > 0xa0 ? 1 : 2);
X}
X
X/*
X * return the number of characters string 's' will take on the screen
X */
X int
Xstrsize(s)
X char *s;
X{
X int len = 0;
X
X while (*s)
X len += charsize(*s++);
X return len;
X}
X
X/*
X * return the number of characters 'c' will take on the screen, taking
X * into account the size of a tab
X */
X int
Xchartabsize(c, col)
X int c, col;
X{
X if ((c >= ' ' && (c <= '~' || p_gr)) || c > 0xa0)
X return 1;
X else if (c == TAB && !p_list)
X return (int)(p_ts - (col % p_ts));
X else
X return 2;
X}
X
X/*
X * return TRUE if 'c' is an identifier character
X */
X int
Xisidchar(c)
X int c;
X{
X#ifdef __STDC__
X return (isalnum(c) || c == '_');
X#else
X return (isalpha(c) || isdigit(c) || c == '_');
X#endif
X}
END_OF_FILE
if test 1994 -ne `wc -c <'vim/src/charset.c'`; then
echo shar: \"'vim/src/charset.c'\" unpacked with wrong size!
fi
# end of 'vim/src/charset.c'
fi
if test -f 'vim/src/help.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/help.c'\"
else
echo shar: Extracting \"'vim/src/help.c'\" \(2810 characters\)
sed "s/^X//" >'vim/src/help.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * help.c: display help from the vim.hlp file
X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X
Xstatic long helpfilepos; /* position in help file */
Xstatic FILE *helpfd; /* file descriptor of help file */
X
X void
Xhelp()
X{
X int c;
X int eof;
X int i;
X long filepos[26]; /* seek position for each screen */
X int screennr; /* screen number; 'c' == 1 */
X char fnamebuf[MAXPATHL];
X#ifdef MSDOS
X char *fnamep;
X#endif
X
X/*
X * try to open the file specified by the "helpfile" option
X */
X expand_env(p_hf, fnamebuf, MAXPATHL);
X if ((helpfd = fopen(fnamebuf, READBIN)) == NULL)
X {
X#ifdef MSDOS
X /*
X * for MSdos: try the DOS search path
X */
X strcpy(fnamebuf, "vim.hlp");
X fnamep = searchpath(fnamebuf);
X if (fnamep == NULL || (helpfd = fopen(fnamep, READBIN)) == NULL)
X {
X#endif
X smsg("Sorry, help file %s not found", fnamebuf);
X return;
X#ifdef MSDOS
X }
X#endif
X }
X helpfilepos = 0;
X screennr = 0;
X for (i = 0; i < 26; ++i)
X filepos[i] = 0;
X State = HELP;
X for (;;)
X {
X eof = redrawhelp();
X if (!eof)
X filepos[screennr + 1] = ftell(helpfd);
X
X if ((c = vgetc()) == '\n' || c == '\r')
X break;
X
X if (c == ' ') /* one screen forwards */
X {
X if (screennr < 25 && !eof)
X ++screennr;
X }
X else if (c == 'a') /* go to first screen */
X screennr = 0;
X else if (c == 'b') /* go one screen backwards */
X {
X if (screennr > 0)
X --screennr;
X }
X else if (c >= 'c' && c <= 'z') /* go to specified screen */
X {
X if (c - 'b' < screennr) /* backwards */
X screennr = c - 'b';
X else /* forwards */
X {
X while (screennr < c - 'b' && filepos[screennr + 1])
X ++screennr;
X fseek(helpfd, filepos[screennr], 0);
X while (screennr < c - 'b')
X {
X while ((i = getc(helpfd)) != '\f' && i != -1)
X ;
X if (i == -1)
X break;
X filepos[++screennr] = ftell(helpfd);
X }
X }
X }
X helpfilepos = filepos[screennr];
X }
X State = NORMAL;
X script_winsize_pp();
X fclose(helpfd);
X updateScreen(CLEAR);
X}
X
X int
Xredrawhelp()
X{
X int nextc;
X int col;
X
X fseek(helpfd, helpfilepos, 0);
X col = Columns - 52;
X if (col < 0)
X col = 0;
X outstr(T_ED);
X while ((nextc = getc(helpfd)) != -1 && nextc != '\f')
X {
X if (nextc == Ctrl('B')) /* begin of invert */
X outstr(T_TI);
X else if (nextc == Ctrl('E')) /* end of invert */
X outstr(T_TP);
X else
X outchar((char)nextc);
X }
X windgoto(0, (int)(Columns - strlen(Version) - 1));
X outstrn(Version);
X windgoto((int)Rows - 1, col);
X outstrn("<space = next; return = quit; a = index; b = back>");
X return (nextc == -1);
X}
END_OF_FILE
if test 2810 -ne `wc -c <'vim/src/help.c'`; then
echo shar: \"'vim/src/help.c'\" unpacked with wrong size!
fi
# end of 'vim/src/help.c'
fi
if test -f 'vim/src/linefunc.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/linefunc.c'\"
else
echo shar: Extracting \"'vim/src/linefunc.c'\" \(2625 characters\)
sed "s/^X//" >'vim/src/linefunc.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * linefunc.c: some functions to move to the next/previous line and
X * to the next/previous character
X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X
X/*
X * coladvance(col)
X *
X * Try to advance the Cursor to the specified column.
X */
X
X void
Xcoladvance(wcol)
X colnr_t wcol;
X{
X int index;
X register u_char *ptr;
X register colnr_t col;
X
X ptr = (u_char *)nr2ptr(Curpos.lnum);
X
X /* try to advance to the specified column */
X index = -1;
X col = 0;
X while (col <= wcol && *ptr)
X {
X ++index;
X /* Count a tab for what it's worth (if list mode not on) */
X col += chartabsize(*ptr, col);
X ++ptr;
X }
X if (index < 0)
X Curpos.col = 0;
X else
X Curpos.col = index;
X}
X
X/*
X * inc(p)
X *
X * Increment the line pointer 'p' crossing line boundaries as necessary. Return
X * 1 when crossing a line, -1 when at end of file, 0 otherwise.
X */
X int
Xinc(lp)
X register FPOS *lp;
X{
X register char *p = pos2ptr(lp);
X
X if (*p != NUL)
X { /* still within line */
X lp->col++;
X return ((p[1] != NUL) ? 0 : 1);
X }
X if (lp->lnum != line_count)
X { /* there is a next line */
X lp->col = 0;
X lp->lnum++;
X return 1;
X }
X return -1;
X}
X
X int
XincCurpos()
X{
X return inc(&Curpos);
X}
X
X/*
X * incl(lp): same as inc(), but skip the NUL at the end of non-empty lines
X */
X int
Xincl(lp)
X register FPOS *lp;
X{
X register int r;
X
X if ((r = inc(lp)) == 1 && lp->col)
X r = inc(lp);
X return r;
X}
X
X/*
X * dec(p)
X *
X * Decrement the line pointer 'p' crossing line boundaries as necessary. Return
X * 1 when crossing a line, -1 when at start of file, 0 otherwise.
X */
X int
Xdec(lp)
X register FPOS *lp;
X{
X if (lp->col > 0)
X { /* still within line */
X lp->col--;
X return 0;
X }
X if (lp->lnum > 1)
X { /* there is a prior line */
X lp->lnum--;
X lp->col = strlen(nr2ptr(lp->lnum));
X return 1;
X }
X return -1; /* at start of file */
X}
X
X int
XdecCurpos()
X{
X return dec(&Curpos);
X}
X
X/*
X * decl(lp): same as dec(), but skip the NUL at the end of non-empty lines
X */
X int
Xdecl(lp)
X register FPOS *lp;
X{
X register int r;
X
X if ((r = dec(lp)) == 1 && lp->col)
X r = dec(lp);
X return r;
X}
X
X/*
X * make sure Curpos in on a valid character
X */
X void
XadjustCurpos()
X{
X int len;
X
X if (Curpos.lnum == 0)
X Curpos.lnum = 1;
X if (Curpos.lnum > line_count)
X Curpos.lnum = line_count;
X
X len = strlen(nr2ptr(Curpos.lnum));
X if (len == 0)
X Curpos.col = 0;
X else if (Curpos.col >= len)
X Curpos.col = len - 1;
X}
END_OF_FILE
if test 2625 -ne `wc -c <'vim/src/linefunc.c'`; then
echo shar: \"'vim/src/linefunc.c'\" unpacked with wrong size!
fi
# end of 'vim/src/linefunc.c'
fi
if test -f 'vim/src/makefile.dice' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/makefile.dice'\"
else
echo shar: Extracting \"'vim/src/makefile.dice'\" \(3130 characters\)
sed "s/^X//" >'vim/src/makefile.dice' <<'END_OF_FILE'
X#
X# Makefile for VIM, using DICE 2.06.40 and 2.06.21
X#
X
X#>>>>> choose options:
X### -DDIGRAPHS digraph support (at the cost of 1.6 Kbyte code)
X### -DWILD_CARDS wildcard expansion code
X### -DNO_ARP do not use arp.library, DOS 2.0 required
X### -DCOMPATIBLE start in vi-compatible mode
X### -DNOBACKUP default is no backup file
X### -DDEBUG output a lot of debugging garbage
X### -DTERMCAP include termcap file support
X### -DNO_BUILTIN_TCAPS do not include builtin termcap entries
X### (use only with -DTERMCAP)
X### -DSOME_BUILTIN_TCAPS include most useful builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)
X### -DALL_BUILTIN_TCAPS include all builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)
XDEFINES = -DWILD_CARDS -DTERMCAP -DDIGRAPHS -DSOME_BUILTIN_TCAPS
X
X#>>>>> if TERMCAP is defined termlib.o has to be used
XTERMLIB = termlib.o
X#TERMLIB =
X
X#>>>>> end of choices
X###########################################################################
X
XCFLAGS = -c -DAMIGA $(DEFINES)
X
XINCL = vim.syms
XPRE = -H${INCL}=vim.h
XLIBS = -lmanx -la
XCC = dcc
XLD = dcc
X
X.c.o:
X ${CC} ${PRE} ${CFLAGS} $*.c -o $@
X
XOBJ = alloc.o amiga.o buffers.o charset.o cmdline.o csearch.o digraph.o \
X edit.o fileio.o help.o linefunc.o main.o mark.o message.o misccmds.o \
X normal.o ops.o param.o quickfix.o regexp.o regsub.o screen.o \
X script.o search.o storage.o tag.o undo.o $(TERMLIB)
X
X/Vim: $(OBJ) version.c
X ${CC} $(CFLAGS) version.c -o version.o
X ${LD} -o /Vim $(OBJ) version.o $(LIBS)
X
Xdebug: $(OBJ) version.c
X ${CC} $(CFLAGS) version.c -o version.o
X ${LD} -s -o /Vim $(OBJ) version.o $(LIBS)
X
Xctags:
X csh -c ctags *.c *.h
X
X# can't use delete here, too many file names
Xclean:
X csh -c rm -f $(OBJ) version.o mkcmdtab.o /Vim $(INCL) mkcmdtab
X
X$(INCL) : vim.h globals.h keymap.h macros.h ascii.h term.h amiga.h
X delete $(INCL)
X
X###########################################################################
X
Xalloc.o: alloc.c $(INCL)
X
Xamiga.o: amiga.c $(INCL) amiga.h
X
Xbuffers.o: buffers.c $(INCL)
X
Xcharset.o: charset.c $(INCL)
X
Xcmdline.o: cmdline.c $(INCL) cmdtab.h
X
Xcsearch.o: csearch.c $(INCL) regexp.h
X
Xdigraph.o: digraph.c $(INCL)
X
Xedit.o: edit.c $(INCL)
X
Xfileio.o: fileio.c $(INCL)
X
Xhelp.o: help.c $(INCL)
X
Xlinefunc.o: linefunc.c $(INCL)
X
Xmain.o: main.c
X ${CC} ${CFLAGS} main.c -o main.o
X
Xmark.o: mark.c $(INCL) mark.h
X
Xmessage.o: message.c $(INCL)
X
Xmisccmds.o: misccmds.c $(INCL)
X
Xnormal.o: normal.c $(INCL) ops.h
X
Xops.o: ops.c $(INCL) ops.h
X
Xparam.o: param.c $(INCL)
X# Because of a bug in DC1 2.06.40, initialisation of unions does not
X# work correctly. dc1-21 is DC1 2.06.21 which does work.
X rename dc1-21 dc1
X ${CC} ${CFLAGS} param.c -o param.o
X rename dc1 dc1-21
X
Xquickfix.o: quickfix.c $(INCL)
X
Xregexp.o: regexp.c $(INCL) regexp.h
X
Xregsub.o: regsub.c $(INCL) regexp.h
X
Xscreen.o: screen.c $(INCL)
X
Xscript.o: script.c $(INCL)
X
Xsearch.o: search.c $(INCL) regexp.h
X
Xtag.o: tags.c $(INCL) mark.h
X
Xtermlib.o: termlib.c $(INCL)
X
Xstorage.o: storage.c $(INCL)
X
Xundo.o: undo.c $(INCL)
X
Xcmdtab.h: cmdtab.tab mkcmdtab
X mkcmdtab cmdtab.tab cmdtab.h
X
Xmkcmdtab: mkcmdtab.o
X ${LD} -o mkcmdtab mkcmdtab.o
END_OF_FILE
if test 3130 -ne `wc -c <'vim/src/makefile.dice'`; then
echo shar: \"'vim/src/makefile.dice'\" unpacked with wrong size!
fi
# end of 'vim/src/makefile.dice'
fi
if test -f 'vim/src/makefile.dos' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/makefile.dos'\"
else
echo shar: Extracting \"'vim/src/makefile.dos'\" \(3966 characters\)
sed "s/^X//" >'vim/src/makefile.dos' <<'END_OF_FILE'
X#
X# Makefile for VIM on MSDOS, using Turbo C
X#
X
X#>>>>> choose options:
X### -DUSE_KBHIT use kbhit() and getch() instead of bioskey()
X### -DDIGRAPHS digraph support (at the cost of 1.6 Kbyte code)
X### -DWILD_CARDS wildcard expansion code
X### -DCOMPATIBLE start in vi-compatible mode
X### -DNOBACKUP default is no backup file
X### -DDEBUG output a lot of debugging garbage
X### -DTERMCAP include termcap file support
X### -DNO_BUILTIN_TCAPS do not include builtin termcap entries
X### (use only with -DTERMCAP)
X### -DSOME_BUILTIN_TCAPS include most useful builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)
X### -DALL_BUILTIN_TCAPS include all builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)
X### -DVIMRC_FILE name of the .vimrc file in current dir
X### -DEXRC_FILE name of the .exrc file in current dir
X### -DSYSVIMRC_FILE name of the global .vimrc file
X### -DSYSEXRC_FILE name of the global .exrc file
X### -DDEFVIMRC_FILE name of the system-wide .vimrc file
X### -DVIM_HLP name of the help file
XDEFINES = -DWILD_CARDS
X
X#>>>>> name of the compiler and linker, name of lib directory
XCC = tcc
XLINK = tlink
XLIB = d:\tc\lib
X
X#>>>>> end of choices
X###########################################################################
X
XINCL = vim.h globals.h param.h keymap.h macros.h ascii.h term.h msdos.h
XCFLAGS = -c -ml -DMSDOS $(DEFINES)
X
XOBJ = alloc.obj msdos.obj buffers.obj charset.obj cmdline.obj csearch.obj \
X digraph.obj edit.obj fileio.obj help.obj linefunc.obj main.obj mark.obj \
X message.obj misccmds.obj normal.obj ops.obj param.obj quickfix.obj \
X regexp.obj regsub.obj screen.obj script.obj search.obj storage.obj \
X tag.obj term.obj undo.obj
X
X..\vim: $(OBJ) version.c
X $(CC) $(CFLAGS) version.c
X $(LINK) /c /m $(LIB)\C0l @vimresp,..\vim,..\vim,$(LIB)\emu $(LIB)\Cl
X
Xctags:
X command /c ctags *.c *.h
X
Xclean:
X del $(OBJ) version.obj mkcmdtab.obj ..\vim mkcmdtab
X
Xaddcr: addcr.c
X $(CC) addcr.c
X command /c addcr.bat
X
X###########################################################################
X
Xalloc.obj: alloc.c $(INCL)
X $(CC) $(CFLAGS) alloc.c
X
Xmsdos.obj: msdos.c $(INCL) msdos.h
X $(CC) $(CFLAGS) msdos.c
X
Xbuffers.obj: buffers.c $(INCL)
X $(CC) $(CFLAGS) buffers.c
X
Xcharset.obj: charset.c $(INCL)
X $(CC) $(CFLAGS) charset.c
X
Xcmdline.obj: cmdline.c $(INCL) cmdtab.h
X $(CC) $(CFLAGS) cmdline.c
X
Xcsearch.obj: csearch.c $(INCL)
X $(CC) $(CFLAGS) csearch.c
X
Xdigraph.obj: digraph.c $(INCL)
X $(CC) $(CFLAGS) digraph.c
X
Xedit.obj: edit.c $(INCL)
X $(CC) $(CFLAGS) edit.c
X
Xfileio.obj: fileio.c $(INCL)
X $(CC) $(CFLAGS) fileio.c
X
Xhelp.obj: help.c $(INCL)
X $(CC) $(CFLAGS) help.c
X
Xlinefunc.obj: linefunc.c $(INCL)
X $(CC) $(CFLAGS) linefunc.c
X
Xmain.obj: main.c $(INCL)
X $(CC) $(CFLAGS) main.c
X
Xmark.obj: mark.c $(INCL)
X $(CC) $(CFLAGS) mark.c
X
Xmessage.obj: message.c $(INCL)
X $(CC) $(CFLAGS) message.c
X
Xmisccmds.obj: misccmds.c $(INCL)
X $(CC) $(CFLAGS) misccmds.c
X
Xnormal.obj: normal.c $(INCL) ops.h
X $(CC) $(CFLAGS) normal.c
X
Xops.obj: ops.c $(INCL) ops.h
X $(CC) $(CFLAGS) ops.c
X
Xparam.obj: param.c $(INCL)
X $(CC) $(CFLAGS) param.c
X
Xquickfix.obj: quickfix.c $(INCL)
X $(CC) $(CFLAGS) quickfix.c
X
Xregexp.obj: regexp.c $(INCL)
X $(CC) $(CFLAGS) regexp.c
X
Xregsub.obj: regsub.c $(INCL)
X $(CC) $(CFLAGS) regsub.c
X
Xscreen.obj: screen.c $(INCL)
X $(CC) $(CFLAGS) screen.c
X
Xscript.obj: script.c $(INCL)
X $(CC) $(CFLAGS) script.c
X
Xsearch.obj: search.c $(INCL)
X $(CC) $(CFLAGS) search.c
X
Xstorage.obj: storage.c $(INCL)
X $(CC) $(CFLAGS) storage.c
X
Xtag.obj: tag.c $(INCL)
X $(CC) $(CFLAGS) tag.c
X
Xterm.obj: term.c $(INCL)
X $(CC) $(CFLAGS) term.c
X
Xundo.obj: undo.c $(INCL)
X $(CC) $(CFLAGS) undo.c
X
Xcmdtab.h: cmdtab.tab mkcmdtab.exe
X mkcmdtab cmdtab.tab cmdtab.h
X
Xmkcmdtab.exe: mkcmdtab.obj
X $(CC) -ml -omkcmdtab mkcmdtab.obj
X
Xmkcmdtab.obj: mkcmdtab.c
X $(CC) $(CFLAGS) mkcmdtab.c
END_OF_FILE
if test 3966 -ne `wc -c <'vim/src/makefile.dos'`; then
echo shar: \"'vim/src/makefile.dos'\" unpacked with wrong size!
fi
# end of 'vim/src/makefile.dos'
fi
if test -f 'vim/src/message.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/message.c'\"
else
echo shar: Extracting \"'vim/src/message.c'\" \(2523 characters\)
sed "s/^X//" >'vim/src/message.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * message.c: functions for displaying messages on the command line
X */
X
X#include "vim.h"
X#include "globals.h"
X#define MESSAGE
X#include "proto.h"
X#include "param.h"
X
Xstatic int msg_invert = FALSE;
X
X/*
X * msg(s) - displays the string 's' on the status line
X */
X void
Xmsg(s)
X char *s;
X{
X int len;
X
X if (Columns == 0) /* terminal not initialized */
X {
X fprintf(stderr, s);
X fflush(stderr);
X return;
X }
X
X gotocmdline(TRUE, NUL);
X if (msg_invert)
X outstr(T_TI);
X len = outtrans(s, -1);
X if (msg_invert)
X {
X outstr(T_TP);
X msg_invert = FALSE;
X }
X flushbuf();
X /*
X * if the string is larger than the window,
X * or the ruler option is set and we run into it,
X * we have to redraw the window.
X * Do not do this if we are abandoning the file.
X */
X if (!exiting && len >= Columns - (p_ru ? 22 : 0))
X {
X outchar('\n');
X wait_return(TRUE);
X }
X}
X
X/* VARARGS */
X#ifndef PROTO /* automatic prototype generation does not understand this */
X void
Xsmsg(s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
X char *s;
X long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
X{
X sprintf(IObuff, s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
X msg(IObuff);
X}
X#endif
X
X/*
X * emsg() - display an error message
X *
X * Rings the bell, if appropriate, and calls message() to do the real work
X */
X void
Xemsg(s)
X char *s;
X{
X if (p_eb)
X beep(); /* also includes flush_buffers() */
X else
X flush_buffers(); /* delete all typeahead characters */
X msg_invert = TRUE;
X msg(s);
X flushbuf();
X if (got_int) /* remove typeahead now, allow typeadhead during sleep */
X inchar(TRUE, FALSE);
X sleep(1); /* give the user a chance to read the message */
X}
X
X void
Xwait_return(redraw)
X int redraw;
X{
X u_char c;
X int oldstate;
X
X oldstate = State;
X State = HITRETURN;
X if (got_int)
X outstrn("Interrupt: ");
X
X#ifdef ORG_HITRETURN
X outstrn("Press RETURN to continue");
X do {
X c = vgetc();
X } while (strchr("\r\n: ", c) == NULL);
X if (c == ':') /* this can vi too (but not always!) */
X stuffReadbuff(mkstr(c));
X#else
X outstrn("Press RETURN or enter command to continue");
X c = vgetc();
X if (strchr("\r\n ", c) == NULL)
X stuffReadbuff(mkstr(c));
X#endif
X
X if (State == SETWINSIZE)
X {
X State = oldstate;
X set_winsize(0, 0, FALSE);
X }
X State = oldstate;
X script_winsize_pp();
X
X if (redraw)
X updateScreen(CLEAR);
X}
END_OF_FILE
if test 2523 -ne `wc -c <'vim/src/message.c'`; then
echo shar: \"'vim/src/message.c'\" unpacked with wrong size!
fi
# end of 'vim/src/message.c'
fi
if test -f 'vim/src/mkcmdtab.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/mkcmdtab.c'\"
else
echo shar: Extracting \"'vim/src/mkcmdtab.c'\" \(2066 characters\)
sed "s/^X//" >'vim/src/mkcmdtab.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * mkcmdtab.c: separate program that reads cmdtab.tab and produces cmdtab.h
X *
X * call with: mkcmdtab cmdtab.tab cmdtab.h
X */
X
X#include <stdlib.h>
X#include <stdio.h>
X#include "vim.h"
X
X void


Xmain(argc, argv)
X int argc;
X char **argv;
X{

X register int c;
X char buffer[100];
X int count;
X int i;
X FILE *ifp, *ofp;
X
X if (argc != 3)
X {
X fprintf(stderr, "Usage: mkcmdtab cmdtab.tab cmdtab.h\n");
X exit(10);
X }
X ifp = fopen(argv[1], "r");
X if (ifp == NULL)
X {
X perror(argv[1]);
X exit(10);
X }
X ofp = fopen(argv[2], "w");
X if (ofp == NULL)
X {
X perror(argv[2]);
X exit(10);
X }
X
X while ((c = getc(ifp)) != '|' && c != EOF)
X putc(c, ofp);
X fprintf(ofp, "THIS FILE IS AUTOMATICALLY PRODUCED - DO NOT EDIT");
X while ((c = getc(ifp)) != '|' && c != EOF)
X ;
X while ((c = getc(ifp)) != '|' && c != EOF)
X putc(c, ofp);
X
X count = 0;
X while ((c = getc(ifp)) != '|' && c != EOF)
X {
X putc(c, ofp);
X while ((c = getc(ifp)) != '"' && c != EOF)
X putc(c, ofp);
X putc(c, ofp);
X
X i = 0;
X while ((c = getc(ifp)) != '"' && c != EOF)
X {
X putc(c, ofp);
X buffer[i++] = c;
X }
X putc(c, ofp);
X buffer[i] = 0;
X
X while ((c = getc(ifp)) != '\n' && c != EOF)
X putc(c, ofp);
X putc(c, ofp);
X
X switch (buffer[0])
X {
X case '@': strcpy(buffer, "at");
X break;
X case '!': strcpy(buffer, "bang");
X break;
X case '<': strcpy(buffer, "lshift");
X break;
X case '>': strcpy(buffer, "rshift");
X break;
X case '=': strcpy(buffer, "equal");
X break;
X case '&': strcpy(buffer, "and");
X break;
X case '~': strcpy(buffer, "tilde");
X break;
X }
X
X fprintf(ofp, "#define CMD_%s %d\n", buffer, count++);
X }
X
X fprintf(ofp, "#define CMD_SIZE %d\n", count);
X
X while ((c = getc(ifp)) != '|' && c != EOF)
X putc(c, ofp);
X
X if (c != '|')
X {
X fprintf(stderr, "not enough |'s\n");
X exit(1);
X }
X exit(0);
X}
END_OF_FILE
if test 2066 -ne `wc -c <'vim/src/mkcmdtab.c'`; then
echo shar: \"'vim/src/mkcmdtab.c'\" unpacked with wrong size!
fi
# end of 'vim/src/mkcmdtab.c'
fi
if test -f 'vim/src/msdos.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/msdos.h'\"
else
echo shar: Extracting \"'vim/src/msdos.h'\" \(2033 characters\)
sed "s/^X//" >'vim/src/msdos.h' <<'END_OF_FILE'
X/* vi:ts=8:sw=4


X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * MSDOS Machine-dependent filenames.
X */
X#ifdef SYSEXRC_FILE
X# undef SYSEXRC_FILE
X# undef SYSVIMRC_FILE
X#endif /* SYSEXRC_FILE */
X#define SYSEXRC_FILE "$VIM\\_exrc"
X#define SYSVIMRC_FILE "$VIM\\_vimrc"
X
X#ifdef EXRC_FILE
X# undef EXRC_FILE
X# undef VIMRC_FILE
X#endif /* EXRC_FILE */
X#define EXRC_FILE "_exrc"
X#define VIMRC_FILE "_vimrc"
X
X#ifdef VIM_HLP
X# undef VIM_HLP
X#endif /* VIM_HLP */
X#define VIM_HLP "$VIM\\vim.hlp"
X
X#ifdef TMPNAME1
X# undef TMPNAME1
X# undef TMPNAME2
X# undef TMPNAMELEN
X#endif /* TMPNAME1 */
X#define TMPNAME1 "viXXXXXX" /* put it in current dir */
X#define TMPNAME2 "voXXXXXX" /* is there a better place? */
X#define TMPNAMELEN 10
X
X/*
X * MSDOS Machine-dependent routines.
X */
X
X#undef remove /* MSDOS remove()s when not readonly */
X
X/* msdos.c */
Xvoid vim_delay __ARGS((void));
Xint remove __ARGS((char *));
Xvoid flushbuf __ARGS((void));
Xvoid outchar __ARGS((unsigned));
Xvoid outstr __ARGS((char *));
Xint GetChars __ARGS((char *, int, int));
Xvoid textfile __ARGS((int));
Xvoid mch_suspend __ARGS((void));
Xvoid mch_windinit __ARGS((void));
Xvoid check_win __ARGS((int, char **));
Xvoid fname_case __ARGS((char *));
Xvoid settitle __ARGS((char *));
Xvoid resettitle __ARGS((void));
Xint dirname __ARGS((char *, int));
Xint FullName __ARGS((char *, char *, int));
Xlong getperm __ARGS((char *));
Xint setperm __ARGS((char *, int));
Xint isdir __ARGS((char *));
Xvoid mch_windexit __ARGS((int));
Xvoid mch_settmode __ARGS((int));
Xint mch_get_winsize __ARGS((void));
Xvoid mch_set_winsize __ARGS((void));
Xint call_shell __ARGS((char *, int));
Xvoid breakcheck __ARGS((void));
Xchar *modname __ARGS((char *, char *));
X#ifdef WILD_CARDS
Xint has_wildcard __ARGS((char *));
Xint ExpandWildCards __ARGS((int, char **, int *, char ***, int, int));
Xvoid FreeWild __ARGS((int, char **));
X#endif
END_OF_FILE
if test 2033 -ne `wc -c <'vim/src/msdos.h'`; then
echo shar: \"'vim/src/msdos.h'\" unpacked with wrong size!
fi
# end of 'vim/src/msdos.h'
fi
if test -f 'vim/src/ops.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/ops.h'\"
else
echo shar: Extracting \"'vim/src/ops.h'\" \(1963 characters\)
sed "s/^X//" >'vim/src/ops.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * ops.h: things shared between normal.c, cmdline.c and ops.c
X */
X
X/*
X * Operators
X */
X#define NOP 0 /* no pending operation */
X#define DELETE 1
X#define YANK 2
X#define CHANGE 3
X#define LSHIFT 4
X#define RSHIFT 5
X#define FILTER 6
X#define TILDE 7
X#define INDENT 8
X#define FORMAT 9
X#define COLON 10
X#define UPPER 11
X#define LOWER 12
X
X/*
X * operator characters; the order must correspond to the defines above
X */
XEXTERN char *opchars INIT(= "dyc<>!~=V:uU");
X
X/*
X * When a cursor motion command is made, it is marked as being a character or
X * line oriented motion. Then, if an operator is in effect, the operation
X * becomes character or line oriented accordingly.
X *
X * Character motions are marked as being inclusive or not. Most char. motions
X * are inclusive, but some (e.g. 'w') are not.
X *
X * Generally speaking, every command in normal() should either clear any pending
X * operator (with CLEAROP), or set the motion type variable.
X */
X
X/*
X * Motion types
X */
X#define MBAD (-1) /* 'bad' motion type marks unusable yank buf */
X#define MCHAR 0
X#define MLINE 1
X#define MBLOCK 2
X
XEXTERN int operator INIT(= NOP); /* current pending operator */
XEXTERN int mtype; /* type of the current cursor motion */
XEXTERN int mincl; /* true if char motion is inclusive */
XEXTERN int oneless; /* 1 if !mincl and startop != endop */
XEXTERN FPOS startop; /* cursor pos. at start of operator */
XEXTERN FPOS endop; /* cursor pos. at end of operator */
XEXTERN colnr_t startvcol; /* start col for block mode operator */
XEXTERN colnr_t endvcol; /* end col for block mode operator */
XEXTERN long nlines; /* lines between startop and endop + 1 */
XEXTERN int yankbuffer INIT(= 0); /* current yank buffer */
END_OF_FILE
if test 1963 -ne `wc -c <'vim/src/ops.h'`; then
echo shar: \"'vim/src/ops.h'\" unpacked with wrong size!
fi
# end of 'vim/src/ops.h'
fi
if test -f 'vim/src/sun_stdlib.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/sun_stdlib.h'\"
else
echo shar: Extracting \"'vim/src/sun_stdlib.h'\" \(1868 characters\)
sed "s/^X//" >'vim/src/sun_stdlib.h' <<'END_OF_FILE'
X/*
X * sun_stdlib.h: declararions used on a sun
X */
X
X#ifndef __stdlib_h
Xextern void free(void *);
Xextern void *malloc(unsigned);
Xextern void *realloc(void *, unsigned);
Xextern void *calloc(unsigned, unsigned);
X#endif
X#ifdef __sys_types_h


Xextern off_t lseek(int, off_t, int);
X

X# ifdef _sys_time_h
Xextern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
X# endif _sys_time_h
X
X#else
Xextern long lseek(int, long, int);
X#endif
X
Xextern long tell(int);
Xextern void perror(char *);
X
X#ifndef __sys_fcntlcom_h


Xextern int open(char *, int, ...);
X#endif
Xextern int close(int);
Xextern int read(int, char *, unsigned);
Xextern int write(int, char *, unsigned);
Xextern int ioctl(int, int, ...);
Xextern int unlink(char *);
X

X#ifdef FILE


Xextern int _filbuf(FILE *);
Xextern int _flsbuf(unsigned char, FILE *);

Xextern int fclose(FILE *);
Xextern int fprintf(FILE *, char *, ...);
Xextern int fscanf(FILE *, char *, ...);
Xextern int fseek(FILE *, long, int);
Xextern int fflush(FILE *);
Xextern int fread(char *, int, int, FILE *);
X#else
Xextern char *sprintf(char *, char *, ...);
X#endif
X
Xextern int printf(char *, ...);
X
Xextern int scanf(char *, ...);
Xextern int sscanf(char *, char *, ...);
X
Xextern int system(char *);
Xextern char *getenv(char *);


X
Xextern char *getcwd(char *, int);

Xextern char *getwd(char *);


X
Xextern int chdir(char *);

Xextern int getuid(void);
Xextern int getgid(void);
X

Xextern int atoi (char *);
Xextern long atol(char *);

Xextern long strtol(char * , char **, int);
X
Xextern void bcopy(char *, char *, int);
Xextern int bcmp(char *, char *, int);
Xextern void bzero(char *, int);
X
Xextern char *memccpy(char *, char *, int, int);
Xextern char *memchr(char *, int, int);
Xextern char *memset(char *, int, int);
X
Xextern int strncmp(char *, char *, int);
Xextern int strcasecmp(char *, char *);
X
Xextern int toupper(int);
Xextern int tolower(int);
Xextern int isatty(int);
END_OF_FILE
if test 1868 -ne `wc -c <'vim/src/sun_stdlib.h'`; then
echo shar: \"'vim/src/sun_stdlib.h'\" unpacked with wrong size!
fi
# end of 'vim/src/sun_stdlib.h'
fi
if test -f 'vim/src/tcconfig.tc.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/tcconfig.tc.uue'\"
else
echo shar: Extracting \"'vim/src/tcconfig.tc.uue'\" \(2410 characters\)
sed "s/^X//" >'vim/src/tcconfig.tc.uue' <<'END_OF_FILE'
X
Xbegin 644 tcconfig.tc
XM5'5R8F\@0R!#;VYF:6=U<F%T:6]N($9I;&4@&@`!#1(7`1H``@$!``(````";
XM``(``0`#``(``@`$``$```4``0``!@`!```(``$`!`D``@````T``@`!``X`2
XM`@```!$``0`($@`"````$P`"`!D`%``"````%0`"``$`%@`"````%P`"``$`^
XM&``"``$`9``!``%E``$``68``0`!9P`!``%H``$``6D``0`!:@`!``%K``$`F
XM`6P``0`!;0`!``%N``$``6\``0`!<``!``%Q``$``7(``0`!<P`!``%T``$`"
XM`74``0`!=@`!``%W``$``7@``0`!>0`!``%Z``$``7L``0``?``!``%]``$`2
XM`7X``0``?P`!``&```$``8(``0``A``!``&%``$``<@``0``R0`!``#*``$`Q
XM`<L``0``S``!``#-``$``,X``0`!SP`!``#0``$`&=$``0!DT@`!`"#5``$`Q
XM`-<``0``V``!``#9``$``=H``0`!VP`!``#<``$``=T``0`!W@`!``#?``$``
XM`.```0``X0`!``#B``$``2P!1```````````````````````````````````8
XM`````````````````````````````````````````````````````````"T!N
XM@`!$.EQ40UQ)3D-,541%````````````````````````````````````````1
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````"X!@`!$S
XM.EQ40UQ,24(`````````````````````````````````````````````````@
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````"\!4`!624TN:
XM4%)*````````````````````````````````````````````````````````L
XM`````````````````````````````````````````#`!!``S,@``,0$%`#(UX
XM````,@$%`#$P,```,P%_`$U31$]3.U=)3$1?0T%21%,`````````````````Y
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM```````````T`1X`*@``````````````````````````````````````-0$>1
XM`"H``````````````````````````````````````#8!'@`J````````````I
XM```````````````````````````W`1X`*@```````````````````````````
XM````````````.`$>`"H``````````````````````````````````````#D![
XM'@`J```````````````````````````````````````Z`1X`*@``````````+
XM````````````````````````````.P$>`"H`````````````````````````$
XM`````````````#P!'@`J```````````````````````````````````````]"
XM`8``````````````````````````````````````````````````````````!
XM`````````````````````````````````````````````````````````````
XM```````````````````````````````````````````````````````^`00`#
XM.````#\!4```````````````````````````````````````````````````(
XM`````````````````````````````````````````````````````````$`!!
XM1`!$.EQ40P``````````````````````````````````````````````````U
XM`````````````````````````````````$$!4```````````````````````2
XM`````````````````````````````````````````````````````````````
X9`````````````````````````/__`@`:````:
X``
Xend
Xsize 1690
END_OF_FILE
if test 2410 -ne `wc -c <'vim/src/tcconfig.tc.uue'`; then
echo shar: \"'vim/src/tcconfig.tc.uue'\" unpacked with wrong size!
fi
# end of 'vim/src/tcconfig.tc.uue'
fi
if test -f 'vim/src/unix.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/unix.h'\"
else
echo shar: Extracting \"'vim/src/unix.h'\" \(1925 characters\)
sed "s/^X//" >'vim/src/unix.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * Unix system-dependent filenames
X */
X#define BACKUPDIR "~/"
X
X#ifdef TMPNAME1
X# undef TMPNAME1
X# undef TMPNAME2
X# undef TMPNAMELEN
X#endif /* TMPNAME1 */
X#define TMPNAME1 "/tmp/viXXXXXX"
X#define TMPNAME2 "/tmp/voXXXXXX"
X#define TMPNAMELEN 15
X
X#ifdef MAX_COLUMNS
X# undef MAX_COLUMNS
X#endif /* MAX_COLUMNS */
X#define MAX_COLUMNS 1024
X
X#define stricmp vim_stricmp
X
Xvoid flushbuf __ARGS((void));
Xvoid outchar __ARGS((unsigned));
Xvoid outstr __ARGS((char *));
Xint GetChars __ARGS((char *, int, int));
Xvoid vim_delay __ARGS((void));
Xvoid mch_suspend __ARGS((void));
Xvoid mch_windinit __ARGS((void));
Xvoid check_win __ARGS((int, char **));
Xvoid fname_case __ARGS((char *));
Xvoid settitle __ARGS((char *));
Xvoid resettitle __ARGS((void));
Xvoid mch_settmode __ARGS((int));
Xint dirname __ARGS((char *, int));
Xint FullName __ARGS((char *, char *, int));
Xlong getperm __ARGS((char *));
Xint setperm __ARGS((char *, int));
Xint isdir __ARGS((char *));
Xvoid mch_windexit __ARGS((int));
Xint mch_get_winsize __ARGS((void));
Xvoid mch_set_winsize __ARGS((void));
Xint call_shell __ARGS((char *, int));
Xvoid breakcheck __ARGS((void));
X#ifndef linux
Xint remove __ARGS((char *));
X
X/* generic functions, not in unix.c */
Xvoid sleep __ARGS((int));
Xint rename __ARGS((char *, char *));
X#endif
X
Xint stricmp __ARGS((char *, char *));
X
X#ifdef WILD_CARDS
Xint has_wildcard __ARGS((char *));
Xint ExpandWildCards __ARGS((int, char **, int *, char ***, int, int));
Xvoid FreeWild __ARGS((int, char **));
X#endif
X
X/* memmove is not present on all systems, use bcopy or memcpy */
X#ifdef SYSV
X#define memmove(to, from, len) memcpy(to, from, len)
X#else
X#define memmove(to, from, len) bcopy(from, to, len);
X#endif
END_OF_FILE
if test 1925 -ne `wc -c <'vim/src/unix.h'`; then
echo shar: \"'vim/src/unix.h'\" unpacked with wrong size!
fi
# end of 'vim/src/unix.h'
fi
if test -f 'vim/termcap' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/termcap'\"
else
echo shar: Extracting \"'vim/termcap'\" \(2694 characters\)
sed "s/^X//" >'vim/termcap' <<'END_OF_FILE'
X#
X# Demonstration of a termcap file
X#
Xsx|ansi|any ansi terminal with pessimistic assumptions:\
X :co#80:li#24:cl=50\E[;H\E[2J:bs:am:cm=\E[%i%d;%dH:\
X :nd=\E[C:up=\E[A:ce=\E[K:ho=\E[H:pt:
XMu|sun|Sun Microsystems Workstation console:\
X :am:bs:km:mi:ms:pt:li#34:co#80:cl=^L:cm=\E[%i%d;%dH:\
X :ce=\E[K:cd=\E[J:\
X :so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:rs=\E[s:\
X :md=\E[1m:mr=\E[7m:me=\E[m:\
X :al=\E[L:dl=\E[M:im=:ei=:ic=\E[@:dc=\E[P:\
X :AL=\E[%dL:DL=\E[%dM:IC=\E[%d@:DC=\E[%dP:\
X :up=\E[A:nd=\E[C:ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:\
X :k1=\E[224z:k2=\E[225z:k3=\E[226z:k4=\E[227z:k5=\E[228z:\
X :k6=\E[229z:k7=\E[230z:k8=\E[231z:k9=\E[232z:
XM-|sun-e|sun-nic|sune|Sun Microsystems Workstation without insert character:\
X :ic@:im@:ei@:tc=sun:
XMu|sun-s|Sun Microsystems Workstation window with status line:\
X :hs:ts=\E]l:fs=\E\\:ds=\E]l\E\\:tc=sun:
XMu|sun-e-s|sun-s-e|Sun Microsystems Workstation with status hacked for emacs:\
X :hs:ts=\E]l:fs=\E\\:ds=\E]l\E\\:tc=sun-e:
XM0|sun-48|Sun 48-line window:\
X :li#48:co#80:tc=sun:
XM1|sun-34|Sun 34-line window:\
X :li#34:co#80:tc=sun:
XM2|sun-24|Sun 24-line window:\
X :li#24:co#80:tc=sun:
XM3|sun-17|Sun 17-line window:\
X :li#17:co#80:tc=sun:
Xv9|925a|tvi925a|TeleVideo Model 925:\
X :al=\EE:am:bs:bt=\EI:bw:cd=\EY:ce=\ET:cl=^Z:cm=\E=%+ %+ :co#80:dc=\EW:\
X :dl=\ER:do=^V:ei=:ic=\EQ:if=/usr/share/lib/tabset/std:im=:kb=^H:kd=^V:\
X :kh=^^:kl=^H:kn#12:kr=^L:ku=^K:li#24:nd=^L:pt:se=\EG0:sg#1:so=\EG4:\
X :ue=\EG0:ug#1:ul:up=^K:us=\EG8:is=\El\
X :vb=\Eb\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ed:\
X :ve=\E.4:vs=\E.2:
Xd0|vt100|vt100-am|vt100am|dec vt100:\
X :do=^J:co#80:li#24:cl=50\E[;H\E[2J:sf=5\ED:\
X :le=^H:bs:am:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\
X :ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\
X :md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:is=\E[1;24r\E[24;1H:\
X :rf=/usr/share/lib/tabset/vt100:\
X :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\
X :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\
X :ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=5\EM:vt#3:xn:\
X :sc=\E7:rc=\E8:cs=\E[%i%d;%dr:
X# Amiga termcap by Bram Moolenaar
XAA|amiga|Amiga ANSI:\
X :co#80:li#25:am:do=\E[B:ce=\E[K:cd=\E[J:\
X :cl=\014:ku=\233A:kd=\233B:kl=\233D:kr=\233C:kb=^H:\
X :#4=\233 A:%i=\233 @:%1=\233?~:\
X :k1=\2330~:k2=\2331~:k3=\2332~:k4=\2333~:k5=\2334~:\
X :k6=\2335~:k7=\2336~:k8=\2337~:k9=\2338~:k;=\2339~:\
X :F1=\23310~:F2=\23311~:F3=\23312~:F4=\23313~:F5=\23314~:\
X :F6=\23315~:F7=\23316~:F8=\23317~:F9=\23318~:FA=\23319~:\
X :al=\E[L:AL=\E[%dL:dl=\E[M:DL=\E[%dM:le=^H:cm=\E[%i%d;%dH:\
X :nd=\E[C:RI=\E[%dC:up=\E[A:\
X :ce=\E[K:ho=\E[H:dc=\E[P:ic=\E[@:vi=\E[0 p:ve=\E[1 p:\
X :so=\E[2m:se=\E[m:us=\E[4m:ue=\E[m:mr=\E[7m:mb=\E[7;2m:me=\E[m:
X#
X# END OF TERMCAP
X#
END_OF_FILE
if test 2694 -ne `wc -c <'vim/termcap'`; then
echo shar: \"'vim/termcap'\" unpacked with wrong size!
fi
# end of 'vim/termcap'
fi
echo shar: End of archive 2 \(of 23\).
cp /dev/null ark2isdone

Bram Moolenaar

unread,
Apr 23, 1993, 1:29:08 PM4/23/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 3
Archive-name: vim/part03
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 3 (of 23)."
# Contents: vim/doc/vim.1 vim/src/arp_proto.h vim/src/cmdtab.h
# vim/src/cmdtab.tab vim/src/makefile.unix vim/src/param.h
# vim/src/quickfix.c vim/src/term.h vim/src/vim.h
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:06 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/vim.1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/vim.1'\"
else
echo shar: Extracting \"'vim/doc/vim.1'\" \(4378 characters\)
sed "s/^X//" >'vim/doc/vim.1' <<'END_OF_FILE'
X.TH VIM 1 "28 March 1992"
X.SH NAME
Xvim \- Vi IMitation, a programmers text editor
X.SH SYNOPSIS
X.B vim
X[options] [file ..]
X.br
X.B vim
X[options] \-t tag
X.br
X.B vim
X[options] +[command] file ..
X.br
X.B vim
X[options] \-c {command} file ..
X.br
X.B vim
X[options] \-e
X.SH DESCRIPTION
X.B Vim
Xis a text editor that is upwards compatible to vi. It can be used to edit any
XASCII text. It is especially useful for editing programs.
X.PP
XThere are a lot of enhancements above vi: multi level undo, command line
Xediting, filename completion, on line help, quoting, etc.. Read difference.doc
Xfor a summary of the differences between vi and Vim.
X.PP
XMost often
X.B Vim
Xis started to edit a single file with the command
X.PP
X vim file
X.PP
XMore generally VIM is started with:
X.PP
X vim [options] [filelist]
X.PP
XIf the filelist is missing, the editor will start with an empty buffer.
XOtherwise exactly one out of the following four may be used to choose one or
Xmore files to be edited.
X.TP 12
Xfile ..
XA list of file names. The first one (alphabetically) will be
Xthe current file and read into the buffer. The cursor will be
Xpositioned on the first line of the buffer. You can get to the other files
Xwith the ":next" command.
X.TP
X+[num] file ..
XSame as the above, but the cursor will be positioned on line
X"num". If "num" is missing, the cursor will be positioned on
Xthe last line.
X.TP
X+/pat file ..
XSame as the above, but the cursor will be positioned on the
Xfirst occurrence of "pat" in the current file (see reference.doc,
Xsection "pattern searches" for the available search
Xpatterns).
X.TP
X+{command} file ..
X.TP
X-c {command} file ..
XSame as the above, but {command} will be executed after the
Xfile has been read. {command} is interpreted as an Ex
Xcommand. If the {command} contains spaces it must
Xbe enclosed in double quotes (this depends on the shell that
Xis used).
XExample: Vim "+set si" main.c
X.TP
X-t {tag}
XThe file to edit and the initial cursor position depends on a "tag", a sort
Xof goto label. {tag} is looked up in the tags file, the associated file
Xbecomes the current file and the associated command is executed. Mostly this
Xis used for C programs. {tag} then should be a function name. The effect is
Xthat the file containing that function becomes the current file and the
Xcursor is positioned on the start of the function (see reference.doc,
Xsection "tag searches").
X.TP
X-e
XStart in quickFix mode. The error file "AztecC.Err"
Xis read and the first error is displayed. Further errors can be jumped to
Xwith the ":cn" command. See reference.doc section 5.6.
X.SH OPTIONS
XThe options, if present, must precede the filelist. The options may be given
Xin any order.
X.TP 12
X-r
XRecovery mode. The autoscript file is read to recover a
Xcrashed editing session. It has almost the same effect as
X"-s file.vim". See reference.doc, chapter "Recovery after a crash".
X.TP
X-v
XView mode. The 'readonly' option will be set. You can still
Xedit the buffer, but will be prevented from accidental
Xoverwriting a file. If you do want to overwrite a file, add
Xan exclamation mark to the Ex command, as in ":w!". The
X'readonly' option can be reset with ":set noro" (see reference.doc,
Xoptions chapter).
X.TP
X-n
XNo autoscript file will be written. Recovery after a crash
Xwill be impossible. Handy if you want to edit a file on a
Xvery slow medium (e.g. floppy). Can also be done with ":set
Xuc=0".
X.TP
X-s {scriptin}
XThe script file {scriptin} is read. The characters in the
Xfile are interpreted as if you had typed them. The same can
Xbe done with the command ":source! {scriptin}". If the end
Xof the file is reached before the editor exits, further
Xcharacters are read from the keyboard.
X.TP
X-w {scriptout}
XAll the characters that you type are recorded in the file
X{scriptout}, until you exit VIM. This is useful if you want
Xto create a script file to be used with "vim -s" or
X":source!".
X.TP
X-T terminal
XTells Vim the name of the terminal you are using. Should be a terminal known
Xto Vim (builtin) or defined in the termcap file.
X.TP
X-d device
XOpen "device" for use as a terminal. Only on the Amiga. Example:
X"\-d con:20/30/600/150".
X.SH SEE ALSO
XVim documentation: Reference.doc, index, difference.doc, unix.doc, vim.hlp.
X.SH AUTHOR
XMost of VIM was made by Bram Moolenaar.
X.br
XVIM is based on Stevie, worked on by: Tim Thompson,
XTony Andrews and G.R. (Fred) Walter
X.SH BUGS
XProbably.
END_OF_FILE
if test 4378 -ne `wc -c <'vim/doc/vim.1'`; then
echo shar: \"'vim/doc/vim.1'\" unpacked with wrong size!
fi
# end of 'vim/doc/vim.1'
fi
if test -f 'vim/src/arp_proto.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/arp_proto.h'\"
else
echo shar: Extracting \"'vim/src/arp_proto.h'\" \(6655 characters\)
sed "s/^X//" >'vim/src/arp_proto.h' <<'END_OF_FILE'
X#ifndef PROTO_ARP_H
X#define PROTO_ARP_H 1
X
X/*
X ************************************************************************
X * The arp copies of the dos.library calls... *
X ************************************************************************
X */
X
X/* Only include these if you can use ARP.library without dos.library... */
X#ifdef DO_ARP_COPIES
X#pragma amicall(ArpBase, 0x1E, Open(d1, d2))
X#pragma amicall(ArpBase, 0x24, Close(d1))
X#pragma amicall(ArpBase, 0x2A, Read(d1, d2, d3))
X#pragma amicall(ArpBase, 0x30, Write(d1, d2, d3))
X#pragma amicall(ArpBase, 0x36, Input())
X#pragma amicall(ArpBase, 0x3C, Output())
X#pragma amicall(ArpBase, 0x42, Seek(d1, d2, d3))
X#pragma amicall(ArpBase, 0x48, DeleteFile(d1))
X#pragma amicall(ArpBase, 0x4E, Rename(d1, d2))
X#pragma amicall(ArpBase, 0x54, Lock(d1, d2))
X#pragma amicall(ArpBase, 0x5A, UnLock(d1))
X#pragma amicall(ArpBase, 0x60, DupLock(d1))
X#pragma amicall(ArpBase, 0x66, Examine(d1, d2))
X#pragma amicall(ArpBase, 0x6C, ExNext(d1, d2))
X#pragma amicall(ArpBase, 0x72, Info(d1, d2))
X#pragma amicall(ArpBase, 0x78, CreateDir(d1))
X#pragma amicall(ArpBase, 0x7E, CurrentDir(d1))
X#pragma amicall(ArpBase, 0x84, IoErr())
X#pragma amicall(ArpBase, 0x8A, CreateProc(d1, d2, d3, d4))
X#pragma amicall(ArpBase, 0x90, Exit(d1))
X#pragma amicall(ArpBase, 0x96, LoadSeg(d1))
X#pragma amicall(ArpBase, 0x9C, UnLoadSeg(d1))
X#pragma amicall(ArpBase, 0xAE, DeviceProc(d1))
X#pragma amicall(ArpBase, 0xB4, SetComment(d1, d2))
X#pragma amicall(ArpBase, 0xBA, SetProtection(d1, d2))
X#pragma amicall(ArpBase, 0xC0, DateStamp(d1))
X#pragma amicall(ArpBase, 0xC6, Delay(d1))
X#pragma amicall(ArpBase, 0xCC, WaitForChar(d1, d2))
X#pragma amicall(ArpBase, 0xD2, ParentDir(d1))
X#pragma amicall(ArpBase, 0xD8, IsInteractive(d1))
X#pragma amicall(ArpBase, 0xDE, Execute(d1, d2, d3))
X#endif
X
X/*
X ************************************************************************
X * Stuff only in arp.library *
X ************************************************************************
X */
X/* amicall(ArpBase, 0x0E4, Printf(a0, a1)) This does not work without glue */
X/* amicall(ArpBase, 0x0EA, FPrintf(d0, a0, a1)) This does not work without glue */
X#pragma amicall(ArpBase, 0x0F0, Puts(a1))
X#pragma amicall(ArpBase, 0x0F6, Readline(a0))
X#pragma amicall(ArpBase, 0x0FC, GADS(a0, d0, a1, a2, a3))
X#pragma amicall(ArpBase, 0x102, Atol(a0))
X#pragma amicall(ArpBase, 0x108, EscapeString(a0))
X#pragma amicall(ArpBase, 0x10E, CheckAbort(a1))
X#pragma amicall(ArpBase, 0x114, CheckBreak(d1, a1))
X#pragma amicall(ArpBase, 0x11A, Getenv(a0, a1, d0))
X#pragma amicall(ArpBase, 0x120, Setenv(a0, a1))
X#pragma amicall(ArpBase, 0x126, FileRequest(a0))
X#pragma amicall(ArpBase, 0x12C, CloseWindowSafely(a0, a1))
X#pragma amicall(ArpBase, 0x132, CreatePort(a0, d0))
X#pragma amicall(ArpBase, 0x138, DeletePort(a1))
X#pragma amicall(ArpBase, 0x13E, SendPacket(d0, a0, a1))
X#pragma amicall(ArpBase, 0x144, InitStdPacket(d0, a0, a1, a2))
X#pragma amicall(ArpBase, 0x14A, PathName(d0, a0, d1))
X#pragma amicall(ArpBase, 0x150, Assign(a0, a1))
X#pragma amicall(ArpBase, 0x156, DosAllocMem(d0))
X#pragma amicall(ArpBase, 0x15C, DosFreeMem(a1))
X#pragma amicall(ArpBase, 0x162, BtoCStr(a0, d0, d1))
X#pragma amicall(ArpBase, 0x168, CtoBStr(a0, d0, d1))
X#pragma amicall(ArpBase, 0x16E, GetDevInfo(a2))
X#pragma amicall(ArpBase, 0x174, FreeTaskResList())
X#pragma amicall(ArpBase, 0x17A, ArpExit(d0, d2))
X#pragma amicall(ArpBase, 0x180, ArpAlloc(d0))
X/* amicall(ArpBase, 0x186, ArpAllocMem(d0, d1)) Secondary result - IoErr() */
X/* amicall(ArpBase, 0x18C, ArpOpen(d1, d2)) Secondary result - IoErr() */
X/* amicall(ArpBase, 0x192, ArpDupLock(d1)) Secondary result - IoErr() */
X/* amicall(ArpBase, 0x198, ArpLock(d1, d2)) Secondary result - IoErr() */
X/* amicall(ArpBase, 0x19E, RListAlloc(a0, d0)) Secondary result - IoErr() */
X#pragma amicall(ArpBase, 0x1A4, FindCLI(d0))
X#pragma amicall(ArpBase, 0x1AA, QSort(a0, d0, d1, a1))
X
X#pragma amicall(ArpBase, 0x1B0, PatternMatch(a0, a1))
X#pragma amicall(ArpBase, 0x1B6, FindFirst(d0, a0))
X#pragma amicall(ArpBase, 0x1BC, FindNext(a0))
X#pragma amicall(ArpBase, 0x1C2, FreeAnchorChain(a0))
X
X#pragma amicall(ArpBase, 0x1C8, CompareLock(d0, d1))
X
X#pragma amicall(ArpBase, 0x1CE, FindTaskResList())
X#pragma amicall(ArpBase, 0x1D4, CreateTaskResList())
X#pragma amicall(ArpBase, 0x1DA, FreeResList(a1))
X#pragma amicall(ArpBase, 0x1E0, FreeTrackedItem(a1))
X/* amicall(ArpBase, 0x1E6, GetTracker()) Stores the ID in the tracker */
X
X#pragma amicall(ArpBase, 0x1EC, GetAccess(a1))
X#pragma amicall(ArpBase, 0x1F2, FreeAccess(a1))
X
X#pragma amicall(ArpBase, 0x1F8, FreeDAList(a1))
X#pragma amicall(ArpBase, 0x1FE, AddDANode(a0, a1, d0, d1))
X#pragma amicall(ArpBase, 0x204, AddDADevs(a0, d0))
X
X#pragma amicall(ArpBase, 0x20A, Strcmp(a0, a1))
X#pragma amicall(ArpBase, 0x210, Strncmp(a0, a1, d0))
X#pragma amicall(ArpBase, 0x216, Toupper(d0))
X#pragma amicall(ArpBase, 0x21C, SyncRun(a0, a1, d0, d1))
X
X/*
X ************************************************************************
X * Added V32 of arp.library *
X * Note that SpawnShell is ASyncRun but was added at V39 of arp... *
X ************************************************************************
X */
X#pragma amicall(ArpBase, 0x222, ASyncRun(a0, a1, a2))
X#pragma amicall(ArpBase, 0x222, SpawnShell(a0, a1, a2))
X#pragma amicall(ArpBase, 0x228, LoadPrg(d1))
X#pragma amicall(ArpBase, 0x22E, PreParse(a0, a1))
X
X/*
X ************************************************************************
X * Added V33 of arp.library *
X ************************************************************************
X */
X#pragma amicall(ArpBase, 0x234, StamptoStr(a0))
X#pragma amicall(ArpBase, 0x23A, StrtoStamp(a0))
X
X#pragma amicall(ArpBase, 0x240, ObtainResidentPrg(a0))
X#pragma amicall(ArpBase, 0x246, AddResidentPrg(d1, a0))
X#pragma amicall(ArpBase, 0x24C, RemResidentPrg(a0))
X#pragma amicall(ArpBase, 0x252, UnLoadPrg(d1))
X#pragma amicall(ArpBase, 0x258, LMult(d0, d1))
X#pragma amicall(ArpBase, 0x25E, LDiv(d0, d1))
X#pragma amicall(ArpBase, 0x264, LMod(d0, d1))
X
X#pragma amicall(ArpBase, 0x26A, CheckSumPrg(d1))
X#pragma amicall(ArpBase, 0x270, TackOn(a0, a1))
X#pragma amicall(ArpBase, 0x276, BaseName(a0))
X#pragma amicall(ArpBase, 0x27C, ReleaseResidentPrg(d1))
X
X/*
X ************************************************************************
X * Added V36 of arp.library *
X ************************************************************************
X */
X/* amicall(ArpBase, 0x282, SPrintf(d0, a0, a1)) This does not work without glue */
X#pragma amicall(ArpBase, 0x288, GetKeywordIndex(a0, a1))
X/* amicall(ArpBase, 0x28E, ArpOpenLibrary(a1, d0)) Secondary result - IoErr() */
X#pragma amicall(ArpBase, 0x294, ArpAllocFreq())
X
X#endif
END_OF_FILE
if test 6655 -ne `wc -c <'vim/src/arp_proto.h'`; then
echo shar: \"'vim/src/arp_proto.h'\" unpacked with wrong size!
fi
# end of 'vim/src/arp_proto.h'
fi
if test -f 'vim/src/cmdtab.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/cmdtab.h'\"
else
echo shar: Extracting \"'vim/src/cmdtab.h'\" \(5973 characters\)
sed "s/^X//" >'vim/src/cmdtab.h' <<'END_OF_FILE'
X/* vi:ts=4


X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * THIS FILE IS AUTOMATICALLY PRODUCED - DO NOT EDIT
X */
X
X#define RANGE 0x01 /* allow a linespecs */
X#define BANG 0x02 /* allow a ! after the command name */
X#define EXTRA 0x04 /* allow extra args after command name */
X#define XFILE 0x08 /* expand wildcards in extra part */
X#define NOSPC 0x10 /* no spaces allowed in the extra part */
X#define DFLALL 0x20 /* default file range is 1,$ */
X#define NODFL 0x40 /* do not default to the current file name */
X#define NEEDARG 0x80 /* argument required */
X#define TRLBAR 0x100 /* check for trailing vertical bar */
X#define REGSTR 0x200 /* allow "x for register designation */
X#define COUNT 0x400 /* allow count in argument */
X#define NOTRLCOM 0x800 /* no trailing comment allowed */
X#define ZEROR 0x1000 /* zero line number allowed */
X#define USECTRLV 0x2000 /* do not remove CTRL-V from argument */
X#define FILES (XFILE + EXTRA) /* multiple extra files allowed */
X#define WORD1 (EXTRA + NOSPC) /* one extra word allowed */
X#define FILE1 (FILES + NOSPC) /* 1 file allowed, defaults to current file */
X#define NAMEDF (FILE1 + NODFL) /* 1 file allowed, defaults to "" */
X#define NAMEDFS (FILES + NODFL) /* multiple files allowed, default is "" */
X
X/*
X * This array maps ex command names to command codes. The order in which
X * command names are listed below is significant -- ambiguous abbreviations
X * are always resolved to be the first possible match (e.g. "r" is taken
X * to mean "read", not "rewind", because "read" comes before "rewind").
X * Not supported commands are included to avoid ambiguities.
X */
Xstatic struct
X{
X char *cmd_name; /* name of the command */
X short cmd_argt; /* command line arguments permitted/needed/used */
X} cmdnames[] =
X{
X {"append", BANG+RANGE+TRLBAR}, /* not supported */
X#define CMD_append 0
X {"abbreviate", EXTRA+TRLBAR+NOTRLCOM}, /* not supported */
X#define CMD_abbreviate 1
X {"args", TRLBAR},
X#define CMD_args 2
X {"change", BANG+RANGE+COUNT+TRLBAR}, /* not supported */
X#define CMD_change 3
X {"cd", NAMEDF+TRLBAR},
X#define CMD_cd 4
X {"cc", TRLBAR+WORD1+BANG},
X#define CMD_cc 5
X {"cf", TRLBAR+FILE1+BANG},
X#define CMD_cf 6
X {"cl", TRLBAR},
X#define CMD_cl 7
X {"cn", TRLBAR+BANG},
X#define CMD_cn 8
X {"cp", TRLBAR+BANG},
X#define CMD_cp 9
X {"cq", TRLBAR+BANG},
X#define CMD_cq 10
X {"copy", RANGE+EXTRA+TRLBAR},
X#define CMD_copy 11
X {"chdir", NAMEDF+TRLBAR},
X#define CMD_chdir 12
X {"delete", RANGE+REGSTR+COUNT+TRLBAR},
X#define CMD_delete 13
X {"display", TRLBAR},
X#define CMD_display 14
X {"digraph", EXTRA+TRLBAR},
X#define CMD_digraph 15
X {"edit", BANG+FILE1+TRLBAR},
X#define CMD_edit 16
X {"ex", BANG+FILE1+TRLBAR},
X#define CMD_ex 17
X {"file", FILE1+TRLBAR},
X#define CMD_file 18
X {"files", TRLBAR},
X#define CMD_files 19
X {"global", RANGE+BANG+EXTRA+DFLALL},
X#define CMD_global 20
X {"help", TRLBAR},
X#define CMD_help 21
X {"insert", BANG+RANGE+TRLBAR}, /* not supported */
X#define CMD_insert 22
X {"join", RANGE+COUNT+TRLBAR},
X#define CMD_join 23
X {"jumps", TRLBAR},
X#define CMD_jumps 24
X {"k", RANGE+WORD1+TRLBAR},
X#define CMD_k 25
X {"list", RANGE+COUNT+TRLBAR},
X#define CMD_list 26
X {"move", RANGE+EXTRA+TRLBAR},
X#define CMD_move 27
X {"mark", RANGE+WORD1+TRLBAR},
X#define CMD_mark 28
X {"marks", TRLBAR},
X#define CMD_marks 29
X {"map", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_map 30
X {"mkexrc", BANG+FILE1+TRLBAR},
X#define CMD_mkexrc 31
X {"mkvimrc", BANG+FILE1+TRLBAR},
X#define CMD_mkvimrc 32
X {"next", RANGE+BANG+NAMEDFS+TRLBAR},
X#define CMD_next 33
X {"number", RANGE+COUNT+TRLBAR},
X#define CMD_number 34
X {"noremap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_noremap 35
X {"Next", RANGE+BANG+TRLBAR},
X#define CMD_Next 36
X {"print", RANGE+COUNT+TRLBAR},
X#define CMD_print 37
X {"pop", RANGE+TRLBAR+ZEROR},
X#define CMD_pop 38
X {"put", RANGE+BANG+REGSTR+TRLBAR},
X#define CMD_put 39
X {"previous", RANGE+BANG+TRLBAR},
X#define CMD_previous 40
X {"quit", BANG+TRLBAR},
X#define CMD_quit 41
X {"read", RANGE+NAMEDF+NEEDARG+TRLBAR+ZEROR},
X#define CMD_read 42
X {"rewind", BANG+TRLBAR},
X#define CMD_rewind 43
X {"recover", FILE1+TRLBAR}, /* not supported */
X#define CMD_recover 44
X {"substitute", RANGE+EXTRA},
X#define CMD_substitute 45
X {"set", EXTRA+TRLBAR},
X#define CMD_set 46
X {"setkeymap", NAMEDF+TRLBAR},
X#define CMD_setkeymap 47
X {"shell", TRLBAR},
X#define CMD_shell 48
X {"source", NAMEDF+NEEDARG+TRLBAR},
X#define CMD_source 49
X {"stop", TRLBAR+BANG},
X#define CMD_stop 50
X {"t", RANGE+EXTRA+TRLBAR},
X#define CMD_t 51
X {"tag", RANGE+BANG+WORD1+TRLBAR+ZEROR},
X#define CMD_tag 52
X {"tags", TRLBAR},
X#define CMD_tags 53
X {"undo", TRLBAR},
X#define CMD_undo 54
X {"unabbreviate", EXTRA+TRLBAR}, /* not supported */
X#define CMD_unabbreviate 55
X {"unmap", BANG+EXTRA+TRLBAR},
X#define CMD_unmap 56
X {"vglobal", RANGE+EXTRA+DFLALL},
X#define CMD_vglobal 57
X {"version", TRLBAR},
X#define CMD_version 58
X {"visual", RANGE+BANG+FILE1+TRLBAR},
X#define CMD_visual 59
X {"write", RANGE+BANG+FILE1+DFLALL+TRLBAR},
X#define CMD_write 60
X {"wnext", RANGE+BANG+FILE1+TRLBAR},
X#define CMD_wnext 61
X {"winsize", EXTRA+NEEDARG+TRLBAR},
X#define CMD_winsize 62
X {"wq", BANG+FILE1+DFLALL+TRLBAR},
X#define CMD_wq 63
X {"xit", BANG+FILE1+DFLALL+TRLBAR},
X#define CMD_xit 64
X {"yank", RANGE+REGSTR+COUNT+TRLBAR},
X#define CMD_yank 65
X {"z", RANGE+COUNT+TRLBAR}, /* not supported */
X#define CMD_z 66
X {"@", RANGE+EXTRA+TRLBAR},
X#define CMD_at 67
X {"!", RANGE+NAMEDFS},
X#define CMD_bang 68
X {"<", RANGE+COUNT+TRLBAR},
X#define CMD_lshift 69
X {">", RANGE+COUNT+TRLBAR},
X#define CMD_rshift 70
X {"=", RANGE+TRLBAR},
X#define CMD_equal 71
X {"&", RANGE+EXTRA},
X#define CMD_and 72
X {"~", RANGE+TRLBAR} /* not supported */
X#define CMD_tilde 73
X#define CMD_SIZE 74
X
X};
END_OF_FILE
if test 5973 -ne `wc -c <'vim/src/cmdtab.h'`; then
echo shar: \"'vim/src/cmdtab.h'\" unpacked with wrong size!
fi
# end of 'vim/src/cmdtab.h'
fi
if test -f 'vim/src/cmdtab.tab' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/cmdtab.tab'\"
else
echo shar: Extracting \"'vim/src/cmdtab.tab'\" \(4518 characters\)
sed "s/^X//" >'vim/src/cmdtab.tab' <<'END_OF_FILE'
X/* vi:ts=4


X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * |This file is read by mkcmdtab to produce cmdtab.h.
X *
X * The bars are used to recognize file positions. Do not insert/delete them.|
X */
X
X#define RANGE 0x01 /* allow a linespecs */
X#define BANG 0x02 /* allow a ! after the command name */
X#define EXTRA 0x04 /* allow extra args after command name */
X#define XFILE 0x08 /* expand wildcards in extra part */
X#define NOSPC 0x10 /* no spaces allowed in the extra part */
X#define DFLALL 0x20 /* default file range is 1,$ */
X#define NODFL 0x40 /* do not default to the current file name */
X#define NEEDARG 0x80 /* argument required */
X#define TRLBAR 0x100 /* check for trailing vertical bar */
X#define REGSTR 0x200 /* allow "x for register designation */
X#define COUNT 0x400 /* allow count in argument */
X#define NOTRLCOM 0x800 /* no trailing comment allowed */
X#define ZEROR 0x1000 /* zero line number allowed */
X#define USECTRLV 0x2000 /* do not remove CTRL-V from argument */
X#define FILES (XFILE + EXTRA) /* multiple extra files allowed */
X#define WORD1 (EXTRA + NOSPC) /* one extra word allowed */
X#define FILE1 (FILES + NOSPC) /* 1 file allowed, defaults to current file */
X#define NAMEDF (FILE1 + NODFL) /* 1 file allowed, defaults to "" */
X#define NAMEDFS (FILES + NODFL) /* multiple files allowed, default is "" */
X
X/*
X * This array maps ex command names to command codes. The order in which
X * command names are listed below is significant -- ambiguous abbreviations
X * are always resolved to be the first possible match (e.g. "r" is taken
X * to mean "read", not "rewind", because "read" comes before "rewind").
X * Not supported commands are included to avoid ambiguities.
X */
Xstatic struct
X{
X char *cmd_name; /* name of the command */
X short cmd_argt; /* command line arguments permitted/needed/used */
X} cmdnames[] =
X{
X| {"append", BANG+RANGE+TRLBAR}, /* not supported */
X {"abbreviate", EXTRA+TRLBAR+NOTRLCOM}, /* not supported */
X {"args", TRLBAR},
X {"change", BANG+RANGE+COUNT+TRLBAR}, /* not supported */
X {"cd", NAMEDF+TRLBAR},
X {"cc", TRLBAR+WORD1+BANG},
X {"cf", TRLBAR+FILE1+BANG},
X {"cl", TRLBAR},
X {"cn", TRLBAR+BANG},
X {"cp", TRLBAR+BANG},
X {"cq", TRLBAR+BANG},
X {"copy", RANGE+EXTRA+TRLBAR},
X {"chdir", NAMEDF+TRLBAR},
X {"delete", RANGE+REGSTR+COUNT+TRLBAR},
X {"display", TRLBAR},
X {"digraph", EXTRA+TRLBAR},
X {"edit", BANG+FILE1+TRLBAR},
X {"ex", BANG+FILE1+TRLBAR},
X {"file", FILE1+TRLBAR},
X {"files", TRLBAR},
X {"global", RANGE+BANG+EXTRA+DFLALL},
X {"help", TRLBAR},
X {"insert", BANG+RANGE+TRLBAR}, /* not supported */
X {"join", RANGE+COUNT+TRLBAR},
X {"jumps", TRLBAR},
X {"k", RANGE+WORD1+TRLBAR},
X {"list", RANGE+COUNT+TRLBAR},
X {"move", RANGE+EXTRA+TRLBAR},
X {"mark", RANGE+WORD1+TRLBAR},
X {"marks", TRLBAR},
X {"map", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"mkexrc", BANG+FILE1+TRLBAR},
X {"mkvimrc", BANG+FILE1+TRLBAR},
X {"next", RANGE+BANG+NAMEDFS+TRLBAR},
X {"number", RANGE+COUNT+TRLBAR},
X {"noremap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"Next", RANGE+BANG+TRLBAR},
X {"print", RANGE+COUNT+TRLBAR},
X {"pop", RANGE+TRLBAR+ZEROR},
X {"put", RANGE+BANG+REGSTR+TRLBAR},
X {"previous", RANGE+BANG+TRLBAR},
X {"quit", BANG+TRLBAR},
X {"read", RANGE+NAMEDF+NEEDARG+TRLBAR+ZEROR},
X {"rewind", BANG+TRLBAR},
X {"recover", FILE1+TRLBAR}, /* not supported */
X {"substitute", RANGE+EXTRA},
X {"set", EXTRA+TRLBAR},
X {"setkeymap", NAMEDF+TRLBAR},
X {"shell", TRLBAR},
X {"source", NAMEDF+NEEDARG+TRLBAR},
X {"stop", TRLBAR+BANG},
X {"t", RANGE+EXTRA+TRLBAR},
X {"tag", RANGE+BANG+WORD1+TRLBAR+ZEROR},
X {"tags", TRLBAR},
X {"undo", TRLBAR},
X {"unabbreviate", EXTRA+TRLBAR}, /* not supported */
X {"unmap", BANG+EXTRA+TRLBAR},
X {"vglobal", RANGE+EXTRA+DFLALL},
X {"version", TRLBAR},
X {"visual", RANGE+BANG+FILE1+TRLBAR},
X {"write", RANGE+BANG+FILE1+DFLALL+TRLBAR},
X {"wnext", RANGE+BANG+FILE1+TRLBAR},
X {"winsize", EXTRA+NEEDARG+TRLBAR},
X {"wq", BANG+FILE1+DFLALL+TRLBAR},
X {"xit", BANG+FILE1+DFLALL+TRLBAR},
X {"yank", RANGE+REGSTR+COUNT+TRLBAR},
X {"z", RANGE+COUNT+TRLBAR}, /* not supported */
X {"@", RANGE+EXTRA+TRLBAR},
X {"!", RANGE+NAMEDFS},
X {"<", RANGE+COUNT+TRLBAR},
X {">", RANGE+COUNT+TRLBAR},
X {"=", RANGE+TRLBAR},
X {"&", RANGE+EXTRA},
X {"~", RANGE+TRLBAR} /* not supported */
X|
X};
X|
END_OF_FILE
if test 4518 -ne `wc -c <'vim/src/cmdtab.tab'`; then
echo shar: \"'vim/src/cmdtab.tab'\" unpacked with wrong size!
fi
# end of 'vim/src/cmdtab.tab'
fi
if test -f 'vim/src/makefile.unix' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/makefile.unix'\"
else
echo shar: Extracting \"'vim/src/makefile.unix'\" \(4829 characters\)
sed "s/^X//" >'vim/src/makefile.unix' <<'END_OF_FILE'
X#
X# Makefile for Vim on Unix, using gcc or standard cc
X#
X
X#>>>>> choose bsd (Sun, Linux, HPUX) or system V (Dynix/PTX)
XMACHINE = -DBSD
X#MACHINE = -DSYSV
X
X#>>>>> choose one compiler
X### standard C compiler, with optimizer or debugger
XCC=cc -O
X#CC=cc -g
X
X### GCC on sun, Dynix
X#CC=gcc -g -Wall -traditional
X
X### GCC 2.2.2d on Linux
X#CC=gcc -O6 -Wall


X
X#>>>>> choose options:
X### -DDIGRAPHS digraph support

X### -DNO_FREE_NULL do not call free() with a null pointer


X### -DWILD_CARDS wildcard expansion code
X### -DCOMPATIBLE start in vi-compatible mode
X### -DNOBACKUP default is no backup file
X### -DDEBUG output a lot of debugging garbage

X### -DSTRNCASECMP use strncasecmp() instead of internal function
X### -DUSE_LOCALE use setlocale() to change ctype() and others
X### -DTERMCAP full termcap file support


X### -DNO_BUILTIN_TCAPS do not include builtin termcap entries
X### (use only with -DTERMCAP)
X### -DSOME_BUILTIN_TCAPS include most useful builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)
X### -DALL_BUILTIN_TCAPS include all builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)

X### -DMAXNAMLEN 31 maximum length of a file name (if not defined in sys/dir.h)


X### -DVIMRC_FILE name of the .vimrc file in current dir
X### -DEXRC_FILE name of the .exrc file in current dir
X### -DSYSVIMRC_FILE name of the global .vimrc file
X### -DSYSEXRC_FILE name of the global .exrc file
X### -DDEFVIMRC_FILE name of the system-wide .vimrc file
X### -DVIM_HLP name of the help file

XDEFS = -DDIGRAPHS -DTERMCAP -DWILD_CARDS -DSOME_BUILTIN_TCAPS -DNO_FREE_NULL \
X -DSYSVIMRC_FILE=\"\$$HOME/.vimrc\" -DSYSEXRC_FILE=\"\$$HOME/.exrc\" \
X -DDEFVIMRC_FILE=\"/etc/vimrc\" -DVIM_HLP=\"/usr/local/doc/vim.hlp\"
X
X#>>>>> link with termlib or termcap only if TERMCAP is defined
X# termcap is for linux, HPUX, etc.
XLIBS = -ltermlib
X#LIBS = -ltermcap
X#LIBS =

X
X#>>>>> end of choices
X###########################################################################
X

XCFLAGS = -c $(MACHINE) $(DEFS)
X
XINCL = vim.h globals.h param.h keymap.h macros.h ascii.h term.h unix.h debug.h
X
XOBJ = alloc.o unix.o buffers.o charset.o cmdline.o csearch.o digraph.o \


X edit.o fileio.o help.o linefunc.o main.o mark.o message.o misccmds.o \
X normal.o ops.o param.o quickfix.o regexp.o regsub.o screen.o \

X script.o search.o storage.o tag.o term.o undo.o
X
X../vim: $(OBJ) version.c
X $(CC) $(CFLAGS) version.c
X $(CC) -o ../vim $(OBJ) version.o $(LIBS)
X
Xdebug: $(OBJ) version.c
X $(CC) $(CFLAGS) version.c
X $(CC) -o ../vim -g $(OBJ) version.o $(LIBS)


X
Xctags:
X csh -c ctags *.c *.h
X

Xclean:
X -rm -f $(OBJ) mkcmdtab.o version.o core ../vim mkcmdtab
X
X#use this in case the files have been transported via an MSDOS system
X
XFILES = *.c *.h makefile makefile.* cmdtab.tab proto/*.pro tags
X
Xdos2unix:
X -mv arp_prot.h arp_proto.h
X -mv ptx_stdl.h ptx_stdlib.h
X -mv sun_stdl.h sun_stdlib.h
X -mv makefile.dic makefile.dice
X -mv makefile.uni makefile.unix
X -mv makefile.man makefile.manx
X -mv makefile.6sa makefile.6sas
X -mv makefile.5sa makefile.5sas
X for i in $(FILES); do tr -d '\r\032' < $$i > ~tmp~; mv ~tmp~ $$i; echo $$i; done


X
X###########################################################################
X
Xalloc.o: alloc.c $(INCL)

X $(CC) $(CFLAGS) alloc.c
X
Xunix.o: unix.c $(INCL) unix.h
X $(CC) $(CFLAGS) unix.c
X
Xbuffers.o: buffers.c $(INCL)
X $(CC) $(CFLAGS) buffers.c
X
Xcharset.o: charset.c $(INCL)
X $(CC) $(CFLAGS) charset.c


X
Xcmdline.o: cmdline.c $(INCL) cmdtab.h

X $(CC) $(CFLAGS) cmdline.c
X
Xcsearch.o: csearch.c $(INCL)


X $(CC) $(CFLAGS) csearch.c
X

Xdigraph.o: digraph.c $(INCL)


X $(CC) $(CFLAGS) digraph.c
X

Xedit.o: edit.c $(INCL)


X $(CC) $(CFLAGS) edit.c
X

Xfileio.o: fileio.c $(INCL)


X $(CC) $(CFLAGS) fileio.c
X

Xhelp.o: help.c $(INCL)


X $(CC) $(CFLAGS) help.c
X

Xlinefunc.o: linefunc.c $(INCL)


X $(CC) $(CFLAGS) linefunc.c
X

Xmain.o: main.c $(INCL)


X $(CC) $(CFLAGS) main.c
X

Xmark.o: mark.c $(INCL)


X $(CC) $(CFLAGS) mark.c
X

Xmessage.o: message.c $(INCL)


X $(CC) $(CFLAGS) message.c
X

Xmisccmds.o: misccmds.c $(INCL)


X $(CC) $(CFLAGS) misccmds.c
X

Xnormal.o: normal.c $(INCL) ops.h
X $(CC) $(CFLAGS) normal.c


X
Xops.o: ops.c $(INCL) ops.h

X $(CC) $(CFLAGS) ops.c
X
Xparam.o: param.c $(INCL)


X $(CC) $(CFLAGS) param.c
X

Xquickfix.o: quickfix.c $(INCL)


X $(CC) $(CFLAGS) quickfix.c
X

Xregexp.o: regexp.c $(INCL)


X $(CC) $(CFLAGS) regexp.c
X

Xregsub.o: regsub.c $(INCL)


X $(CC) $(CFLAGS) regsub.c
X

Xscreen.o: screen.c $(INCL)


X $(CC) $(CFLAGS) screen.c
X

Xscript.o: script.c $(INCL)


X $(CC) $(CFLAGS) script.c
X

Xsearch.o: search.c $(INCL)


X $(CC) $(CFLAGS) search.c
X

Xstorage.o: storage.c $(INCL)


X $(CC) $(CFLAGS) storage.c
X

Xtag.o: tag.c $(INCL)


X $(CC) $(CFLAGS) tag.c
X

Xterm.o: term.c $(INCL)


X $(CC) $(CFLAGS) term.c
X

Xundo.o: undo.c $(INCL)


X $(CC) $(CFLAGS) undo.c
X
Xcmdtab.h: cmdtab.tab mkcmdtab

X ./mkcmdtab cmdtab.tab cmdtab.h
X
Xmkcmdtab: mkcmdtab.o
X $(CC) -o mkcmdtab mkcmdtab.o
END_OF_FILE
if test 4829 -ne `wc -c <'vim/src/makefile.unix'`; then
echo shar: \"'vim/src/makefile.unix'\" unpacked with wrong size!
fi
# end of 'vim/src/makefile.unix'
fi
if test -f 'vim/src/param.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/param.h'\"
else
echo shar: Extracting \"'vim/src/param.h'\" \(5234 characters\)
sed "s/^X//" >'vim/src/param.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * param.h: definition of global variables for settable parameters
X *
X * EXTERN is only defined in main.c (and vim.h)
X */
X
X#ifndef EXTERN
X# define EXTERN extern
X# define INIT(x)
X#else
X# ifndef INIT
X# define INIT(x) x
X# endif
X#endif
X
X/*
X * The following are actual variabables for the parameters
X */
X
XEXTERN int p_ai INIT(= FALSE); /* auto-indent */
XEXTERN int p_aw INIT(= FALSE); /* auto-write */
XEXTERN long p_bs INIT(= 0); /* backspace over newlines in insert mode */
X#if defined(COMPATIBLE) || defined(NOBACKUP)
XEXTERN int p_bk INIT(= FALSE); /* make backups when writing out files */
X#else
XEXTERN int p_bk INIT(= TRUE); /* make backups when writing out files */
X#endif
X#ifdef UNIX
XEXTERN char *p_bdir INIT(= BACKUPDIR); /* directory for backups */
X#endif
XEXTERN int p_cp INIT(= FALSE); /* vi-compatible */
X#ifdef DIGRAPHS
XEXTERN int p_dg INIT(= FALSE); /* enable digraphs */
X#endif /* DIGRAPHS */
XEXTERN char *p_dir INIT(= ""); /* directory for autoscript file */
XEXTERN char *p_ep INIT(= "indent"); /* program name for '=' command */
XEXTERN int p_eb INIT(= FALSE); /* ring bell for errors */
X#ifdef AMIGA
XEXTERN char *p_ef INIT(= "AztecC.Err"); /* name of errorfile */
X#else
XEXTERN char *p_ef INIT(= ""); /* name of errorfile */
X#endif
XEXTERN int p_et INIT(= FALSE); /* expand tabs into spaces */
X#ifdef MSDOS
XEXTERN int p_gr INIT(= TRUE); /* display graphic characters */
X#else
XEXTERN int p_gr INIT(= FALSE); /* display graphic characters */
X#endif
XEXTERN long p_hi INIT(= 20); /* command line history size */
XEXTERN char *p_hf INIT(= VIM_HLP); /* name of help file */
XEXTERN int p_ic INIT(= FALSE); /* ignore case in searches */
XEXTERN int p_im INIT(= FALSE); /* start editing in input mode */
XEXTERN char *p_kp INIT(= "ref"); /* keyword program */
XEXTERN int p_js INIT(= TRUE); /* use two spaces after period with Join */
XEXTERN int p_list INIT(= FALSE); /* show tabs and newlines graphically */
XEXTERN int p_magic INIT(= TRUE); /* use some characters for reg exp */
XEXTERN long p_ml INIT(= 5); /* number of mode lines */
XEXTERN int p_nu INIT(= FALSE); /* number lines on the screen */
XEXTERN char *p_para INIT(= "IPLPPPQPP LIpplpipbp"); /* paragraphs */
XEXTERN int p_ro INIT(= FALSE); /* readonly */
XEXTERN int p_remap INIT(= TRUE); /* remap */
XEXTERN int p_rd INIT(= TRUE); /* delete when replacing */
XEXTERN long p_report INIT(= 2); /* minimum number of lines for report */
XEXTERN int p_ru INIT(= FALSE); /* show column/line number */
XEXTERN long p_scroll INIT(= 12); /* scroll size */
XEXTERN long p_sj INIT(= 1); /* scroll jump size */
XEXTERN char *p_sections INIT(= "SHNHH HUnhsh"); /* sections */
X#ifdef MSDOS
XEXTERN char *p_sh INIT(= "command"); /* name of shell to use */
X#else
XEXTERN char *p_sh INIT(= "sh"); /* name of shell to use */
X#endif
XEXTERN long p_st INIT(= 0); /* type of shell */
XEXTERN int p_sr INIT(= FALSE); /* shift round off (for < and >) */
XEXTERN long p_sw INIT(= 8); /* shiftwidth (for < and >) */
X#ifdef COMPATIBLE
XEXTERN int p_sc INIT(= FALSE); /* show command in status line */
X#else
XEXTERN int p_sc INIT(= TRUE); /* show command in status line */
X#endif
X#ifndef MSDOS
XEXTERN int p_sn INIT(= FALSE); /* short names in file system */
X#endif
XEXTERN int p_sm INIT(= FALSE); /* showmatch */
X#ifdef COMPATIBLE
XEXTERN int p_mo INIT(= FALSE); /* show mode */
X#else
XEXTERN int p_mo INIT(= TRUE); /* show mode */
X#endif
XEXTERN int p_si INIT(= FALSE); /* smart-indent for c programs */
XEXTERN char *p_su INIT(= ".bak.o.h.info.vim"); /* suffixes for wildcard expansion */
XEXTERN long p_ts INIT(= 8); /* tab size in the file */
XEXTERN long p_tl INIT(= 0); /* used tag length */
XEXTERN char *p_tags INIT(= "tags"); /* tags search path */
XEXTERN int p_terse INIT(= TRUE); /* terse (not used) */
X#ifdef MSDOS
XEXTERN int p_tx INIT(= TRUE); /* textmode for file I/O */
X#endif
XEXTERN long p_tw INIT(= 9999); /* textwidth */
XEXTERN int p_to INIT(= FALSE); /* tilde is an operator */
XEXTERN int p_timeout INIT(= TRUE); /* mappings entered within one second */
XEXTERN int p_ttimeout INIT(= FALSE); /* key codes entered within one second */
X#ifdef COMPATIBLE
XEXTERN long p_ul INIT(= 0); /* number of Undo Levels */
XEXTERN long p_uc INIT(= 0); /* update count for auto script file */
X#else
XEXTERN long p_ul INIT(= 100); /* number of Undo Levels */
XEXTERN long p_uc INIT(= 100); /* update count for auto script file */
X#endif
XEXTERN long p_ut INIT(= 2000); /* update time for auto script file */
XEXTERN int p_vb INIT(= FALSE); /* visual bell only (no beep) */
XEXTERN int p_warn INIT(= TRUE); /* warn for changes at shell command */
XEXTERN int p_ws INIT(= TRUE); /* wrap scan */
XEXTERN long p_wm INIT(= 0); /* wrapmargin */
XEXTERN int p_wa INIT(= FALSE); /* write any */
X#if defined(COMPATIBLE) || defined(NOBACKUP)
XEXTERN int p_wb INIT(= FALSE); /* write backup files */
X#else
XEXTERN int p_wb INIT(= TRUE); /* write backup files */
X#endif
XEXTERN int p_ye INIT(= FALSE); /* Y yanks to end of line */
END_OF_FILE
if test 5234 -ne `wc -c <'vim/src/param.h'`; then
echo shar: \"'vim/src/param.h'\" unpacked with wrong size!
fi
# end of 'vim/src/param.h'
fi
if test -f 'vim/src/quickfix.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/quickfix.c'\"
else
echo shar: Extracting \"'vim/src/quickfix.c'\" \(5881 characters\)
sed "s/^X//" >'vim/src/quickfix.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * quickfix.c: functions for quickfix mode, using the Manx errorfile


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X

Xstatic void qf_free __ARGS((void));
X
X/*
X * for each error the next struct is allocated and linked in a list
X */
Xstruct qf_line
X{
X struct qf_line *qf_next; /* pointer to next error in the list */
X struct qf_line *qf_prev; /* pointer to previous error in the list */
X linenr_t qf_lnum; /* line number where the error occurred */
X char *qf_mark; /* pointer to that line (if != NULL) */
X int qf_col; /* column where the error occurred */
X char qf_cleared;/* set to TRUE if qf_mark has been cleared */
X char qf_type; /* type of the error (mostly 'E') */
X int qf_nr; /* error number */
X char *qf_fname; /* file name where the error occurred */
X char *qf_text; /* description of the error */
X};
X
Xstatic struct qf_line *qf_start; /* pointer to the first error */
Xstatic struct qf_line *qf_ptr; /* pointer to the current error */
X
Xstatic int qf_count = 0; /* number of errors (0 means no error list) */
X int qf_index; /* current index in the error list */
Xstatic int qf_marksset; /* set to 1 when qf_mark-s have been set */
X
X/*
X * Read the errorfile into memory, line by line, building the error list.
X * Return 1 for error, 0 for success.
X */
X int
Xqf_init(fname)
X char *fname;
X{
X char namebuf[CMDBUFFSIZE];
X char errmsg[CMDBUFFSIZE];
X FILE *fd;
X struct qf_line *qfp = NULL;
X
X if (fname == NULL)
X {
X emsg(e_errorf);
X return 1;
X }
X if ((fd = fopen(fname, "r")) == NULL)
X {
X emsg(e_openerrf);
X return 1;
X }
X qf_free();
X
X while (fgets(IObuff, IOSIZE, fd) != NULL)
X {
X if ((qfp = (struct qf_line *)alloc((unsigned)sizeof(struct qf_line))) == NULL)
X goto error2;
X
X /* parse the line: "filename>linenr:colnr:type:number:text" */
X if (sscanf(IObuff, "%[^>]>%ld:%d:%c:%d:%[^\n]", namebuf,
X &qfp->qf_lnum, &qfp->qf_col, &qfp->qf_type,
X &qfp->qf_nr, errmsg) != 6)
X goto error;
X if ((qfp->qf_fname = strsave(namebuf)) == NULL)
X goto error1;
X if ((qfp->qf_text = strsave(errmsg)) == NULL)
X {
X free(qfp->qf_fname);
X goto error1;
X }
X if (qf_count == 0) /* first element in the list */
X {
X qf_start = qfp;
X qfp->qf_prev = qfp; /* first element points to itself */
X }
X else
X {
X qfp->qf_prev = qf_ptr;
X qf_ptr->qf_next = qfp;
X }
X qfp->qf_next = qfp; /* last element points to itself */
X qfp->qf_mark = NULL;
X qfp->qf_cleared = FALSE;
X qf_ptr = qfp;
X ++qf_count;
X }
X if (!ferror(fd))
X {
X qf_ptr = qf_start;
X qf_index = 1;
X fclose(fd);
X return 0;
X }
Xerror:
X emsg(e_readerrf);
Xerror1:
X free(qfp);
Xerror2:
X fclose(fd);
X qf_free();


X return 1;
X}
X

X/*
X * jump to quickfix line "errornr"; if "errornr" is zero, redisplay the same line
X */
X void
Xqf_jump(errornr)
X int errornr;
X{
X struct qf_line *qfp;
X linenr_t i;
X char *msgp;
X
X if (qf_count == 0)
X {
X emsg(e_quickfix);
X return;
X }
X if (errornr == 0)
X errornr = qf_index;
X while (errornr < qf_index && qf_index > 1)
X {
X --qf_index;
X qf_ptr = qf_ptr->qf_prev;
X }
X while (errornr > qf_index && qf_index < qf_count)
X {
X ++qf_index;
X qf_ptr = qf_ptr->qf_next;
X }
X
X /*
X * read the wanted file if needed, and check autowrite etc.
X */
X if (getfile(qf_ptr->qf_fname, TRUE) <= 0)
X {
X /*
X * use mark if possible, because the line number may be invalid
X * after line inserts / deletes
X */
X i = 0;
X msgp = "";
X if ((qf_ptr->qf_mark != NULL && (i = ptr2nr(qf_ptr->qf_mark, (linenr_t)0)) == 0) || qf_ptr->qf_cleared)
X msgp = "(line changed) ";
X if (i == 0)
X i = qf_ptr->qf_lnum;
X if (i > line_count)
X i = line_count;
X Curpos.lnum = i;
X Curpos.col = qf_ptr->qf_col;
X adjustCurpos();
X cursupdate();
X smsg("(%d of %d) %s%s %d: %s", qf_index, qf_count, msgp, qf_ptr->qf_type == 'E' ? "Error" : "Warning", qf_ptr->qf_nr, qf_ptr->qf_text);
X
X if (!qf_marksset) /* marks not set yet: try to find them for
X the errors in the curren file */
X {
X for (i = 0, qfp = qf_start; i < qf_count; ++i, qfp = qfp->qf_next)
X if (strcmp(qfp->qf_fname, qf_ptr->qf_fname) == 0 && qfp->qf_lnum <= line_count)
X qfp->qf_mark = nr2ptr(qfp->qf_lnum);
X qf_marksset = 1;
X }
X }
X}
X
X/*
X * list all errors
X */
X void
Xqf_list()
X{
X struct qf_line *qfp;
X int i;
X
X if (qf_count == 0)
X {
X emsg(e_quickfix);
X return;
X }
X qfp = qf_start;
X gotocmdline(TRUE, NUL);
X#ifdef AMIGA
X settmode(0); /* set cooked mode so output can be halted */
X#endif
X for (i = 1; i <= qf_count; ++i)
X {
X sprintf(IObuff, "%2d line %ld col %2d %s %3d: %s",
X i,
X (long)qfp->qf_lnum,
X qfp->qf_col,
X qfp->qf_type == 'E' ? "Error" : "Warning",
X qfp->qf_nr,
X qfp->qf_text);
X outstr(IObuff);
X outchar('\n');
X qfp = qfp->qf_next;
X flushbuf();
X }
X#ifdef AMIGA
X settmode(1);
X#endif
X wait_return(TRUE);
X}
X
X/*
X * free the error list
X */
X static void
Xqf_free()
X{
X struct qf_line *qfp;
X
X while (qf_count)
X {
X qfp = qf_start->qf_next;
X free(qf_start->qf_fname);
X free(qf_start->qf_text);
X free(qf_start);
X qf_start = qfp;
X --qf_count;
X }
X qf_marksset = 0;
X}
X
X/*
X * qf_clrallmarks() - clear all marks
X *
X * Used mainly when trashing the entire buffer during ":e" type commands
X */
X void
Xqf_clrallmarks()
X{
X int i;
X struct qf_line *qfp;
X
X if (qf_count)
X for (i = 0, qfp = qf_start; i < qf_count; i++, qfp = qfp->qf_next)
X qfp->qf_mark = NULL;
X qf_marksset = 0;
X}
X
X/*
X * qf_adjustmark: set new ptr for a mark
X */
X void
Xqf_adjustmark(old, new)
X char *old, *new;
X{
X register int i;
X struct qf_line *qfp;
X
X if (qf_count)
X {
X for (i = 0, qfp = qf_start; i < qf_count; ++i, qfp = qfp->qf_next)
X if (qfp->qf_mark == old)
X {
X qfp->qf_mark = new;
X if (new == NULL)
X qfp->qf_cleared = TRUE;
X }
X }
X}
END_OF_FILE
if test 5881 -ne `wc -c <'vim/src/quickfix.c'`; then
echo shar: \"'vim/src/quickfix.c'\" unpacked with wrong size!
fi
# end of 'vim/src/quickfix.c'
fi
if test -f 'vim/src/term.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/term.h'\"
else
echo shar: Extracting \"'vim/src/term.h'\" \(7566 characters\)
sed "s/^X//" >'vim/src/term.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *

X * term.h -- VIM - Vi IMitation


X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * This file contains the machine dependent escape sequences that the editor
X * needs to perform various operations. Some of the sequences here are
X * optional. Anything not available should be indicated by a null string. In
X * the case of insert/delete line sequences, the editor checks the capability
X * and works around the deficiency, if necessary.
X */
X
X/*
X * the terminal capabilities are stored in this structure
X * keep in sync with array in term.c
X */
Xtypedef struct _tcarr
X{
X/* output codes */
X char *t_name; /* name of this terminal entry */
X char *t_el; /* el ce clear to end of line */
X char *t_il; /* il1 al add new blank line */
X char *t_cil; /* il AL add number of blank lines */
X char *t_dl; /* dl1 dl delete line */
X char *t_cdl; /* dl DL delete number of lines */
X char *t_ed; /* clear cl clear screen */
X char *t_ci; /* civis vi cursur invisible */
X char *t_cv; /* cnorm ve cursur visible */
X char *t_tp; /* sgr0 me normal mode */
X char *t_ti; /* rev mr reverse mode */
X char *t_cm; /* cup cm cursor motion */
X char *t_sr; /* ri sr scroll reverse (backward) */
X char *t_cri; /* cuf RI cursor number of chars right */
X char *t_vb; /* flash vb visual bell */
X char *t_ks; /* smkx ks put terminal in "keypad transmit" mode */
X char *t_ke; /* rmkx ke out of "keypad transmit" mode */
X char *t_ts; /* ti put terminal in termcap mode */
X char *t_te; /* te out of termcap mode */
X
X/* key codes */
X char *t_ku; /* kcuu1 ku arrow up */
X char *t_kd; /* kcud1 kd arrow down */
X char *t_kl; /* kcub1 kl arrow left */
X char *t_kr; /* kcuf1 kr arrow right */
X char *t_sku; /* shift arrow up */
X char *t_skd; /* shift arrow down */
X char *t_skl; /* kLFT #4 shift arrow left */
X char *t_skr; /* kRIT % shift arrow right */
X char *t_f1; /* kf1 k1 function key 1 */
X char *t_f2; /* kf2 k2 function key 2 */
X char *t_f3; /* kf3 k3 function key 3 */
X char *t_f4; /* kf4 k4 function key 4 */
X char *t_f5; /* kf5 k5 function key 5 */
X char *t_f6; /* kf6 k6 function key 6 */
X char *t_f7; /* kf7 k7 function key 7 */
X char *t_f8; /* kf8 k8 function key 8 */
X char *t_f9; /* kf9 k9 function key 9 */
X char *t_f10; /* kf10 k; function key 10 */
X char *t_sf1; /* kf11 F1 shifted function key 1 */
X char *t_sf2; /* kf12 F2 shifted function key 2 */
X char *t_sf3; /* kf13 F3 shifted function key 3 */
X char *t_sf4; /* kf14 F4 shifted function key 4 */
X char *t_sf5; /* kf15 F5 shifted function key 5 */
X char *t_sf6; /* kf16 F6 shifted function key 6 */
X char *t_sf7; /* kf17 F7 shifted function key 7 */
X char *t_sf8; /* kf18 F8 shifted function key 8 */
X char *t_sf9; /* kf19 F9 shifted function key 9 */
X char *t_sf10; /* kf20 FA shifted function key 10 */
X char *t_help; /* khlp %1 help key */
X char *t_undo; /* kund &8 undo key */
X /* adjust inchar() for last entry! */
X} Tcarr;
X
Xextern Tcarr term_strings; /* currently used terminal strings */
X
X/*
X * strings used for terminal
X */
X#define T_EL (term_strings.t_el)
X#define T_IL (term_strings.t_il)
X#define T_CIL (term_strings.t_cil)
X#define T_DL (term_strings.t_dl)
X#define T_CDL (term_strings.t_cdl)
X#define T_ED (term_strings.t_ed)
X#define T_CI (term_strings.t_ci)
X#define T_CV (term_strings.t_cv)
X#define T_TP (term_strings.t_tp)
X#define T_TI (term_strings.t_ti)
X#define T_CM (term_strings.t_cm)
X#define T_SR (term_strings.t_sr)
X#define T_CRI (term_strings.t_cri)
X#define T_VB (term_strings.t_vb)
X#define T_KS (term_strings.t_ks)
X#define T_KE (term_strings.t_ke)
X#define T_TS (term_strings.t_ts)
X#define T_TE (term_strings.t_te)
X
X
X#ifndef NO_BUILTIN_TCAPS
X/*
X * here are the builtin termcap entries.
X * They not stored as complete Tcarr structures, as such a structure
X * is to big.
X * Each termcap is a concatenated string of entries, where '\0' characters
X * followed by a skip character sepereate the capabilities. The skip
X * character is the relative structure offset for the following entry.
X * See parse_builtin_tcap() in term.c for all details.
X */
X# define AMIGA_TCAP "amiga\0\
X\0\033[K\0\
X\0\033[L\0\
X\0\033[%dL\0\
X\0\033[M\0\
X\0\033[%dM\0\
X\0\014\0\
X\0\033[0 p\0\
X\0\033[1 p\0\
X\0\033[0m\0\
X\0\033[7m\0\
X\0\033[%i%d;%dH\0\
X\1\033[%dC\0\
X\5\233A\0\
X\0\233B\0\
X\0\233D\0\
X\0\233C\0\
X\0\233T\0\
X\0\233S\0\
X\0\233 A\0\
X\0\233 @\0\
X\0\233\060~\0\
X\0\233\061~\0\
X\0\233\062~\0\
X\0\233\063~\0\
X\0\233\064~\0\
X\0\233\065~\0\
X\0\233\066~\0\
X\0\233\067~\0\
X\0\233\070~\0\
X\0\233\071~\0\
X\0\233\061\060~\0\
X\0\233\061\061~\0\
X\0\233\061\062~\0\
X\0\233\061\063~\0\
X\0\233\061\064~\0\
X\0\233\061\065~\0\
X\0\233\061\066~\0\
X\0\233\061\067~\0\
X\0\233\061\070~\0\
X\0\233\061\071~\0\
X\0\233?~\0\
X\0\0"
X
X# define ATARI_TCAP "atari\0\
X\0\033l\0\
X\0\033L\0\
X\1\033M\0\
X\1\033E\0\
X\0\033f\0\
X\0\033e\0\
X\0\0"
X
X# define ANSI_TCAP "ansi\0\
X\0\033[2K\0\
X\0\033[L\0\
X\0\033[%dL\0\
X\0\033[M\0\
X\0\033[%dM\0\
X\0\033[2J\0\
X\2\033[0m\0\
X\0\033[7m\0\
X\0\033[%i%d;%dH\0\
X\1\033[%dC\0\
X\0\0"
X
X/*
X * These codes are valid when ansi.sys or equivalent has been installed.
X * Function keys on a PC are preceded with a NUL. These are converted into
X * K_ZERO '\236' in GetChars(), because we cannot handle NULs in key codes.
X * CTRL-arrow is used instead of SHIFT-arrow.
X */
X# define PCTERM_TCAP "pcterm\0\
X\0\033[K\0\
X\0\033|L\0\
X\1\033|M\0\
X\1\033[2J\0\
X\2\033[0m\0\
X\0\033[7m\0\
X\0\033[%i%d;%dH\0\
X\1\033[%dC\0\
X\5\236H\0\
X\0\236P\0\
X\0\236K\0\
X\0\236M\0\
X\2\236s\0\
X\0\236t\0\
X\0\236;\0\
X\0\236<\0\
X\0\236=\0\
X\0\236>\0\
X\0\236?\0\
X\0\236@\0\
X\0\236A\0\
X\0\236B\0\
X\0\236C\0\
X\0\236D\0\
X\0\236T\0\
X\0\236U\0\
X\0\236V\0\
X\0\236W\0\
X\0\236X\0\
X\0\236Y\0\
X\0\236Z\0\
X\0\236[\0\
X\0\236\\\0\
X\0\236]\0\
X\0\0"
X
X# define VT52_TCAP "vt52\0\
X\0\033K\0\
X\0\033T\0\
X\1\033U\0\
X\1\014\0\
X\2\033SO\0\
X\0\033S2\0\
X\0\033Y%+ %+ \0\
X\0\0"
X
X# define XTERM_TCAP "xterm\0\
X\0\033[K\0\
X\0\033[L\0\
X\0\033[%dL\0\
X\0\033[M\0\
X\0\033[%dM\0\
X\0\033[2J\0\
X\2\033[m\0\
X\0\033[7m\0\
X\0\033[%i%d;%dH\0\
X\0\033M\0\
X\0\033[%dC\0\
X\1\033[?1h\0\
X\0\033[?0h\0\
X\2\033[OA\0\
X\0\033[OB\0\
X\0\033[OD\0\
X\0\033[OC\0\
X\0\033[Ox\0\
X\0\033[Or\0\
X\0\033[Ot\0\
X\0\033[Ov\0\
X\0\033[12~\0\
X\0\033[13~\0\
X\0\033[14~\0\
X\0\033[15~\0\
X\0\033[16~\0\
X\0\033[17~\0\
X\0\033[18~\0\
X\0\033[19~\0\
X\0\033[20~\0\
X\0\033[21~\0\
X\0\033[23~\0\
X\0\033[24~\0\
X\10\033[28~\0\
X\0\033[26~\0\
X\0\0"
X
X# define DEBUG_TCAP "debug\0\
X\0[EL]\0\
X\0[IL]\0\
X\0[CIL%d]\0\
X\0[DL]\0\
X\0[CDL%d]\0\
X\0[ED]\0\
X\0[CI]\0\
X\0[CV]\0\
X\0[TP]\0\
X\0[TI]\0\
X\0[%dCM%d]\0\
X\0[SR]\0\
X\0[CRI%d]\0\
X\0[VB]\0\
X\0[KS]\0\
X\0[KE]\0\
X\0[TI]\0\
X\0[TE]\0\
X\0[KU]\0\
X\0[KD]\0\
X\0[KL]\0\
X\0[KR]\0\
X\0[SKU]\0\
X\0[SKD]\0\
X\0[SKL]\0\
X\0[SKR]\0\
X\0[F1]\0\
X\0[F2]\0\
X\0[F3]\0\
X\0[F4]\0\
X\0[F5]\0\
X\0[F6]\0\
X\0[F7]\0\
X\0[F8]\0\
X\0[F9]\0\
X\0[F10]\0\
X\0[SF1]\0\
X\0[SF2]\0\
X\0[SF3]\0\
X\0[SF4]\0\
X\0[SF5]\0\
X\0[SF6]\0\
X\0[SF7]\0\
X\0[SF8]\0\
X\0[SF9]\0\
X\0[SF10]\0\
X\0[HELP]\0\
X\0[UNDO]\0\
X\0\0"
X
X# ifdef ATARI
X# define DFLT_TCAP ATARI_TCAP
X# endif /* ATARI */
X
X# ifdef AMIGA
X# define DFLT_TCAP AMIGA_TCAP
X# endif /* AMIGA */
X
X# ifdef MSDOS
X# define DFLT_TCAP PCTERM_TCAP
X# endif /* MSDOS */
X
X# ifdef UNIX
X# define DFLT_TCAP ANSI_TCAP
X# endif /* UNIX */
X
X#endif /* NO_BUILTIN_TCAPS */
END_OF_FILE
if test 7566 -ne `wc -c <'vim/src/term.h'`; then
echo shar: \"'vim/src/term.h'\" unpacked with wrong size!
fi
# end of 'vim/src/term.h'
fi
if test -f 'vim/src/vim.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/vim.h'\"
else
echo shar: Extracting \"'vim/src/vim.h'\" \(6430 characters\)
sed "s/^X//" >'vim/src/vim.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X

X#if defined(SYSV) || defined(BSD)
X# ifndef UNIX
X# define UNIX
X# endif
X#endif
X
X#include "debug.h"
X
X#include <stdio.h>
X
X#ifndef SYSV
X# include <stdlib.h>
X#endif
X
X#include <ctype.h>
X
X#ifdef BSD
X# include <strings.h>
X#else
X# include <string.h>
X#endif
X
X#include "ascii.h"
X#include "keymap.h"
X#include "term.h"
X#include "macros.h"
X#ifdef LATTICE
X# include <sys/types.h>
X# include <sys/stat.h>
X#else
X# ifdef _DCC
X# include <sys/stat.h>
X# else
X# ifdef MSDOS
X# include <sys\stat.h>
X# else
X# ifdef UNIX
X# ifndef linux
X# define volatile /* needed for gcc */
X# define signed /* needed for gcc */
X# endif
X# include <sys/types.h>
X# include <sys/stat.h>
X# else
X# include <stat.h>
X# endif
X# endif
X# endif
X#endif
X
X#ifdef AMIGA
X/*
X * arpbase.h must be included before functions.h
X */
X# include <libraries/arpbase.h>
X
X/*
X * This won't be needed if you have a version of Lattice 4.01 without broken
X * break signal handling.
X */
X#include <signal.h>
X#endif
X
X#ifndef AMIGA
X/*
X * For the Amiga we use a version of getenv that does local variables under 2.0
X */
X#define vimgetenv(x) getenv(x)
X#endif
X
X#ifdef AZTEC_C
X# include <functions.h>
X# define __ARGS(x) x
X# define __PARMS(x) x
X#endif
X
X#ifdef SASC
X# include <clib/exec_protos.h>
X# define __ARGS(x) x
X# define __PARMS(x) x
X#endif
X
X#ifdef _DCC
X# include <functions.h>
X# define __ARGS(x) x
X# define __PARMS(x) x
X#endif
X
X#ifdef __TURBOC__
X# define __ARGS(x) x
X#endif
X
X#ifdef MSDOS
X# include <dos.h>
X# include <dir.h>
X#endif
X
X#ifdef UNIX
X# include <sys/dir.h> /* for MAXNAMLEN */
X# if defined(UFS_MAXNAMLEN) && !defined(MAXNAMLEN)
X# define MAXNAMLEN UFS_MAXNAMLEN /* for dynix/ptx */
X# endif
X# if defined(NAME_MAX) && !defined(MAXNAMLEN)
X# define MAXNAMLEN NAME_MAX /* for Linux befor .99p3 */
X# endif
X#endif
X
X#if defined(__STDC__) || defined(__GNUC__)
X# ifndef __ARGS
X# define __ARGS(x) x
X# endif /* __ARGS */
X# if defined(_SEQUENT_)
X# include "ptx_stdlib.h"
X# endif
X# if defined(sun)
X# include "sun_stdlib.h"
X# endif
X# if defined(linux)
X# include <unistd.h> /* may make sense for others too. jw. */
X# endif
X#else /*__STDC__*/
X# if defined(_SEQUENT_) && !defined(_STDLIB_H_)
X extern char *getenv();
X extern void *malloc();
X# endif
X#endif /* __STDC__ */
X
X#ifndef __ARGS
X#define __ARGS(x) ()
X#endif
X#ifndef __PARMS
X#define __PARMS(x) ()
X#endif
X
X/*
X * for systems that do not allow free(NULL)
X */
X#ifdef NO_FREE_NULL
X# define free(x) nofreeNULL(x)
X extern void nofreeNULL __ARGS((void *));
X#endif
X
X/*
X * fnamecmp() is used to compare filenames.
X * On some systems case in a filename does not matter, on others it does.
X * (this does not account for maximum name lengths, thus it is not 100% accurate!)
X */
X#if defined(AMIGA) || defined(MSDOS)
X# define fnamecmp(x, y) stricmp((x), (y))
X#else
X# define fnamecmp(x, y) strcmp((x), (y))
X#endif
X
X/* flags for updateScreen() */
X#define VALID 90 /* buffer not changed */
X#define NOT_VALID 91 /* buffer changed */
X#define VALID_TO_CURSCHAR 92 /* buffer before cursor not changed */
X#define INVERTED 93 /* redisplay inverted part */
X#define CLEAR 94 /* first clear screen */
X#define CURSUPD 95 /* update cursor first */
X
X/* values for State */
X#define NORMAL 0
X#define CMDLINE 1
X#define INSERT 2
X#define APPEND 3
X#define REPLACE 4 /* replace mode */
X#define HELP 5
X#define NOMAPPING 6 /* no :mapping mode for vgetc() */
X#define HITRETURN 7
X#define SETWINSIZE 8
X#define NORMAL_BUSY 9 /* busy interpreting a command */
X
X/* directions */
X#define FORWARD 1
X#define BACKWARD -1
X
X/* for GetChars */
X#define T_PEEK 1 /* do not wait at all */
X#define T_WAIT 2 /* wait for a short time */
X#define T_BLOCK 3 /* wait forever */
X
X#define QUOTELINE 29999 /* Quoting is linewise */
X
X/*
X * Names for the EXRC, HELP and temporary files.
X * Some of these may have been defined in the makefile.
X */
X#ifndef SYSVIMRC_FILE
X# define SYSVIMRC_FILE "s:.vimrc"
X#endif
X#ifndef SYSEXRC_FILE
X# define SYSEXRC_FILE "s:.exrc"
X#endif
X#ifndef VIMRC_FILE
X# define VIMRC_FILE ".vimrc"
X#endif
X#ifndef EXRC_FILE
X# define EXRC_FILE ".exrc"
X#endif
X#ifndef VIM_HLP
X# define VIM_HLP "vim:vim.hlp"
X#endif
X#define TMPNAME1 "t:viXXXXXX"
X#define TMPNAME2 "t:voXXXXXX"
X#define TMPNAMELEN 12
X
X/*
X * Boolean constants
X */
X#ifndef TRUE
X#define FALSE (0) /* note: this is an int, not a long! */
X#define TRUE (1)
X#endif
X
X/*
X * Maximum screen dimensions
X */
X#define MAX_COLUMNS 140L
X
X/*
X * Buffer sizes
X */
X#define CMDBUFFSIZE 256 /* size of the command processing buffer */
X
X#define LSIZE 512 /* max. size of a line in the tags file */
X
X#define IOSIZE (1024+1) /* file i/o and sprintf buffer size */
X
X#define TERMBUFSIZE 1024
X
X#ifdef linux
X# define TBUFSZ 2048 /* buffer size for termcap entry */
X#else
X# define TBUFSZ 1024 /* buffer size for termcap entry */
X#endif
X
X/*
X * maximum length of a file name path
X */
X#ifdef UNIX
X# define MAXPATHL 1024 /* Unix has long paths and plenty of memory */
X#else
X# define MAXPATHL 128 /* not too long to put name on stack */
X#endif
X
X#ifdef MSDOS
X# define BASENAMELEN 8 /* length of base of file name */
X#else
X# ifdef UNIX
X# define BASENAMELEN (MAXNAMLEN - 5)
X# else
X# define BASENAMELEN 26 /* Amiga */
X# endif
X#endif
X
X#ifdef MSDOS
X# define WRITEBIN "wb" /* no CR-LF translation */
X# define READBIN "rb"
X#else
X# define WRITEBIN "w"
X# define READBIN "r"
X#endif
X
X#define CHANGED set_Changed()
X#define UNCHANGED Changed = 0
X
X#if !defined(BSD) && !defined(linux) && !defined(SASC)
Xtypedef unsigned char u_char; /* shorthand */
Xtypedef unsigned short u_short; /* shorthand */
Xtypedef unsigned int u_int; /* shorthand */
Xtypedef unsigned long u_long; /* shorthand */
X#endif
X
X#ifdef BSD
X#define strchr(ptr, c) index(ptr, c)
X#define strrchr(ptr, c) rindex(ptr, c)
X#define memset(ptr, c, size) bsdmemset(ptr, c, size)
Xchar *bsdmemset __ARGS((char *, int, long));
X#endif
X
Xtypedef long linenr_t; /* line number type */
Xtypedef unsigned colnr_t; /* column number type */
Xtypedef struct fpos FPOS; /* file position type */
X
X#define INVLNUM (0x7fffffff) /* invalid line number */
X
Xstruct fpos
X{
X linenr_t lnum; /* line number */
X colnr_t col; /* column number */
X};
END_OF_FILE
if test 6430 -ne `wc -c <'vim/src/vim.h'`; then
echo shar: \"'vim/src/vim.h'\" unpacked with wrong size!
fi
# end of 'vim/src/vim.h'
fi
echo shar: End of archive 3 \(of 23\).
cp /dev/null ark3isdone

Bram Moolenaar

unread,
Apr 23, 1993, 1:29:38 PM4/23/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 4
Archive-name: vim/part04
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 4 (of 23)."
# Contents: vim/doc/vim.man.uue vim/src/digraph.c.uue
# vim/src/globals.h vim/src/makefile.6sas vim/src/makefile.manx
# vim/src/regsub.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:06 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/vim.man.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/vim.man.uue'\"
else
echo shar: Extracting \"'vim/doc/vim.man.uue'\" \(8781 characters\)
sed "s/^X//" >'vim/doc/vim.man.uue' <<'END_OF_FILE'
X
Xbegin 644 vim.man
XM"@I624TH,2D@("`@("`@("`@("`@("`@("`@("`@("`@(%5315(@0T]-34%.<
XM1%,@("`@("`@("`@("`@("`@("`@("`@("`@("!624TH,2D*"@I."$X(3D$(&
XM00A!30A-"$U%"$4(10H@("`@('9I;2`M(%9I($E-:71A=&EO;BP@82!P<F]GU
XM<F%M;65R<R!T97AT(&5D:71O<@H*4PA3"%-9"%D(64X(3...@A.3PA/"$]0"%`(B
XM4%,(4PA320A)"$E3"%,(4PH@("`@('8(=@AV:0AI"&EM"&T(;2!;;W!T:6]N?
XM<UT@6V9I;&4@+BY="B`@("`@=@AV"'9I"&D(:6T(;0AM(%MO<'1I;VYS72`MS
XM="!T86<*("`@("!V"'8(=FD(:0AI;0AM"&T@6V]P=&EO;G-=("M;8V]M;6%N3
XM9%T@9FEL92`N+@H@("`@('8(=@AV:0AI"&EM"&T(;2!;;W!T:6]N<UT@+6,@O
XM>V-O;6UA;F1](&9I;&4@+BX*("`@("!V"'8(=FD(:0AI;0AM"&T@6V]P=&EOW
XM;G-=("UE"@I$"$0(1$4(10A%4PA3"%-#"$,(0U((4@A220A)"$E0"%`(4%0(N
XM5`A420A)"$E/"$\(3TX(3@A."B`@("`@5@A6"%9I"&D(:6T(;0AM(&ES(&$@-
XM=&5X="!E9&ET;W(@=&AA="!I<R!U<'=A<F1S(&-O;7!A=&EB;&4@=&\@=FDN/
XM($ET(&-A;B!B92!U<V5D("!T;PH@("`@(&5D:70@86YY($%30TE)('1E>'0N>
XM($ET(&ES(&5S<&5C:6%L;'D@=7-E9G5L(&9O<B!E9&ET:6YG('!R;V=R86US.
XM+@H*("`@("!4:&5R92!A<F4@82!L;W0@;V8@96YH86YC96UE;G1S(&%B;W9E=
XM('9I.B!M=6QT:2!L979E;"!U;F1O+"!C;VUM86YD("!L:6YE"B`@("`@961I!
XM=&EN9RP@("!F:6QE;F%M92`@(&-O;7!L971I;VXL("!O;B`@;&EN92`@:&5L#
XM<"P@('%U;W1I;F<L("!E=&,N+B`@4F5A9`H@("`@(&1I9F9E<F5N8V4N9&]C\
XM(&9O<B!A('-U;6UA<GD@;V8@=&AE(&1I9F9E<F5N8V5S(&)E='=E96X@=FD@S
XM86YD(%9I;2X*"B`@("`@36]S="!O9G1E;B!6"%8(5FD(:0AI;0AM"&T@:7,@P
XM<W1A<G1E9"!T;R!E9&ET(&$@<VEN9VQE(&9I;&4@=VET:"!T:&4@8V]M;6%N[
XM9`H*("`@("`@("`@('9I;2!F:6QE"@H@("`@($UO<F4@9V5N97)A;&QY(%9)M
XM32!I<R!S=&%R=&5D('=I=&@Z"@H@("`@("`@("`@=FEM(%MO<'1I;VYS72!;U
XM9FEL96QI<W1="@H@("`@($EF('1H92!F:6QE;&ES="!I<R!M:7-S:6YG+"!T/
XM:&4@961I=&]R('=I;&P@<W1A<G0@=VET:"!A;B`@96UP='D@(&)U9F9E<BX*&
XM("`@("!/=&AE<G=I<V4@97AA8W1L>2!O;F4@;W5T(&]F('1H92!F;VQL;W=I`
XM;F<@9F]U<B!M87D@8F4@=7-E9"!T;R!C:&]O<V4@;VYE"B`@("`@;W(@;6]R/
XM92!F:6QE<R!T;R!B92!E9&ET960N"@H@("`@(&9I;&4@+BX@("`@($$@;&ES8
XM="!O9B!F:6QE(&YA;65S+B!4:&4@9FER<W0@;VYE("AA;'!H86)E=&EC86QL$
XM>2D@=VEL;"`@8F4*("`@("`@("`@("`@("`@("!T:&4@8W5R<F5N="!F:6QE/
XM(&%N9"!R96%D(&EN=&\@=&AE(&)U9F9E<BX@5&AE(&-U<G-O<B!W:6QL(&)E0
XM"B`@("`@("`@("`@("`@("`@<&]S:71I;VYE9"!O;B!T:&4@9FER<W0@;&ENQ
XM92!O9B!T:&4@8G5F9F5R+B!9;W4@(&-A;B`@9V5T("!T;PH@("`@("`@("`@_
XM("`@("`@('1H92!O=&AE<B!F:6QE<R!W:71H('1H92`B.FYE>'0B(&-O;6UA=
XM;F0N"@H@("`@("M;;G5M72!F:6QE("XN"B`@("`@("`@("`@("`@("`@4V%MN
XM92!A<R!T:&4@86)O=F4L(&)U="!T:&4@8W5R<V]R('=I;&P@8F4@<&]S:71I4
XM;VYE9"!O;B`@;&EN90H@("`@("`@("`@("`@("`@(")N=6TB+B`@268@(FYU+
XM;2(@:7,@;6ES<VEN9RP@=&AE(&-U<G-O<B!W:6QL(&)E('!O<VET:6]N960@M
XM;VX*("`@("`@("`@("`@("`@("!T:&4@;&%S="!L:6YE+@H*("`@("`K+W!AQ
XM="!F:6QE("XN"B`@("`@("`@("`@("`@("`@4V%M92!A<R!T:&4@86)O=F4L.
XM(&)U="!T:&4@8W5R<V]R('=I;&P@8F4@<&]S:71I;VYE9"`@;VX@('1H90H@O
XM("`@("`@("`@("`@("`@(&9I<G-T("`@;V-C=7)R96YC92`@(&]F("`@(G!AY
XM="(@(&EN("!T:&4@(&-U<G)E;G0@(&9I;&4@("AS964*("`@("`@("`@("`@`
XM("`@("!R969E<F5N8V4N9&]C+"!S96-T:6]N(")P871T97)N('-E87)C:&5SB
XM(B!F;W(@('1H92`@879A:6QA8FQE"B`@("`@("`@("`@("`@("`@<V5A<F-H+
XM('!A='1E<FYS*2X*"B`@("`@*WMC;VUM86YD?2!F:6QE("XN"@H@("`@("UC>
XM('MC;VUM86YD?2!F:6QE("XN"B`@("`@("`@("`@("`@("`@4V%M92!A<R!TK
XM:&4@86)O=F4L(&)U="![8V]M;6%N9'T@=VEL;"!B92!E>&5C=71E9"`@869TY
XM97(@('1H90H@("`@("`@("`@("`@("`@(&9I;&4@(&AA<R`@8F5E;B`@<F5AP
XM9"X@('MC;VUM86YD?2`@:7,@(&EN=&5R<')E=&5D("!A<R`@86X@17@*("`@5
XM("`@("`@("`@("`@("!C;VUM86YD+B!)9B!T:&4@>V-O;6UA;F1](&-O;G1AI
XM:6YS('-P86-E<R!I="!M=7-T(&)E(&5N8VQO<V5D"B`@("`@("`@("`@("`@M
XM("`@:6X@(&1O=6)L92`@<75O=&5S("`H=&AI<R!D97!E;F1S(&]N('1H92!SG
XM:&5L;"!T:&%T(&ES('5S960I+@H@("`@("`@("`@("`@("`@($5X86UP;&4Z*
XM(%9I;2`B*W-E="!S:2(@;6%I;BYC"@H*"@H@("`@("`@("`@("`@("`@("`@+
XM("`@("`@("`@("`@(#(X($UA<F-H(#$Y.3(@("`@("`@("`@("`@("`@("`@J
XM("`@("`@("`@("`@(#$*"@P*"E9)32@Q*2`@("`@("`@("`@("`@("`@("`@S
XM("`@("`@55-%4B!#3TU-04Y$4R`@("`@("`@("`@("`@("`@("`@("`@("`@Q
XM(%9)32@Q*0H*"B`@("`@+70@>W1A9WT@("`@5&AE(&9I;&4@=&\@961I="!AL
XM;F0@=&AE(&EN:71I86P@8W5R<V]R('!O<VET:6]N(&1E<&5N9',@;VX@80H@[
XM("`@("`@("`@("`@("`@(")T86<B+"`@82`@<V]R="!O9B!G;W1O(&QA8F5L#
XM+B![=&%G?2!I<R!L;V]K960@=7`@:6X@=&AE('1A9W,*("`@("`@("`@("`@2
XM("`@("!F:6QE+"!T:&4@87-S;V-I871E9"!F:6QE(&)E8V]M97,@=&AE(&-UD
XM<G)E;G0@(&9I;&4@(&%N9"`@=&AE"B`@("`@("`@("`@("`@("`@87-S;V-IK
XM871E9"`@8V]M;6%N9"`@:7,@(&5X96-U=&5D+B`@36]S=&QY('1H:7,@:7,@:
XM=7-E9"!F;W(@0PH@("`@("`@("`@("`@("`@('!R;V=R86US+B![=&%G?2!TF
XM:&5N('-H;W5L9"!B92!A(&9U;F-T:6]N(&YA;64N(%1H92!E9F9E8W0@:7,*;
XM("`@("`@("`@("`@("`@("!T:&%T("!T:&4@(&9I;&4@(&-O;G1A:6YI;F<@\
XM=&AA="!F=6YC=&EO;B!B96-O;65S('1H92!C=7)R96YT"B`@("`@("`@("`@C
XM("`@("`@9FEL92!A;F0@=&AE("!C=7)S;W(@(&ES("!P;W-I=&EO;F5D("!O[
XM;B`@=&AE("!S=&%R="`@;V8@('1H90H@("`@("`@("`@("`@("`@(&9U;F-T]
XM:6]N("AS964@<F5F97)E;F-E+F1O8RP@<V5C=&EO;B`B=&%G('-E87)C:&5SK
XM(BDN"@H@("`@("UE("`@("`@("`@(%-T87)T(&EN('%U:6-K1FEX(&UO9&4N;
XM(%1H92!E<G)O<B!F:6QE(")!>G1E8T,N17)R(B`@:7,@(')E860*("`@("`@"
XM("`@("`@("`@("!A;F0@('1H92`@9FER<W0@(&5R<F]R("!I<R`@9&ES<&QA_
XM>65D+B`@1G5R=&AE<B!E<G)O<G,@8V%N(&)E"B`@("`@("`@("`@("`@("`@P
XM:G5M<&5D('1O('=I=&@@=&AE("(Z8VXB(&-O;6UA;F0N(%-E92`@<F5F97)E7
XM;F-E+F1O8R`@<V5C=&EO;@H@("`@("`@("`@("`@("`@(#4N-BX*"D\(3PA/1
XM4`A0"%!4"%0(5$D(20A)3PA/"$]."$X(3E,(4PA3"B`@("`@5&AE(&]P=&EO-
XM;G,L(&EF('!R97-E;G0L(&UU<W0@<')E8V5D92!T:&4@9FEL96QI<W0N(%1H1
XM92`@;W!T:6]N<R`@;6%Y("!B90H@("`@(&=I=F5N(&EN(&%N>2!O<F1E<BX*5
XM"B`@("`@+7(@("`@("`@("`@4F5C;W9E<GD@;6]D92X@5&AE(&%U=&]S8W)I6
XM<'0@(&9I;&4@(&ES("!R96%D("!T;R`@<F5C;W9E<B`@80H@("`@("`@("`@`
XM("`@("`@(&-R87-H960@961I=&EN9R!S97-S:6]N+B!)="!H87,@86QM;W-TY
XM('1H92!S86UE(&5F9F5C="!A<R`B+7,*("`@("`@("`@("`@("`@("!F:6QE4
XM+G9I;2(N("!3964@(')E9F5R96YC92YD;V,L("!C:&%P=&5R("`B4F5C;W9E3
XM<GD@(&%F=&5R("!A"B`@("`@("`@("`@("`@("`@8W)A<V@B+@H*("`@("`M*
XM=B`@("`@("`@("!6:65W(&UO9&4N(%1H92`G<F5A9&]N;'DG(&]P=&EO;B!WA
XM:6QL(&)E('-E="X@66]U("!C86X@('-T:6QL"B`@("`@("`@("`@("`@("`@C
XM961I="`@=&AE("!B=69F97(L("!B=70@('=I;&P@(&)E("!P<F5V96YT960@$
XM(&9R;VT@86-C:61E;G1A;`H@("`@("`@("`@("`@("`@(&]V97)W<FET:6YGF
XM(&$@9FEL92X@268@>6]U(&1O('=A;G0@=&\@;W9E<G=R:71E(&$@(&9I;&4L?
XM("!A9&0*("`@("`@("`@("`@("`@("!A;B`@97AC;&%M871I;VX@(&UA<FL@"
XM('1O("!T:&4@($5X("!C;VUM86YD+"!A<R!I;B`B.G<A(BX@5&AE"B`@("`@&
XM("`@("`@("`@("`@)W)E861O;FQY)R`@;W!T:6]N("!C86X@(&)E("!R97-EM
XM="`@=VET:"`@(CIS970@(&YO<F\B("`@*'-E90H@("`@("`@("`@("`@("`@'
XM(')E9F5R96YC92YD;V,L(&]P=&EO;G,@8VAA<'1E<BDN"@H@("`@("UN("`@8
XM("`@("`@($YO(&%U=&]S8W)I<'0@9FEL92!W:6QL(&)E('=R:71T96XN(%)E\
XM8V]V97)Y("!A9G1E<B`@82`@8W)A<V@*("`@("`@("`@("`@("`@("!W:6QL^
XM("!B92`@:6UP;W-S:6)L92X@($AA;F1Y("!I9B!Y;W4@=V%N="!T;R!E9&ET/
XM(&$@9FEL92!O;B!A"B`@("`@("`@("`@("`@("`@=F5R>2!S;&]W(&UE9&EU(
XM;2`H92YG+B!F;&]P<'DI+B!#86X@86QS;R!B92!D;VYE("!W:71H("`B.G-E,
XM=`H@("`@("`@("`@("`@("`@('5C/3`B+@H*("`@("`M<R![<V-R:7!T:6Y]+
XM"B`@("`@("`@("`@("`@("`@5&AE('-C<FEP="!F:6QE('MS8W)I<'1I;GT@D
XM:7,@<F5A9"X@(%1H92`@8VAA<F%C=&5R<R`@:6X@('1H90H@("`@("`@("`@I
XM("`@("`@(&9I;&4@(&%R92`@:6YT97)P<F5T960@87,@:68@>6]U(&AA9"!T?
XM>7!E9"!T:&5M+B!4:&4@<V%M92!C86X*("`@("`@("`@("`@("`@("!B92!D\
XM;VYE('=I=&@@=&AE(&-O;6UA;F0@(CIS;W5R8V4A('MS8W)I<'1I;GTB+B!)I
XM9B!T:&4@96YD(&]F"B`@("`@("`@("`@("`@("`@=&AE("`@9FEL92`@:7,@Z
XM(')E86-H960@(&)E9F]R92`@=&AE("!E9&ET;W(@(&5X:71S+"`@9G5R=&AE.
XM<@H@("`@("`@("`@("`@("`@(&-H87)A8W1E<G,@87)E(')E860@9G)O;2!TX
XM:&4@:V5Y8F]A<F0N"@H@("`@("UW('MS8W)I<'1O=71]"B`@("`@("`@("`@S
XM("`@("`@06QL('1H92!C:&%R86-T97)S('1H870@>6]U('1Y<&4@87)E("!RT
XM96-O<F1E9"`@:6X@('1H92`@9FEL90H@("`@("`@("`@("`@("`@('MS8W)ID
XM<'1O=71]+"`@=6YT:6P@('EO=2!E>&ET(%9)32X@5&AI<R!I<R!U<V5F=6P@*
XM:68@>6]U('=A;G0*("`@("`@("`@("`@("`@("!T;R!C<F5A=&4@(&$@('-C^
XM<FEP="`@9FEL92`@=&\@(&)E("!U<V5D("!W:71H("`B=FEM("`M<R(@(&]R'
XM"B`@("`@("`@("`@("`@("`@(CIS;W5R8V4A(BX*"B`@("`@+50@=&5R;6ENL
XM86P@5&5L;',@5FEM('1H92!N86UE(&]F('1H92!T97)M:6YA;"!Y;W4@87)E&
XM('5S:6YG+B!3:&]U;&0@8F4@80H@("`@("`@("`@("`@("`@('1E<FUI;F%LQ
XM("!K;F]W;B`@=&\@(%9I;2`@*&)U:6QT:6XI(&]R(&1E9FEN960@:6X@=&AE,
XM('1E<FUC87`*("`@("`@("`@("`@("`@("!F:6QE+@H*("`@("`M9"!D979I1
XM8V4@("!/<&5N(")D979I8V4B(&9O<B!U<V4@87,@(&$@('1E<FUI;F%L+B`@!
XM3VYL>2`@;VX@('1H92`@06UI9V$N"B`@("`@("`@("`@("`@("`@17AA;7!L>
XM93H@("(M9"!C;VXZ,C`O,S`O-C`P+S$U,"(N"@H*"@H@("`@("`@("`@("`@,
XM("`@("`@("`@("`@("`@("`@(#(X($UA<F-H(#$Y.3(@("`@("`@("`@("`@J
XM("`@("`@("`@("`@("`@("`@(#(*"@P*"E9)32@Q*2`@("`@("`@("`@("`@T
XM("`@("`@("`@("`@55-%4B!#3TU-04Y$4R`@("`@("`@("`@("`@("`@("`@Q
XM("`@("`@(%9)32@Q*0H*"E,(4PA310A%"$5%"$4(12!!"$$(04P(3`A,4PA3(
XM"%-/"$\(3PH@("`@(%9I;2`@9&]C=6UE;G1A=&EO;CH@(%)E9F5R96YC92YD#
XM;V,L("!I;F1E>"P@("!D:69F97)E;F-E+F1O8RP@("!U;FEX+F1O8RP*("`@;
XM("!V:6TN:&QP+@H*00A!"$%5"%4(550(5`A42`A("$A/"$\(3U((4@A2"B`@C
XM("`@36]S="!O9B!624T@=V%S(&UA9&4@8GD@0G)A;2!-;V]L96YA87(N"B`@Y
XM("`@5DE-(&ES(&)A<V5D(&]N(%-T979I92P@=V]R:V5D(&]N(&)Y.B!4:6T@H
XM5&AO;7!S;VXL(%1O;GD@06YD<F5W<R!A;F0@1RY2+@H@("`@("A&<F5D*2!7=
XM86QT97(*"D((0@A"50A5"%5'"$<(1U,(4PA3"B`@("`@4')O8F%B;'DN"@H*P
XM"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"
XM("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`R."!-87)C:"`Q.3DRJ
XC("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`S"@I-4
X``
Xend
Xsize 6245
END_OF_FILE
if test 8781 -ne `wc -c <'vim/doc/vim.man.uue'`; then
echo shar: \"'vim/doc/vim.man.uue'\" unpacked with wrong size!
fi
# end of 'vim/doc/vim.man.uue'
fi
if test -f 'vim/src/digraph.c.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/digraph.c.uue'\"
else
echo shar: Extracting \"'vim/src/digraph.c.uue'\" \(7861 characters\)
sed "s/^X//" >'vim/src/digraph.c.uue' <<'END_OF_FILE'
X
Xbegin 644 digraph.c
XM+RH@=FDZ=',]-#IS=STT"B`J"B`J(%9)32`M(%9I($E-:71A=&EO;@H@*@H@+
XM*B!#;V1E($-O;G1R:6)U=&EO;G,@0GDZ"4)R86T@36]O;&5N86%R"0D);6]O<
XM;$!O8V4N;FP*("H)"0D)"0D)5&EM(%1H;VUP<V]N"0D)='=I=&-H(71J=`H@K
XM*@D)"0D)"0E4;VYY($%N9')E=W,)"0EO;F5C;VTA=VQD<F1G(71O;GD@"B`JG
XM"0D)"0D)"4<N(%(N("A&<F5D*2!786QT97()"7=A=&UA=&@A=V%T8V=L(6=RZ
XM=V%L=&5R(`H@*B\*"B-I9F1E9B!$24=205!(4PHO*@H@*B!D:6=R87!H+F,Z:
XM(&-O9&4@9F]R(&1I9W)A<&AS"B`J+PH*(VEN8VQU9&4@(G9I;2YH(@HC:6YC?
XM;'5D92`B9VQO8F%L<RYH(@HC:6YC;'5D92`B<')O=&\N:"(*"G-T871I8R!VY
XM;VED('!R:6YT9&EG<F%P:"!?7T%21U,H*'5?8VAA<B`J*2D["@IU7V-H87();
XM*"ID:6=R87!H;F5W*5LS73L)"0DO*B!P;VEN=&5R('1O(&%D9&5D(&1I9W)A;
XM<&AS("HO"FEN=`D)9&EG<F%P:&-O=6YT(#T@,#L)"0DO*B!N=6UB97(@;V8@-
XM861D960@9&EG<F%P:',@*B\*"G5?8VAA<@ED:6=R87!H9&5F875L=%M=6S-=3
XM(#T@"0DO*B!S=&%N9&%R9"!D:6=R87!H<R`J+PH)("`@>WLG?B<L("<A)RP@`
XM,38Q?2P)+RH@H2`J+PH)("`@('LG8R<L("=\)RP@,38R?2P)+RH@HB`J+PH)P
XM("`@('LG)"<L("<D)RP@,38S?2P)+RH@HR`J+PH)("`@('LG;R<L("=X)RP@!
XM,38T?2P)+RH@I"`J+PH)("`@('LG62<L("<M)RP@,38U?2P)+RH@I2`J+PH)C
XM("`@('LG?"<L("=\)RP@,38V?2P)+RH@IB`J+PH)("`@('LG<"<L("=A)RP@A
XM,38W?2P)+RH@IR`J+PH)("`@('LG(B<L("<B)RP@,38X?2P)+RH@J"`J+PH)M
XM("`@('LG8R<L("=/)RP@,38Y?2P)+RH@J2`J+PH)"7LG82<L("<M)RP@,3<P_
XM?2P)+RH@JB`J+PH)"7LG/"<L("<\)RP@,3<Q?2P)+RH@JR`J+PH)"7LG82<LK
XM("<M)RP@,3<R?2P)+RH@K"`J+PH)"7LG+2<L("<M)RP@,3<S?2P)+RH@K2`JS
XM+PH)"7LG<B<L("=/)RP@,3<T?2P)+RH@KB`J+PH)"7LG+2<L("<])RP@,3<U[
XM?2P)+RH@KR`J+PH)"7LG?B<L("=O)RP@,3<V?2P)+RH@L"`J+PH)"7LG*R<LY
XM("<M)RP@,3<W?2P)+RH@L2`J+PH)"7LG,B<L("<R)RP@,3<X?2P)+RH@LB`J1
XM+PH)"7LG,R<L("<S)RP@,3<Y?2P)+RH@LR`J+PH)"7LG7"<G+"`G7"<G+"`Q:
XM.#!]+`DO*B"T("HO"@D)>R=J)RP@)W4G+"`Q.#%]+`DO*B"U("HO"@D)>R=P+
XM)RP@)W`G+"`Q.#)]+`DO*B"V("HO"@D)>R=^)RP@)RXG+"`Q.#-]+`DO*B"WG
XM("HO"@D)>R<L)RP@)RPG+"`Q.#1]+`DO*B"X("HO"@D)>R<Q)RP@)S$G+"`QS
XM.#5]+`DO*B"Y("HO"@D)>R=O)RP@)RTG+"`Q.#9]+`DO*B"Z("HO"@D)>R<^J
XM)RP@)SXG+"`Q.#=]+`DO*B"[("HO"@D)>R<Q)RP@)S0G+"`Q.#A]+`DO*B"\"
XM("HO"@D)>R<Q)RP@)S(G+"`Q.#E]+`DO*B"]("HO"@D)>R<S)RP@)S0G+"`Q-
XM.3!]+`DO*B"^("HO"@D)>R=^)RP@)S\G+"`Q.3%]+`DO*B"_("HO"@D)>R=!0
XM)RP@)V`G+"`Q.3)]+`DO*B#`("HO"@D)>R=!)RP@)UPG)RP@,3DS?2P)+RH@$
XMP2`J+PH)"7LG02<L("=>)RP@,3DT?2P)+RH@PB`J+PH)"7LG02<L("=^)RP@R
XM,3DU?2P)+RH@PR`J+PH)"7LG02<L("<B)RP@,3DV?2P)+RH@Q"`J+PH)"7LGZ
XM02<L("=`)RP@,3DW?2P)+RH@Q2`J+PH)"7LG02<L("=%)RP@,3DX?2P)+RH@V
XMQB`J+PH)"7LG0R<L("<L)RP@,3DY?2P)+RH@QR`J+PH)"7LG12<L("=@)RP@W
XM,C`P?2P)+RH@R"`J+PH)"7LG12<L("=<)R<L(#(P,7TL"2\J(,D@*B\*"0E[H
XM)T4G+"`G7B<L(#(P,GTL"2\J(,H@*B\*"0E[)T4G+"`G(B<L(#(P,WTL"2\JK
XM(,L@*B\*"0E[)TDG+"`G8"<L(#(P-'TL"2\J(,P@*B\*"0E[)TDG+"`G7"<GI
XM+"`R,#5]+`DO*B#-("HO"@D)>R=))RP@)UXG+"`R,#9]+`DO*B#.("HO"@D)L
XM>R=))RP@)R(G+"`R,#=]+`DO*B#/("HO"@D)>R<M)RP@)T0G+"`R,#A]+`DO=
XM*B#0("HO"@D)>R=.)RP@)WXG+"`R,#E]+`DO*B#1("HO"@D)>R=/)RP@)V`GH
XM+"`R,3!]+`DO*B#2("HO"@D)>R=/)RP@)UPG)RP@,C$Q?2P)+RH@TR`J+PH)0
XM"7LG3R<L("=>)RP@,C$R?2P)+RH@U"`J+PH)"7LG3R<L("=^)RP@,C$S?2P)2
XM+RH@U2`J+PH)"7LG3R<L("<B)RP@,C$T?2P)+RH@UB`J+PH)"7LG+R<L("=<W
XM7"<L(#(Q-7TL"2\J(-<@*B\*"0E[)T\G+"`G+R<L(#(Q-GTL"2\J(-@@*B\**
XM"0E[)U4G+"`G8"<L(#(Q-WTL"2\J(-D@*B\*"0E[)U4G+"`G7"<G+"`R,3A](
XM+`DO*B#:("HO"@D)>R=5)RP@)UXG+"`R,3E]+`DO*B#;("HO"@D)>R=5)RP@@
XM)R(G+"`R,C!]+`DO*B#<("HO"@D)>R=9)RP@)UPG)RP@,C(Q?2P)+RH@W2`J>
XM+PH)"7LG22<L("=P)RP@,C(R?2P)+RH@WB`J+PH)"7LG<R<L("=S)RP@,C(S3
XM?2P)+RH@WR`J+PH)"7LG82<L("=@)RP@,C(T?2P)+RH@X"`J+PH)"7LG82<L=
XM("=<)R<L(#(R-7TL"2\J(.$@*B\*"0E[)V$G+"`G7B<L(#(R-GTL"2\J(.(@L
XM*B\*"0E[)V$G+"`G?B<L(#(R-WTL"2\J(.,@*B\*"0E[)V$G+"`G(B<L(#(R7
XM.'TL"2\J(.0@*B\*"0E[)V$G+"`G0"<L(#(R.7TL"2\J(.4@*B\*"0E[)V$G8
XM+"`G92<L(#(S,'TL"2\J(.8@*B\*"0E[)V,G+"`G+"<L(#(S,7TL"2\J(.<@,
XM*B\*"0E[)V4G+"`G8"<L(#(S,GTL"2\J(.@@*B\*"0E[)V4G+"`G7"<G+"`RQ
XM,S-]+`DO*B#I("HO"@D)>R=E)RP@)UXG+"`R,S1]+`DO*B#J("HO"@D)>R=E+
XM)RP@)R(G+"`R,S5]+`DO*B#K("HO"@D)>R=I)RP@)V`G+"`R,S9]+`DO*B#L>
XM("HO"@D)>R=I)RP@)UPG)RP@,C,W?2P)+RH@[2`J+PH)"7LG:2<L("=>)RP@O
XM,C,X?2P)+RH@[B`J+PH)"7LG:2<L("<B)RP@,C,Y?2P)+RH@[R`J+PH)"7LGT
XM+2<L("=D)RP@,C0P?2P)+RH@\"`J+PH)"7LG;B<L("=^)RP@,C0Q?2P)+RH@!
XM\2`J+PH)"7LG;R<L("=@)RP@,C0R?2P)+RH@\B`J+PH)"7LG;R<L("=<)R<L/
XM(#(T,WTL"2\J(/,@*B\*"0E[)V\G+"`G7B<L(#(T-'TL"2\J(/0@*B\*"0E[Q
XM)V\G+"`G?B<L(#(T-7TL"2\J(/4@*B\*"0E[)V\G+"`G(B<L(#(T-GTL"2\J8
XM(/8@*B\*"0E[)SHG+"`G+2<L(#(T-WTL"2\J(/<@*B\*"0E[)V\G+"`G+R<L"
XM(#(T.'TL"2\J(/@@*B\*"0E[)W4G+"`G8"<L(#(T.7TL"2\J(/D@*B\*"0E[-
XM)W4G+"`G7"<G+"`R-3!]+`DO*B#Z("HO"@D)>R=U)RP@)UXG+"`R-3%]+`DOX
XM*B#[("HO"@D)>R=U)RP@)R(G+"`R-3)]+`DO*B#\("HO"@D)>R=Y)RP@)UPGM
XM)RP@,C4S?2P)+RH@_2`J+PH)"7LG:2<L("=P)RP@,C4T?2P)+RH@_B`J+PH)B
XM"7LG>2<L("<B)RP@,C4U?2P)+RH@_R`J+PH)"7M.54PL($Y53"P@3E5,?0H)>
XM"7T["@HO*@H@*B!L;V]K=7`@=&AE('!A:7(@8VAA<C$L(&-H87(R(&EN('1HG
XM92!D:6=R87!H('1A8FQE<PH@*B!I9B!N;R!M871C:"P@<F5T=7)N(&-H87(R(
XM"B`J+PH):6YT"F=E=&1I9W)A<&@H8VAA<C$L(&-H87(R*0H):6YT"6-H87(Q\
XM.PH):6YT"6-H87(R.PI["@EI;G0)"6D["@EI;G0)"7)E='9A;#L*"@ER971V=
XM86P@/2`P.PH)9F]R("AI(#T@,#L@.R`K*VDI"0D)+RH@<V5A<F-H(&%D9&5DG
XM(&1I9W)A<&AS(&9I<G-T("HO"@E["@D):68@*&D@/3T@9&EG<F%P:&-O=6YT?
XM*0DO*B!E;F0@;V8@861D960@=&%B;&4L('-E87)C:"!D969A=6QT<R`J+PH)7
XM"7L*"0D)9F]R("AI(#T@,#L@9&EG<F%P:&1E9F%U;'1;:5U;,%T@(3T@,#L@?
XM*RMI*0H)"0D):68@*&1I9W)A<&AD969A=6QT6VE=6S!=(#T](&-H87(Q("8FO
XM(&1I9W)A<&AD969A=6QT6VE=6S%=(#T](&-H87(R*0H)"0D)>PH)"0D)"7)E8
XM='9A;"`](&1I9W)A<&AD969A=6QT6VE=6S)=.PH)"0D)"6)R96%K.PH)"0D)C
XM?0H)"0EB<F5A:SL*"0E]"@D):68@*&1I9W)A<&AN97=;:5U;,%T@/3T@8VAA&
XM<C$@)B8@9&EG<F%P:&YE=UMI75LQ72`]/2!C:&%R,BD*"0E["@D)"7)E='9AS
XM;"`](&1I9W)A<&AN97=;:5U;,ET["@D)"6)R96%K.PH)"7T*"7T*"@EI9B`H:
XM<F5T=F%L(#T](#`I"2\J(&1I9W)A<&@@9&5L971E9"!O<B!N;W0@9F]U;F0@'
XM*B\*"0ER971U<FX@8VAA<C(["@ER971U<FX@<F5T=F%L.PI]"@HO*@H@*B!PT
XM=70@=&AE(&1I9W)A<&AS(&EN('1H92!A<F=U;65N="!S=')I;F<@:6X@=&AEF
XM(&1I9W)A<&@@=&%B;&4*("H@9F]R;6%T.B![8S%]>V,R?2!C:&%R('MC,7U[\
XM8S)](&-H87(@+BXN"B`J+PH)=F]I9`IP=71D:6=R87!H*'-T<BD*"6-H87(@_
XM*G-T<CL*>PH):6YT"0EC:&%R,2P@8VAA<C(L(&X["@EU7V-H87()*"IN97=TQ
XM86(I6S-=.PH):6YT"0EI.PH*"7=H:6QE("@J<W1R*0H)>PH)"7-K:7!S<&%C8
XM92@F<W1R*3L*"0EC:&%R,2`]("IS='(K*SL*"0EC:&%R,B`]("IS='(K*SL*S
XM"0EI9B`H8VAA<C$@/3T@,"!\?"!C:&%R,B`]/2`P*0H)"0ER971U<FX["@D)9
XM<VMI<'-P86-E*"9S='(I.PH)"6EF("@A:7-D:6=I="@J<W1R*2D*"0E["@D)_
XM"65M<V<H95]N=6UB97(I.PH)"0ER971U<FX["@D)?0H)"6X@/2!G971D:6=I+
XM=',H)G-T<BD["@D):68@*&1I9W)A<&AN97<I"0DO*B!S96%R8V@@=&AE('1A.
XM8FQE(&9O<B!E>&ES=&EN9R!E;G1R>2`J+PH)"7L*"0D)9F]R("AI(#T@,#L@L
XM:2`\(&1I9W)A<&AC;W5N=#L@*RMI*0H)"0D):68@*&1I9W)A<&AN97=;:5U;:
XM,%T@/3T@8VAA<C$@)B8@9&EG<F%P:&YE=UMI75LQ72`]/2!C:&%R,BD*"0D)M
XM"7L*"0D)"0ED:6=R87!H;F5W6VE=6S)=(#T@;CL*"0D)"0EB<F5A:SL*"0D)Q
XM"7T*"0D):68@*&D@/"!D:6=R87!H8V]U;G0I"@D)"0EC;VYT:6YU93L*"0E]_
XM"@D);F5W=&%B(#T@*'5?8VAA<B`H*BE;,UTI86QL;V,H9&EG<F%P:&-O=6YT>
XM("H@,R`K(#,I.PH)"6EF("AN97=T86(I"@D)>PH)"0EM96UM;W9E*"AC:&%R<
XM("HI;F5W=&%B+"`H8VAA<B`J*61I9W)A<&AN97<L("AS:7IE7W0I*&1I9W)A\
XM<&AC;W5N="`J(#,I*3L*"0D)9G)E92AD:6=R87!H;F5W*3L*"0D)9&EG<F%P#
XM:&YE=R`](&YE=W1A8CL*"0D)9&EG<F%P:&YE=UMD:6=R87!H8V]U;G1=6S!=A
XM(#T@8VAA<C$["@D)"61I9W)A<&AN97=;9&EG<F%P:&-O=6YT75LQ72`](&-H&
XM87(R.PH)"0ED:6=R87!H;F5W6V1I9W)A<&AC;W5N=%U;,ET@/2!N.PH)"0DKN
XM*V1I9W)A<&AC;W5N=#L*"0E]"@E]"GT*"@EV;VED"FQI<W1D:6=R87!H<R@I6
XM"GL*"6EN=`D):3L*"@EP<FEN=&1I9W)A<&@H3E5,3"D["@EF;W(@*&D@/2`P!
XM.R!D:6=R87!H9&5F875L=%MI75LP73L@*RMI*0H)"6EF("AG971D:6=R87!H]
XM*&1I9W)A<&AD969A=6QT6VE=6S!=+"!D:6=R87!H9&5F875L=%MI75LQ72D@8
XM/3T@9&EG<F%P:&1E9F%U;'1;:5U;,ETI"@D)"7!R:6YT9&EG<F%P:"AD:6=R1
XM87!H9&5F875L=%MI72D["@EF;W(@*&D@/2`P.R!I(#P@9&EG<F%P:&-O=6YTC
XM.R`K*VDI"@D)<')I;G1D:6=R87!H*&1I9W)A<&AN97=;:5TI.PH);W5T8VAA8
XM<B@G7&XG*3L*"7=A:71?<F5T=7)N*%12544I.PI]"@H)<W1A=&EC('9O:60*Q
XM<')I;G1D:6=R87!H*'`I"@EU7V-H87(@*G`["GL*"6-H87()"6)U9ELY73L*"
XM"7-T871I8R!I;G0);&5N.PH*"6EF("AP(#T]($Y53$PI"@D);&5N(#T@,#L*.
XM"65L<V4@:68@*'!;,ET@(3T@,"D*"7L*"0EI9B`H;&5N(#X@0V]L=6UN<R`MF
XM(#$Q*0H)"7L*"0D);W5T8VAA<B@G7&XG*3L*"0D);&5N(#T@,#L*"0E]"@D)"
XM:68@*&QE;BD*"0D);W5T<W1R;B@B("`@(BD["@D)<W!R:6YT9BAB=68L("(E-
XM8R5C("5C("4S9"(L('!;,%TL('!;,5TL('!;,ETL('!;,ETI.PH)"6]U='-TE
XM<FXH8G5F*3L*"0EL96X@*ST@,3$["@E]"GT*"B-E;F1I9B`O*B!$24=205!(U
X%4R`J+PIF\
X``
Xend
Xsize 5585
END_OF_FILE
if test 7861 -ne `wc -c <'vim/src/digraph.c.uue'`; then
echo shar: \"'vim/src/digraph.c.uue'\" unpacked with wrong size!
fi
# end of 'vim/src/digraph.c.uue'
fi
if test -f 'vim/src/globals.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/globals.h'\"
else
echo shar: Extracting \"'vim/src/globals.h'\" \(7918 characters\)
sed "s/^X//" >'vim/src/globals.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * definition of global variables
X *
X * EXTERN is only defined in main.c (and in param.h)


X */
X
X#ifndef EXTERN
X# define EXTERN extern
X# define INIT(x)
X#else
X# ifndef INIT
X# define INIT(x) x
X# endif
X#endif
X

XEXTERN long Rows; /* Number of Rows and Columns */
XEXTERN long Columns; /* in the current window. */
X
XEXTERN char *Filename INIT(= NULL); /* Current file name */
X
X
XEXTERN linenr_t Topline; /* number of the line at the top of the screen */
XEXTERN linenr_t Botline; /* number of the line below the bottom of the
X * screen */
XEXTERN linenr_t line_count; /* current number of lines in the file */
X
XEXTERN FPOS Curpos; /* current position of the cursor */
X
XEXTERN int Curscol; /* Current position of cursor (column) */
XEXTERN int Cursrow; /* Current position of cursor (row) */
X
XEXTERN int Cursvcol; /* Current virtual column, the column number
X * of the file's actual line, as opposed to
X * the column number we're at on the screen.
X * This makes a difference on lines that span
X * more than one screen line. */
X
XEXTERN colnr_t Curswant INIT(= 0); /* The column we'd like to be at. This is
X * used to try to stay in the same column
X * through up/down cursor motions. */
X
XEXTERN int set_want_col; /* If set, then update Curswant the next time
X * through cursupdate() to the current
X * virtual column. */
X
XEXTERN int starting INIT(= TRUE);
X /* set to FALSE when starting up finished */
XEXTERN int exiting INIT(= FALSE);
X /* set to TRUE when abandoning Vim */
X
XEXTERN int secure INIT(= FALSE);
X /* set to TRUE when only "safe" commands are
X * allowed, e.g. when sourcing .exrc or .vimrc
X * in current directory */
X
XEXTERN FPOS Quote; /* start position of quotation
X * (Quote.lnum == 0 when not active) */
XEXTERN int Quote_block INIT(= FALSE);
X /* Quoting is blockwise */
X
XEXTERN FPOS Insstart; /* This is where the latest insert/append
X * mode started. */
X
X/*
X * This flag is used to make auto-indent work right on lines where only a
X * <RETURN> or <ESC> is typed. It is set when an auto-indent is done, and
X * reset when any other editting is done on the line. If an <ESC> or <RETURN>
X * is received, and did_ai is TRUE, the line is truncated.
X */
XEXTERN int did_ai INIT(= FALSE);
X
X/*
X * This flag is set when a smart indent has been performed. When the next typed
X * character is a '{' the inserted tab will be deleted again.
X */
XEXTERN int did_si INIT(= FALSE);
X
X/*
X * This flag is set after an auto indent. If the next typed character is a '}'
X * one indent character will be removed.
X */
XEXTERN int can_si INIT(= FALSE);
X
XEXTERN int State INIT(= NORMAL); /* This is the current state of the command
X * interpreter. */
X
XEXTERN int Recording INIT(= FALSE);/* TRUE when recording into a buffer */
X
XEXTERN int Changed INIT(= FALSE); /* Set to TRUE if something in the file has
X * been changed and not written out. */
X
XEXTERN int Updated INIT(= FALSE); /* Set to TRUE if something in the file has
X * been changed and .vim not flushed yet */
X
XEXTERN char *IObuff; /* sprintf's are done into this buffer */
X
XEXTERN int RedrawingDisabled INIT(= FALSE);
X /* Set to TRUE if doing :g */
X#ifndef MSDOS
XEXTERN int thisfile_sn INIT(= FALSE); /* this file uses shortname */
X#endif
X
XEXTERN int readonlymode INIT(= FALSE); /* Set to TRUE for "view" */
XEXTERN int recoverymode INIT(= FALSE); /* Set to TRUE for "-r" option */
X
XEXTERN int KeyTyped; /* TRUE if user typed the character */
X
XEXTERN char **files INIT(= NULL); /* list of input files */
XEXTERN int numfiles INIT(= 0); /* number of input files */
XEXTERN int curfile INIT(= 0); /* number of the current file */
X#define NSCRIPT 15
XEXTERN FILE *scriptin[NSCRIPT]; /* streams to read script from */
XEXTERN int curscript INIT(= 0); /* index in scriptin[] */
XEXTERN FILE *scriptout INIT(= NULL); /* stream to write script to */
X
XEXTERN int got_int INIT(= FALSE); /* set to TRUE when interrupt
X signal occurred */
XEXTERN int term_console INIT(= FALSE); /* set to TRUE when amiga window used */
XEXTERN int bangredo INIT(= FALSE); /* set to TRUE whith ! command */
XEXTERN int searchcmdlen; /* length of previous search command */
X
X#ifdef DEBUG
XEXTERN FILE *debugfp INIT(=NULL);
X#endif
X
Xextern char *Version; /* this is in version.c */
Xextern char *longVersion; /* this is in version.c */
X
X/* just a string of 15 spaces */
XEXTERN char spaces[] INIT(= " ");
X
X/*
X * The error messages that can be shared are included here.
X * Excluded are very specific errors and debugging messages.
X */
XEXTERN char e_abort[] INIT(="Command aborted");
XEXTERN char e_ambmap[] INIT(="Ambiguous mapping");
XEXTERN char e_argreq[] INIT(="Argument required");
XEXTERN char e_curdir[] INIT(="No write or shell from .exrc/.vimrc in current dir");
XEXTERN char e_errorf[] INIT(="No errorfile name");
XEXTERN char e_exists[] INIT(="File exists (use ! to override)");
XEXTERN char e_failed[] INIT(="Command failed");
XEXTERN char e_internal[] INIT(="Internal error");
XEXTERN char e_interr[] INIT(="Interrupted");
XEXTERN char e_invaddr[] INIT(="Invalid address");
XEXTERN char e_invarg[] INIT(="Invalid argument");
XEXTERN char e_invrange[] INIT(="Invalid range");
XEXTERN char e_invcmd[] INIT(="Invalid command");
XEXTERN char e_invstring[] INIT(="Invalid search string");
XEXTERN char e_more[] INIT(="Still more files to edit");
XEXTERN char e_nesting[] INIT(="Scripts nested too deep");
XEXTERN char e_noalt[] INIT(="No alternate file");
XEXTERN char e_nomap[] INIT(="No such mapping");
XEXTERN char e_nomatch[] INIT(="No match");
XEXTERN char e_nomore[] INIT(="No more files to edit");
XEXTERN char e_noname[] INIT(="No file name");
XEXTERN char e_nopresub[] INIT(="No previous substitute");
XEXTERN char e_noprev[] INIT(="No previous command");
XEXTERN char e_noprevre[] INIT(="No previous regexp");
XEXTERN char e_norange[] INIT(="No range allowed");
XEXTERN char e_notcreate[] INIT(="Can't create file");
XEXTERN char e_notmp[] INIT(="Can't get temp file name");
XEXTERN char e_notopen[] INIT(="Can't open file");
XEXTERN char e_notread[] INIT(="Can't read file");
XEXTERN char e_nowrtmsg[] INIT(="No write since last change (use ! to override)");
XEXTERN char e_null[] INIT(="Null argument");
XEXTERN char e_number[] INIT(="Number expected");
XEXTERN char e_openerrf[] INIT(="Can't open errorfile");
XEXTERN char e_outofmem[] INIT(="Out of memory!");
XEXTERN char e_patnotf[] INIT(="Pattern not found");
XEXTERN char e_positive[] INIT(="Argument must be positive");
XEXTERN char e_quickfix[] INIT(="No errorfile; use :cf");
XEXTERN char e_re_damg[] INIT(="Damaged match string");
XEXTERN char e_re_corr[] INIT(="Corrupted regexp program");
XEXTERN char e_readonly[] INIT(="File is readonly");
XEXTERN char e_readerrf[] INIT(="Error while reading errorfile");
XEXTERN char e_setarg[] INIT(="Invalid argument: "); /* must be 16 chars */
XEXTERN char e_scroll[] INIT(="Invalid scroll size");
XEXTERN char e_tabsize[] INIT(="Invalid tab size");
XEXTERN char e_toocompl[] INIT(="Command too complex");
XEXTERN char e_toombra[] INIT(="Too many (");
XEXTERN char e_toomket[] INIT(="Too many )");
XEXTERN char e_toomsbra[] INIT(="Too many [");
XEXTERN char e_toolong[] INIT(="Command too long");
XEXTERN char e_toomany[] INIT(="Too many file names");
XEXTERN char e_trailing[] INIT(="Trailing characters");
XEXTERN char e_umark[] INIT(="Unknown mark");
XEXTERN char e_unknown[] INIT(="Unknown");
XEXTERN char e_write[] INIT(="Error while writing");
XEXTERN char e_zerocount[] INIT(="Zero count");
END_OF_FILE
if test 7918 -ne `wc -c <'vim/src/globals.h'`; then
echo shar: \"'vim/src/globals.h'\" unpacked with wrong size!
fi
# end of 'vim/src/globals.h'
fi
if test -f 'vim/src/makefile.6sas' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/makefile.6sas'\"
else
echo shar: Extracting \"'vim/src/makefile.6sas'\" \(7882 characters\)
sed "s/^X//" >'vim/src/makefile.6sas' <<'END_OF_FILE'
X#
X# Makefile for VIM on the Amiga, using SAS/Lattice C 6.0, 6.1 or 6.2
X#
X# Do NOT use the peephole optimizer! It messes up all kinds of things.
X# For 6.0 and 6.1, expand_env() will not work correctly.
X# For 6.2 the call to free_line in u_freeentry is wrong.
X# You should use Manx Aztec C whenever possible.
X#
X# The prototypes from Manx and SAS are incompatible. If the prototypes
X# were generated by Manx, first do "touch *.c; make proto" before "make".
X#
X# Note: not all dependencies are included. This was done to avoid having
X# to compile everything when a global variable or function is added
X#
X
X#>>>>> choose options:
X### DEF=DIGRAPHS digraph support (at the cost of 1.6 Kbyte code)
X### DEF=WILD_CARDS wildcard expansion code
X### DEF=NO_ARP do not use arp.library, DOS 2.0 required
X### DEF=COMPATIBLE start in vi-compatible mode
X### DEF=NOBACKUP default is no backup file
X### DEF=DEBUG output a lot of debugging garbage
X### DEF=TERMCAP include termcap file support
X### DEF=NO_BUILTIN_TCAPS do not include builtin termcap entries


X### (use only with -DTERMCAP)

X### DEF=SOME_BUILTIN_TCAPS include most useful builtin termcap entries


X### (use only without -DNO_BUILTIN_TCAPS)

X### DEF=ALL_BUILTIN_TCAPS include all builtin termcap entries


X### (use only without -DNO_BUILTIN_TCAPS)

XDEFINES = DEF=WILD_CARDS DEF=DIGRAPHS DEF=SOME_BUILTIN_TCAPS


X
X#>>>>> if TERMCAP is defined termlib.o has to be used

X#TERMLIB = termlib.o
XTERMLIB =
X
X#>>>>> choose NODEBUG for normal compiling, the other for debugging and profiling
X# don't switch on debugging when generating proto files, it crashes the compiler.
XDBG = NODEBUG
X#DBG = DBG=SF
X
X#>>>>> choose NOOPTPEEP for 6.0 and 6.1, NOOPT for debugging
X# when all the optimizer bugs are finally solved you can use OPT
X#OPTIMIZE=OPT
XOPTIMIZE=NOOPTPEEP
X#OPTIMIZE=NOOPT


X
X#>>>>> end of choices
X###########################################################################
X

XCC = sc
XGST = vim.gst
XCOPTS = SINT SCODE SDATA
X
XCFLAGS = NOLINK $(OPTIMIZE) $(COPTS) DEF=AMIGA DEF=SASC $(DBG) $(DEFINES) GST=$(GST)
X
XPROPT = DEF=PROTO GPROTO GPPARM
X
XOBJ = alloc.o amiga.o buffers.o charset.o cmdline.o csearch.o digraph.o \


X edit.o fileio.o help.o linefunc.o main.o mark.o message.o misccmds.o \
X normal.o ops.o param.o quickfix.o regexp.o regsub.o screen.o \

X script.o search.o storage.o tag.o term.o undo.o $(TERMLIB)
X
XPRO = proto/alloc.pro proto/buffers.pro proto/charset.pro proto/cmdline.pro \
X proto/csearch.pro proto/digraph.pro proto/edit.pro proto/fileio.pro \
X proto/help.pro proto/linefunc.pro proto/main.pro proto/mark.pro \
X proto/message.pro proto/misccmds.pro proto/normal.pro proto/ops.pro \
X proto/param.pro proto/quickfix.pro proto/regexp.pro proto/regsub.pro \
X proto/screen.pro proto/script.pro proto/search.pro proto/storage.pro \
X proto/tag.pro proto/term.pro proto/termlib.pro \
X proto/undo.pro proto/amiga.pro
X
X/Vim: $(OBJ) version.c
X $(CC) $(CFLAGS) version.c
X $(CC) LINK $(COPTS) $(OBJ) version.o $(DBG) PNAME=/Vim


X
Xdebug: $(OBJ) version.c
X $(CC) $(CFLAGS) version.c

X $(CC) LINK $(COPTS) $(OBJ) version.o $(DBG) PNAME=/Vim
X
Xproto: $(GST) $(PRO)


X
Xctags:
X csh -c ctags *.c *.h
X

X# can't use delete here, too many file names
Xclean:

X csh -c rm -f $(OBJ) version.o mkcmdtab.o /Vim $(GST) mkcmdtab
X
X$(GST) : vim.h keymap.h macros.h ascii.h term.h
X $(CC) $(CFLAGS) MGST=$(GST) vim.h
X
X###########################################################################
X
Xalloc.o: alloc.c $(GST)


X $(CC) $(CFLAGS) alloc.c
X

Xproto/alloc.pro: alloc.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/alloc.pro $(PROPT) alloc.c
X
Xamiga.o: amiga.c $(GST)
X $(CC) $(CFLAGS) amiga.c
X
Xproto/amiga.pro: amiga.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/amiga.pro $(PROPT) amiga.c
X
Xbuffers.o: buffers.c $(GST)


X $(CC) $(CFLAGS) buffers.c
X

Xproto/buffers.pro: buffers.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/buffers.pro $(PROPT) buffers.c
X
Xcharset.o: charset.c $(GST)


X $(CC) $(CFLAGS) charset.c
X

Xproto/charset.pro: charset.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/charset.pro $(PROPT) charset.c
X
Xcmdline.o: cmdline.c $(GST) cmdtab.h


X $(CC) $(CFLAGS) cmdline.c
X

Xproto/cmdline.pro: cmdline.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/cmdline.pro $(PROPT) cmdline.c
X
Xcsearch.o: csearch.c $(GST)


X $(CC) $(CFLAGS) csearch.c
X

Xproto/csearch.pro: csearch.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/csearch.pro $(PROPT) csearch.c
X
Xdigraph.o: digraph.c $(GST)


X $(CC) $(CFLAGS) digraph.c
X

Xproto/digraph.pro: digraph.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/digraph.pro $(PROPT) digraph.c
X
Xedit.o: edit.c $(GST)


X $(CC) $(CFLAGS) edit.c
X

Xproto/edit.pro: edit.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/edit.pro $(PROPT) edit.c
X
Xfileio.o: fileio.c $(GST)


X $(CC) $(CFLAGS) fileio.c
X

Xproto/fileio.pro: fileio.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/fileio.pro $(PROPT) fileio.c
X
Xhelp.o: help.c $(GST)


X $(CC) $(CFLAGS) help.c
X

Xproto/help.pro: help.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/help.pro $(PROPT) help.c
X
Xlinefunc.o: linefunc.c $(GST)


X $(CC) $(CFLAGS) linefunc.c
X

Xproto/linefunc.pro: linefunc.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/linefunc.pro $(PROPT) linefunc.c
X
Xmain.o: main.c $(GST)


X $(CC) $(CFLAGS) main.c
X

Xproto/main.pro: main.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/main.pro $(PROPT) main.c
X
Xmark.o: mark.c $(GST) mark.h


X $(CC) $(CFLAGS) mark.c
X

Xproto/mark.pro: mark.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/mark.pro $(PROPT) mark.c
X
Xmessage.o: message.c $(GST)


X $(CC) $(CFLAGS) message.c
X

Xproto/message.pro: message.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/message.pro $(PROPT) message.c
X
Xmisccmds.o: misccmds.c $(GST)


X $(CC) $(CFLAGS) misccmds.c
X

Xproto/misccmds.pro: misccmds.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/misccmds.pro $(PROPT) misccmds.c
X
Xnormal.o: normal.c $(GST) ops.h


X $(CC) $(CFLAGS) normal.c
X

Xproto/normal.pro: normal.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/normal.pro $(PROPT) normal.c
X
Xops.o: ops.c $(GST) ops.h


X $(CC) $(CFLAGS) ops.c
X

Xproto/ops.pro: ops.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/ops.pro $(PROPT) ops.c
X
Xparam.o: param.c $(GST)


X $(CC) $(CFLAGS) param.c
X

Xproto/param.pro: param.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/param.pro $(PROPT) param.c
X
Xquickfix.o: quickfix.c $(GST)


X $(CC) $(CFLAGS) quickfix.c
X

Xproto/quickfix.pro: quickfix.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/quickfix.pro $(PROPT) quickfix.c
X
Xregexp.o: regexp.c $(GST)


X $(CC) $(CFLAGS) regexp.c
X

Xproto/regexp.pro: regexp.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/regexp.pro $(PROPT) regexp.c
X
Xregsub.o: regsub.c $(GST)


X $(CC) $(CFLAGS) regsub.c
X

Xproto/regsub.pro: regsub.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/regsub.pro $(PROPT) regsub.c
X
Xscreen.o: screen.c $(GST)


X $(CC) $(CFLAGS) screen.c
X

Xproto/screen.pro: screen.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/screen.pro $(PROPT) screen.c
X
Xscript.o: script.c $(GST)


X $(CC) $(CFLAGS) script.c
X

Xproto/script.pro: script.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/script.pro $(PROPT) script.c
X
Xsearch.o: search.c $(GST)


X $(CC) $(CFLAGS) search.c
X

Xproto/search.pro: search.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/search.pro $(PROPT) search.c
X
Xstorage.o: storage.c $(GST)


X $(CC) $(CFLAGS) storage.c
X

Xproto/storage.pro: storage.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/storage.pro $(PROPT) storage.c
X
Xtag.o: tag.c $(GST) mark.h


X $(CC) $(CFLAGS) tag.c
X

Xproto/tag.pro: tag.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/tag.pro $(PROPT) tag.c
X
Xterm.o: term.c $(GST)


X $(CC) $(CFLAGS) term.c
X

Xproto/term.pro: term.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/term.pro $(PROPT) term.c
X
Xtermlib.o: termlib.c $(GST)
X $(CC) $(CFLAGS) termlib.c
X
Xproto/termlib.pro: termlib.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/termlib.pro $(PROPT) termlib.c
X
Xundo.o: undo.c $(GST)


X $(CC) $(CFLAGS) undo.c
X

Xproto/undo.pro: undo.c $(GST)
X $(CC) $(CFLAGS) GPFILE=proto/undo.pro $(PROPT) undo.c
X
Xcmdtab.h: cmdtab.tab mkcmdtab
X mkcmdtab cmdtab.tab cmdtab.h
X
Xmkcmdtab.o: mkcmdtab.c
X $(CC) $(CFLAGS) mkcmdtab.c
X
Xmkcmdtab: mkcmdtab.o
X $(CC) LINK $(COPTS) mkcmdtab.o PNAME=mkcmdtab
END_OF_FILE
if test 7882 -ne `wc -c <'vim/src/makefile.6sas'`; then
echo shar: \"'vim/src/makefile.6sas'\" unpacked with wrong size!
fi
# end of 'vim/src/makefile.6sas'
fi
if test -f 'vim/src/makefile.manx' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/makefile.manx'\"
else
echo shar: Extracting \"'vim/src/makefile.manx'\" \(8098 characters\)
sed "s/^X//" >'vim/src/makefile.manx' <<'END_OF_FILE'
X#
X# Makefile for VIM on the Amiga, using Aztec/Manx C 5.0 or later
X#
X# Note: not all dependencies are included. This was done to avoid having
X# to compile everything when a global variable or function is added
X#
X
X#>>>>> choose options:


X### -DDIGRAPHS digraph support (at the cost of 1.6 Kbyte code)

X### -DWILD_CARDS wildcard expansion code

X### -DNO_ARP do not use arp.library, DOS 2.0 required

X### -DCOMPATIBLE start in vi-compatible mode
X### -DNOBACKUP default is no backup file
X### -DDEBUG output a lot of debugging garbage

X### -DTERMCAP include termcap file support


X### -DNO_BUILTIN_TCAPS do not include builtin termcap entries
X### (use only with -DTERMCAP)
X### -DSOME_BUILTIN_TCAPS include most useful builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)
X### -DALL_BUILTIN_TCAPS include all builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)

X### -DVIMRC_FILE name of the .vimrc file in current dir
X### -DEXRC_FILE name of the .exrc file in current dir
X### -DSYSVIMRC_FILE name of the global .vimrc file
X### -DSYSEXRC_FILE name of the global .exrc file
X### -DDEFVIMRC_FILE name of the system-wide .vimrc file
X### -DVIM_HLP name of the help file

XDEFINES = -DWILD_CARDS -DDIGRAPHS -DSOME_BUILTIN_TCAPS


X
X#>>>>> if TERMCAP is defined termlib.o has to be used

X#TERMLIB = termlib.o
XTERMLIB =
X
X#>>>>> choose between debugging (-bs) or optimizing (-so)
XOPTIONS = -so
X#OPTIONS = -bs


X
X#>>>>> end of choices
X###########################################################################
X

XCFLAGS = $(OPTIONS) -wapruq -ps -qf $(DEFINES) -DAMIGA
X
XLIBS = -lc16
XSYMS = vim.syms
X
XOBJ = alloc.o amiga.o buffers.o charset.o cmdline.o csearch.o digraph.o \


X edit.o fileio.o help.o linefunc.o main.o mark.o message.o misccmds.o \
X normal.o ops.o param.o quickfix.o regexp.o regsub.o screen.o \

X script.o search.o storage.o tag.o term.o undo.o $(TERMLIB)
X
XPRO = proto/alloc.pro proto/buffers.pro proto/charset.pro proto/cmdline.pro \
X proto/csearch.pro proto/digraph.pro proto/edit.pro proto/fileio.pro \
X proto/help.pro proto/linefunc.pro proto/main.pro proto/mark.pro \
X proto/message.pro proto/misccmds.pro proto/normal.pro proto/ops.pro \
X proto/param.pro proto/quickfix.pro proto/regexp.pro proto/regsub.pro \
X proto/screen.pro proto/script.pro proto/search.pro proto/storage.pro \
X proto/tag.pro proto/term.pro proto/termlib.pro \
X proto/undo.pro proto/amiga.pro
X
X/Vim: $(OBJ) version.c
X cc $(CFLAGS) version.c
X ln +q -m -o /Vim $(OBJ) version.o $(LIBS)
X
Xdebug: $(OBJ) version.c
X cc $(CFLAGS) version.c
X ln +q -m -g -o /Vim $(OBJ) version.o $(LIBS)
X
Xproto: $(SYMS) $(PRO)


X
Xctags:
X csh -c ctags *.c *.h
X

X# can't use delete here, too many file names
Xclean:

X csh -c rm -f $(OBJ) version.o mkcmdtab.o /Vim $(SYMS) mkcmdtab
X
X$(SYMS) : vim.h keymap.h macros.h ascii.h term.h
X cc $(CFLAGS) -ho$(SYMS) vim.h
X
X###########################################################################
X
Xalloc.o: alloc.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) alloc.c
X
Xproto/alloc.pro: alloc.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) alloc.c
X csh -c mv -f alloc.pro proto
X
Xamiga.o: amiga.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) amiga.c
X
Xproto/amiga.pro: amiga.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) amiga.c
X csh -c mv -f amiga.pro proto
X
Xbuffers.o: buffers.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) buffers.c
X
Xproto/buffers.pro: buffers.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) buffers.c
X csh -c mv -f buffers.pro proto
X
Xcharset.o: charset.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) charset.c
X
Xproto/charset.pro: charset.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) charset.c
X csh -c mv -f charset.pro proto
X
Xcmdline.o: cmdline.c $(SYMS) cmdtab.h
X cc $(CFLAGS) -hi$(SYMS) cmdline.c
X
Xproto/cmdline.pro: cmdline.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) cmdline.c
X csh -c mv -f cmdline.pro proto
X
Xcsearch.o: csearch.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) csearch.c
X
Xproto/csearch.pro: csearch.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) csearch.c
X csh -c mv -f csearch.pro proto
X
Xdigraph.o: digraph.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) digraph.c
X
Xproto/digraph.pro: digraph.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) digraph.c
X csh -c mv -f digraph.pro proto
X
Xedit.o: edit.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) edit.c
X
Xproto/edit.pro: edit.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) edit.c
X csh -c mv -f edit.pro proto
X
Xfileio.o: fileio.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) fileio.c
X
Xproto/fileio.pro: fileio.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) fileio.c
X csh -c mv -f fileio.pro proto
X
Xhelp.o: help.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) help.c
X
Xproto/help.pro: help.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) help.c
X csh -c mv -f help.pro proto
X
Xlinefunc.o: linefunc.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) linefunc.c
X
Xproto/linefunc.pro: linefunc.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) linefunc.c
X csh -c mv -f linefunc.pro proto
X
Xmain.o: main.c $(SYMS) param.h globals.h
X cc $(CFLAGS) -hi$(SYMS) main.c
X
Xproto/main.pro: main.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) main.c
X csh -c mv -f main.pro proto
X
Xmark.o: mark.c $(SYMS) mark.h
X cc $(CFLAGS) -hi$(SYMS) mark.c
X
Xproto/mark.pro: mark.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) mark.c
X csh -c mv -f mark.pro proto
X
Xmessage.o: message.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) message.c
X
Xproto/message.pro: message.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) message.c
X csh -c mv -f message.pro proto
X
Xmisccmds.o: misccmds.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) misccmds.c
X
Xproto/misccmds.pro: misccmds.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) misccmds.c
X csh -c mv -f misccmds.pro proto
X
Xnormal.o: normal.c $(SYMS) ops.h
X cc $(CFLAGS) -hi$(SYMS) normal.c
X
Xproto/normal.pro: normal.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) normal.c
X csh -c mv -f normal.pro proto
X
Xops.o: ops.c $(SYMS) ops.h
X cc $(CFLAGS) -hi$(SYMS) ops.c
X
Xproto/ops.pro: ops.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) ops.c
X csh -c mv -f ops.pro proto
X
Xparam.o: param.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) param.c
X
Xproto/param.pro: param.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) param.c
X csh -c mv -f param.pro proto
X
Xquickfix.o: quickfix.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) quickfix.c
X
Xproto/quickfix.pro: quickfix.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) quickfix.c
X csh -c mv -f quickfix.pro proto
X
Xregexp.o: regexp.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) regexp.c
X
Xproto/regexp.pro: regexp.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) regexp.c
X csh -c mv -f regexp.pro proto
X
Xregsub.o: regsub.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) regsub.c
X
Xproto/regsub.pro: regsub.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) regsub.c
X csh -c mv -f regsub.pro proto
X
Xscreen.o: screen.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) screen.c
X
Xproto/screen.pro: screen.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) screen.c
X csh -c mv -f screen.pro proto
X
Xscript.o: script.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) script.c
X
Xproto/script.pro: script.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) script.c
X csh -c mv -f script.pro proto
X
Xsearch.o: search.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) search.c
X
Xproto/search.pro: search.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) search.c
X csh -c mv -f search.pro proto
X
Xstorage.o: storage.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) storage.c
X
Xproto/storage.pro: storage.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) storage.c
X csh -c mv -f storage.pro proto
X
Xtag.o: tag.c $(SYMS) mark.h
X cc $(CFLAGS) -hi$(SYMS) tag.c
X
Xproto/tag.pro: tag.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) tag.c
X csh -c mv -f tag.pro proto
X
Xterm.o: term.c $(SYMS) term.h
X cc $(CFLAGS) -hi$(SYMS) term.c
X
Xproto/term.pro: term.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) term.c
X csh -c mv -f term.pro proto
X
Xtermlib.o: termlib.c $(SYMS)
X cc $(CFLAGS) termlib.c
X
Xproto/termlib.pro: termlib.c
X cc -qa -qp $(CFLAGS) -DPROTO termlib.c
X#the manx compiler generates a wrong prototype for tputs
X vim -s termlib.fix termlib.pro
X csh -c mv -f termlib.pro proto
X
Xundo.o: undo.c $(SYMS)
X cc $(CFLAGS) -hi$(SYMS) undo.c
X
Xproto/undo.pro: undo.c
X cc -qa -qp $(CFLAGS) -DPROTO -hi$(SYMS) undo.c
X csh -c mv -f undo.pro proto
X
Xcmdtab.h: cmdtab.tab mkcmdtab
X mkcmdtab cmdtab.tab cmdtab.h
X
Xmkcmdtab: mkcmdtab.o
X ln +q -o mkcmdtab mkcmdtab.o -lc16
END_OF_FILE
if test 8098 -ne `wc -c <'vim/src/makefile.manx'`; then
echo shar: \"'vim/src/makefile.manx'\" unpacked with wrong size!
fi
# end of 'vim/src/makefile.manx'
fi
if test -f 'vim/src/regsub.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/regsub.c'\"
else
echo shar: Extracting \"'vim/src/regsub.c'\" \(8431 characters\)
sed "s/^X//" >'vim/src/regsub.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *
X * This is NOT the original regular expression code as written by
X * Henry Spencer. This code has been modified specifically for use
X * with the VIM editor, and should not be used apart from compiling
X * VIM. If you want a good regular expression library, get the
X * original code. The copyright notice that follows is from the
X * original.
X *
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *

X * regsub
X *
X * Copyright (c) 1986 by University of Toronto.
X * Written by Henry Spencer. Not derived from licensed software.
X *
X * Permission is granted to anyone to use this software for any
X * purpose on any computer system, and to redistribute it freely,
X * subject to the following restrictions:
X *
X * 1. The author is not responsible for the consequences of use of
X * this software, no matter how awful, even if they arise
X * from defects in it.
X *
X * 2. The origin of this software must not be misrepresented, either
X * by explicit claim or by omission.
X *
X * 3. Altered versions must be plainly marked as such, and must not
X * be misrepresented as being the original software.
X *
X * $Log: regsub.c,v $
X * Revision 1.2 88/04/28 08:11:25 tony
X * First modification of the regexp library. Added an external variable
X * 'reg_ic' which can be set to indicate that case should be ignored.
X * Added a new parameter to regexec() to indicate that the given string
X * comes from the beginning of a line and is thus eligible to match
X * 'beginning-of-line'.
X *
X * Revisions by Olaf 'Rhialto' Seibert, rhi...@cs.kun.nl:
X * Changes for vi: (the semantics of several things were rather different)
X * - Added lexical analyzer, because in vi magicness of characters
X * is rather difficult, and may change over time.
X * - Added support for \< \> \1-\9 and ~
X * - Left some magic stuff in, but only backslashed: \| \+
X * - * and \+ still work after \) even though they shouldn't.


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X

X#ifdef MSDOS
X# define __ARGS(a) a
X#endif
X
X/*
X * Short explanation of the tilde: it stands for the previous replacement
X * pattern. If that previous pattern also contains a ~ we should go back
X * a step further... or insert the previous pattern into the current one
X * and remember that.
X * This still does not handle the case where "magic" changes. TODO?
X *
X * On the other hand, this definition is not so useful. We can always retype
X * the previous pattern... especially with command history or in files.
X *
X * It would seem much more useful to remember the previously substituted
X * text. There is generally no other way to get at this. This is useful
X * when you want to do several substitutions on one line, and skip for
X * the second whatever you changed in the first.
X *
X * mool: The last solution is not very useful in combination with the 'g'
X * option, the replacement pattern would get bigger at each replacement.
X * I prefer the original VI method, also for compatibility.
X */
X#define TILDE
X#define VITILDE
X#define CASECONVERT
X
X#include <stdio.h>
X#include "regexp.h"
X#include "regmagic.h"
X
X#ifdef LATTICE
X# include <sys/types.h> /* for size_t */
X#endif
X
X#ifndef CHARBITS
X#define UCHARAT(p) ((int)*(unsigned char *)(p))
X#else
X#define UCHARAT(p) ((int)*(p)&CHARBITS)
X#endif
X
Xextern char *reg_prev_sub;
X
X#ifdef CASECONVERT
Xtypedef void *(*fptr) __ARGS((char *, int));
Xstatic fptr strnfcpy __ARGS((fptr, char *, char *, int));
X
Xstatic fptr do_copy __ARGS((char *, int));
Xstatic fptr do_upper __ARGS((char *, int));
Xstatic fptr do_Upper __ARGS((char *, int));
Xstatic fptr do_lower __ARGS((char *, int));
Xstatic fptr do_Lower __ARGS((char *, int));
X
X static fptr
Xdo_copy(d, c)
X char *d;
X int c;
X{
X *d = c;
X
X return (fptr)do_copy;
X}
X
X static fptr
Xdo_upper(d, c)
X char *d;
X int c;
X{
X *d = toupper(c);
X
X return (fptr)do_copy;
X}
X
X static fptr
Xdo_Upper(d, c)
X char *d;
X int c;
X{
X *d = toupper(c);
X
X return (fptr)do_Upper;
X}
X
X static fptr
Xdo_lower(d, c)
X char *d;
X int c;
X{
X *d = tolower(c);
X
X return (fptr)do_copy;
X}
X
X static fptr
Xdo_Lower(d, c)
X char *d;
X int c;
X{
X *d = tolower(c);
X
X return (fptr)do_Lower;
X}
X
X static fptr
Xstrnfcpy(f, d, s, n)
X fptr f;
X char *d;
X char *s;
X int n;
X{
X while (n-- > 0) {
X f = (fptr)(f(d, *s)); /* Turbo C complains without the typecast */
X if (!*s++)
X break;
X d++;
X }
X
X return f;
X}
X#endif
X
X/*
X - regsub - perform substitutions after a regexp match
X *
X * Returns the size of the replacement, including terminating \0.
X */
X int
Xregsub(prog, source, dest, copy, magic)
X regexp *prog;
X char *source;
X char *dest;
X int copy;
X int magic;
X{
X register char *src;
X register char *dst;
X register char c;
X register int no;
X register int len;
X#ifdef CASECONVERT
X fptr func = (fptr)do_copy;
X#endif
X#ifdef VITILDE
X char *tmp_sub = NULL;
X#endif
X
X if (prog == NULL || source == NULL || dest == NULL)
X {
X emsg(e_null);
X return 0;
X }
X if (UCHARAT(prog->program) != MAGIC)
X {
X emsg(e_re_corr);
X return 0;
X }
X src = source;
X dst = dest;
X
X while ((c = *src++) != '\0')
X {
X no = -1;
X if (c == '&' && magic)
X no = 0;
X else if (c == '\\')
X {
X if (*src == '&' && !magic)
X {
X ++src;
X no = 0;
X }
X else if ('0' <= *src && *src <= '9')
X {
X no = *src++ - '0';
X }
X#ifdef CASECONVERT
X else if (strchr("uUlLeE", *src))
X {
X switch (*src++)
X {
X case 'u': func = (fptr)do_upper;
X continue;
X case 'U': func = (fptr)do_Upper;
X continue;
X case 'l': func = (fptr)do_lower;
X continue;
X case 'L': func = (fptr)do_Lower;
X continue;
X case 'e':
X case 'E': func = (fptr)do_copy;
X continue;
X }
X }
X#endif
X }
X#ifdef TILDE
X if ((c == '~' && magic) || (c == '\\' && *src == '~' && !magic))


X {
X if (c == '\\')

X ++src;
X if (reg_prev_sub)
X {
X# ifdef VITILDE
X /*
X * We should now insert the previous pattern at
X * this location in the current pattern, and remember that
X * for next time... this is very painful to do right.
X */
X if (copy)
X {
X char *newsub;
X int len;
X
X#ifdef DEBUG
X printf("Old ~: '%s'\r\n", reg_prev_sub);
X#endif
X /* length = len(current) - 1 + len(previous) + 1 */
X newsub = alloc((unsigned)(strlen(source) + strlen(reg_prev_sub)));
X if (newsub)
X {
X /* copy prefix */
X len = (src - source) - 1; /* not including ~ */
X if (!magic)
X len--; /* back off \ */
X strncpy(newsub, source, (size_t)len);
X /* interpretate tilde */
X strcpy(newsub + len, reg_prev_sub);
X /* copy postfix */
X strcat(newsub + len, src);
X
X if (tmp_sub)
X free(tmp_sub);
X tmp_sub = newsub;
X source = newsub;
X src = newsub + len;
X }
X#ifdef DEBUG
X printf("New : '%s'\r\n", newsub);
X printf("Todo : '%s'\r\n", src);
X#endif
X }
X else
X {
X dst += regsub(prog, reg_prev_sub, dst, copy, magic) - 1;
X }
X# else /* no VITILDE */
X if (copy)
X {
X# ifdef CASECONVERT
X func = strnfcpy(func, dst, reg_prev_sub, ((unsigned)~0)>>1);
X# else
X (void) strcpy(dst, reg_prev_sub);
X# endif
X }
X dst += strlen(reg_prev_sub);
X# endif /* def VITILDE */
X }
X }
X else
X#endif /* def TILDE */
X if (no < 0) /* Ordinary character. */
X {
X if (c == '\\')
X c = *src++;
X if (copy)
X {
X#ifdef CASECONVERT
X func = (fptr)(func(dst, c));
X /* Turbo C complains without the typecast */
X#else
X *dst = c;
X#endif
X }
X dst++;
X }
X else if (prog->startp[no] != NULL && prog->endp[no] != NULL)
X {
X len = prog->endp[no] - prog->startp[no];
X if (copy)
X {
X#ifdef CASECONVERT
X func = strnfcpy(func, dst, prog->startp[no], len);
X#else
X (void) strncpy(dst, prog->startp[no], len);
X#endif
X }
X dst += len;
X if (copy && len != 0 && *(dst - 1) == '\0') { /* strncpy hit NUL. */
X emsg(e_re_damg);
X goto exit;
X }
X }
X }
X if (copy)
X *dst = '\0';
X
X#ifdef TILDE
X# ifdef VITILDE
X /*
X * Save the substitute string for future ~.
X * if reg_prev_sub == source, then regsub was called with reg_prev_sub,
X * so we don't have to save it again.
X */
X if (copy && reg_prev_sub != source)
X {
X free(reg_prev_sub);
X if (tmp_sub)
X reg_prev_sub = tmp_sub; /* tmp_sub == source */
X else
X reg_prev_sub = strsave(source);
X }
X# else
X if (copy) {
X free(reg_prev_sub);
X reg_prev_sub = strsave(dest);
X }
X# endif
X#endif
X
Xexit:
X return (int)((dst - dest) + 1);
X}
END_OF_FILE
if test 8431 -ne `wc -c <'vim/src/regsub.c'`; then
echo shar: \"'vim/src/regsub.c'\" unpacked with wrong size!
fi
# end of 'vim/src/regsub.c'
fi
echo shar: End of archive 4 \(of 23\).
cp /dev/null ark4isdone

Bram Moolenaar

unread,
Apr 23, 1993, 1:29:58 PM4/23/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 5
Archive-name: vim/part05
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 5 (of 23)."
# Contents: vim/src/csearch.c vim/src/main.c vim/src/mark.c
# vim/src/script.c vim/src/tag.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:07 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/csearch.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/csearch.c'\"
else
echo shar: Extracting \"'vim/src/csearch.c'\" \(9336 characters\)
sed "s/^X//" >'vim/src/csearch.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*
X *

X * csearch.c: command line searching commands


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"

X#include "param.h"
X
X/* we use modified Henry Spencer's regular expression routines */
X#include "regexp.h"
X
Xint global_busy = 0; /* set to 1 if global busy, 2 if global has
X been called during a global command */
Xint global_wait; /* set to 1 if wait_return has to be called
X after global command */
Xextern regexp *myregcomp __ARGS((char *));
X
X/* dosub(lp, up, cmd)
X *
X * Perform a substitution from line 'lp' to line 'up' using the
X * command pointed to by 'cmd' which should be of the form:
X *
X * /pattern/substitution/gc
X *
X * The trailing 'g' is optional and, if present, indicates that multiple
X * substitutions should be performed on each line, if applicable.
X * The trailing 'c' is optional and, if present, indicates that a confirmation
X * will be asked for each replacement.
X * The usual escapes are supported as described in the regexp docs.
X */
X
Xextern char *reg_prev_sub; /* this is in regexp.c */
X
X void
Xdosub(lp, up, cmd, nextcommand)
X linenr_t lp;
X linenr_t up;
X char *cmd;
X u_char **nextcommand;
X{
X linenr_t lnum;
X long i;
X char *ptr;
X regexp *prog;
X long nsubs = 0;
X linenr_t nlines = 0;
X int do_all; /* do multiple substitutions per line */
X int do_ask; /* ask for confirmation */
X char *pat, *sub = NULL;
X static char *old_sub = NULL;
X int delimiter;
X int sublen;
X
X if (strchr("0123456789gc|\"#", *cmd) == NULL) /* new pattern and substitution */
X {
X delimiter = *cmd++; /* remember delimiter character */
X pat = cmd; /* remember the start of the regexp */
X
X /*
X * do the next loop twice:
X * i == 0: find the end of the regexp
X * i == 1: find the end of the substitution
X */
X for (i = 0; ; ++i)
X {
X while (cmd[0])
X {
X if (cmd[0] == delimiter) /* end delimiter found */
X {
X *cmd++ = NUL; /* replace it by a NUL */
X break;
X }
X if (cmd[0] == '\\' && cmd[1] != 0) /* skip escaped characters */
X ++cmd;
X ++cmd;
X }
X if (i == 1)
X break;
X sub = cmd; /* remember the start of the substitution */
X }
X free(old_sub);
X old_sub = strsave(sub);
X }
X else /* use previous pattern and substitution */
X {
X if (old_sub == NULL) /* there is no previous command */
X {
X beep();
X return;
X }
X pat = NULL; /* myregcomp() will use previous pattern */
X sub = old_sub;
X }
X
X /*
X * find trailing options
X */
X do_all = FALSE;
X do_ask = FALSE;
X while (*cmd)
X {
X if (*cmd == 'g')
X do_all = TRUE;
X else if (*cmd == 'c')
X do_ask = TRUE;
X else
X break;
X ++cmd;
X }
X
X /*
X * check for a trailing count
X */
X skipspace(&cmd);
X if (isdigit(*cmd))
X {
X i = getdigits(&cmd);
X if (i <= 0)
X {
X emsg(e_zerocount);
X return;
X }
X lp = up;
X up += i - 1;
X }
X
X /*
X * check for trailing '|', '"' or '#'
X */
X skipspace(&cmd);
X if (*cmd)
X {
X if (strchr("|\"#", *cmd) != NULL)
X {
X *nextcommand = (u_char *)cmd;
X }
X else
X {
X emsg(e_trailing);
X return;
X }
X }
X
X if ((prog = myregcomp(pat)) == NULL)
X {
X emsg(e_invcmd);
X return;
X }
X
X for (lnum = lp; lnum <= up && !got_int; ++lnum)
X {
X ptr = nr2ptr(lnum);
X if (regexec(prog, ptr, (int)TRUE)) /* a match on this line */
X {
X char *ns, *sns = NULL, *p, *prevp, *oldp = NULL;
X int did_sub = FALSE;
X
X if (nsubs == 0)
X setpcmark();
X /*
X * Save the line that was last changed for the final cursor
X * position (just like the real vi).
X */
X Curpos.lnum = lnum;
X
X prevp = p = ptr;
X do
X {
X Curpos.col = prog->startp[0] - ptr;
X /*
X * First match empty string does not count, except for first match.
X * This reproduces the strange vi behaviour.
X * This also catches endless loops.
X */
X if (did_sub && p == oldp && p == prog->endp[0])
X {
X ++p;
X goto skip2;
X }
X if (do_ask)
X {
X updateScreen(CURSUPD);
X smsg("replace by %s (y/n/q)? ", sub);
X setcursor();
X if ((i = vgetc()) == 'q')
X {
X got_int = TRUE;
X break;
X }
X else if (i != 'y')
X goto skip;
X }
X
X /* get length of substitution part */
X sublen = regsub(prog, sub, ptr, 0, (int)p_magic);
X if (did_sub == FALSE)
X {
X /*
X * Get some space for a temporary buffer to do the substitution
X * into.
X */
X if ((sns = alloc((unsigned)(strlen(ptr) + sublen + 5))) == NULL)
X goto outofmem;
X *sns = NUL;
X did_sub = TRUE;
X }
X else
X {
X /*
X * extend the temporary buffer to do the substitution into.
X */
X if ((ns = alloc((unsigned)(strlen(sns) + strlen(prevp) + sublen + 1))) == NULL)
X goto outofmem;
X strcpy(ns, sns);
X free(sns);
X sns = ns;
X }
X
X for (ns = sns; *ns; ns++)
X ;
X /*
X * copy up to the part that matched
X */
X while (prevp < prog->startp[0])
X *ns++ = *prevp++;
X
X regsub(prog, sub, ns, 1, (int)p_magic);
X nsubs++;
X /*
X * Regsub may have replaced a ~ by the old sub.
X * We have to use the result, otherwise the ~ is replaced
X * over and over again.
X */
X sub = reg_prev_sub;
X
X prevp = prog->endp[0]; /* remember last copied character */
X /*
X * continue searching after the match
X * prevent endless loop with patterns that match empty strings,
X * e.g. :s/$/pat/g or :s/[a-z]* /(&)/g
X */
Xskip:
X p = prog->endp[0];
X oldp = p;
X if (*p == NUL) /* end of line: quit here */
X break;
X
Xskip2:
X /* breakcheck is slow, don't call it too often */
X if ((nsubs & 15) == 0)
X breakcheck();
X
X } while (!got_int && do_all && regexec(prog, p, (int)FALSE));
X
X if (did_sub)
X {
X /*
X * copy the rest of the line, that didn't match
X */
X strcat(sns, prevp);
X
X if ((ptr = save_line(sns)) != NULL)
X u_savesub(lnum, replaceline(lnum, ptr));
X
X free(sns); /* free the temp buffer */
X ++nlines;
X }
X }
X /* breakcheck is slow, don't call it too often */
X if ((lnum & 15) == 0)
X breakcheck();
X }
X
Xoutofmem:
X if (nsubs)
X {
X CHANGED;
X updateScreen(CURSUPD); /* need this to update LineSizes */
X beginline(TRUE);
X if (nsubs > p_report)
X smsg("%s%ld substitution%s on %ld line%s",
X got_int ? "(Interrupted) " : "",
X nsubs, plural(nsubs),
X (long)nlines, plural((long)nlines));
X else if (got_int)
X msg(e_interr);
X else if (do_ask)
X msg("");
X }
X else if (got_int)
X msg(e_interr);
X else
X msg("No match");
X
X free((char *) prog);
X}
X
X/*
X * doglob(cmd)
X *
X * Execute a global command of the form:
X *
X * g/pattern/X : execute X on all lines where pattern matches
X * v/pattern/X : execute X on all lines where pattern does not match
X *
X * where 'X' is an EX command
X *
X * The command character (as well as the trailing slash) is optional, and
X * is assumed to be 'p' if missing.
X *
X * This is implemented in two passes: first we scan the file for the pattern and
X * set a mark for each line that (not) matches. secondly we execute the command
X * for each line that has a mark. This is required because after deleting
X * lines we do not know where to search for the next match.


X */
X
X void

Xdoglob(type, lp, up, cmd)
X int type;
X linenr_t lp, up;
X char *cmd;
X{
X linenr_t lnum; /* line number according to old situation */
X linenr_t old_lcount; /* line_count before the command */
X int ndone;
X
X char delim; /* delimiter, normally '/' */
X char *pat;
X regexp *prog;
X int match;
X
X if (global_busy)
X {
X emsg("Cannot do :global recursive");
X ++global_busy;
X return;
X }
X
X delim = *cmd++; /* skip the delimiter */
X pat = cmd;
X
X while (cmd[0])
X {
X if (cmd[0] == delim) /* end delimiter found */
X {
X *cmd++ = NUL; /* replace it by a NUL */
X break;
X }
X if (cmd[0] == '\\' && cmd[1] != 0) /* skip escaped characters */
X ++cmd;
X ++cmd;
X }
X
X reg_ic = p_ic; /* set "ignore case" flag appropriately */
X
X if ((prog = myregcomp(pat)) == NULL)
X {
X emsg(e_invcmd);
X return;
X }
X msg("");
X
X/*
X * pass 1: set marks for each (not) matching line
X */
X ndone = 0;
X for (lnum = lp; lnum <= up && !got_int; ++lnum)
X {
X match = regexec(prog, nr2ptr(lnum), (int)TRUE); /* a match on this line? */
X if ((type == 'g' && match) || (type == 'v' && !match))
X {
X setmarked(lnum);
X ndone++;
X }
X /* breakcheck is slow, don't call it too often */
X if ((lnum & 15) == 0)
X breakcheck();
X }
X
X/*
X * pass 2: execute the command for each line that has been marked
X */
X if (got_int)
X msg("Interrupted");
X else if (ndone == 0)
X msg("No match");
X else
X {
X global_busy = 1;
X global_wait = 0;
X RedrawingDisabled = TRUE;
X old_lcount = line_count;
X while (!got_int && (lnum = firstmarked()) != 0 && global_busy == 1)
X {
X Curpos.lnum = lnum;
X Curpos.col = 0;
X if (*cmd == NUL)
X docmdline((u_char *)"p");
X else
X docmdline((u_char *)cmd);
X breakcheck();
X }
X
X RedrawingDisabled = FALSE;
X if (global_wait) /* wait for return */
X wait_return(FALSE);
X updateScreen(CLEAR);
X msgmore(line_count - old_lcount);
X }
X
X clearmarked(); /* clear rest of the marks */
X global_busy = 0;
X free((char *) prog);
X}
END_OF_FILE
if test 9336 -ne `wc -c <'vim/src/csearch.c'`; then
echo shar: \"'vim/src/csearch.c'\" unpacked with wrong size!
fi
# end of 'vim/src/csearch.c'
fi
if test -f 'vim/src/main.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/main.c'\"
else
echo shar: Extracting \"'vim/src/main.c'\" \(9338 characters\)
sed "s/^X//" >'vim/src/main.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X

X#define EXTERN


X#include "vim.h"
X#include "globals.h"
X#include "proto.h"

X#include "param.h"
X
Xstatic void usage __PARMS((int));
X
X static void
Xusage(n)
X int n;
X{
X register int i;
X static char *(use[]) = {"[file ..]\n",
X "-t tag\n",
X "+[command] file ..\n",
X "-c {command} file ..\n",
X "-e\n"};
X static char *(errors[]) = {"Unknown option\n", /* 0 */
X "Too many arguments\n", /* 1 */
X "Argument missing\n", /* 2 */
X };
X
X fprintf(stderr, errors[n]);
X fprintf(stderr, "usage:");
X for (i = 0; ; ++i)
X {
X fprintf(stderr, " vim [options] ");
X fprintf(stderr, use[i]);
X if (i == (sizeof(use) / sizeof(char *)) - 1)
X break;
X fprintf(stderr, " or:");
X }
X#ifdef AMIGA
X fprintf(stderr, "\noptions: -v -n -r -d device -s scriptin -w scriptout -T terminal\n");
X#else
X fprintf(stderr, "\noptions: -v -n -r -s scriptin -w scriptout -T terminal\n");
X#endif
X mch_windexit(1);
X}
X
X void


Xmain(argc, argv)
X int argc;
X char **argv;
X{

X char *initstr; /* init string from the environment */
X char *term = NULL; /* specified terminal name */
X char *fname = NULL; /* file name from command line */
X char *command = NULL; /* command from + option */
X char *tagname = NULL; /* tag from -t option */
X int c;
X int doqf = 0;
X int i;
X
X#ifdef DEBUG
X# ifdef MSDOS
X OPENDEBUG("#debug#");
X# else
X OPENDEBUG("/tmp/debug/vim");
X# endif
X#endif
X
X/*
X * Check if we have an interactive window.
X * If not, open one with a newcli command (needed for :! to work).
X * check_win will also handle the -d argument (for the Amiga).
X */
X check_win(argc, argv);
X
X ++argv;
X /*
X * Process the command line arguments
X * '-s scriptin'
X * '-w scriptout'
X * '-v'
X * '-n'
X * '-r'
X * '-T terminal'
X */
X while (argc > 1 && argv[0][0] == '-' &&
X strchr("swvnrTd", c = argv[0][1]) != NULL && c)
X {
X --argc;
X switch (c)
X {
X case 'v':
X readonlymode = TRUE;
X p_ro = TRUE;
X /*FALLTHROUGH*/
X
X case 'n':
X p_uc = 0;
X break;
X
X case 'r':
X recoverymode = 1;
X break;
X
X default: /* options with argument */
X ++argv;
X --argc;
X if (argc < 1)
X usage(2);
X
X switch (c)
X {
X case 's':
X if ((scriptin[0] = fopen(argv[0], READBIN)) == NULL)
X {
X fprintf(stderr, "cannot open %s for reading\n", argv[0]);
X mch_windexit(2);
X }
X break;
X
X case 'w':
X if ((scriptout = fopen(argv[0],
X#ifdef MSDOS
X "ab"
X#else
X "a"
X#endif
X )) == NULL)
X {
X fprintf(stderr, "cannot open %s for output\n", argv[0]);
X mch_windexit(2);
X }
X break;
X
X/*
X * The -T term option is always available and when TERMCAP is supported it
X * overrides the environment variable TERM.
X */
X case 'T':
X term = *argv;
X break;
X
X /* case 'd': This is ignored as it is handled in check_win() */
X }
X }
X ++argv;
X }
X
X /*
X * Allocate space for the generic buffer
X */
X if ((IObuff = alloc(IOSIZE)) == NULL)
X mch_windexit(0);
X
X /* note that we may use mch_windexit() before mch_windinit()! */
X mch_windinit();
X set_init(); /* after mch_windinit because Rows is used */
X
X /*
X * Process the other command line arguments.
X */
X if (argc > 1)
X {
X c = argv[0][1];
X switch (argv[0][0])
X {
X case '-':
X switch (c)
X {
X case 'e': /* -e QuickFix mode */
X if (argc != 2)
X usage(1);
X doqf = 1;
X break;
X
X case 'c': /* -c {command} file .. */
X if (argc <= 3)
X usage(2);
X ++argv;
X --argc;
X command = &(argv[0][0]);
X goto getfiles;
X
X case 't': /* -t tag */
X if (argc < 3)
X usage(2);
X if (argc > 3)
X usage(1);
X ++argv;
X tagname = argv[0];
X break;
X
X default:
X usage(0);
X }
X break;
X
X case '+': /* + or +{number} or +/{pat} or +{command} */
X if (argc < 3) /* no filename */
X usage(2);
X if (c == NUL)
X command = "$";
X else
X command = &(argv[0][1]);
X
Xgetfiles:
X ++argv;
X --argc;
X /*FALLTHROUGH*/
X
X default: /* must be a file name */
X#if defined(WILD_CARDS) && !defined(UNIX)
X ExpandWildCards(argc - 1, argv, &numfiles, &files, TRUE, TRUE);
X if (numfiles != 0)
X fname = files[0];
X
X#else
X files = argv;
X numfiles = argc - 1;
X fname = argv[0];
X#endif
X if (numfiles > 1)
X printf("%d files to edit\n", numfiles);
X break;
X }
X }
X
X if (numfiles == 0)
X numfiles = 1;
X
X RedrawingDisabled = TRUE;
X filealloc(); /* Initialize storage structure */
X init_yank(); /* init yank buffers */
X termcapinit(term); /* get terminal capabilities */
X
X#ifdef USE_LOCALE
X#include <locale.h>
X setlocale(LC_ALL, ""); /* for ctype() and the like */
X#endif
X
X#ifdef MSDOS /* default mapping for some often used keys */
X domap(0, "#1 :help\r", 0); /* F1 is help key */
X domap(0, "\236R i", 0); /* INSERT is 'i' */
X domap(0, "\236S x", 0); /* DELETE is 'x' */
X domap(0, "\236G 0", 0); /* HOME is '0' */
X domap(0, "\236w H", 0); /* CTRL-HOME is 'H' */
X domap(0, "\236O $", 0); /* END is '$' */
X domap(0, "\236u L", 0); /* CTRL-END is 'L' */
X domap(0, "\236I \002", 0); /* PageUp is '^B' */
X domap(0, "\236\204 1G", 0); /* CTRL-PageUp is '1G' */
X domap(0, "\236Q \006", 0); /* PageDown is '^F' */
X domap(0, "\236v G", 0); /* CTRL-PageDown is 'G' */
X /* insert mode */
X domap(0, "\236S \017x", INSERT); /* DELETE is '^Ox' */
X domap(0, "\236G \017""0", INSERT); /* HOME is '^O0' */
X domap(0, "\236w \017H", INSERT); /* CTRL-HOME is '^OH' */
X domap(0, "\236O \017$", INSERT); /* END is '^O$' */
X domap(0, "\236u \017L", INSERT); /* CTRL-END is '^OL' */
X domap(0, "\236I \017\002", INSERT); /* PageUp is '^O^B' */
X domap(0, "\236\204 \017\061G", INSERT); /* CTRL-PageUp is '^O1G' */
X domap(0, "\236Q \017\006", INSERT); /* PageDown is '^O^F' */
X domap(0, "\236v \017G", INSERT); /* CTRL-PageDown is '^OG' */
X#endif
X
X/*
X * get system wide defaults (for unix)
X */
X#ifdef DEFVIMRC_FILE
X dosource(DEFVIMRC_FILE);
X#endif
X
X/*
X * Try to read initialization commands from the following places:
X * - environment variable VIMINIT
X * - file s:.vimrc ($HOME/.vimrc for Unix)
X * - environment variable EXINIT
X * - file s:.exrc ($HOME/.exrc for Unix)
X * The first that exists is used, the rest is ignored.
X */
X if ((initstr = (char *)vimgetenv("VIMINIT")) != NULL)
X docmdline((u_char *)initstr);
X else if (dosource(SYSVIMRC_FILE))
X {
X if ((initstr = (char *)vimgetenv("EXINIT")) != NULL)
X docmdline((u_char *)initstr);
X else
X dosource(SYSEXRC_FILE);
X }
X
X/*
X * Read initialization commands from ".vimrc" or ".exrc" in current directory.
X * Because of security reasons we disallow shell and write commands now,
X * except for unix if the file is owned by the user.
X * Only do this if VIMRC_FILE is not the same as SYSVIMRC_FILE or DEFVIMRC_FILE.
X */
X#ifdef UNIX
X {
X struct stat s;
X
X stat(VIMRC_FILE, &s);
X if (s.st_uid != getuid()) /* ".vimrc" file is not owned by user */
X secure = 1;
X }
X#else
X secure = 1;
X#endif
X
X i = 1;
X if (fullpathcmp(SYSVIMRC_FILE, VIMRC_FILE)
X#ifdef DEFVIMRC_FILE
X && fullpathcmp(DEFVIMRC_FILE, VIMRC_FILE)
X#endif
X )
X i = dosource(VIMRC_FILE);
X#ifdef UNIX
X if (i)
X {
X struct stat s;
X
X stat(EXRC_FILE, &s);
X if (s.st_uid != getuid()) /* ".exrc" file is not owned by user */
X secure = 1;
X else
X secure = 0;
X }
X#endif
X if (i && fullpathcmp(SYSEXRC_FILE, EXRC_FILE))
X dosource(EXRC_FILE);
X
X/*
X * Call settmode and starttermcap here, so the T_KS and T_TS may be defined
X * by termcapinit and redifined in .exrc.
X */
X settmode(1);
X starttermcap();
X
X if (secure == 2) /* done something that is not allowed */
X wait_return(TRUE); /* must be called after settmode(1) */
X secure = 0;
X
X#ifdef AMIGA
X fname_case(fname); /* set correct case for file name */
X#endif
X setfname(fname);
X maketitle();
X
X/*
X * start putting things on the screen
X */
X starting = FALSE;
X screenalloc();
X screenclear();
X if (Filename != NULL)
X readfile(Filename, (linenr_t)0, TRUE);
X else
X msg("Empty Buffer");
X
X setpcmark();
X if (!tagname)
X startscript(); /* start writing to auto script file */
X
X if (recoverymode && !scriptin[curscript]) /* first do script file, then recover */
X openrecover();
X
X /* position the display and the cursor at the top of the file. */
X Topline = 1;
X Curpos.lnum = 1;
X Curpos.col = 0;
X Cursrow = Curscol = 0;
X
X if (doqf)
X {
X if (qf_init(p_ef))
X mch_windexit(3);
X qf_jump(0);
X }
X
X if (command)
X docmdline((u_char *)command);
X /*
X * put the :ta command in the stuff buffer here, so that it will not
X * be erased by an emsg().
X */
X if (tagname)
X {
X stuffReadbuff(":ta ");
X stuffReadbuff(tagname);
X stuffReadbuff("\n");
X }
X
X RedrawingDisabled = FALSE;
X updateScreen(NOT_VALID);
X
X /* start in insert mode (already taken care of for :ta command) */
X if (p_im && stuff_empty())
X stuffReadbuff("i");
X/*
X * main command loop
X */


X for (;;)
X {

X adjustCurpos();
X cursupdate(); /* Figure out where the cursor is based on Curpos. */
X
X if (Quote.lnum)
X updateScreen(INVERTED); /* update inverted part */
X setcursor();
X
X normal(); /* get and execute a command */
X }
X /*NOTREACHED*/
X}
X
X void
Xgetout(r)
X int r;
X{
X windgoto((int)Rows - 1, 0);
X outchar('\r');
X outchar('\n');
X mch_windexit(r);
X}
END_OF_FILE
if test 9338 -ne `wc -c <'vim/src/main.c'`; then
echo shar: \"'vim/src/main.c'\" unpacked with wrong size!
fi
# end of 'vim/src/main.c'
fi
if test -f 'vim/src/mark.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/mark.c'\"
else
echo shar: Extracting \"'vim/src/mark.c'\" \(8995 characters\)
sed "s/^X//" >'vim/src/mark.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * mark.c: functions for setting marks and jumping to them


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"

X#include "mark.h"
X#include "ops.h" /* for endop and startop */
X
X/*
X * This file contains routines to maintain and manipulate marks.
X */
X
X#define NMARKS 26 /* max. # of named marks */
X#define JUMPLISTSIZE 50 /* max. # of marks in jump list */
X
Xstatic struct mark pcmark; /* previous context mark */
Xstatic struct mark namedm[NMARKS]; /* original vi marks */
Xstatic struct filemark namedfm[NMARKS]; /* new marks with file nr */
Xstatic struct filemark jumplist[JUMPLISTSIZE]; /* list of old pcmarks */
X
Xstatic int jumplistlen = 0;
Xstatic int jumplistidx = 0;
X
Xstatic FPOS *mark2pos __ARGS((struct mark *));
X
X/*
X * setmark(c) - set named mark 'c' at current cursor position
X *
X * Returns TRUE on success, FALSE if no room for mark or bad name given.
X */
X int
Xsetmark(c)
X int c;
X{
X int i;
X
X if (islower(c))
X {
X i = c - 'a';
X namedm[i].ptr = nr2ptr(Curpos.lnum);
X namedm[i].col = Curpos.col;
X return TRUE;
X }
X if (isupper(c))
X {
X i = c - 'A';
X namedfm[i].mark.ptr = nr2ptr(Curpos.lnum);
X namedfm[i].mark.col = Curpos.col;
X namedfm[i].lnum = Curpos.lnum;
X namedfm[i].fnum = 0;
X return TRUE;
X }
X return FALSE;
X}
X
X/*
X * setpcmark() - set the previous context mark to the current position
X * and insert it into the jump list
X */
X void
Xsetpcmark()
X{
X int i;
X#ifdef ROTATE
X struct filemark tempmark;
X#endif
X
X pcmark.ptr = nr2ptr(Curpos.lnum);
X pcmark.col = Curpos.col;
X
X#ifndef ROTATE
X /*
X * simply add the new entry at the end of the list
X */
X jumplistidx = jumplistlen;
X#else
X /*
X * If last used entry is not at the top, put it at the top by rotating
X * the stack until it is (the newer entries will be at the bottom).
X * Keep one entry (the last used one) at the top.
X */
X if (jumplistidx < jumplistlen)
X ++jumplistidx;
X while (jumplistidx < jumplistlen)
X {
X tempmark = jumplist[jumplistlen - 1];
X for (i = jumplistlen - 1; i > 0; --i)
X jumplist[i] = jumplist[i - 1];
X jumplist[0] = tempmark;
X ++jumplistidx;
X }
X#endif
X
X /* only add new entry if it differs from the last one */
X if (jumplistlen == 0 || jumplist[jumplistidx - 1].mark.ptr != pcmark.ptr)
X {
X /* if jumplist is full: remove oldest entry */
X if (++jumplistlen > JUMPLISTSIZE)
X {
X jumplistlen = JUMPLISTSIZE;
X for (i = 1; i < jumplistlen; ++i)
X jumplist[i - 1] = jumplist[i];
X --jumplistidx;
X }
X
X jumplist[jumplistidx].mark = pcmark;
X jumplist[jumplistidx].lnum = Curpos.lnum;
X jumplist[jumplistidx].fnum = 0;
X ++jumplistidx;
X }
X}
X
X/*
X * move "count" positions in the jump list (count may be negative)
X */
X FPOS *
Xmovemark(count)
X int count;
X{
X FPOS *pos;
X
X if (jumplistlen == 0) /* nothing to jump to */
X return (FPOS *)NULL;
X
X if (jumplistidx + count < 0 || jumplistidx + count >= jumplistlen)
X return (FPOS *)NULL;
X
X /*
X * if first CTRL-O or CTRL-I command after a jump, add cursor position to list
X */
X if (jumplistidx == jumplistlen)
X {
X setpcmark();
X --jumplistidx; /* skip the new entry */
X }
X
X jumplistidx += count;
X if (jumplist[jumplistidx].mark.ptr == NULL) /* jump to other file */
X {
X if (getaltfile(jumplist[jumplistidx].fnum - 1, jumplist[jumplistidx].lnum, FALSE))
X return (FPOS *)NULL;
X Curpos.col = jumplist[jumplistidx].mark.col;
X jumplist[jumplistidx].fnum = 0;
X jumplist[jumplistidx].mark.ptr = nr2ptr(Curpos.lnum);
X pos = (FPOS *)-1;
X }
X else
X pos = mark2pos(&jumplist[jumplistidx].mark);
X return pos;
X}
X
X/*
X * getmark(c) - find mark for char 'c'
X *
X * Return pointer to FPOS if found
X * NULL if no such mark.
X * -1 if mark is in other file (only if changefile is TRUE)
X */
X FPOS *
Xgetmark(c, changefile)
X int c;
X int changefile;
X{
X FPOS *posp;
X
X posp = NULL;
X if (c == '\'' || c == '`') /* previous context mark */
X posp = mark2pos(&pcmark);
X else if (c == '[') /* to start of previous operator */
X {
X if (startop.lnum > 0 && startop.lnum <= line_count)
X posp = &startop;
X }
X else if (c == ']') /* to end of previous operator */
X {
X if (endop.lnum > 0 && endop.lnum <= line_count)
X posp = &endop;
X }
X else if (islower(c)) /* normal named mark */
X posp = mark2pos(&(namedm[c - 'a']));
X else if (isupper(c)) /* named file mark */
X {
X c -= 'A';
X posp = mark2pos(&(namedfm[c].mark));
X if (posp == NULL && namedfm[c].lnum != 0 && (changefile || samealtfile(namedfm[c].fnum - 1)))
X {
X if (!getaltfile(namedfm[c].fnum - 1, namedfm[c].lnum, TRUE))
X {
X Curpos.col = namedfm[c].mark.col;
X namedfm[c].fnum = 0;
X namedfm[c].mark.ptr = nr2ptr(Curpos.lnum);
X posp = (FPOS *)-1;
X }
X }
X }
X return posp;
X}
X
X static FPOS *
Xmark2pos(markp)
X struct mark *markp;
X{
X static FPOS pos;
X
X if (markp->ptr != NULL && (pos.lnum = ptr2nr(markp->ptr, (linenr_t)1)) != 0)
X {
X pos.col = markp->col;
X return (&pos);
X }
X return (FPOS *)NULL;
X}
X
X/*
X * clrallmarks() - clear all marks


X *
X * Used mainly when trashing the entire buffer during ":e" type commands
X */
X void

Xclrallmarks()
X{
X static int i = -1;
X
X if (i == -1) /* first call ever: initialize */
X for (i = 0; i < NMARKS; i++)
X namedfm[i].lnum = 0;
X
X for (i = 0; i < NMARKS; i++)
X {
X namedm[i].ptr = NULL;
X namedfm[i].mark.ptr = NULL;
X }
X pcmark.ptr = NULL;
X qf_clrallmarks();
X for (i = 0; i < jumplistlen; ++i)
X jumplist[i].mark.ptr = NULL;
X}
X
X/*
X * increment the file number for all filemarks
X * called when adding a file to the file stack
X */
X void
Xincrmarks()


X{
X int i;
X

X for (i = 0; i < NMARKS; i++)
X ++namedfm[i].fnum;
X
X for (i = 0; i < jumplistlen; ++i)
X {
X#if 0 /* this would take too much time */
X if (jumplist[i].fnum == 0) /* current file */
X jumplist[i].lnum = ptr2nr(jumplist[i].mark.ptr, 1);
X#endif
X ++jumplist[i].fnum;
X }
X}
X
X/*
X * decrement the file number for the filemarks of the current file
X * called when not adding the current file name to the file stack
X */
X void
Xdecrmarks()


X{
X int i;
X

X for (i = 0; i < NMARKS; i++)
X if (namedfm[i].fnum == 1)
X namedfm[i].fnum = 0;
X
X for (i = 0; i < jumplistlen; ++i)
X if (jumplist[i].fnum == 1)
X jumplist[i].fnum = 0;
X}
X
X/*
X * adjustmark: set new ptr for a mark
X * if new == NULL the mark is effectively deleted
X */
X void
Xadjustmark(old, new)


X char *old, *new;
X{
X register int i;
X

X for (i = 0; i < NMARKS; ++i)
X {
X if (namedm[i].ptr == old)
X namedm[i].ptr = new;
X if (namedfm[i].mark.ptr == old)
X {
X namedfm[i].mark.ptr = new;


X if (new == NULL)

X namedfm[i].lnum = 0; /* delete this mark */
X }
X }
X if (pcmark.ptr == old)
X pcmark.ptr = new;
X for (i = 0; i < jumplistlen; ++i)
X if (jumplist[i].mark.ptr == old)
X jumplist[i].mark.ptr = new;
X qf_adjustmark(old, new);
X}
X
X/*
X * get name of file from a filemark (use the occasion to update the lnum)


X */
X char *

Xfm_getname(fmark)
X struct filemark *fmark;
X{
X linenr_t nr;
X char *name;
X
X if (fmark->fnum != 0) /* maybe not current file */
X {
X name = getaltfname(fmark->fnum - 1);
X if (name == NULL)
X return "-none-";
X if (Filename == NULL || fnamecmp(name, Filename) != 0) /* not current file */
X return name;
X fmark->fnum = 0;
X }
X if (fmark->mark.ptr == NULL)
X fmark->mark.ptr = nr2ptr(fmark->lnum); /* update ptr */
X else
X {
X nr = ptr2nr(fmark->mark.ptr, (linenr_t)1);
X if (nr != 0)
X fmark->lnum = nr; /* update lnum */
X }
X return "-current-";
X}
X
X/*
X * print the marks (use the occasion to update the line numbers)
X */
X void
Xdomarks()
X{
X int i;
X char *name;
X
X#ifdef AMIGA
X settmode(0); /* set cooked mode, so output can be halted */
X#endif
X outstrn("\nmark line file\n");
X for (i = 0; i < NMARKS; ++i)
X {
X if (namedm[i].ptr != NULL)
X {
X sprintf(IObuff, " %c %5ld\n",
X i + 'a',
X ptr2nr(namedm[i].ptr, (linenr_t)1));
X outstrn(IObuff);
X }
X flushbuf();
X }
X for (i = 0; i < NMARKS; ++i)
X {
X if (namedfm[i].lnum != 0)
X {
X name = fm_getname(&namedfm[i]);
X if (name == NULL) /* file name not available */
X continue;
X
X sprintf(IObuff, " %c %5ld %s\n",
X i + 'A',
X namedfm[i].lnum,
X name);
X outstrn(IObuff);
X }


X flushbuf();
X }
X#ifdef AMIGA
X settmode(1);
X#endif
X wait_return(TRUE);
X}
X
X/*

X * print the jumplist (use the occasion to update the line numbers)
X */
X void
Xdojumps()
X{
X int i;
X char *name;
X
X#ifdef AMIGA
X settmode(0); /* set cooked mode, so output can be halted */
X#endif
X outstrn("\n jump line file\n");
X for (i = 0; i < jumplistlen; ++i)
X {
X if (jumplist[i].lnum != 0)
X {
X name = fm_getname(&jumplist[i]);
X if (name == NULL) /* file name not available */
X continue;
X
X sprintf(IObuff, "%c %2d %5ld %s\n",
X i == jumplistidx ? '>' : ' ',
X i + 1,
X jumplist[i].lnum,
X name);
X outstrn(IObuff);
X }
X flushbuf();
X }
X if (jumplistidx == jumplistlen)
X outstrn(">\n");


X#ifdef AMIGA
X settmode(1);
X#endif
X wait_return(TRUE);
X}

END_OF_FILE
if test 8995 -ne `wc -c <'vim/src/mark.c'`; then
echo shar: \"'vim/src/mark.c'\" unpacked with wrong size!
fi
# end of 'vim/src/mark.c'
fi
if test -f 'vim/src/script.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/script.c'\"
else
echo shar: Extracting \"'vim/src/script.c'\" \(11660 characters\)
sed "s/^X//" >'vim/src/script.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * script.c: functions for handling script files


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"

X#include "param.h"
X
Xstatic char *scriptname; /* name of the script in use */
Xstatic FILE *autoscriptfd = NULL;
Xstatic char *makescriptname __ARGS((void));
Xstatic void Supdatescript __ARGS((char *));
X
Xextern int global_busy; /* this is in csearch.c */
X
X/*
X * for Amiga Dos 2.0x we use Open/Close/Flush instead of fopen/fclose
X */
X#ifdef AMIGA
X# ifndef NO_ARP
Xextern int dos2; /* this is in amiga.c */
X# endif
X# ifdef SASC
X# include <proto/dos.h>
X# endif
X#endif
X
X/*
X * We use this flag to avoid writing :win to commands to the script file
X * during startup.
X */
Xstatic int script_started = FALSE;
X
X/*
X * startscript(): open automatic script file
X */
X void
Xstartscript()
X{
X int n;
X char buf[25];
X#ifdef AMIGA
X int r;
X FILE *dummyfd = NULL;
X#endif
X
X script_started = TRUE;
X
X#ifdef AMIGA
X/*
X * With Amiga DOS 2.0 the system may lockup with the sequence: write to .vim
X * file, close it, delete it, create a new .vim file and write to it.
X * This is a problem in the filesystem hash chains (solved in version 39.xx).
X * The Delay seems to solve this problem, maybe because DOS gets a chance to
X * finish closing and deleting the old .vim file. Also do this for DOS 1.3,
X * just in case.
X */
X if (stopscript())
X Delay(10L); /* This should fix the lockup bug */
X#else
X stopscript(); /* stop any old script */
X#endif
X
X if (p_uc == 0 || exiting) /* no auto script wanted/needed */
X return;
X if (Changed)
X emsg("Warning: buffer already changed, auto script file will be incomplete");
X
X#ifdef AMIGA
X/*
X * If we start editing a new file, e.g. "test.doc", which resides on an MSDOS
X * compatible filesystem, it is possible that the file "test.doc.vim" which we
X * create will be exactly the same file. To avoid this problem we temporarily
X * create "test.doc".
X */
X if (!(p_sn || thisfile_sn) && Filename && getperm(Filename) < 0)
X dummyfd = fopen(Filename, "w");
X#endif
X
X/*
X * we try different names until we find one that does not exist yet
X */
X scriptname = makescriptname();


X for (;;)
X {

X if (scriptname == NULL) /* must be out of memory */
X break;
X if ((n = strlen(scriptname)) == 0) /* safety check */
X {
X free(scriptname);
X break;
X }
X
X /*
X * check if the scriptfile already exists
X */
X if (getperm(scriptname) < 0) /* it does not exist */
X {
X /*
X * Create the autoscript file.
X */
X#ifdef AMIGA
X# ifndef NO_ARP
X if (dos2)
X# endif
X autoscriptfd = (FILE *)Open((UBYTE *)scriptname, (long)MODE_NEWFILE);
X# ifndef NO_ARP
X else
X autoscriptfd = fopen(scriptname, "w");
X# endif
X#else /* !AMIGA */
X autoscriptfd = fopen(scriptname, WRITEBIN);


X#endif /* AMIGA */
X

X#ifdef AMIGA
X /*
X * on the Amiga getperm() will return -1 when the file exists but
X * is being used by another program. This happens if you edit
X * a file twice.
X */
X if (autoscriptfd != NULL || (IoErr() != ERROR_OBJECT_IN_USE && IoErr() != ERROR_OBJECT_EXISTS))
X#endif
X break;
X }
X /*
X * get here when file already exists
X */
X if (scriptname[n - 1] == 'm') /* first try */
X {
X#ifdef AMIGA
X /*
X * on MS-DOS compatible filesystems (e.g. messydos) file.doc.vim
X * and file.doc are the same file. To guess if this problem is
X * present try if file.doc.vix exists. If it does, we set thisfile_sn
X * and try file_doc.vim (dots replaced by underscores for this file),
X * and try again. If it doesn't we assume that "file.doc.vim" already
X * exists.
X */
X if (!(p_sn || thisfile_sn)) /* not tried yet */
X {
X scriptname[n - 1] = 'x';
X r = getperm(scriptname); /* try "file.vix" */
X scriptname[n - 1] = 'm';
X if (r >= 0) /* it seems to exist */
X {
X thisfile_sn = TRUE;
X free(scriptname);
X scriptname = makescriptname(); /* '.' replaced by '_' */
X continue; /* try again */
X }
X }
X#endif
X /* if we get here ".vim" file really exists */
X emsg(".vim file exists: an edit of this file has not been finished");
X }
X
X if (scriptname[n - 1] == 'a') /* tried enough names, give up */
X {
X free(scriptname);
X break;
X }
X --scriptname[n - 1]; /* change last char of the name */
X }
X if (autoscriptfd != NULL) /* ".vim" file has been created */
X {
X script_winsize(); /* always start with a :win command */
X /* output cursor position if neccessary */
X if (Curpos.lnum > 1 || Curpos.col > 0)
X {
X sprintf(buf, "%ldG0%dl", (long)Curpos.lnum, (int)Curpos.col);
X Supdatescript(buf);
X }
X }
X
X#ifdef AMIGA
X if (dummyfd) /* file has been created temporarily */
X {
X fclose(dummyfd);
X remove(Filename);
X }
X#endif
X}
X
X int
Xstopscript()
X{
X if (!autoscriptfd)
X return FALSE; /* nothing to stop */
X
X#ifdef AMIGA
X# ifndef NO_ARP
X if (dos2)
X# endif
X Close((BPTR)autoscriptfd);
X# ifndef NO_ARP
X else
X fclose(autoscriptfd);
X# endif
X#else
X fclose(autoscriptfd);
X#endif
X remove(scriptname); /* delete the file */
X autoscriptfd = NULL;
X free(scriptname);
X return TRUE;
X}
X
X/*
X * open new script file
X * return 0 on success, 1 on error
X */
X int
Xopenscript(name)
X char *name;
X{
X int oldcurscript;
X
X if (curscript + 1 == NSCRIPT)
X {
X emsg(e_nesting);
X return 1;
X }
X else
X {
X if (scriptin[curscript] != NULL) /* already reading script */
X ++curscript;
X if ((scriptin[curscript] = fopen((char *)name, READBIN)) == NULL)
X {
X emsg(e_notopen);
X if (curscript)
X --curscript;
X return 1;
X }
X /*
X * With command ":g/pat/so! file" we have to execute the
X * commands from the file now.
X */
X if (global_busy)


X {
X State = NORMAL;

X oldcurscript = curscript;
X do
X {
X normal();
X vpeekc(); /* check for end of file */
X }
X while (scriptin[oldcurscript]);
X State = CMDLINE;
X }
X }


X return 0;
X}
X

X/*
X * updatescipt() is called when a character has to be written into the script file
X * or when we have waited some time for a character (c == 0)
X */
X void
Xupdatescript(c)
X int c;
X{
X static int count = 0;
X
X if (c && scriptout)
X putc(c, scriptout);
X if (autoscriptfd == NULL || (c == 0 && count == 0)) /* nothing to do */
X return;
X if (c)
X {
X#ifdef AMIGA
X# ifndef NO_ARP
X if (dos2)
X# endif
X FPutC((BPTR)autoscriptfd, (unsigned long)c);
X# ifndef NO_ARP
X else
X putc(c, autoscriptfd);
X# endif
X#else
X putc(c, autoscriptfd);
X#endif
X ++count;
X }
X if ((c == 0 || count >= p_uc) && Updated)
X {
X /*
X * Before DOS 2.0x we have to close and open the file in order to really
X * get the characters in the file to disk!
X * With DOS 2.0x Flush() can be used for that
X */
X#ifdef AMIGA
X# ifndef NO_ARP
X if (dos2)
X# endif
X Flush((BPTR)autoscriptfd);
X# ifndef NO_ARP
X else
X {
X fclose(autoscriptfd);
X autoscriptfd = fopen(scriptname, "a");
X }
X# endif
X#else /* !AMIGA */
X fclose(autoscriptfd);
X# ifdef MSDOS
X autoscriptfd = fopen(scriptname, "ab");
X# else
X autoscriptfd = fopen(scriptname, "a");
X# endif
X#endif
X count = 0;
X Updated = 0;
X }
X}
X
X static void
XSupdatescript(str)
X char *str;
X{
X while (*str)
X updatescript(*str++);
X}
X
X/*
X * try to open the ".vim" file for recovery
X * if recoverymode is 1: start recovery, set recoverymode to 2
X * if recoverymode is 2: stop recovery mode
X */
X void
Xopenrecover()
X{
X char *fname;
X struct stat efile, rfile;
X
X if (recoverymode == 2) /* end of recovery */
X {
X if (got_int)
X {
X emsg("Recovery Interrupted");
X /* somehow the cursor ends up in the wrong place (why?) */
X setcursor();
X flushbuf();
X }
X else
X msg("Recovery completed");
X recoverymode = 0;
X }
X else
X {
X fname = makescriptname();
X if (fname)
X {
X recoverymode = 2;
X if (Filename != NULL &&
X stat(Filename, &efile) != -1 &&
X stat(fname, &rfile) != -1 &&
X efile.st_mtime > rfile.st_mtime)
X emsg(".vim file is older; file not recovered");
X else
X {
X if (openscript(fname))
X emsg("Cannot open .vim file; file not recovered");
X }
X free(fname);


X }
X }
X}
X
X/*

X * make script name out of the filename
X */
X static char *
Xmakescriptname()
X{
X char *r, *s, *fname;
X
X r = modname(Filename, ".vim");
X if (*p_dir == 0 || r == NULL)
X return r;
X
X for (fname = s = r; *s; ++s) /* skip path */
X {
X#ifdef UNIX
X if (*s == '/') /* UNIX has ':' inside file names */
X#else
X if (*s == ':' || *s == PATHSEP)
X#endif
X fname = s + 1;
X }
X
X s = alloc((unsigned)(strlen(p_dir) + strlen(fname) + 1));
X if (s != NULL)
X {
X strcpy(s, p_dir);
X strcat(s, fname);
X }
X free(r);
X return s;
X}
X
X/*
X * add extention to filename - change path/fo.o.h to path/fo.o.h.ext or
X * fo_o_h.ext for MSDOS or when dotfname option reset.
X *
X * Assumed that fname is a valid name found in the filesystem we assure that
X * the return value is a different name and ends in ".ext".
X * "ext" MUST start with a "." and MUST be at most 4 characters long.
X * Space for the returned name is allocated, must be freed later.
X */
X
X char *
Xmodname(fname, ext)
X char *fname, *ext;
X{
X char *retval;
X register char *s;
X register char *ptr;
X register int fnamelen, extlen;
X char currentdir[512];
X
X extlen = strlen(ext);
X
X /*
X * if there is no filename we must get the name of the current directory
X * (we need the full path in case :cd is used)
X */
X if (fname == NULL || *fname == NUL)
X {
X (void)dirname(currentdir, 511);
X strcat(currentdir, PATHSEPSTR);
X fnamelen = strlen(currentdir);
X }
X else
X fnamelen = strlen(fname);
X retval = alloc((unsigned) (fnamelen + extlen + 1));
X if (retval != NULL)
X {
X if (fname == NULL || *fname == NUL)
X strcpy(retval, currentdir);
X else
X strcpy(retval, fname);
X /*
X * search backwards until we hit a '\' or ':' replacing all '.' by '_'
X * for MSDOS or when dotfname option reset.
X * Then truncate what is after the '\' or ':' to 8 characters for MSDOS
X * and 26 characters for AMIGA and UNIX.
X */
X for (ptr = retval + fnamelen; ptr >= retval; ptr--)
X {
X#ifndef MSDOS
X if (p_sn || thisfile_sn)
X#endif
X if (*ptr == '.') /* replace '.' by '_' */
X *ptr = '_';
X#ifdef UNIX
X if (*ptr == '/') /* UNIX has ':' inside file names */
X#else
X if (*ptr == ':' || *ptr == PATHSEP)
X#endif
X break;
X }
X ptr++;
X
X /* the filename has at most BASENAMELEN characters. */
X if (strlen(ptr) > BASENAMELEN)
X ptr[BASENAMELEN] = '\0';
X#ifndef MSDOS
X if ((p_sn || thisfile_sn) && strlen(ptr) > 8)
X ptr[8] = '\0';
X#endif
X s = ptr + strlen(ptr);
X
X /*
X * Append the extention.
X * ext must start with '.' and cannot exceed 3 more characters.
X */
X strcpy(s, ext);
X if (fname != NULL && strcmp(fname, retval) == 0)
X {
X /* after modification still the same name? */
X /* we search for a character that can be replaced by '_' */
X while (--s >= ptr)
X {
X if (*s != '_')
X {
X *s = '_';
X break;
X }
X }
X if (s < ptr)
X {
X /* fname was "________.<ext>" how tricky! */
X *ptr = 'v';
X }
X }
X }
X return retval;
X}
X
X/*
X * the new window size must be used in scripts;
X * write a ":winsize width height" command to the (auto)script
X * Postpone this action if not in NORMAL State, otherwise we may insert the
X * command halfway another command.
X */
Xint script_winsize_postponed = FALSE;
X
X void
Xscript_winsize()
X{
X char buf[25];
X
X if (!script_started || State != NORMAL) /* postpone action */
X {
X script_winsize_postponed = TRUE;
X return;
X }
X
X sprintf(buf, ":win %d %d\r", (int)Columns, (int)Rows);
X Supdatescript(buf);
X script_winsize_postponed = FALSE;
X}
X
X/*
X * This function is called after each "State = NORMAL"
X */
X void
Xscript_winsize_pp()
X{
X if (script_winsize_postponed)
X script_winsize();
X}
END_OF_FILE
if test 11660 -ne `wc -c <'vim/src/script.c'`; then
echo shar: \"'vim/src/script.c'\" unpacked with wrong size!
fi
# end of 'vim/src/script.c'
fi
if test -f 'vim/src/tag.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/tag.c'\"
else
echo shar: Extracting \"'vim/src/tag.c'\" \(9119 characters\)
sed "s/^X//" >'vim/src/tag.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * Code to handle tags and the tag stack


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"

X#include "param.h"
X#include "mark.h"
X
X#define TAGSTACKSIZE 20
X
X/*
X * the taggy struct is used to store the information about a :tag command:
X * the tag name and the cursor position BEFORE the :tag command
X */
Xstruct taggy
X{
X char *tagname; /* tag name */
X struct filemark fmark; /* cursor position */
X};
X
X/*
X * the tagstack grows from 0 upwards:
X * entry 0: older
X * entry 1: newer
X * entry 2: newest
X */
Xstatic struct taggy tagstack[TAGSTACKSIZE]; /* the tag stack */
Xstatic int tagstackidx = 0; /* index just below active entry */
Xstatic int tagstacklen = 0; /* number of tags on the stack */
X
Xstatic int findtag __ARGS((char *));
Xstatic char *firsttaborspace __ARGS((char *));
X
Xstatic char bottommsg[] = "at bottom of tag stack";
Xstatic char topmsg[] = "at top of tag stack";
X
X/*
X * Jump to tag; handling of tag stack
X *
X * *tag != NUL (:tag): jump to new tag, add to tag stack
X * type == 1 (:pop) || type == 2 (CTRL-T): jump to old position
X * type == 0 (:tag): jump to old tag
X */
X void
Xdotag(tag, type, count)
X char *tag;
X int type;
X int count;
X{
X int i;
X struct taggy temptag;
X
X if (*tag != NUL) /* new pattern, add to the stack */
X {
X /*
X * if last used entry is not at the top, put it at the top by rotating
X * the stack until it is (the newer entries will be at the bottom)
X */
X while (tagstackidx < tagstacklen)
X {
X temptag = tagstack[tagstacklen - 1];
X for (i = tagstacklen - 1; i > 0; --i)
X tagstack[i] = tagstack[i - 1];
X tagstack[0] = temptag;
X ++tagstackidx;
X }
X /* if tagstack is full: remove oldest entry */
X if (++tagstacklen > TAGSTACKSIZE)
X {
X tagstacklen = TAGSTACKSIZE;
X free(tagstack[0].tagname);
X for (i = 1; i < tagstacklen; ++i)
X tagstack[i - 1] = tagstack[i];
X --tagstackidx;
X }
X /*
X * remember the tag and the position before the jump
X */
X tagstack[tagstackidx].tagname = strsave(tag);
X tagstack[tagstackidx].fmark.lnum = Curpos.lnum;
X tagstack[tagstackidx].fmark.mark.col = Curpos.col;
X tagstack[tagstackidx].fmark.mark.ptr = nr2ptr(Curpos.lnum);
X tagstack[tagstackidx].fmark.fnum = 0;
X }
X else if (tagstacklen == 0) /* empty stack */
X {
X emsg("tag stack empty");
X return;
X }
X else if (type) /* go to older position */
X {
X if ((tagstackidx -= count) < 0)
X {
X tagstackidx = 0;
X emsg(bottommsg);
X }
X else if (tagstackidx >= tagstacklen) /* must have been count == 0 */
X {
X emsg(topmsg);
X return;
X }
X if (tagstack[tagstackidx].fmark.mark.ptr == NULL) /* jump to other file */
X {
X if (getaltfile(tagstack[tagstackidx].fmark.fnum - 1, tagstack[tagstackidx].fmark.lnum, TRUE))
X {
X emsg(e_notopen);
X return;
X }
X /* "refresh" this position, so we will not fall off the altfile array */
X tagstack[tagstackidx].fmark.fnum = 0;
X tagstack[tagstackidx].fmark.mark.ptr = nr2ptr(Curpos.lnum);
X }
X else
X Curpos.lnum = ptr2nr(tagstack[tagstackidx].fmark.mark.ptr, (linenr_t)1);
X Curpos.col = tagstack[tagstackidx].fmark.mark.col;
X return;
X }
X else /* go to newer pattern */
X {
X if ((tagstackidx += count - 1) >= tagstacklen)
X {
X tagstackidx = tagstacklen - 1;
X emsg(topmsg);
X }
X else if (tagstackidx < 0) /* must have been count == 0 */
X {
X emsg(bottommsg);
X tagstackidx = 0;
X return;
X }
X }
X if (findtag(tagstack[tagstackidx].tagname) > 0)
X ++tagstackidx;
X else if (bufempty()) /* "vim -t tag" failed, start script now */
X startscript();
X}
X
X/*
X * invalidate the line pointer for all tags
X * called when abandoning the current file
X */
X void
Xclrtags()


X{
X int i;
X

X for (i = 0; i < tagstacklen; ++i)
X tagstack[i].fmark.mark.ptr = NULL;
X}
X
X/*
X * increment the file number for all tags
X * called when adding a file to the file stack
X */
X void
Xincrtags()


X{
X int i;
X

X for (i = 0; i < tagstacklen; ++i)
X {
X#if 0 /* this would take too much time */
X if (tagstack[i].fmark.fnum == 0) /* current file */
X tagstack[i].fmark.lnum = ptr2nr(tagstack[i].fmark.mark.ptr, 1);
X#endif
X ++tagstack[i].fmark.fnum;
X }
X}
X
X/*
X * decrement the file number for the tags of the current file
X * called when not adding the current file name to the file stack
X */
X void
Xdecrtags()


X{
X int i;
X

X for (i = 0; i < tagstacklen; ++i)
X if (tagstack[i].fmark.fnum == 1)
X tagstack[i].fmark.fnum = 0;
X}
X
X/*
X * Print the tag stack (use the occasion to update the line numbers)
X */
X void
Xdotags()
X{
X int i;
X char *name;
X


X#ifdef AMIGA
X settmode(0); /* set cooked mode so output can be halted */
X#endif

X outstrn("\n # TO tag FROM line in file\n");
X for (i = 0; i < tagstacklen; ++i)
X {
X if (tagstack[i].tagname != NULL)
X {
X name = fm_getname(&(tagstack[i].fmark));
X if (name == NULL) /* file name not available */
X continue;
X
X sprintf(IObuff, "%c%2d %-15s %4ld %s\n",
X i == tagstackidx ? '>' : ' ',
X i + 1,
X tagstack[i].tagname,
X tagstack[i].fmark.lnum,
X name);
X outstrn(IObuff);
X }
X flushbuf();
X }
X if (tagstackidx == tagstacklen) /* idx at top of stack */
X outstrn(">\n");


X#ifdef AMIGA
X settmode(1);
X#endif
X wait_return(TRUE);
X}
X
X/*

X * findtag(tag) - goto tag
X * return 0 for failure, 1 for success
X */
X static int
Xfindtag(tag)
X char *tag;
X{
X FILE *tp, *fopen();
X char lbuf[LSIZE];
X char pbuf[LSIZE]; /* search pattern buffer */
X char *fname, *str;
X int cmplen;
X char *m = NULL;
X register char *p;
X char *np; /* pointer into file name string */
X char sbuf[CMDBUFFSIZE + 1]; /* tag file name */
X int i;
X int save_secure;
X
X if (tag == NULL) /* out of memory condition */
X return 0;
X
X if ((cmplen = p_tl) == 0)
X cmplen = 999;
X
X /* get stack of tag file names from tags option */
X for (np = p_tags; *np; )
X {
X for (i = 0; i < CMDBUFFSIZE && *np; ++i) /* copy next file name into lbuf */
X {
X if (*np == ' ')
X {
X ++np;
X break;
X }
X sbuf[i] = *np++;
X }
X sbuf[i] = 0;
X if ((tp = fopen(sbuf, "r")) == NULL)
X {
X m = "Can't open tags file %s";
X goto erret2;
X }
X while (fgets(lbuf, LSIZE, tp) != NULL)
X {
X m = "Format error in tags file %s"; /* default error message */
X
X /* find start of file name, after first TAB or space */
X fname = firsttaborspace(lbuf);


X if (fname == NULL)

X goto erret;
X *fname++ = '\0';
X
X /* find start of search command, after second TAB or space */
X str = firsttaborspace(fname);
X if (str == NULL)
X goto erret;
X *str++ = '\0';
X
X if (strncmp(lbuf, tag, (size_t)cmplen) == 0)
X {
X fclose(tp);
X /*
X * Tag found!
X * If the command is a string like "/^function fname"
X * scan through the search string. If we see a magic
X * char, we have to quote it. This lets us use "real"
X * implementations of ctags.
X */
X if (*str == '/' || *str == '?')
X {
X p = pbuf;
X *p++ = *str++; /* copy the '/' or '?' */
X if (*str == '^')
X *p++ = *str++; /* copy the '^' */
X
X while (*str)
X {
X switch (*str)
X {
X case '\\': if (str[1] == '(') /* remove '\' before '(' */
X ++str;
X else
X *p++ = *str++;
X break;
X
X case '\n': *p++ = pbuf[0]; /* copy '/' or '?' */
X *str = 'n'; /* no setpcmark() for search */
X break;
X
X /*
X * if string ends in search character: skip it
X * else escape it with '\'
X */
X case '/':
X case '?': if (*str != pbuf[0]) /* not a search char */
X break;
X if (str[1] == '\n') /* last char */
X {
X ++str;
X continue;
X }
X case '[':
X if (!p_magic)
X break;
X case '^':
X case '*':
X case '.': *p++ = '\\';
X break;
X }
X *p++ = *str++;
X }
X }
X else /* not a search command, just copy it */
X for (p = pbuf; *str && *str != '\n'; )
X *p++ = *str++;
X *p = NUL;
X
X RedrawingDisabled = TRUE;
X if ((i = getfile(fname, TRUE)) <= 0)
X {
X set_want_col = TRUE;
X
X RedrawingDisabled = FALSE;
X /* dosearch(pbuf[0] == '/' ? FORWARD : BACKWARD, pbuf + 1, FALSE, 1L); */
X save_secure = secure;
X secure = 1;
X docmdline((u_char *)pbuf);
X if (secure == 2) /* done something that is not allowed */
X wait_return(TRUE);
X secure = save_secure;
X
X if (p_im && i == -1)
X stuffReadbuff("\033\007i"); /* ESC CTRL-G i */
X else
X stuffReadbuff("\007"); /* CTRL-G */
X return 1;
X }
X RedrawingDisabled = FALSE;


X return 0;
X }
X }

X m = NULL;
X
Xerret:
X fclose(tp);
Xerret2:
X if (m)
X {
X smsg(m, sbuf);
X sleep(1);
X }
X }
X if (m == NULL)
X emsg("tag not found");


X return 0;
X}
X

X/*
X * find first TAB or space
X */
X static char *
Xfirsttaborspace(str)
X char *str;
X{
X char *p1, *p2;
X
X p1 = strchr(str, TAB); /* find first TAB */
X p2 = strchr(str, ' '); /* find first space */
X if (p1 == NULL || (p2 != NULL && p2 < p1))
X return p2; /* space comes first */
X return p1;
X}
END_OF_FILE
if test 9119 -ne `wc -c <'vim/src/tag.c'`; then
echo shar: \"'vim/src/tag.c'\" unpacked with wrong size!
fi
# end of 'vim/src/tag.c'
fi
echo shar: End of archive 5 \(of 23\).
cp /dev/null ark5isdone

Bram Moolenaar

unread,
Apr 23, 1993, 1:30:36 PM4/23/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 6
Archive-name: vim/part06
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 6 (of 23)."
# Contents: vim/src/misccmds.c vim/src/msdos.c vim/src/undo.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:08 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/misccmds.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/misccmds.c'\"
else
echo shar: Extracting \"'vim/src/misccmds.c'\" \(13737 characters\)
sed "s/^X//" >'vim/src/misccmds.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * misccmds.c: functions that didn't seem to fit elsewhere


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X

Xstatic char *(si_tab[]) = {"if", "else", "while", "for", "do"};
X
X/*
X * count the size of the indent in the current line
X */
X int
Xget_indent()
X{
X register char *ptr;
X register int count = 0;
X
X for (ptr = nr2ptr(Curpos.lnum); *ptr; ++ptr)
X {
X if (*ptr == TAB) /* count a tab for what it is worth */
X count += p_ts - (count % p_ts);
X else if (*ptr == ' ')
X ++count; /* count a space for one */


X else
X break;
X }

X return (count);
X}
X
X/*
X * set the indent of the current line
X * leaves the cursor on the first non-blank in the line
X */
X void
Xset_indent(size, delete)
X register int size;
X int delete;
X{
X int oldstate = State;
X
X State = INSERT; /* don't want REPLACE for State */
X Curpos.col = 0;
X if (delete)
X {
X while (isspace(gcharCurpos())) /* delete old indent */
X delchar(FALSE);
X }
X while (size >= p_ts)
X {
X inschar(TAB);
X size -= p_ts;
X }
X while (size)
X {
X inschar(' ');
X --size;


X }
X State = oldstate;
X script_winsize_pp();

X}
X
X/*
X * Opencmd
X *
X * Add a blank line below or above the current line.
X */
X
X int
XOpencmd(dir, redraw)
X int dir;
X int redraw;
X{
X char *l;
X char *ptr;
X FPOS oldCurpos; /* old cursor position */
X int newcol = 0; /* new cursor column */
X int newindent = 0; /* auto-indent of the new line */
X int extra = 0; /* number of bytes to be copied from current line */
X int n;
X int truncate = FALSE; /* truncate current line afterwards */
X int no_si = FALSE; /* reset did_si afterwards */
X
X ptr = nr2ptr(Curpos.lnum);
X u_clearline(); /* cannot do "U" command when adding lines */
X did_si = FALSE;
X if (p_ai || p_si)
X {
X /*
X * count white space on current line
X */
X newindent = get_indent();
X
X /*
X * If we just did an auto-indent, then we didn't type anything on the
X * prior line, and it should be truncated.
X */
X if (dir == FORWARD && did_ai)
X truncate = TRUE;
X else if (p_si)
X {
X char *p;
X char *pp;
X int i, save;
X
X p = ptr;
X skipspace(&p);
X if (dir == FORWARD)
X {
X if (*p == '{')
X {
X did_si = TRUE;
X no_si = TRUE;
X }
X else
X {
X for (pp = p; islower(*pp); ++pp) ;
X if (!isidchar(*pp))
X {
X save = *pp;
X *pp = NUL;
X for (i = sizeof(si_tab)/sizeof(char *); --i >= 0; )
X if (strcmp(p, si_tab[i]) == 0)
X {
X did_si = TRUE;
X break;
X }
X *pp = save;
X }
X }
X }
X else
X {
X if (*p == '}')
X did_si = TRUE;
X }
X }
X did_ai = TRUE;
X if (p_si)
X can_si = TRUE;
X }
X if (State == INSERT || State == REPLACE) /* only when dir == FORWARD */
X extra = strlen(ptr + Curpos.col);
X if ((l = alloc_line(extra)) == NULL)
X return (FALSE);
X if (extra)
X {
X strcpy(l, ptr + Curpos.col);
X did_ai = FALSE; /* don't trucate now */
X }
X
X oldCurpos = Curpos;
X if (dir == BACKWARD)
X --Curpos.lnum;
X if (appendline(Curpos.lnum, l) == FALSE)
X return FALSE;
X if (newindent || did_si)
X {
X ++Curpos.lnum;
X if (did_si)
X {
X if (p_sr)
X newindent -= newindent % p_sw;
X newindent += p_sw;
X }
X set_indent(newindent, FALSE);
X newcol = Curpos.col;
X if (no_si)
X did_si = FALSE;
X }
X Curpos = oldCurpos;
X
X if (dir == FORWARD)
X {
X if (truncate)
X *ptr = NUL;
X else if (extra)
X {
X truncate = TRUE;
X *(ptr + Curpos.col) = NUL; /* truncate current line at cursor */
X }
X if (truncate)
X canincrease(0);
X
X /*
X * Get the cursor to the start of the line, so that 'Cursrow' gets
X * set to the right physical line number for the stuff that
X * follows...
X */


X Curpos.col = 0;
X

X if (redraw)
X {
X cursupdate();
X
X /*
X * If we're doing an open on the last logical line, then go ahead and
X * scroll the screen up. Otherwise, just insert a blank line at the
X * right place. We use calls to plines() in case the cursor is
X * resting on a long line.
X */
X n = Cursrow + plines(Curpos.lnum);
X if (n == (Rows - 1))
X scrollup(1L);
X else
X s_ins(n, 1, TRUE);
X }
X ++Curpos.lnum; /* cursor moves down */
X }
X else if (redraw)
X s_ins(Cursrow, 1, TRUE); /* insert physical line */
X
X Curpos.col = newcol;
X if (redraw)
X {
X updateScreen(VALID_TO_CURSCHAR);
X cursupdate(); /* update Cursrow */
X }
X CHANGED;
X
X return (TRUE);
X}
X
X/*
X * plines(p) - return the number of physical screen lines taken by line 'p'
X */
X int
Xplines(p)
X linenr_t p;
X{
X register int col = 0;
X register u_char *s;
X
X#ifdef DEBUG
X if (p == 0)
X {
X emsg("plines(0) ????");
X return (0);
X }
X#endif
X s = (u_char *)nr2ptr(p);
X
X if (*s == NUL) /* empty line */
X return 1;
X
X while (*s != NUL)
X col += chartabsize(*s++, col);
X
X /*
X * If list mode is on, then the '$' at the end of the line takes up one
X * extra column.
X */
X if (p_list)
X col += 1;
X
X /*
X * If 'number' mode is on, add another 8.
X */
X if (p_nu)
X col += 8;
X
X return ((col + ((int)Columns - 1)) / (int)Columns);
X}
X
X/*
X * Count the physical lines (rows) for the lines "first" to "last" inclusive.
X */
X int
Xplines_m(first, last)
X linenr_t first, last;
X{
X int count = 0;
X
X while (first <= last)
X count += plines(first++);
X return (count);
X}
X
X void
Xfileinfo()
X{
X if (bufempty())
X {
X msg("Buffer Empty");
X return;
X }
X sprintf(IObuff, "\"%s\"%s line %ld of %ld -- %d %% --",
X (Filename != NULL) ? Filename : "No File",
X Changed ? " [Modified]" : "",
X (long)Curpos.lnum,
X (long)line_count,
X (int)(((long)Curpos.lnum * 100L) / (long)line_count));
X
X if (numfiles > 1)
X sprintf(IObuff + strlen(IObuff), " (file %d of %d)", curfile + 1, numfiles);
X msg(IObuff);
X}
X
X void
Xsetfname(s)
X char *s;
X{


X if (Filename != NULL)

X free(Filename);
X if (s == NULL || *s == NUL)
X Filename = NULL;
X else
X {
X FullName(s, IObuff, IOSIZE);
X Filename = (char *)strsave(IObuff);
X }
X#ifndef MSDOS
X thisfile_sn = FALSE;
X#endif
X}
X
X/*
X * return nonzero if "s" is not the same file as current file
X */
X int
Xotherfile(s)
X char *s;
X{
X if (s == NULL || *s == NUL || Filename == NULL) /* no name is different */
X return TRUE;
X FullName(s, IObuff, IOSIZE);
X return fnamecmp(IObuff, Filename);
X}
X
X/*
X * put filename in title bar of window
X */
X void
Xmaketitle()
X{
X#ifdef AMIGA
X if (Filename == NULL)
X settitle("");
X else
X {
X if (numfiles == 1)
X settitle(Filename);
X else
X {
X sprintf(IObuff, "%s (%d of %d)", Filename, curfile + 1, numfiles);
X settitle(IObuff);
X }
X }
X#endif
X}
X
X void
Xinschar(c)
X int c;
X{
X register char *p;
X register char *pend;
X
X p = nr2ptr(Curpos.lnum);
X pend = p + Curpos.col;
X if (State != REPLACE || *pend == NUL)
X {
X /* make room for the new char. */
X if (!canincrease(1))
X return;
X
X p = nr2ptr(Curpos.lnum);
X pend = p + Curpos.col;
X p += strlen(p) + 1;
X
X for (; p > pend; p--)
X *p = *(p - 1);
X }
X *pend = c;
X
X /*
X * If we're in insert mode and showmatch mode is set, then check for
X * right parens and braces. If there isn't a match, then beep. If there
X * is a match AND it's on the screen, then flash to it briefly. If it
X * isn't on the screen, don't do anything.
X */
X if (p_sm && State == INSERT && (c == ')' || c == '}' || c == ']'))
X {
X FPOS *lpos, csave;
X
X if ((lpos = showmatch()) == NULL) /* no match, so beep */
X beep();
X else if (lpos->lnum >= Topline)
X {
X updateScreen(VALID_TO_CURSCHAR); /* show the new char first */
X csave = Curpos;
X Curpos = *lpos; /* move to matching char */
X cursupdate();
X setcursor();
X flushbuf();
X vim_delay(); /* brief pause */
X Curpos = csave; /* restore cursor position */
X cursupdate();
X }
X }
X ++Curpos.col;
X
X CHANGED;
X}
X
X void
Xinsstr(s)
X register char *s;
X{
X register char *p;
X register char *pend;
X register int n = strlen(s);
X
X /* Move everything in the file over to make */
X /* room for the new string. */
X if (!canincrease(n))
X return;
X
X p = nr2ptr(Curpos.lnum);
X pend = p + Curpos.col;
X p += strlen(p) + n;
X
X for (; p > pend; p--)
X *p = *(p - n);
X
X Curpos.col += n;
X while (--n >= 0)
X *p++ = *s++;
X
X CHANGED;
X}
X
X int
Xdelchar(fixpos)
X int fixpos; /* if TRUE fix the cursor position when done */
X{
X char *ptr;
X int lastchar;
X
X ptr = pos2ptr(&Curpos);
X
X if (*ptr == NUL) /* can't do anything */
X return FALSE;
X
X lastchar = (*++ptr == NUL);
X /* Delete the char. at Curpos by shifting everything in the line down. */
X do
X *(ptr - 1) = *ptr;
X while (*ptr++);
X
X /*
X * If we just took off the last character of a non-blank line, we don't
X * want to end up positioned at the newline.
X */
X if (fixpos && Curpos.col > 0 && lastchar && State != INSERT)
X --Curpos.col;
X
X (void)canincrease(0);
X CHANGED;


X return TRUE;
X}
X

X void
Xdellines(nlines, can_update)
X long nlines;
X int can_update;
X{
X int doscreen; /* if true, update the screen */
X int num_plines = 0;
X
X doscreen = can_update;
X /*
X * There's no point in keeping the screen updated if we're deleting more
X * than a screen's worth of lines.
X */
X if (nlines > (Rows - 1) && can_update)
X {
X doscreen = FALSE;
X /* flaky way to clear rest of screen */
X s_del(Cursrow, (int)Rows - 1, TRUE);
X }
X while (nlines-- > 0)
X {
X if (bufempty()) /* nothing to delete */


X break;
X
X /*

X * Set up to delete the correct number of physical lines on the
X * screen
X */
X if (doscreen)
X num_plines += plines(Curpos.lnum);
X
X free_line(delsline(Curpos.lnum, TRUE));
X
X CHANGED;
X
X /* If we delete the last line in the file, stop */
X if (Curpos.lnum > line_count)
X {
X Curpos.lnum = line_count;
X break;
X }
X }
X Curpos.col = 0;
X /*
X * Delete the correct number of physical lines on the screen
X */
X if (doscreen && num_plines > 0)
X s_del(Cursrow, num_plines, TRUE);
X}
X
X int
Xgchar(pos)
X FPOS *pos;
X{
X return (int)(*(pos2ptr(pos)));
X}
X
X int
XgcharCurpos()
X{
X return (int)(*(pos2ptr(&Curpos)));
X}
X
X/*
X * return TRUE if the cursor is before or on the first non-blank in the line
X */
X int
Xinindent()
X{
X register char *ptr;
X register int col;
X
X for (col = 0, ptr = nr2ptr(Curpos.lnum); isspace(*ptr++); ++col)
X ;
X if (col >= Curpos.col)
X return TRUE;
X else


X return FALSE;
X}
X
X/*

X * skipspace: skip over ' ' and '\t'.
X *
X * note: you must give a pointer to a char pointer!
X */
X void
Xskipspace(pp)
X char **pp;
X{


X register char *p;
X

X for (p = *pp; *p == ' ' || *p == '\t'; ++p) /* skip to next non-white */
X ;
X *pp = p;
X}
X
X/*
X * skiptospace: skip over text until ' ' or '\t'.
X *
X * note: you must give a pointer to a char pointer!
X */
X void
Xskiptospace(pp)
X char **pp;
X{


X register char *p;
X

X for (p = *pp; *p != ' ' && *p != '\t' && *p != NUL; ++p)
X ;
X *pp = p;
X}
X
X/*
X * getdigits: get a number from a string and skip over it
X *
X * note: you must give a pointer to a char pointer!
X */
X
X long
Xgetdigits(pp)
X char **pp;
X{
X register char *p;
X long retval;
X
X p = *pp;
X retval = atol(p);
X while (isdigit(*p)) /* skip to next non-digit */
X ++p;
X *pp = p;


X return retval;
X}
X

X char *
Xplural(n)
X long n;
X{
X static char buf[2] = "s";
X
X if (n == 1)
X return &(buf[1]);
X return &(buf[0]);
X}
X
X/*
X * set_Changed is called whenever something in the file is changed
X * If the file is readonly, give a warning message with the first change.
X */
X void
Xset_Changed()
X{
X if (Changed == 0 && p_ro)
X emsg("Warning: Changing a readonly file");
X Changed = 1;
X Updated = 1;
X}
X
X int
Xask_yesno(str)
X char *str;
X{
X int r = ' ';
X
X while (r != 'y' && r != 'n')
X {
X smsg("%s (y/n)? ", str);
X r = vgetc();
X outchar(r); /* show what you typed */
X flushbuf();
X }


X return r;
X}
X

X void
Xmsgmore(n)
X long n;
X{
X long pn;
X
X if (n > 0)
X pn = n;
X else
X pn = -n;
X
X if (pn > p_report)
X smsg("%ld %s line%s %s", pn, n > 0 ? "more" : "fewer", plural(pn),
X got_int ? "(Interrupted)" : "");
X}
X
X/*
X * give a warning for an error
X */
X void
Xbeep()
X{
X flush_buffers();
X if (p_vb)
X {
X if (T_VB && *T_VB)
X outstr(T_VB);
X else
X { /* very primitive visual bell */
X msg(" ^G");
X msg(" ^G");
X msg(" ^G ");
X msg(" ^G");


X msg(" ");
X }
X }

X else
X outchar('\007');
X}
X
X/*
X * Expand environment variable with path name.
X * If anything fails no expansion is done and dst equals src.
X */
X void
Xexpand_env(src, dst, dstlen)
X char *src; /* input string e.g. "$HOME/vim.hlp" */
X char *dst; /* where to put the result */
X int dstlen; /* maximum length of the result */
X{
X char *tail;
X int c;
X char *var;
X
X if (*src == '$')
X {
X/*
X * The variable name is copied into dst temporarily, because it may be
X * a string in read-only memory.
X */
X tail = src + 1;
X var = dst;
X c = dstlen;
X while (c-- > 0 && *tail && *tail != PATHSEP)
X *var++ = *tail++;
X *var = NUL;
X var = (char *)vimgetenv(dst);
X if (*tail)
X ++tail;
X if (var && (strlen(var) + strlen(tail) + 1 < dstlen))
X {
X sprintf(dst, "%s%c%s", var, PATHSEP, tail);
X return;
X }
X }
X strncpy(dst, src, (size_t)dstlen);
X}
X
X/*
X * Compare two file names and return TRUE if they are different files.
X * For the first name environment variables are expanded
X */
X int
Xfullpathcmp(s1, s2)
X char *s1, *s2;
X{
X#ifdef UNIX
X struct stat st1, st2;
X char buf1[MAXPATHL];
X
X expand_env(s1, buf1, MAXPATHL);
X st1.st_dev = 99; /* if stat fails, st1 and st2 will be different */
X st2.st_dev = 100;
X stat(buf1, &st1);
X stat(s2, &st2);
X if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
X return FALSE;
X return TRUE;
X#else
X char buf1[MAXPATHL];
X char buf2[MAXPATHL];
X
X expand_env(s1, buf2, MAXPATHL);
X if (FullName(buf2, buf1, MAXPATHL) && FullName(s2, buf2, MAXPATHL))
X return strcmp(buf1, buf2);
X /*
X * one of the FullNames() failed, file probably doesn't exist.
X */
X return TRUE;
X#endif
X}
END_OF_FILE
if test 13737 -ne `wc -c <'vim/src/misccmds.c'`; then
echo shar: \"'vim/src/misccmds.c'\" unpacked with wrong size!
fi
# end of 'vim/src/misccmds.c'
fi
if test -f 'vim/src/msdos.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/msdos.c'\"
else
echo shar: Extracting \"'vim/src/msdos.c'\" \(13589 characters\)
sed "s/^X//" >'vim/src/msdos.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * msdos.c
X *
X * MSDOS system-dependent routines.
X * A cheap plastic imitation of the amiga dependent code.
X * A lot in this file was made by Juergen Weigert (jw).


X */
X
X#include "vim.h"
X#include "globals.h"

X#include "param.h"
X#include "proto.h"
X#include <conio.h>
X#include <fcntl.h>
X#include <bios.h>
X
Xstatic int WaitForChar __ARGS((int));
Xstatic int cbrk_handler __ARGS(());
X
X#ifdef WILD_CARDS
Xtypedef struct filelist
X{
X char **file;
X int nfiles;
X int maxfiles;
X} FileList;
X
Xstatic void addfile __ARGS((FileList *, char *));
Xstatic int pstrcmp __ARGS((char **, char **));
Xstatic void strlowcpy __ARGS((char *, char *));
Xstatic int expandpath __ARGS((FileList *, char *, int, int, int));
X#endif
X
Xstatic int cbrk_pressed = FALSE; /* set by ctrl-break interrupt */
Xstatic int ctrlc_pressed = FALSE; /* set when ctrl-C or ctrl-break detected */
Xstatic int delayed_redraw = FALSE; /* set when ctrl-C detected */
X
X/*
X * the number of calls to Write is reduced by using the buffer "outbuf"
X */
X#define BSIZE 2048
Xstatic u_char outbuf[BSIZE];
Xstatic int bpos = 0;
X
X#ifdef DEBUG
X/*
X * Put two characters in the video buffer without calling BIOS or DOS.
X */
Xblink(n)
X int n;
X{
X char far *p;
X static int counter;
X
X p = MK_FP(0xb800, 0x10 + n); /* p points in screen buffer */
X *p = counter;
X *(p + 1) = counter;
X *(p + 2) = counter;
X *(p + 3) = counter;
X ++counter;
X}
X#endif
X
X void
Xvim_delay()
X{
X delay(500);
X}
X
X/*
X * this version of remove is not scared by a readonly (backup) file
X */
X int
Xremove(name)
X char *name;
X{
X setperm(name, 0); /* default permissions */
X return unlink(name);
X}
X
X/*
X * flushbuf(): flush the output buffer
X */
X void
Xflushbuf()
X{
X if (bpos != 0)
X {
X write(1, (char *)outbuf, (long)bpos);
X bpos = 0;
X }
X}
X
X/*
X * outchar(c): put a character into the output buffer.
X * Flush it if it becomes full.
X */
X void
Xoutchar(c)
X unsigned c;
X{
X outbuf[bpos] = c;
X ++bpos;
X if (bpos >= BSIZE)
X flushbuf();
X}
X
X/*
X * outstr(s): put a string character at a time into the output buffer.
X */
X void
Xoutstr(s)
X register char *s;
X{
X if (!s) /* s is NULL in case of not defined termcap entry */
X return;
X /*
X * The prefix ESC| is used to emulate capabilities
X * missing in ansi.sys by direct calls to conio routines.
X * If we want to avoid this we need the nansi.sys driver. (jw)
X * Only works if the string starts with ESC!
X */
X if (s[0] == ESC && s[1] == '|')
X {
X flushbuf();
X switch (s[2])
X {
X case 'L': insline();
X return;
X
X case 'M': delline();
X return;
X
X default: outstr("OOPS");
X return;
X }
X }
X#ifdef TERMCAP
X tputs(s, 1, outchar);
X#else
X while (*s)
X outchar(*s++);
X#endif
X}
X
X#define POLL_SPEED 10 /* milliseconds between polls */
X
X/*
X * Simulate WaitForChar() by slowly polling with bioskey(1).
X *
X * If Vim should work over the serial line after a 'ctty com1' we must use
X * kbhit() and getch(). (jw)
X * Usually kbhit() is not used, because then CTRL-C will be catched by DOS (mool).
X */
X
X static int
XWaitForChar(msec)
X int msec;
X{
X do
X {
X#ifdef USE_KBHIT
X if (kbhit() || cbrk_pressed)
X#else
X if (bioskey(1) || cbrk_pressed)
X#endif
X return 1;
X delay(POLL_SPEED);
X msec -= POLL_SPEED;
X }
X while (msec >= 0);


X return 0;
X}
X
X/*

X * GetChars(): low level input function.
X * Get characters from the keyboard.
X * If type == T_PEEK do not wait for characters.
X * If type == T_WAIT wait a short time for characters.
X * If type == T_BLOCK wait for characters.
X */
X int
XGetChars(buf, maxlen, type)
X char *buf;
X int maxlen;
X int type;


X{
X int len = 0;

X int time = 1000; /* one second */
X int c;
X
X/*
X * if we got a ctrl-C when we were busy, there will be a "^C" somewhere
X * on the sceen, so we need to redisplay it.
X */
X if (delayed_redraw)
X {
X delayed_redraw = FALSE;
X updateScreen(CLEAR);


X setcursor();
X flushbuf();
X }
X

X switch (type)
X {
X case T_PEEK:
X time = 1;
X /* FALLTHROUGH */
X
X case T_WAIT:
X if (WaitForChar(time) == 0) /* no character available */
X return 0;
X break;
X
X case T_BLOCK:
X /*
X * If there is no character available within 2 seconds (default)
X * write the autoscript file to disk
X */
X if (WaitForChar((int)p_ut) == 0)
X updatescript(0);
X }
X
X/*
X * Try to read as many characters as there are.
X * Works for the controlling tty only.
X */
X --maxlen; /* may get two chars at once */
X /*
X * we will get at least one key. Get more if they are available
X * After a ctrl-break we have to read a 0 (!) from the buffer.
X * bioskey(1) will return 0 if no key is available and when a
X * ctrl-break was typed. When ctrl-break is hit, this does not always
X * implies a key hit.
X */
X cbrk_pressed = FALSE;
X#ifdef USE_KBHIT
X while ((len == 0 || kbhit()) && len < maxlen)
X {
X switch (c = getch())
X {
X case 0:
X *buf++ = K_NUL;
X break;
X case 3:
X cbrk_pressed = TRUE;
X /*FALLTHROUGH*/
X default:
X *buf++ = c;
X }
X len++;
X }
X#else
X while ((len == 0 || bioskey(1)) && len < maxlen)
X {
X c = bioskey(0); /* get the key */
X if (c == 0) /* ctrl-break */
X c = 3; /* return a CTRL-C */
X if ((c & 0xff) == 0)
X {
X if (c == 0x0300) /* CTRL-@ is 0x0300, translated into K_ZERO */
X c = K_ZERO;
X else /* extended key code 0xnn00 translated into K_NUL, nn */
X {
X c >>= 8;
X *buf++ = K_NUL;
X ++len;
X }
X }
X
X *buf++ = c;
X len++;
X }
X#endif


X return len;
X}
X

Xextern int _fmode;
X
X void
Xtextfile(on)
X int on;
X{
X /*
X * in O_TEXT mode we read and write files with CR/LF translation.
X */
X _fmode = on ? O_TEXT : O_BINARY;
X}
X
X/*
X * We have no job control, fake it by starting a new shell.
X */
X void
Xmch_suspend()
X{
X outstr("new shell started\n");
X stoptermcap();
X call_shell(NULL, 0);
X starttermcap();
X}
X
X/*
X * we do not use windows, there is not much to do here
X */
X void
Xmch_windinit()
X{
X textfile(p_tx);
X flushbuf();
X}
X
X void
Xcheck_win(argc, argv)


X int argc;
X char **argv;
X{

X if (!isatty(0) || !isatty(1))
X {
X fprintf(stderr, "VIM: no controlling terminal\n");
X exit(2);
X }
X}
X
X/*
X * fname_case(): Set the case of the filename, if it already exists.
X * msdos filesystem is far to primitive for that. do nothing.
X */
X void
Xfname_case(name)


X char *name;
X{
X}

X
X/*
X * settitle(): set titlebar of our window.
X * Dos console has no title.
X */
X void
Xsettitle(str)


X char *str;
X{
X}

X
X void
Xresettitle()
X{
X}
X
X/*
X * get name of current directory into buffer 'buf' of length 'len' bytes
X */
X int
Xdirname(buf, len)
X char *buf;
X int len;
X{
X return (int)getcwd(buf, len);
X}
X
X/*
X * get absolute filename into buffer 'buf' of length 'len' bytes
X */
X int
XFullName(fname, buf, len)
X char *fname, *buf;
X int len;
X{
X /* failed, because we are under MSDOS */
X strncpy(buf, fname, len);


X return 0;
X}
X
X/*

X * get file permissions for 'name'
X * -1 : error
X * else FA_attributes defined in dos.h
X */
X long
Xgetperm(name)
X char *name;
X{
X int r;
X
X r = _chmod(name, 0, 0); /* get file mode */


X return r;
X}
X

X/*
X * set file permission for 'name' to 'perm'
X */
X int
Xsetperm(name, perm)
X char *name;
X int perm;
X{
X perm &= ~FA_ARCH;
X return _chmod(name, 1, perm);
X}
X
X/*
X * check if "name" is a directory
X */
X int
Xisdir(name)
X char *name;
X{
X return (_chmod(name, 0, 0) & FA_DIREC) ? 1 : 0;
X}
X
X/*
X * Careful: mch_windexit() may be called before mch_windinit()!
X */
X void
Xmch_windexit(r)
X int r;
X{
X settmode(0);
X stoptermcap();
X flushbuf();
X stopscript(); /* remove autoscript file */
X exit(r);
X}
X
X/*
X * function for ctrl-break interrupt
X */
X void interrupt
Xcatch_cbrk()
X{
X cbrk_pressed = TRUE;
X ctrlc_pressed = TRUE;
X}
X
X/*
X * ctrl-break handler for DOS. Never called when a ctrl-break is typed, because
X * we catch interrupt 1b. If you type ctrl-C while Vim is waiting for a
X * character this function is not called. When a ctrl-C is typed while Vim is
X * busy this function may be called. By that time a ^C has been displayed on
X * the screen, so we have to redisplay the screen. We can't do that here,
X * because we may be called by DOS. The redraw is in GetChars().


X */
X static int

Xcbrk_handler()
X{
X delayed_redraw = TRUE;
X return 1; /* resume operation after ctrl-break */
X}
X
X/*
X * function for critical error interrupt
X * For DOS 1 and 2 return 0 (Ignore).
X * For DOS 3 and later return 3 (Fail)
X */
X void interrupt
Xcatch_cint(bp, di, si, ds, es, dx, cx, bx, ax)
X unsigned bp, di, si, ds, es, dx, cx, bx, ax;
X{
X ax = (ax & 0xff00); /* set AL to 0 */
X if (_osmajor >= 3)
X ax |= 3; /* set AL to 3 */
X}
X
X/*
X * set the tty in (raw) ? "raw" : "cooked" mode
X *
X * Does not change the tty, as bioskey() works raw all the time.
X */
X
Xextern void interrupt CINT_FUNC();
X
X void
Xmch_settmode(raw)
X int raw;
X{
X static int saved_cbrk;
X static void interrupt (*old_cint)();
X static void interrupt (*old_cbrk)();
X
X if (raw)
X {
X saved_cbrk = getcbrk(); /* save old ctrl-break setting */
X setcbrk(0); /* do not check for ctrl-break */
X old_cint = getvect(0x24); /* save old critical error interrupt */
X setvect(0x24, catch_cint); /* install our critical error interrupt */
X old_cbrk = getvect(0x1B); /* save old ctrl-break interrupt */
X setvect(0x1B, catch_cbrk); /* install our ctrl-break interrupt */
X ctrlbrk(cbrk_handler); /* vim's ctrl-break handler */
X }
X else
X {
X setcbrk(saved_cbrk); /* restore ctrl-break setting */
X setvect(0x24, old_cint); /* restore critical error interrupt */
X setvect(0x1B, old_cbrk); /* restore ctrl-break interrupt */
X /* restore ctrl-break handler, how ??? */
X }
X}
X
X int
Xmch_get_winsize()
X{
X struct text_info ti;
X
X debug("mch_get_winsize\n");
X if (!term_console)
X return 1;
X gettextinfo(&ti);
X Columns = ti.screenwidth;
X Rows = ti.screenheight;
X if (Columns < 5 || Columns > MAX_COLUMNS ||
X Rows < 2 || Rows > MAX_COLUMNS)
X {
X /* these values are not used. overwritten by termcap size or default */
X Columns = 80;
X Rows = 24;
X return 1;
X }


X return 0;
X}
X

X void
Xmch_set_winsize()
X{
X /* should try to set the window size to Rows and Columns */
X /* may involve switching display mode.... */
X}
X
X int
Xcall_shell(cmd, filter)
X char *cmd;
X int filter; /* if != 0: called by dofilter() */
X{
X int x;
X char newcmd[200];
X
X flushbuf();
X
X settmode(0); /* set to cooked mode */
X
X if (cmd == NULL)
X x = system(p_sh);
X else
X { /* we use "command" to start the shell, slow but easy */
X sprintf(newcmd, "%s /c %s", p_sh, cmd);
X x = system(newcmd);
X }
X outchar('\n');
X settmode(1); /* set to raw mode */
X
X if (x)
X {
X smsg("%d returned", x);


X outchar('\n');
X }

X
X resettitle();
X return x;
X}
X
X/*
X * check for an "interrupt signal": CTRL-break or CTRL-C
X */
X void
Xbreakcheck()
X{
X if (ctrlc_pressed)
X {
X ctrlc_pressed = FALSE;
X got_int = TRUE;
X flush_buffers(); /* remove all typeahead and macro stuff */
X }
X}
X
X#ifdef WILD_CARDS
X#define FL_CHUNK 32
X
X static void
Xaddfile(fl, f)
X FileList *fl;
X char *f;
X{
X if (!fl->file)
X {
X fl->file = (char **)alloc(sizeof(char *) * FL_CHUNK);
X if (!fl->file)
X return;
X fl->nfiles = 0;
X fl->maxfiles = FL_CHUNK;
X }
X if (fl->nfiles >= fl->maxfiles)
X {
X char **t;
X int i;
X
X t = (char **)alloc(sizeof(char *) * (fl->maxfiles + FL_CHUNK));
X if (!t)
X return;
X for (i = fl->nfiles - 1; i >= 0; i--)
X t[i] = fl->file[i];
X free(fl->file);
X fl->file = t;
X fl->maxfiles += FL_CHUNK;
X }
X fl->file[fl->nfiles++] = f;
X}
X
X static int
Xpstrcmp(a, b)
X char **a, **b;
X{
X return (strcmp(*a, *b));
X}
X
X int
Xhas_wildcard(s)
X char *s;
X{
X if (s)
X for ( ; *s; ++s)
X if (*s == '?' || *s == '*')
X return 1;


X return 0;
X}
X

X static void
Xstrlowcpy(d, s)
X char *d, *s;
X{
X while (*s)
X *d++ = tolower(*s++);
X *d = '\0';
X}
X
X static int
Xexpandpath(fl, path, fonly, donly, notf)
X FileList *fl;
X char *path;
X int fonly, donly, notf;
X{
X char buf[MAXPATH];
X char *p, *s, *e;
X int lastn, c, r;
X struct ffblk fb;
X
X lastn = fl->nfiles;
X
X/*
X * Find the first part in the path name that contains a wildcard.
X * Copy it into buf, including the preceding characters.
X */
X p = buf;
X s = NULL;
X e = NULL;
X while (*path)
X {
X if (*path == '\\' || *path == ':' || *path == '/')
X {
X if (e)
X break;
X else
X s = p;
X }
X if (*path == '*' || *path == '?')
X e = p;
X *p++ = *path++;
X }
X e = p;
X if (s)
X s++;
X else
X s = buf;
X
X /* now we have one wildcard component between s and e */
X *e = '\0';
X r = 0;
X if ((c = findfirst(buf, &fb, *path ? FA_DIREC : 0)) != 0)
X {
X /* not found */
X strcpy(e, path);
X if (notf)
X addfile(fl, strsave(buf));
X return 1; /* unexpanded or empty */
X }
X while (!c)
X {
X strlowcpy(s, fb.ff_name);
X if (*s != '.' || (s[1] != '\0' && (s[1] != '.' || s[2] != '\0')))
X {
X strcat(buf, path);
X if (!has_wildcard(path))
X addfile(fl, strsave(buf));
X else
X r |= expandpath(fl, buf, fonly, donly, notf);
X }
X c = findnext(&fb);
X }
X qsort(fl->file + lastn, fl->nfiles - lastn, sizeof(char *), pstrcmp);


X return r;
X}
X

X/*
X * MSDOS rebuilt of Scott Ballantynes ExpandWildCard for amiga/arp.
X * jw
X */
X
X int
XExpandWildCards(num_pat, pat, num_file, file, files_only, list_notfound)
X int num_pat;
X char **pat;
X int *num_file;
X char ***file;
X int files_only, list_notfound;
X{
X int i, r = 0;
X FileList f;
X
X f.file = NULL;
X f.nfiles = 0;
X for (i = 0; i < num_pat; i++)
X {
X if (!has_wildcard(pat[i]))
X addfile(&f, strsave(pat[i]));
X else
X r |= expandpath(&f, pat[i], files_only, 0, list_notfound);
X }
X if (r == 0)
X {
X *num_file = f.nfiles;
X *file = f.file;
X }


X return r;
X}
X

X void
XFreeWild(num, file)
X int num;
X char **file;
X{
X if (file == NULL || num <= 0)
X return;
X while (num--)
X free(file[num]);
X free(file);
X}
X#endif /* WILD_CARDS */
END_OF_FILE
if test 13589 -ne `wc -c <'vim/src/msdos.c'`; then
echo shar: \"'vim/src/msdos.c'\" unpacked with wrong size!
fi
# end of 'vim/src/msdos.c'
fi
if test -f 'vim/src/undo.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/undo.c'\"
else
echo shar: Extracting \"'vim/src/undo.c'\" \(13273 characters\)
sed "s/^X//" >'vim/src/undo.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * undo.c: multi level undo facility
X *
X * The saved lines are stored in a list of lists:
X *
X * u_oldhead----------------------------------------------+
X * |
X * V
X * +--------------+ +--------------+ +--------------+
X * u_newhead--->| u_header | | u_header | | u_header |
X * | uh_next------>| uh_next------>| uh_next---->NULL
X * NULL<--------uh_prev |<---------uh_prev |<---------uh_prev |
X * | uh_entry | | uh_entry | | uh_entry |
X * +--------|-----+ +--------|-----+ +--------|-----+
X * | | |
X * V V V
X * +--------------+ +--------------+ +--------------+
X * | u_entry | | u_entry | | u_entry |
X * | ue_next | | ue_next | | ue_next |
X * +--------|-----+ +--------|-----+ +--------|-----+
X * | | |
X * V V V
X * +--------------+ NULL NULL
X * | u_entry |
X * | ue_next |
X * +--------|-----+
X * |
X * V
X * etc.
X *
X * Each u_entry list contains the information for one undo or redo.
X * u_curhead points to the header of the last undo (the next redo), or is
X * NULL if nothing has been undone.
X *
X * All data is allocated with alloc_line(), thus it will be freed as soon as
X * we switch files!


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"

X#include "ops.h" /* for endop and startop */
X

Xstruct u_entry
X{
X struct u_entry *ue_next; /* pointer to next entry in list */
X linenr_t ue_top; /* number of line above undo block */
X linenr_t ue_bot; /* number of line below undo block */
X char *ue_botptr; /* pointer to line below undo block */
X char **ue_array; /* array of lines in undo block */
X long ue_size; /* number of lines in ue_array */
X};
X
Xstruct u_header
X{
X struct u_header *uh_next; /* pointer to next header in list */
X struct u_header *uh_prev; /* pointer to previous header in list */
X struct u_entry *uh_entry; /* pointer to first entry */
X FPOS uh_curpos; /* cursor position before saving */
X};
X
Xstatic struct u_header *u_oldhead = NULL; /* pointer to oldest header */
Xstatic struct u_header *u_newhead = NULL; /* pointer to newest header */
Xstatic struct u_header *u_curhead = NULL; /* pointer to current header */
Xstatic int u_numhead = 0; /* current number of headers */
Xstatic int u_synced = TRUE; /* entry lists are synced */
X
X/*
X * variables for "U" command
X */
Xstatic char *u_line_ptr = NULL; /* saved line for "U" command */
Xstatic linenr_t u_line_lnum; /* line number of line in u_line */
Xstatic colnr_t u_line_colnr; /* optional column number */
X
Xstatic void u_getbot __ARGS((void));
Xstatic int u_savecommon __ARGS((linenr_t, linenr_t, int, char *));
Xstatic void u_undoredo __ARGS((void));
Xstatic void u_freelist __ARGS((struct u_header *));
Xstatic void u_freeentry __ARGS((struct u_entry *, long));
X
X/*
X * save the current line for both the "u" and "U" command
X */
X int
Xu_saveCurpos()
X{
X return (u_save((linenr_t)(Curpos.lnum - 1), (linenr_t)(Curpos.lnum + 1)));
X}
X
X/*
X * Save the lines between "top" and "bot" for both the "u" and "U" command.
X * "top" may be 0 and bot may be line_count + 1.
X * Returns FALSE when lines could not be saved.
X */
X int
Xu_save(top, bot)
X linenr_t top, bot;
X{
X if (top > line_count || top >= bot || bot > line_count + 1)
X return FALSE; /* rely on caller to do error messages */
X
X if (top + 2 == bot)
X u_saveline((linenr_t)(top + 1));
X
X return (u_savecommon(top, bot, 0, (char *)0));
X}
X
X/*
X * save the line "lnum", pointed at by "ptr" (used by :g//s commands)
X * "ptr" is handed over to the undo routines
X */
X int
Xu_savesub(lnum, ptr)
X linenr_t lnum;
X char *ptr;
X{
X return (u_savecommon(lnum - 1, lnum + 1, 1, ptr));
X}
X
X/*
X * save the line "lnum", pointed at by "ptr" (used by :g//d commands)
X * "ptr" is handed over to the undo routines
X */
X int
Xu_savedel(lnum, ptr)
X linenr_t lnum;
X char *ptr;
X{
X return (u_savecommon(lnum - 1, lnum, 1, ptr));
X}
X
X static int
Xu_savecommon(top, bot, flag, ptr)
X linenr_t top, bot;
X int flag;
X char *ptr;


X{
X linenr_t lnum;
X long i;

X struct u_header *uhp;
X struct u_entry *uep;
X long size;
X
X /*
X * if u_synced == TRUE make a new header
X */
X if (u_synced)
X {
X /*
X * if we undid more than we redid, free the entry lists before and
X * including u_curhead
X */
X while (u_curhead != NULL)
X u_freelist(u_newhead);
X
X /*
X * free headers to keep the size right
X */
X while (u_numhead > p_ul && u_oldhead != NULL)
X u_freelist(u_oldhead);
X
X /*
X * make a new header entry
X */
X uhp = (struct u_header *)alloc_line((unsigned)sizeof(struct u_header));
X if (uhp == NULL)
X goto nomem;
X uhp->uh_prev = NULL;
X uhp->uh_next = u_newhead;
X if (u_newhead != NULL)
X u_newhead->uh_prev = uhp;
X uhp->uh_entry = NULL;
X uhp->uh_curpos = Curpos; /* save cursor position for undo */
X u_newhead = uhp;
X if (u_oldhead == NULL)
X u_oldhead = uhp;
X ++u_numhead;
X }
X else /* find line number for ue_botptr for previous u_save() */
X u_getbot();
X
X /*
X * add lines in front of entry list
X */
X uep = (struct u_entry *)alloc_line((unsigned)sizeof(struct u_entry));
X if (uep == NULL)
X goto nomem;
X
X if (flag)
X size = 1;
X else
X size = bot - top - 1;
X uep->ue_size = size;
X uep->ue_top = top;
X uep->ue_botptr = NULL;
X if (flag)
X uep->ue_bot = bot;
X /*
X * use 0 for ue_bot if bot is below last line or if the buffer is empty, in
X * which case the last line may be replaced (e.g. with 'O' command).
X */
X else if (bot > line_count || bufempty())
X uep->ue_bot = 0;
X else
X uep->ue_botptr = nr2ptr(bot); /* we have to do ptr2nr(ue_botptr) later */
X
X if (size)
X {
X if ((uep->ue_array = (char **)alloc_line((unsigned)(sizeof(char *) * size))) == NULL)
X {
X u_freeentry(uep, 0L);
X goto nomem;
X }
X if (flag)
X uep->ue_array[0] = ptr;
X else
X for (i = 0, lnum = top + 1; i < size; ++i)
X if ((uep->ue_array[i] = save_line(nr2ptr(lnum++))) == NULL)
X {
X u_freeentry(uep, i);
X goto nomem;
X }
X }
X uep->ue_next = u_newhead->uh_entry;
X u_newhead->uh_entry = uep;
X u_synced = FALSE;
X return TRUE;
X
Xnomem:
X if (flag)
X free_line(ptr);
X else if (ask_yesno("no undo possible; continue anyway") == 'y')
X return TRUE;


X return FALSE;
X}
X

X void
Xu_undo(count)
X int count;
X{
X startop.lnum = 0; /* unset '[ mark */
X endop.lnum = 0; /* unset '] mark */
X while (count--)
X {
X if (u_curhead == NULL) /* first undo */
X u_curhead = u_newhead;
X else if (p_ul != 0) /* multi level undo */
X u_curhead = u_curhead->uh_next; /* get next undo */
X
X if (u_numhead == 0 || u_curhead == NULL) /* nothing to undo */
X {
X u_curhead = u_oldhead; /* stick u_curhead at end */


X beep();
X return;
X }
X

X u_undoredo();
X }
X}
X
X void
Xu_redo(count)
X int count;
X{
X while (count--)
X {
X if (u_curhead == NULL || p_ul == 0) /* nothing to redo */


X {
X beep();
X return;
X }
X

X u_undoredo();
X
X u_curhead = u_curhead->uh_prev; /* advance for next redo */
X }
X}
X
X/*
X * u_undoredo: common code for undo and redo
X *
X * The lines in the file are replaced by the lines in the entry list at u_curhead.
X * The replaced lines in the file are saved in the entry list for the next undo/redo.


X */
X static void

Xu_undoredo()
X{
X char **newarray = NULL;
X linenr_t oldsize;
X linenr_t newsize;
X linenr_t top, bot;
X linenr_t lnum = 0;
X linenr_t newlnum = INVLNUM;
X long i;
X long newcount = 0, oldcount = 0;
X struct u_entry *uep, *nuep;
X struct u_entry *newlist = NULL;
X
X if (u_synced == FALSE)
X {
X emsg("undo not synced");
X return;
X }
X
X CHANGED;
X for (uep = u_curhead->uh_entry; uep != NULL; uep = nuep)
X {
X top = uep->ue_top;
X bot = uep->ue_bot;
X if (bot == 0)
X bot = line_count + 1;
X if (top > line_count || top >= bot)
X {
X emsg("u_undo: line numbers wrong");
X return;
X }
X
X if (top < newlnum)
X {
X newlnum = top;
X Curpos.lnum = top + 1;
X }
X oldsize = bot - top - 1; /* number of lines before undo */
X
X newsize = uep->ue_size; /* number of lines after undo */
X
X /* delete the lines between top and bot and save them in newarray */
X if (oldsize)
X {
X if ((newarray = (char **)alloc_line((unsigned)(sizeof(char *) * oldsize))) == NULL)
X {
X /*
X * We have messed up the entry list, repair is impossible.
X * we have to free the rest of the list.
X */
X while (uep != NULL)
X {
X nuep = uep->ue_next;
X u_freeentry(uep, uep->ue_size);
X uep = nuep;
X }
X break;
X }
X /* delete backwards, it goes faster in some cases */
X for (lnum = bot - 1, i = oldsize; --i >= 0; --lnum)
X newarray[i] = delsline(lnum, TRUE);
X }
X /* insert the lines in u_array between top and bot */
X if (newsize)
X {
X for (lnum = top, i = 0; i < newsize; ++i, ++lnum)
X appendline(lnum, uep->ue_array[i]);
X free_line((char *)uep->ue_array);
X }
X newcount += newsize;
X oldcount += oldsize;
X uep->ue_size = oldsize;
X uep->ue_array = newarray;
X uep->ue_bot = lnum + 1;
X
X /*
X * insert this entry in front of the new entry list
X */
X nuep = uep->ue_next;
X uep->ue_next = newlist;
X newlist = uep;
X }
X
X u_curhead->uh_entry = newlist;
X
X /*
X * If we deleted or added lines, report the number of less/more lines.
X * Otherwise, report the number of changed lines (this may be incorrect
X * in some cases, but it's better than nothing).
X */
X if ((oldcount -= newcount) != 0)
X msgmore(-oldcount);
X else if (newcount > p_report)
X smsg("%ld line%s changed", newcount, plural(newcount));
X
X if (u_curhead->uh_curpos.lnum == Curpos.lnum)
X Curpos.col = u_curhead->uh_curpos.col;
X else
X Curpos.col = 0;
X updateScreen(CURSUPD);
X}
X
X/*
X * u_sync: stop adding to the current entry list
X */
X void
Xu_sync()
X{
X if (u_synced)
X return; /* already synced */
X u_getbot(); /* compute ue_bot of previous u_undo */
X u_curhead = NULL;
X}
X
X/*
X * u_getbot(): compute the line number of the previous u_undo


X */
X static void

Xu_getbot()
X{
X register struct u_entry *uep;
X
X if (u_newhead == NULL || (uep = u_newhead->uh_entry) == NULL)
X {
X emsg("undo list corrupt");
X return;
X }
X
X if (uep->ue_botptr != NULL)
X if ((uep->ue_bot = ptr2nr(uep->ue_botptr, uep->ue_top)) == 0)
X {
X emsg("undo line missing");
X uep->ue_bot = uep->ue_top + 1; /* guess what it is */
X }
X
X u_synced = TRUE;
X}
X
X/*
X * u_freelist: free one entry list and adjust the pointers


X */
X static void

Xu_freelist(uhp)
X struct u_header *uhp;
X{
X register struct u_entry *uep, *nuep;
X
X for (uep = uhp->uh_entry; uep != NULL; uep = nuep)
X {
X nuep = uep->ue_next;
X u_freeentry(uep, uep->ue_size);
X }
X
X if (u_curhead == uhp)
X u_curhead = NULL;
X
X if (uhp->uh_next == NULL)
X u_oldhead = uhp->uh_prev;
X else
X uhp->uh_next->uh_prev = uhp->uh_prev;
X
X if (uhp->uh_prev == NULL)
X u_newhead = uhp->uh_next;
X else
X uhp->uh_prev->uh_next = uhp->uh_next;
X
X free_line((char *)uhp);
X --u_numhead;
X}
X
X/*
X * free entry 'uep' and 'n' lines in uep->ue_array[]


X */
X static void

Xu_freeentry(uep, n)
X struct u_entry *uep;
X register long n;
X{
X while (n)
X free_line(uep->ue_array[--n]);
X free_line((char *)uep);
X}
X
X/*
X * invalidate the undo buffer; called when storage has already been released


X */
X
X void

Xu_clearall()
X{
X u_newhead = u_oldhead = u_curhead = NULL;
X u_synced = TRUE;
X u_numhead = 0;
X u_line_ptr = NULL;
X u_line_lnum = 0;
X}
X
X/*
X * save the line "lnum" for the "U" command
X */
X void
Xu_saveline(lnum)
X linenr_t lnum;
X{
X if (lnum == u_line_lnum) /* line is already saved */
X return;
X if (lnum < 1 || lnum > line_count) /* should never happen */
X return;
X u_clearline();
X u_line_lnum = lnum;
X if (Curpos.lnum == lnum)
X u_line_colnr = Curpos.col;
X else
X u_line_colnr = 0;
X u_line_ptr = save_line(nr2ptr(lnum)); /* when out of mem alloc() will give a warning */
X}
X
X/*
X * clear the line saved for the "U" command
X * (this is used externally for crossing a line while in insert mode)
X */
X void
Xu_clearline()
X{
X if (u_line_ptr != NULL)
X {
X free_line(u_line_ptr);
X u_line_ptr = NULL;
X u_line_lnum = 0;
X }
X}
X
X/*
X * Implementation of the "U" command.
X * Differentiation from vi: "U" can be undone with the next "U".
X * We also allow the cursor to be in another line.
X */
X void
Xu_undoline()
X{
X colnr_t t;
X
X if (u_line_ptr == NULL || u_line_lnum > line_count)


X {
X beep();
X return;
X }

X /* first save the line for the 'u' command */
X u_savecommon(u_line_lnum - 1, u_line_lnum + 1, 0, (char *)0);
X u_line_ptr = replaceline(u_line_lnum, u_line_ptr);
X
X t = u_line_colnr;
X if (Curpos.lnum == u_line_lnum)
X u_line_colnr = Curpos.col;
X Curpos.col = t;
X Curpos.lnum = u_line_lnum;
X cursupdate();
X updateScreen(VALID_TO_CURSCHAR);
X}
END_OF_FILE
if test 13273 -ne `wc -c <'vim/src/undo.c'`; then
echo shar: \"'vim/src/undo.c'\" unpacked with wrong size!
fi
# end of 'vim/src/undo.c'
fi
echo shar: End of archive 6 \(of 23\).
cp /dev/null ark6isdone

Bram Moolenaar

unread,
Apr 23, 1993, 1:31:05 PM4/23/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 7
Archive-name: vim/part07
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 7 (of 23)."
# Contents: vim/doc/difference.doc vim/src/termlib.c vim/src/version.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:08 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/difference.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/difference.doc'\"
else
echo shar: Extracting \"'vim/doc/difference.doc'\" \(14014 characters\)
sed "s/^X//" >'vim/doc/difference.doc' <<'END_OF_FILE'
XThis is a summary of the differences between VIM and vi.
X
X
XThe most interesting additions:
X
XMulti level undo.
X'u' goes backward in time, 'ctrl-R' goes forward again. Set option
X'undolines' to the number of changes to be remembered (default 100). Set
X'undolines' to 0 for vi-compatible one level undo.
X
X
XRepeat a series of commands.
X'v'<c> starts recording typed characters into named buffer <c> (append to the
Xbuffer if buffer name is upper case). A subsequent 'v' stops recording. The
Xbuffer can then be executed with the '@'<c> command. This is very useful to
Xrepeat a complex action.
X
X
XFlexible insert mode.
XThe arrow keys can be used in insert mode to move around in the file. This
Xbreaks the insert in two parts as far as undo and redo is concerned.
X
XCTRL-O can be used to execute a single command-mode command. This is almost
Xthe same as hitting ESC, typing the command and hitting 'a'. For undo/redo
Xonly those inserts are remembered where something was actually inserted.
X
X
XQuoting.
XQuoting can be used to first choose a piece of text and then give a command
Xto do something with it. This is an (easy to use) alternative to first giving
Xthe operator and then moving to the end of the text to be operated upon. 'q'
Xand 'Q' are used to start quoting a piece of text. 'q' works on characters
Xand 'Q' on lines. Move the cursor to extend the quoted part. It is shown
Xhighlighted on the screen. By typing 'o' the other end of the quoted text can
Xbe moved. The quoted text can be affected by an operator:
X d delete
X c change
X y yank
X > or < insert or delete indent
X ! filter through external program
X = filter through indent
X : start ":" command for the quoted lines.
X V format text to 'textwidth' columns
X J join lines
X ~ swap case
X u make uppercase
X U make lowercase
X
X
XBlock operators.
XWith quoting a rectangular block of text can be selected. Start quoting with
XCTRL-Q. The block can be deleted ('d'), yanked ('d') or its case can be
Xswapped ('~'). A deleted or yanked block can be put into the text with the
X'p' and 'P' commands.
X
X
XOnline help.
X':help' command and help key (F1 for MSDOS) display several pages of concise
Xhelp. The name of the help file can be set with the "helpfile" option.
X
X
XCommand line editing.
XYou can insert or delete at any place in the command line using the cursor
Xkeys. The right/left cursor keys can be used to move forward/backward one
Xcharacter. The shifted right/left cursor keys can be used to move
Xforward/backward one word.
X
XThe command lines are remembered. The up/down cursor keys can be used to
Xrecall previous command lines. The 'history' option can be set to the number
Xof lines that will be remembered.
X
X
XFilename completion.
XWhile entering a command line (on the bottom line of the screen) <ESC> can be
Xtyped after an (incomplete) file name wildcard; the wildcard will be
Xexpanded. If there are multiple matches, CTRL-N (next) and CTRL-P (previous)
Xwill walk through the matches. CTRL-D can be typed after an (incomplete) file
Xname wildcard; all matching files will be listed.
X
X
XText formatting.
XThe 'textwidth' (tw) option can be used to automatically limit the line
Xlength. This replaces the 'wrapmargin' option of Vi, which was not very
Xuseful. The 'V' operator can be used to format a piece of text ("V}" formats
Xa paragraph).
X
X
XCommand line options:
X
XWhen Vim is started with "-v" (View) then readonly mode is used (includes
X"-n").
X
XWhen Vim is started with "-s scriptfile", the characters read from
X"scriptfile" are treated as if you typed them. If end of file is reached
Xbefore the editor exits, further characters are read from the console.
X
XThe "-w" option can be used to record all typed characters in a script file.
XThis file can then be used to redo the editing, possibly on another file or
Xafter changing some commands in the script file.
X
XThe "-n" option disables the writing of a ".vim" file (see below).
X
XThe "-c command" option does the same as the the "+command" option.
X
XThe "-T terminal" option sets the terminal type.
X
X
XIn command mode:
X
XMissing command: 'Q' (go to Ex mode).
XMissing Ex commands: append, change, insert, open, preserve, recover,
X(un)abbreviate, visual, z and ~.
X
XThe command characters are shown in the last line of the screen. They are
Xremoved when the command is finished. If you do not want this (on a slow
Xterminal) reset the 'showcmd' option.
X
XIf the 'ruler' option is set, the current cursor position is shown in the
Xlast line of the screen.
X
X'u' and CTRL-R accept a count for the number of undos/redos.
X
X'U' still works after having moved off of the last changed line and after
X'u'.
X
XNulls in the file are replaced by newlines internally. This allows editing of
Xbinary files (more or less). When searching for nulls, use a newline in the
Xsearch pattern.
X
XCharacters with the 8th bit set are displayed. The characters between '~' and
X0xa0 are displayed as "~?", "~@", "~A", etc., unless the "graphic' option is
Xset.
X
X'=' is an operator to filter lines through an external command (vi: lisp
Xstuff). The name of the command can be set with the 'equalprg' option. The
Xdefault is "indent".
X
X'][' goes to the next ending of a C function ('}' in column 1).
X'[]' goes to the previous ending of a C function ('}' in column 1).
X
X'*' searches forward for the identifier under the cursor, '#' backward.
X'K' runs the program defined by the "keywordprg" option, with the identifier
Xunder the cursor as argument.
X
X'%' can be preceded with a count. The cursor jumps to the line that
Xpercentage down in the file.
X
XWith the CTRL-] command, the cursor may be in the middle of the identifier.
X
XThe used tags are remembered. Commands that can be used with the tag stack
Xare CTRL-T, ':pop' and ':tag'. ':tags' lists the tag stack.
X
XThe 'tags' option can be set to a list of tag file names. Thus multiple
Xtag files can be used.
X
XPreviously used file names are remembered in the alternate file name list.
XCTRL-^ accepts a count, which is an index in this list.
X
XSearch patterns have more features.
X
XSearches can find the end of a match and may include a character offset.
X
XCount added to '~', ':next', ':Next', 'n' and 'N'.
X
XAdded :wnext command. Same as ":write" followed by ":next".
X
XIf option "tildeop" has been set, '~' is an operator (must be followed by a
Xmovement command).
X
XWith the 'J' (join) command you can reset the 'joinspaces' (js) option to
Xhave only one space after a period (Vi inserts two spaces).
X
X'cw' can be used to change white space formed by several characters (Vi is
Xconfusing: 'cw' only changes one space, while 'dw' deletes all white space).
X
X'o' and 'O' accept a count for repeating the insert (Vi clears a part of
Xdisplay).
X
X':dis' command shows the contents of the yank buffers.
X
XPreviously used file names are remembered in the alternate file name list.
X':files' command shows the list of alternate filenames.
X'#'<N> means <N>th alternate filename in the list.
X
XFlags after command not supported (no plans to include it).
X
XQuickFix commands included, almost the same as with Manx's Z editor.
XThe 'errorfile' option has the name of the file with error messages.
X
X":cd" command shows current directory instead of going to the home directory.
X":cd ~" goes to home directory.
X
X':source!' command reads Vi commands from a file.
X
X':mkexrc' command writes current modified options and mappings to a ".exrc"
Xfile. ':mkvimrc' writes to a ".vimrc" file.
X
XThe :put! command inserts the contents of a register above the current line.
X
XThe named register '.' can be used with commands p, P and :put. The contents
Xof the register is the last inserted text.
X
X':noremap' command can be used to enter a mapping that will not be remapped.
XThis is useful to exchange the meaning of two keys.
X
X':@r' command executes buffer r (is in some versions of vi).
X
XCTRL-O/CTRL-I can be used to jump to older/newer positions. These are the
Xsame positions as used with the '' command, but may be in another file. The
X':jumps' command lists the older positions.
X
XIf the 'shiftround' option is set, an indent is rounded to a multiple of
X'shiftwidth' with '>' and '<' commands.
X
XThe 'scrolljump' option can be set to the minimal number of lines to scroll
Xwhen the cursor gets off the screen. Use this when scrolling is slow.
X
XUppercase marks can be used to jump between files. The ':marks' command lists
Xall currently set marks. The commands "']" and "`]" jump to the end of the
Xprevious operator or end of the text inserted with the put command. "'[" and
X"`[" do jump to the start.
X
XThe 'shelltype' option can be set to reflect the type of shell used.
X
XThe CTRL-A (add) and CTRL-S (subtract) commands are new. The count to the
Xcommand (default 1) is added to/subtracted from the number at or after the
Xcursor. That number may be decimal, octal (starts with a '0') or hexadecimal
X(starts with '0x'). Very useful in macros.
X
XWith the :set command the prefix "inv" can be used to invert toggle options.
X
X
XIn insert mode:
X
XThe backspace key can be used just like CTRL-D to remove auto-indents.
X
XYou can backspace, ctrl-U and CTRL-W over newlines if the 'backspace' (bs)
Xoption is set to non-zero. You can backspace over the start of insert if the
X'backspace' option is set to 2.
X
XIf the 'repdel' option is reset, a <BS> in replace mode will not delete a
Xcharacter.
X
XCTRL-T/CTRL-D always insert/delete an indent in the current line, no matter
Xwhat column the cursor is in. '0' and '^' before CTRL-D are ignored.
X
XCTRL-@ (insert previously inserted text) works always (Vi: only when typed as
Xfirst character).
X
XCTRL-A works like CTRL-@ but does not leave insert mode.
X
XCTRL-B <0-9a-z> can be used to insert the contents of a register.
X
XWhen the 'smartindent' (si) option is set, C programs will be better
Xauto-indented.
X
XCTRL-R and CTRL-E can be used to copy a character from above/below the
Xcurrent cursor position.
X
XAfter CTRL-V you can enter a three digit decimal number. This byte value is
Xinserted in the text as a single character. Useful for international
Xcharacters that are not on your keyboard.
X
XWhen the 'expandtab' (et) option is set, a <TAB> is expanded to the
Xappropriate number of spaces.
X
XThe window always reflects the contents of the buffer (Vi does not do this
Xwhen changing text and in some other cases).
X
XIf Vim is compiled with DIGRAPHS defined, digraphs are supported. A set of
Xnormal Amiga digraphs is included. They are shown with the :digraph" command.
XMore can be added with ":digraph {char1}{char2} {number}". A digraph is
Xentered with "CTRL-K {char1} {char2}" or "{char1} BS {char2}" (only when
X'digraph' option is set).
X
X
Xgeneral:
X
XMissing options: autoprint (ap), beautify (bf), edcompatible, hardtabs (ht),
Xlisp, mesg, open, optimize (op), prompt, redraw, slowopen (slow),
Xwarn, window, w300, w1200 and w9600. Terse option ignored.
X
XWhen the 'compatible' option is set, all options are set for maximum
Xvi-compatibility
X
XThe 'ttimeout' option is like 'timeout', but only works for cursor and
Xfunction keys, not for ordinary mapped characters.
X
XThere is an option for each terminal string. Can be used when termcap is not
Xsupported or to change individual strings.
X
XOn systems that have no job control (most systems but BSD-UNIX) the CTRL-Z
Xand ":stop" command starts a new shell.
X
XIf Vim is started on the Amiga without an interactive window for output, a
Xwindow is opened (and :sh still works). You can give a device to use for
Xediting with the '-d' argument, e.g. "-d con:20/20/600/150".
X
XOn startup the VIMINIT or EXINIT environment variables, the file s:.vimrc or
Xs:.exrc and .vimrc or .exrc are read for initialization commands. When
Xreading .vimrc and .exrc some commands are not allowed because of security
Xreasons (shell commands and writing to a file, :map commands are echoed).
X
XLine lenght can be upto 32767 characters, file length upto 2147483646 lines.
XIf a line is larger than the screen, the last line is filled with <@>s and
Xonly the part of the line before that is shown.
X
XThe 'columns' option is used to set or get the width of the display.
X
XThe name of the current file name is shown in the title bar of the window.
X
XWildcards in file names are expanded.
X
XOption settings are read from the first and last few lines of the file.
XOption 'modelines' determines how many lines are tried (default is 5). Note
Xthat this is different from the Vi versions that can execute any Ex command
Xin a modeline (a major security problem).
X
XIf the 'insertmode' option is set (e.g. in .exrc), Vim starts in insert mode.
X
XAll text is kept in memory. Available memory limits the file size (and other
Xthings such as undo). This may be a problem with MSDOS, is hardly a problem
Xont the Amiga and almost never with Unix.
X
XIf the "backup" or "writebackup" option is set: Before a file is overwritten,
Xa backup file (.bak) is made. If the "backup" option is set it is left
Xbehind.
X
XAll entered commands and text is written into a script file, ending in
X".vim". This can be used to recover your work if the machine crashes during
Xan edit session. This can be switched off by setting the 'updatecount' option
Xto 0 or starting Vim with the "-n" option. Use the 'directory' option for
Xplacing the .vim file somewhere else.
X
XThe 'shortname' (sn) option, when set, tells Vim that ".bak" and ".vim"
Xfilenames are to be MSDOS-like: 8 characters plus 3 for extention. This
Xshould be used on messydos or crossdos filesystems on the Amiga. If this
Xoption is off, Vim tries to guess if MSDOS filename restrictions are
Xeffective.
X
XRecovery after a crash has a smaller chance for success, because there is no
Xtemporary file.
X
XError messages are shown at least one second (Vi overwrites error messages).
X
XIf Vim asks to "Hit RETURN to continue", you can hit any key. Characters
Xother than <CR>, <NL> and <SPACE> are interpreted as the (start of) a
Xcommand. (Vi only accepts a command starting with ':').
X
XThe contents of the numbered registers is remembered when changing files.
X
XThe AUX: device of the Amiga is supported.
X
Xvi:tw=77:
END_OF_FILE
if test 14014 -ne `wc -c <'vim/doc/difference.doc'`; then
echo shar: \"'vim/doc/difference.doc'\" unpacked with wrong size!
fi
# end of 'vim/doc/difference.doc'
fi
if test -f 'vim/src/termlib.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/termlib.c'\"
else
echo shar: Extracting \"'vim/src/termlib.c'\" \(15527 characters\)
sed "s/^X//" >'vim/src/termlib.c' <<'END_OF_FILE'
X/* vi:sw=4:ts=4:
X The following software is (C) 1984 Peter da Silva,
X the Mad Australian, in the public domain. It may
X be re-distributed for any purpose with the inclusion
X of this notice. */
X/* modified by Bram Moolenaar */
X
X/* TERMLIB: Terminal independant database. */
X
X#include "vim.h"
X#include "proto.h"
X#include "proto/termlib.pro"
X
X#ifndef AMIGA
X# include <sgtty.h>
X#endif
X
Xstatic int getent __PARMS((char *, char *, FILE *, int));
Xstatic int nextent __PARMS((char *, FILE *, int));
Xstatic int _match __PARMS((char *, char *));
Xstatic char *_addfmt __PARMS((char *, char *, int));
Xstatic char *_find __PARMS((char *, char *));
X
X/*
X * Global variables for termlib
X */
X
Xchar *tent; /* Pointer to terminal entry, set by tgetent */
Xchar PC = 0; /* Pad character, default NULL */
Xchar *UP = 0, *BC = 0; /* Pointers to UP and BC strings from database */
Xshort ospeed; /* Baud rate (1-16, 1=300, 16=19200), as in stty */
X
X/*
X * Module: tgetent
X *
X * Purpose: Get termcap entry for <term> into buffer at <tbuf>.
X *
X * Calling conventions: char tbuf[TBUFSZ+], term=canonical name for
X * terminal.
X *
X * Returned values: 1 = success, -1 = can't open file,
X * 0 = can't find terminal.
X *
X * Notes
X * Should probably supply static buffer.
X *
X * Uses environment variables "TERM" and
X * "TERMCAP". If TERM = term (that is, if the argument
X * matches the environment) then it looks at TERMCAP.
X * If TERMCAP begins with a slash, then it assumes
X * this is the file to search rather than /etc/termcap.
X * If TERMCAP does not begin with a slash, and it
X * matches TERM, then this is used as the entry.
X *
X * This could be simplified considerably for non-UNIX
X * systems.
X */
X
X#ifdef AMIGA
X# define TERMCAPFILE "s:termcap"
X#else
X# define TERMCAPFILE "/etc/termcap"
X#endif
X
Xtgetent(tbuf, term)
X char *tbuf; /* Buffer to hold termcap entry, TBUFSZ bytes max */
X char *term; /* Name of terminal */
X{
X char tcbuf[32]; /* Temp buffer to handle */
X char *tcptr = tcbuf; /* extended entries */
X char *tcap = TERMCAPFILE; /* Default termcap file */
X char *tmp;
X FILE *termcap;


X int retval = 0;

X int len;
X
X if ((tmp = (char *)vimgetenv("TERMCAP")) != NULL)
X {
X if (*tmp == '/') /* TERMCAP = name of termcap file */
X tcap = tmp ;
X else /* TERMCAP = termcap entry itself */
X {
X int tlen = strlen(term);
X
X while (*tmp && *tmp != ':') /* Check if TERM matches */
X {
X while (*tmp == '|')
X tmp++;
X if (_match(tmp, term) == tlen)
X {
X strcpy(tbuf, tmp);
X tent = tbuf;
X return 1;
X }
X else
X tmp = _find(tmp, ":|");
X }
X }
X }
X if (!(termcap = fopen(tcap, "r")))
X {
X strcpy(tbuf, tcap);


X return -1;
X }
X

X len = 0;
X while (getent(tbuf + len, term, termcap, TBUFSZ - len))
X {
X if ((term = tgetstr("tc", &tcptr))) /* extended entry */
X {
X rewind(termcap);
X len = strlen(tbuf);
X }
X else
X {
X retval = 1;
X tent = tbuf;
X break;
X }
X }
X fclose(termcap);


X return retval;
X}
X

X static int
Xgetent(tbuf, term, termcap, buflen)
X char *tbuf, *term;
X FILE *termcap;
X int buflen;
X{
X char *tptr;
X int tlen = strlen(term);
X
X while (nextent(tbuf, termcap, buflen)) /* For each possible entry */
X {
X tptr = tbuf;
X while (*tptr && *tptr != ':') /* : terminates name field */
X {
X while (*tptr == '|') /* | seperates names */
X tptr++;
X if (_match(tptr, term) == tlen) /* FOUND! */
X {
X tent = tbuf;
X return 1;
X }
X else /* Look for next name */
X tptr = _find(tptr, ":|");
X }


X }
X return 0;
X}
X

X static int
Xnextent(tbuf, termcap, buflen) /* Read 1 entry from TERMCAP file */
X char *tbuf;
X FILE *termcap;
X int buflen;
X{
X char *lbuf = tbuf; /* lbuf=line buffer */
X /* read lines straight into buffer */
X
X while (lbuf < tbuf+buflen && /* There's room and */
X fgets(lbuf, (int)(tbuf+buflen-lbuf), termcap)) /* another line */
X {
X int llen = strlen(lbuf);
X
X if (*lbuf == '#') /* eat comments */
X continue;
X if (lbuf[-1] == ':' && /* and whitespace */
X lbuf[0] == '\t' &&
X lbuf[1] == ':')
X {
X strcpy(lbuf, lbuf+2);
X llen -= 2;
X }
X if (lbuf[llen-2] == '\\') /* and continuations */
X lbuf += llen-2;
X else
X {
X lbuf[llen-1]=0; /* no continuation, return */


X return 1;
X }
X }

X
X return 0; /* ran into end of file */
X}
X
X/*
X * Module: tgetflag
X *
X * Purpose: returns flag true or false as to the existence of a given
X * entry. used with 'bs', 'am', etc...
X *
X * Calling conventions: id is the 2 character capability id.
X *
X * Returned values: 1 for success, 0 for failure.
X */
X
Xtgetflag(id)
X char *id;
X{
X char buf[256], *ptr = buf;
X
X return tgetstr(id, &ptr) ? 1 : 0;
X}
X
X/*
X * Module: tgetnum
X *
X * Purpose: get numeric value such as 'li' or 'co' from termcap.
X *
X * Calling conventions: id = 2 character id.
X *
X * Returned values: -1 for failure, else numerical value.
X */
X
Xtgetnum(id)
Xchar *id;
X{
X char *ptr, buf[256];
X ptr = buf;
X
X if (tgetstr(id, &ptr))
X return atoi(buf);
X else


X return 0;
X}
X
X/*

X * Module: tgetstr
X *
X * Purpose: get terminal capability string from database.
X *
X * Calling conventions: id is the two character capability id.
X * (*buf) points into a hold buffer for the
X * id. the capability is copied into the buffer
X * and (*buf) is advanced to point to the next
X * free byte in the buffer.
X *
X * Returned values: 0 = no such entry, otherwise returns original
X * (*buf) (now a pointer to the string).
X *
X * Notes
X * It also decodes certain escape sequences in the buffer.
X * they should be obvious from the code:
X * \E = escape.
X * \n, \r, \t, \f, \b match the 'c' escapes.
X * ^x matches control-x (^@...^_).
X * \nnn matches nnn octal.
X * \x, where x is anything else, matches x. I differ
X * from the standard library here, in that I allow ^: to match
X * :.
X *
X */
X
Xchar *
Xtgetstr(id, buf)
Xchar *id, **buf;
X{
X int len = strlen(id);
X char *tmp=tent;
X char *hold;
X int i;
X
X do {
X tmp = _find(tmp, ":"); /* For each field */
X while (*tmp == ':') /* skip empty fields */
X tmp++;
X if (!*tmp)
X break;
X
X if (_match(id, tmp) == len) {
X tmp += len; /* find '=' '@' or '#' */
X if (*tmp == '@') /* :xx@: entry for tc */
X return 0; /* deleted entry */
X hold= *buf;
X while (*++tmp && *tmp != ':') {/* not at end of field */
X switch(*tmp) {
X case '\\': /* Expand escapes here */
X switch(*++tmp) {
X case 0: /* ignore backslashes */
X tmp--; /* at end of entry */
X break; /* shouldn't happen */
X case 'e':
X case 'E': /* ESC */
X *(*buf)++ = '\033';
X break;
X case 'n': /* \n */
X *(*buf)++ = '\n';
X break;
X case 'r': /* \r */
X *(*buf)++ = '\r';
X break;
X case 't': /* \t */
X *(*buf)++ = '\t';
X break;
X case 'b': /* \b */
X *(*buf)++ = '\b';
X break;
X case 'f': /* \f */
X *(*buf)++ = '\f';
X break;
X case '0': /* \nnn */
X case '1':
X case '2':
X case '3':
X case '4':
X case '5':
X case '6':
X case '7':
X case '8':
X case '9':
X **buf = 0;
X /* get up to three digits */
X for (i = 0; i < 3 && isdigit(*tmp); ++i)
X **buf = **buf * 8 + *tmp++ - '0';
X (*buf)++;
X tmp--;
X break;
X default: /* \x, for all other x */
X *(*buf)++= *tmp;
X }
X break;
X case '^': /* control characters */
X *(*buf)++ = *++tmp - '@';
X break;
X default:
X *(*buf)++ = *tmp;
X }
X }
X *(*buf)++ = 0;
X return hold;
X }
X } while (*tmp);


X
X return 0;
X}
X

X/*
X * Module: tgoto
X *
X * Purpose: decode cm cursor motion string.
X *
X * Calling conventions: cm is cursor motion string.
X * line, col, are the desired destination.
X *
X * Returned values: a string pointing to the decoded string, or
X * "OOPS" if it cannot be decoded.
X *
X * Notes
X * The accepted escapes are:
X * %d as in printf, 0 origin.
X * %2, %3 like %02d, %03d in printf.
X * %. like %c
X * %+x adds <x> to value, then %.
X * %>xy if value>x, adds y. No output.
X * %i increments line& col, no output.
X * %r reverses order of line&col. No output.
X * %% prints as a single %.
X * %n exclusive or row & col with 0140.
X * %B BCD, no output.
X * %D reverse coding (x-2*(x%16)), no output.
X */
X
Xchar *
Xtgoto(cm, col, line)
Xchar *cm; /* cm string, from termcap */
Xint col, /* column, x position */
X line; /* line, y position */
X{
X char gx, gy, /* x, y */
X *ptr, /* pointer in 'cm' */
X reverse = 0, /* reverse flag */
X *bufp, /* pointer in returned string */
X addup = 0, /* add upline */
X addbak = 0, /* add backup */
X c;
X static char buffer[32];
X
X if (!cm)
X return "OOPS"; /* Kludge, but standard */
X
X bufp = buffer;
X ptr = cm;
X
X while (*ptr) {
X if ((c = *ptr++) != '%') { /* normal char */
X *bufp++ = c;
X } else { /* % escape */
X switch(c = *ptr++) {
X case 'd': /* decimal */
X bufp = _addfmt(bufp, "%d", line);
X line = col;
X break;
X case '2': /* 2 digit decimal */
X bufp = _addfmt(bufp, "%02d", line);
X line = col;
X break;
X case '3': /* 3 digit decimal */
X bufp = _addfmt(bufp, "%03d", line);
X line = col;
X break;
X case '>': /* %>xy: if >x, add y */
X gx = *ptr++;
X gy = *ptr++;
X if (col>gx) col += gy;
X if (line>gx) line += gy;
X break;
X case '+': /* %+c: add c */
X line += *ptr++;
X case '.': /* print x/y */
X if (line == '\t' || /* these are */
X line == '\n' || /* chars that */
X line == '\004' || /* UNIX hates */
X line == '\0') {
X line++; /* so go to next pos */
X if (reverse == (line == col))
X addup=1; /* and mark UP */
X else
X addbak=1; /* or BC */
X }
X *bufp++=line;
X line = col;
X break;
X case 'r': /* r: reverse */
X gx = line;
X line = col;
X col = gx;
X reverse = 1;
X break;
X case 'i': /* increment (1-origin screen) */
X col++;
X line++;
X break;
X case '%': /* %%=% literally */
X *bufp++='%';
X break;
X case 'n': /* magic DM2500 code */
X line ^= 0140;
X col ^= 0140;
X break;
X case 'B': /* bcd encoding */
X line = line/10<<4+line%10;
X col = col/10<<4+col%10;
X break;
X case 'D': /* magic Delta Data code */
X line = line-2*(line&15);
X col = col-2*(col&15);
X break;
X default: /* Unknown escape */
X return "OOPS";
X }
X }
X }
X
X if (addup) /* add upline */
X if (UP) {
X ptr=UP;
X while (isdigit(*ptr) || *ptr == '.')
X ptr++;
X if (*ptr == '*')
X ptr++;
X while (*ptr)
X *bufp++ = *ptr++;
X }
X
X if (addbak) /* add backspace */
X if (BC) {
X ptr=BC;
X while (isdigit(*ptr) || *ptr == '.')
X ptr++;
X if (*ptr == '*')
X ptr++;
X while (*ptr)
X *bufp++ = *ptr++;
X }
X else
X *bufp++='\b';
X
X *bufp = 0;
X
X return(buffer);
X}
X
X/*
X * Module: tinit
X *
X * Purpose: simplified terminal initialisation.
X *
X * Calling conventions: name is name of terminal.
X *
X * Returned values: none.
X *
X * Notes
X * tinit calls tgetent, then sets up the global
X * variables PC, UP, BC, ospeed appropriately.
X *
X */
X
X#if 0 /* already included in term.c */
X
Xchar tbuf[TBUFSZ]; /* Buffer for termcap entry */
Xchar junkbuf[TBUFSZ]; /* Big buffer for junk */
Xchar *junkptr;
X
Xtinit(name)
Xchar *name;
X{
X#ifndef AMIGA
X struct sgttyb sgbuf;
X#endif
X char *ps;
X
X junkptr = junkbuf;
X
X tgetent(tbuf, name);
X
X ps = tgetstr("pc", &junkptr);
X if (ps) PC = *ps;
X UP = tgetstr("up", &junkptr);
X BC = tgetstr("bc", &junkptr);
X
X#ifdef AMIGA
X ospeed=0;
X#else
X gtty(1, &sgbuf);
X ospeed=sgbuf.sg_ospeed;
X#endif
X return 0;
X}
X#endif
X
X/*
X * Module: tputs
X *
X * Purpose: decode padding information
X *
X * Calling conventions: cp = string to be padded, affcnt = # of items
X * affected (lines, characters, whatever),
X * outc = routine to output 1 character.
X *
X * Returned values: none
X *
X * Notes
X * cp has padding information ahead of it, in the form
X * nnnTEXT or nnn*TEXT. nnn is the number of milliseconds to delay,
X * and may be a decimal (nnn.mmm). If the asterisk is given, then
X * the delay is multiplied by afcnt. The delay is produced by outputting
X * a number of nulls (or other padding char) after printing the
X * TEXT.
X *
X */
X
Xlong _bauds[16]={
X 0, 50, 75, 110,
X 134, 150, 200, 300,
X 600, 1200, 1800, 2400,
X 4800, 9600, 19200, 19200 };
X
Xtputs(cp, affcnt, outc)
Xchar *cp; /* string to print */
Xint affcnt; /* Number of lines affected */
Xvoid (*outc) __ARGS((unsigned int)); /* routine to output 1 character */
X{
X long frac, /* 10^(#digits after decimal point) */
X counter, /* digits */
X atol();
X
X if (isdigit(*cp)) {
X counter = 0;
X frac = 1000;
X while (isdigit(*cp))
X counter = counter * 10L + (long)(*cp++ - '0');
X if (*cp == '.')
X while (isdigit(*++cp)) {
X counter = counter * 10L + (long)(*cp++ - '0');
X frac = frac * 10;
X }
X if (*cp!='*') { /* multiply by affected lines */
X if (affcnt>1) affcnt = 1;
X }
X else
X cp++;
X
X /* Calculate number of characters for padding counter/frac ms delay */
X if (ospeed)
X counter = (counter * _bauds[ospeed] * (long)affcnt) / frac;
X
X while (*cp) /* output string */
X (*outc)(*cp++);
X if (ospeed)
X while (counter--) /* followed by pad characters */
X (*outc)(PC);
X }
X else
X while (*cp)
X (*outc)(*cp++);


X return 0;
X}
X
X/*

X * Module: tutil.c
X *
X * Purpose: Utility routines for TERMLIB functions.
X *


X */
X
X static int

X_match(s1, s2) /* returns length of text common to s1 and s2 */
Xchar *s1, *s2;
X{
X int i = 0;
X
X while (s1[i] && s1[i] == s2[i])
X i++;
X
X return i;
X}
X
X static char *
X_find(s, set) /* finds next c in s that's a member of set, returns pointer */
Xchar *s, *set;
X{
X for(; *s; s++) {
X char *ptr = set;
X
X while (*ptr && *s != *ptr)
X ptr++;
X
X if (*ptr)


X return s;
X }
X
X return s;
X}
X

X static char *
X_addfmt(buf, fmt, val) /* add val to buf according to format fmt */
Xchar *buf, *fmt;
Xint val;
X{
X sprintf(buf, fmt, val);
X while (*buf)
X buf++;
X return buf;
X}
END_OF_FILE
if test 15527 -ne `wc -c <'vim/src/termlib.c'`; then
echo shar: \"'vim/src/termlib.c'\" unpacked with wrong size!
fi
# end of 'vim/src/termlib.c'
fi
if test -f 'vim/src/version.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/version.c'\"
else
echo shar: Extracting \"'vim/src/version.c'\" \(14258 characters\)
sed "s/^X//" >'vim/src/version.c' <<'END_OF_FILE'
X/* vi:ts=4:sw=4:tw=77
X *


X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X Started with Stevie version 3.6 (Fish disk 217) - GRWalter (Fred)
X
X VIM 1.0 - Changed so many things that I felt that a new name was required
X (I didn't like the name Stevie that much: I don't have an ST).
X - VIM stands for "Vi IMitation".
X - New storage structure, MULTI-LEVEL undo and redo,
X improved screen output, removed an awful number of bugs,
X removed fixed size buffers, added counts to a lot of commands,
X added new commands, added new options, added 'smart indent',
X added recording mode, added script files, moved help to a file,
X etc. etc. etc.
X - Compiles under Manx/Aztec C 5.0. You can use "rez" to make VIM
X resident.
X - Bram Moolenaar (Mool)
X
X VIM 1.09 - spaces can be used in tags file instead of tabs (compatible with
X Manx ctags).
X
X VIM 1.10 - Csh not required anymore for CTRL-D. Search options /e and /s added.
X Shell option implemented. BS in replace mode does not delete
X character. Backspace, wrapmargin and tags options added.
X Added support for Manx's QuickFix mode (just like "Z").
X The ENV: environment variables instead of the Old Manx environment
X variables are now used, because Vim was compiled with version 5.0d
X of the compiler. "mool" library not used anymore. Added index to
X help screens.
X
X VIM 1.11 - removed bug that caused :e of same file, but with name in upper case,
X to re-edit that file.
X
X VIM 1.12 - The second character of several commands (e.g. 'r', 't', 'm') not
X :mapped anymore (UNIX vi does it like this, don't know why); Some
X operators did not work when doing a 'l' on the last character in
X a line (e.g. 'yl'); Added :mapping when executing registers;
X Removed vi incompatibility from 't' and 'T' commands; :mapping! also
X works for command line editing; Changed a few details to have Vim
X run the macros for solving a maze and Towers of Hanoi! It now also
X runs the Turing machine macros!
X
X VIM 1.13 - Removed a bug for !! on empty line. "$" no longer puts cursor at
X the end of the line when combined with an operator. Added
X automatic creation of a script file for recovery after a crash.
X Added "-r" option. Solved bug for not detecting end of script file.
X ".bak" is now appended, thus "main.c" and "main.h" will have
X separate backup files.
X
X VIM 1.14 - Removed a few minor bugs. Added "-n" option to skip autoscript.
X Made options more Vi compatible. Improved ^C handling. On serious
X errors typahead and scripts are discarded. 'U' is now correctly
X undone with 'u'. Fixed showmatch() handling of 'x' and '\x'.
X Solved window size dependency for scripts by adding ":winsize"
X commands to scripts. This version released on Fish disk 591.
X
X VIM 1.15 - No extra return in recording mode (MCHAR instead of MLINE buffer).
X plural() argument is now a long. Search patterns shared between
X :g, :s and /. After recovery a message is given. Overflow of mapbuf
X is detected. Line number possible with :read. Error message when
X characters follow a '$' in a search pattern. Cause for crash
X removed: ":s/pat/repl/g" allocated not enough memory. Option
X "directory" added. Option "expandtab" added. Solved showmode non-
X functioning. Solved bug with window resizing. Removed some *NULL
X references. CTRL-], * and # commands now skips non-identifier
X characters. Added tag list, CTRL-T, :pop and :tags commands.
X Added jump list, CTRL-O and CTRL-I commands. Added "shiftround"
X option. Applied AUX and Lattice mods from Juergen Weigert.
X Finally made linenr_t a long, files can be > 65000 lines!
X :win command could be written to script file halfway a command.
X Option shelltype added. With ^V no mapping anymore.
X Added :move, :copy, :t, :mark and :k. Improved Ex address parsing.
X Many delimiters possible with :s.
X
X VIM 1.16 - Solved bug with zero line number in Ex range. Added file-number to
X jump list. Solved bug when scrolling downwards. Made tagstack vi
X compatible. Cmdline editing: CTRL-U instead of '@'. Made Vim DICE
X compatible. Included regexp improvements from Olaf Seibert,
X mapstring() removed. Removed bug with CTRL-U in insert mode.
X Count allowed before ". Added uppercase (file) marks. Added
X :marks command. Added joinspaces option. Added :jumps command. Made
X jumplist compatible with tag list. Added count to :next and :Next.
X
X VIM 1.17 - Removed '"' for Ex register name. Repaired stupid bug in tag code.
X Now compiled with Aztec 5.2a. Changed Arpbase.h for use with 2.04
X includes. Added repdel option. Improved :set listing. Added count
X to 'u' and CTRL-R commands. "vi:" and "ex:" in modelines must now
X be preceded with a blank. Option "+command" for command line and
X :edit command added.
X
X VIM 1.18 - Screen was not updated when all lines deleted. Readfile() now
X puts cursor on first new line. Catch strange disk label.
X Endless "undo line missing" loop removed. With empty file 'O' would
X cause this. Added window size reset in windexit(). Flush .vim file
X only when buffer has been changed. Added the nice things from
X Elvis 1.5: Added "equalprg" and "ruler" option. Added quoting.
X Added third meaning to 'backspace' option: backspacing over start
X of insert. Added "-c {command}" command line option. Made generating
X of prototypes automatically. Added insert mode command CTRL-O and
X arrow keys. CTRL-T/CTRL-D now always insert/delete indent. When
X starting an edit on specified lnum there was redraw of first lines.
X Added 'inputmode' option. Added CTRL-A and CTRL-S commands. '`' is
X now exclusive (as it should be). Added digraphs as an option.
X Changed implementation of parameters. Added :wnext command.
X Added ':@r' command. Changed handling of CTRL-V in command line.
X Block macros now work. Added keyword lookup command 'K'. Added
X CTRL-N and CTRL-P to command line editing. For DOS 2.0x the Flush
X function is used for the autoscript file; this should solve the
X lockup bug. Added wait_return to msg() for long messages.
X
X VIM 1.19 - Changes from Juergen Weigert:
X Terminal type no longer restricted to machine console. New
X option -T terminal. New set option "term". Builtin termcap
X entries for "amiga", "ansi", "atari", "nansi", "pcterm".
X Ported to MSDOS. New set option "textmode" ("tx") to control
X CR-LF translation. CTRL-U and CTRL-D scroll half a screen full,
X rather than 12 lines. New set option "writebackup" ("wb") to
X disable even the 'backup when writing' feature.
X Ported to SunOS. Full termcap support. Does resize on SIGWINCH.
X
X Made storage.c portable. Added reading of ".vimrc". Added
X 'helpfile' option. With quoting the first char of an empty line
X is inverted. Optimized screen updating a bit. Startup code
X looks for VIMINIT variable and .vimrc file first. Added option
X helpfile. Solved bug of inserting deletes: redefined ISSPECIAL.
X Changed inchar() to use key codes from termcap. Added parameters
X for terminal codes. Replaced aux device handling by amiga window
X handling. Added optional termcap code. Added 'V', format
X operator.
X
X VIM 1.20 - wait_return only ignores CR, LF and space. 'V' also works for
X single line. No redrawing while formatting text. Added CTRL-Z.
X Added usage of termcap "ks" and "ke". Fixed showmatch().
X Added timeout option. Added newfile argument to readfile().
X
X VIM 1.21 - Added block mode. Added 'o' command for quoting. Added :set inv.
X Added pos2ptr(). Added repeating and '$' to Quoting.
X
X VIM 1.22 - Fixed a bug in doput() with count > 1.
X Port to linux by Juergen Weigert included.
X More unix semantics in writeit(), forceit flag ignores errors while
X preparing backup file. For UNIX, backup is now copied, not moved.
X When the current directory is not writable, vim now tries a backup
X in the directory given with the backupdir option. For UNIX, raw mode
X has now ICRNL turned off, that allowes ^V^M. Makefiles for BSD,
X SYSV, and linux unified in makefile.unix. For MSDOS
X mch_get_winsize() implemented. Reimplemented builtin termcaps in
X term.c and term.h. set_term() now handles all cases. Even builtins
X when TERMCAP is defined. Show "..." while doing filename completion.
X
X VIM 1.23 - Improved MSDOS version: Added function and cursor keys to builtin
X pcterm. Replaced setmode by settmode, delay by vim_delay and
X delline by dellines to avoid name conflicts. Made F1 help key.
X Renamed makecmdtab to mkcmdtab and cmdsearch to csearch for
X 8 char name limit. Wildcard expansion adds *.* to names without a
X dot. Added shell execution.
X For unix: writeit() overwrites readonly files when forced write,
X more safety checks. Termcap buffer for linux now 2048 bytes.
X Expandone() no longer appends "*" to file name. Added "graphic"
X option. Added ':' command to quoting.
X
X VIM 1.24 Adjusted number of spaces inserted by dojoin(). MSDOS version uses
X searchpath() to find helpfile. Fixed a few small problems. Fixed
X nasty bug in getperm() for SAS 6.0. Removed second argument from
X wait_return(). Script files accessed in binary mode with MSDOS.
X Added 'u' and 'U' commands to quoting (make upper or lower case).
X Added "CTRL-V [0-9]*" to enter any byte value. Fixed doput().
X Dodis() displays register 0. Added CTRL-B to insert mode. Attempt
X to fix the lockup bug by adding Delay() to startscript(). -v
X option now implies -n option. doformat() added to improve 'V'
X command. Replace bool_t with int. Fixed handling of \& and ~ in
X regsub(). Added interrupt handling in msdos.c for ctrl-break and
X critical errors. Added scrolljump option. Added :stop. Added -d
X argument. Fixed bug in quickfix startup from cli. Fixed enforcer
X hit with aux:. Added CTRL-C handling to unix.c. Fixed "O<BS><CR>"
X bug with autoindent. Worked around :cq not working by adding a
X printf()!? Added default mapping for MSDOS PageUp etc. Fixed
X cursor position after 'Y'. Added shift-cursor commands. Changed
X ExpandFile() to keep names with errors. Added CLEAR and CURSUPD
X arguments to updateScreen(). Fixed CTRL-@ after a change command.
X modname() changes '.' into '_'. Added emptyrows to screen.c.
X Fixed redo of search with offset. Added count to 'z' command.
X Made :so! work with :global. Added writing of cursor postition to
X startscript(). Minimized terminal requirements. Fixed problem
X with line in tags file with mixed spaces and tabs. Fixed problem
X with pattern "\\" in :s and :g. This version posted on Usenet.
X
X VIM 1.25 Improved error messages for :set. Open helpfile in binary mode
X for MSDOS. Fixed ignorecase for Unix in cstrncmp(). Fixed read
X from NULL with :tags after vim -t. Repaired 'z' command. Changed
X outnum() for >32767. In msdos.c flushbuf did write(1, .. instead
X of write(0, .. Added secure to fix security. Fixed pointer
X use after free() bug in regsub() (made :s fail under MSDOS).
X Added nofreeNULL(), needed for some UNIXes. Improved window
X resizing for Unix. Fixed messages for report == 0. Added
X bsdmemset(). Changed a few small things for portability. Added
X :list. Made '0' and '^' exclusive. Fixed regexp for /pattern*
X (did /(pattern)* instead of /pattern(n)*). Added "']" and "'[".
X Changed Delay(2L) into Delay(10L). Made 'timeout' option
X vi-compatible, added 'ttimeout' option. Changed TIOCSETP to
X TIOCSETN in unix.c. Added "ti" and "te" termcap entries, makes
X sun cmdtool work. Added stop- and starttermcap(). Use cooked
X output for listings on Amiga only. Added "starting" flag, no ~s
X anymore with every startup. Modname made portable; Added
X 'shortname' option, Fixed problems with .vim file on messydos.
X Global .exrc/.vimrc for Unix added. Added patches for SCO Xenix.
X Add :w argument to list of alternate file names. Applied a few
X changes for HPUX. Added Flock in writeit() for safety. Command
X ":'a,'bm." moved to 'b instead of current line. Argument in
X 'shell' option allowed. Re-implemented :copy and :move. Fixed
X BS-CR-BS on empty line bug in edit.c. -t option was ignored if
X there is a file ".vim". Changed amiga.c to work without
X arp.library for dos 2.0. Fixed "\$" and "\^" in regexp. Fixed
X pipe in filter command. Fixed CTRL-U and CTRL-D. With '}' indent
X in front of the cursor is included in the operated text. Fixed
X tag with '[' in search pattern. Added CTRL-V to 'r'. Fixed "tc"
X entry in termlib.c. term_console now default off. Added :noremap
X and ^V in :map argument. Replaced CTRL by Ctrl because some
X unixes have this already. Fixed "Empty file" message disappearing
X when there is no .exrc file. Added CTRL-K for entering digraphs.
X Removed escape codes from vim.hlp, added handling of inversion to
X help().
X
X VIM 1.26 For Unix: Removed global .exrc; renamed global .vimrc to vimrc.
X Moved names of *rc and help files to makefile. Added various
X little changes for different kinds of Unix. Changed CR-LF
X handling in dosource() for MSDOS. Added :mkvimrc. Fixed
X WildExpand in unix.c for empty file. Fixed incompatibility with
X msdos share program (removed setperm(fname, 0) from fileio.c).
X Added ":set compatible". Fixed 'history=0'.
X
X VIM 1.27 Added USE_LOCALE. Changed swapchar() to use toupper() and
X tolower(). Changed init order: .vimrc before EXINIT. Half-fixed
X lines that do not fit on screen. A few minor bug fixes. Fixed
X typehead bug in Read() in unix.c. Added :number. Reset IXON flag
X in unix.c for CTRL-Q. In tags file any Ex command can be used. Ex
X search command accepts same flags as normal search command. Fixed
X '?' in tag search pattern. 'New file' message was wrong when 'bk'
X and 'wb' options were both off.
X*/
X
Xchar *Version = "VIM 1.27";
X#if !defined(linux) && defined(BSD) || defined(SYSV)
Xchar *longVersion = "Vi IMitation 1.27 (1993 April 6) by Bram Moolenaar";
X#else
Xchar *longVersion = "Vi IMitation 1.27 (" __DATE__ " " __TIME__ ") by Bram Moolenaar";
X#endif
END_OF_FILE
if test 14258 -ne `wc -c <'vim/src/version.c'`; then
echo shar: \"'vim/src/version.c'\" unpacked with wrong size!
fi
# end of 'vim/src/version.c'
fi
echo shar: End of archive 7 \(of 23\).
cp /dev/null ark7isdone

Bram Moolenaar

unread,
Apr 23, 1993, 1:31:36 PM4/23/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 8
Archive-name: vim/part08
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 8 (of 23)."
# Contents: vim/src/edit.c vim/src/param.c vim/src/unix.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:09 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/edit.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/edit.c'\"
else
echo shar: Extracting \"'vim/src/edit.c'\" \(16324 characters\)
sed "s/^X//" >'vim/src/edit.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * edit.c: functions for insert mode
X */
X
X#include "vim.h"


X#include "globals.h"
X#include "proto.h"
X#include "param.h"

X#include "ops.h" /* for operator */
X
Xextern u_char *get_inserted();
Xstatic void start_arrow __ARGS((void));
Xstatic void stop_arrow __ARGS((void));
Xstatic void stop_insert __ARGS((void));
X
Xint arrow_used; /* Normally FALSE, set to TRUE after hitting
X * cursor key in insert mode. Used by vgetorpeek()
X * to decide when to call u_sync() */
Xint restart_edit; /* call edit when next command finished */
Xstatic u_char *last_insert = NULL;
X /* the text of the previous insert */
Xstatic int last_insert_skip;
X /* number of chars in front of the previous insert */
Xstatic int new_insert_skip;
X /* number of chars in front of the current insert */
X
X void
Xedit(count)
X long count;
X{
X u_char c;
X u_char cc;
X u_char *ptr;
X linenr_t lnum;
X int temp = 0, mode;
X int nextc = 0;
X
X#ifdef DIGRAPHS
X int inserted = 0; /* last 'normal' inserted char */
X int backspaced = 0; /* last backspace char */


X#endif /* DIGRAPHS */
X

X if (restart_edit)
X {
X arrow_used = TRUE;
X restart_edit = FALSE;
X }
X else
X arrow_used = FALSE;
X
X/*
X * Get the current length of the redo buffer, those characters have to be
X * skipped if we want to get to the inserted characters.
X */
X
X ptr = get_inserted();
X new_insert_skip = strlen((char *)ptr);
X free(ptr);
X


X for (;;)
X {

X if (arrow_used) /* don't repeat insert when arrow key used */
X count = 0;
X
X set_want_col = TRUE; /* set Curswant in case of K_DARROW or K_UARROW */


X cursupdate(); /* Figure out where the cursor is based on Curpos. */

X setcursor();
X if (nextc) /* character remaining from CTRL-V */
X {
X c = nextc;
X nextc = 0;
X }
X else
X c = vgetc();
X
X#ifdef DIGRAPHS
X if (p_dg)
X {
X if (backspaced)
X c = getdigraph(backspaced, c);
X backspaced = 0;
X if (c == BS && inserted)
X backspaced = inserted;
X else
X inserted = c;
X }
X#endif /* DIGRAPHS */
X
X if (c == Ctrl('V'))
X {
X outchar('^');
X AppendToRedobuff("\026"); /* CTRL-V */


X cursupdate();
X setcursor();
X

X c = get_literal(&nextc);
X
X /* erase the '^' */
X if ((cc = gcharCurpos()) == NUL)
X outchar(' ');
X else
X outstrn(transchar(cc));
X
X insertchar(c);
X continue;
X }
X switch (c) /* handle character in insert mode */
X {
X case Ctrl('O'): /* execute one command */
X count = 0;
X restart_edit = TRUE;
X /*FALLTHROUGH*/
X
X case ESC: /* an escape ends input mode */
X doESCkey:
X if (!arrow_used)
X {
X AppendToRedobuff(ESC_STR);
X
X if (--count > 0) /* repeat what was typed */
X {
X start_redo_ins();
X continue;
X }
X stop_insert();


X }
X set_want_col = TRUE;

X
X /*
X * The cursor should end up on the last inserted character.
X */
X if (Curpos.col != 0 && (!restart_edit || gcharCurpos() == NUL))
X decCurpos();
X State = NORMAL;
X script_winsize_pp(); /* may need to put :winsize in script */
X /* inchar() may have deleted the "INSERT" message */
X if (Recording)
X showmode();
X else if (p_mo)
X msg("");
X return;
X
X /*
X * Insert the previously inserted text.
X * Last_insert actually is a copy of the redo buffer, so we
X * first have to remove the command.
X * For ^@ the trailing ESC will end the insert.
X */
X case K_ZERO:
X case Ctrl('A'):
X stuff_inserted(NUL, 1L, (c == Ctrl('A')));


X break;
X
X /*

X * insert the contents of a register
X */
X case Ctrl('B'):
X if (!insertbuf(vgetc()))
X beep();


X break;
X
X /*

X * If the cursor is on an indent, ^T/^D insert/delete one
X * shiftwidth. Otherwise ^T/^D behave like a TAB/backspace.
X * This isn't completely compatible with
X * vi, but the difference isn't very noticeable and now you can
X * mix ^D/backspace and ^T/TAB without thinking about which one
X * must be used.
X */
X case Ctrl('T'): /* make indent one shiftwidth greater */
X case Ctrl('D'): /* make indent one shiftwidth smaller */
X stop_arrow();
X AppendToRedobuff(mkstr(c));
X
X /* determine offset from first non-blank */
X temp = Curpos.col;
X beginline(TRUE);
X temp -= Curpos.col;
X
X shift_line(c == Ctrl('D'));
X
X /* try to put cursor on same character */
X temp += Curpos.col;
X if (temp <= 0)
X Curpos.col = 0;
X else
X Curpos.col = temp;
X did_ai = FALSE;
X did_si = FALSE;
X can_si = FALSE;
X goto redraw;
X
X case BS:
X case DEL:
Xnextbs:
X mode = 0;
Xdodel:
X /* can't backup past first character in buffer */
X /* can't backup past starting point unless "backspace" > 1 */
X /* can backup to a previous line if "backspace" == 0 */
X if ((Curpos.lnum == 1 && Curpos.col <= 0) ||
X (p_bs < 2 && (arrow_used ||
X (Curpos.lnum == Insstart.lnum &&
X Curpos.col <= Insstart.col) ||
X (Curpos.col <= 0 && p_bs == 0))))
X {
X beep();
X goto redraw;
X }
X
X stop_arrow();
X if (Curpos.col <= 0) /* delete newline! */
X {
X if (Curpos.lnum == Insstart.lnum)
X {
X if (!u_save((linenr_t)(Curpos.lnum - 2), (linenr_t)(Curpos.lnum + 1)))
X goto redraw;
X --Insstart.lnum;
X Insstart.col = 0;
X }
X /* in replace mode with 'repdel' off we only move the cursor */
X if (State != REPLACE || p_rd)
X {
X temp = gcharCurpos(); /* remember current char */
X --Curpos.lnum;
X dojoin(FALSE);
X if (temp == NUL && gcharCurpos() != NUL)
X ++Curpos.col;
X }
X else
X decCurpos();
X did_ai = FALSE;
X }
X else
X {
X /* delete upto starting point, start of line or previous word */
X do
X {
X decCurpos();
X /* start of word? */
X if (mode == 1 && !isspace(gcharCurpos()))
X {
X mode = 2;
X temp = isidchar(gcharCurpos());
X }
X /* end of word? */
X if (mode == 2 && isidchar(gcharCurpos()) != temp)
X {
X incCurpos();
X break;
X }
X if (State != REPLACE || p_rd)
X delchar(TRUE);
X if (mode == 0) /* just a single backspace */
X break;
X } while (Curpos.col > 0 && (Curpos.lnum != Insstart.lnum ||
X Curpos.col != Insstart.col));
X }
X did_si = FALSE;
X can_si = FALSE;
X if (Curpos.col <= 1)
X did_ai = FALSE;
X /*
X * It's a little strange to put backspaces into the redo
X * buffer, but it makes auto-indent a lot easier to deal
X * with.
X */
X AppendToRedobuff(mkstr(c));
X if (vpeekc() == BS)
X {
X c = vgetc();
X goto nextbs; /* speedup multiple backspaces */
X }
Xredraw:
X cursupdate();
X updateline();
X break;
X
X case Ctrl('W'):
X /* delete word before cursor */
X mode = 1;
X goto dodel;
X
X case Ctrl('U'):
X mode = 3;
X goto dodel;
X
X case K_LARROW:
X if (oneleft())
X start_arrow();
X else
X beep();
X break;
X
X case K_SLARROW:


X if (Curpos.lnum > 1 || Curpos.col > 0)
X {

X bck_word(1L, 0);
X start_arrow();
X }
X else
X beep();
X break;
X
X case K_RARROW:
X if (gcharCurpos() != NUL)


X {
X set_want_col = TRUE;

X start_arrow();
X ++Curpos.col;
X }
X else
X beep();
X break;
X
X case K_SRARROW:
X if (Curpos.lnum < line_count || gcharCurpos() != NUL)
X {
X fwd_word(1L, 0);
X start_arrow();
X }
X else
X beep();
X break;
X
X case K_UARROW:
X if (oneup(1L))
X start_arrow();
X else
X beep();
X break;
X
X case K_SUARROW:
X if (onepage(BACKWARD, 1L))
X start_arrow();
X else
X beep();
X break;
X
X case K_DARROW:
X if (onedown(1L))
X start_arrow();
X else
X beep();
X break;
X
X case K_SDARROW:
X if (onepage(FORWARD, 1L))
X start_arrow();
X else
X beep();
X break;
X
X case TAB:
X if (!p_et)
X goto normalchar;
X /* expand a tab into spaces */
X stop_arrow();
X did_ai = FALSE;
X did_si = FALSE;
X can_si = FALSE;
X insstr(" " + 16 - (p_ts - Curpos.col % p_ts));
X AppendToRedobuff("\t");
X goto redraw;
X
X case CR:
X case NL:
X stop_arrow();
X if (State == REPLACE) /* DMT added, 12/89 */
X delchar(FALSE);
X AppendToRedobuff(NL_STR);
X if (!Opencmd(FORWARD, TRUE))
X goto doESCkey; /* out of memory */
X break;
X
X#ifdef DIGRAPHS
X case Ctrl('K'):
X outchar('?');
X AppendToRedobuff("\026"); /* CTRL-V */
X setcursor();
X c = vgetc();
X outstrn(transchar(c));
X setcursor();
X c = getdigraph(c, vgetc());
X goto normalchar;
X#endif /* DIGRAPHS */
X
X case Ctrl('R'):
X /*
X * addition by mool: copy from previous line
X */
X lnum = Curpos.lnum - 1;
X goto copychar;
X
X case Ctrl('E'):
X lnum = Curpos.lnum + 1;
Xcopychar:


X if (lnum < 1 || lnum > line_count)

X {
X beep();
X break;
X }
X
X /* try to advance to the cursor column */
X temp = 0;
X ptr = (u_char *)nr2ptr(lnum);
X while (temp < Cursvcol && *ptr)
X temp += chartabsize(*ptr++, temp);
X
X if (temp > Cursvcol)
X --ptr;
X if ((c = *ptr) == NUL)
X {
X beep();
X break;
X }
X
X /*FALLTHROUGH*/
X default:
Xnormalchar:
X if (Curpos.col > 0 && ((can_si && c == '}') || (did_si && c == '{')))
X shift_line(TRUE);
X insertchar(c);


X break;
X }
X }
X}

X
X/*
X * Next character is interpreted literally.
X * A one, two or three digit decimal number is interpreted as its byte value.
X * If one or two digits are entered, *nextc is set to the next character.
X */
X int
Xget_literal(nextc)
X int *nextc;
X{
X u_char cc;
X u_char nc;
X int oldstate;
X int i;
X
X oldstate = State;
X State = NOMAPPING; /* next characters not mapped */
X
X cc = 0;
X for (i = 0; i < 3; ++i)
X {
X nc = vgetc();
X if (!isdigit(nc))
X break;
X cc = cc * 10 + nc - '0';
X nc = 0;
X }
X if (i == 0) /* no number entered */
X {
X cc = nc;
X nc = 0;
X }
X else if (cc == 0) /* NUL is stored as NL */
X cc = '\n';


X
X State = oldstate;

X *nextc = nc;
X return cc;
X}
X
X/*
X * Special characters in this context are those that need processing other
X * than the simple insertion that can be performed here. This includes ESC
X * which terminates the insert, and CR/NL which need special processing to
X * open up a new line. This routine tries to optimize insertions performed by
X * the "redo", "undo" or "put" commands, so it needs to know when it should
X * stop and defer processing to the "normal" mechanism.
X */
X#define ISSPECIAL(c) ((c) < ' ' || (c) >= DEL)
X
X void
Xinsertchar(c)
X unsigned c;
X{
X int must_redraw = FALSE;
X
X stop_arrow();
X /*
X * If the cursor is past 'textwidth' and we are inserting a non-space,
X * try to break the line in two or more pieces. If c == NUL then we have
X * been called to do formatting only.
X */
X if (c == NUL || !isspace(c))
X {
X while (Cursvcol >= p_tw)
X {
X int startcol; /* Cursor column at entry */
X int wantcol; /* column at textwidth border */
X int foundcol; /* column for start of word */
X int mincol; /* minimum column for break */
X
X if ((startcol = Curpos.col) == 0)
X break;
X coladvance((int)p_tw); /* find column of textwidth border */
X wantcol = Curpos.col;
X beginline((int)p_ai); /* find start of text */
X mincol = Curpos.col;
X
X Curpos.col = startcol - 1;
X foundcol = 0;
X while (Curpos.col > mincol) /* find position to break at */
X {
X if (isspace(gcharCurpos()))
X {
X foundcol = Curpos.col + 1;
X while (Curpos.col > 1 && isspace(gcharCurpos()))
X --Curpos.col;
X if (Curpos.col < wantcol)
X break;
X }
X --Curpos.col;
X }
X
X if (foundcol == 0) /* no spaces, cannot break line */
X {
X Curpos.col = startcol;
X break;
X }
X Curpos.col = foundcol;
X startcol -= Curpos.col;
X Opencmd(FORWARD, FALSE);
X Curpos.col += startcol;
X curs_columns(); /* update Cursvcol */
X must_redraw = TRUE;
X }
X if (c == NUL) /* formatting only */
X return;
X if (must_redraw)
X updateScreen(CURSUPD);
X }
X
X did_ai = FALSE;
X did_si = FALSE;
X can_si = FALSE;
X
X /*
X * If there's any pending input, grab up to MAX_COLUMNS at once.
X * This speeds up normal text input considerably.
X */
X if (vpeekc() != NUL && State != REPLACE)
X {
X char p[MAX_COLUMNS + 1];
X int i;
X
X p[0] = c;
X i = 1;
X while ((c = vpeekc()) != NUL && !ISSPECIAL(c) && i < MAX_COLUMNS &&
X (Cursvcol += charsize(p[i - 1])) < p_tw)
X p[i++] = vgetc();
X p[i] = '\0';
X insstr(p);
X AppendToRedobuff(p);
X }
X else
X {
X inschar(c);
X AppendToRedobuff(mkstr(c));
X }
X
X updateline();
X}
X
X
X/*
X * start_arrow() is called when an arrow key is used in insert mode.
X * It resembles hitting the <ESC> key.


X */
X static void

Xstart_arrow()
X{
X if (!arrow_used) /* something has been inserted */
X {
X AppendToRedobuff(ESC_STR);
X arrow_used = TRUE; /* this means we stopped the current insert */
X stop_insert();
X }
X}
X
X/*
X * stop_arrow() is called before a change is made in insert mode.
X * If an arrow key has been used, start a new insertion.


X */
X static void

Xstop_arrow()
X{
X if (arrow_used)
X {
X u_saveCurpos(); /* errors are ignored! */
X Insstart = Curpos; /* new insertion starts here */
X ResetBuffers();
X AppendToRedobuff("1i"); /* pretend we start an insertion */
X arrow_used = FALSE;
X }
X}
X
X/*
X * do a few things to stop inserting


X */
X static void

Xstop_insert()
X{
X stop_redo_ins();
X
X /*
X * save the inserted text for later redo with ^@
X */
X free(last_insert);
X last_insert = get_inserted();
X last_insert_skip = new_insert_skip;
X
X /*
X * If we just did an auto-indent, truncate the line, and put
X * the cursor back.
X */
X if (did_ai && !arrow_used)
X {
X *nr2ptr(Curpos.lnum) = NUL;
X canincrease(0);


X Curpos.col = 0;
X }

X did_ai = FALSE;
X did_si = FALSE;
X can_si = FALSE;
X}
X
X/*
X * oneright oneleft onedown oneup
X *
X * Move one char {right,left,down,up}. Return TRUE when sucessful, FALSE when
X * we hit a boundary (of a line, or the file).


X */
X
X int

Xoneright()


X{
X char *ptr;
X

X ptr = pos2ptr(&Curpos);
X set_want_col = TRUE;
X
X if (*ptr++ == NUL || *ptr == NUL)
X return FALSE;
X ++Curpos.col;


X return TRUE;
X}
X

X int
Xoneleft()
X{
X set_want_col = TRUE;
X
X if (Curpos.col == 0)
X return FALSE;
X --Curpos.col;


X return TRUE;
X}
X
X void

Xbeginline(flag)
X int flag;


X{
X Curpos.col = 0;

X if (flag)


X {
X register char *ptr;
X

X for (ptr = nr2ptr(Curpos.lnum); isspace(*ptr); ++ptr)
X ++Curpos.col;
X }
X set_want_col = TRUE;
X}
X
X int
Xoneup(n)
X long n;
X{
X if (n != 0 && Curpos.lnum == 1)
X return FALSE;
X if (n >= Curpos.lnum)
X Curpos.lnum = 1;
X else
X Curpos.lnum -= n;
X
X if (operator == NOP)
X cursupdate(); /* make sure Topline is valid */
X
X /* try to advance to the column we want to be at */
X coladvance(Curswant);


X return TRUE;
X}
X

X int
Xonedown(n)
X long n;
X{
X if (n != 0 && Curpos.lnum == line_count)
X return FALSE;
X Curpos.lnum += n;
X if (Curpos.lnum > line_count)


X Curpos.lnum = line_count;
X

X if (operator == NOP)
X cursupdate(); /* make sure Topline is valid */
X
X /* try to advance to the column we want to be at */
X coladvance(Curswant);


X return TRUE;
X}
X

X int
Xonepage(dir, count)
X int dir;
X long count;
X{
X linenr_t lp;
X long n;
X
X if (line_count == 1) /* nothing to do */
X return FALSE;
X for ( ; count > 0; --count)
X {
X if (dir == FORWARD ? (Topline >= line_count - 1) : (Topline == 1))
X {
X beep();
X return FALSE;
X }
X lp = Topline;
X n = 0;


X if (dir == BACKWARD)

X {
X if (lp < line_count)
X ++lp;
X Curpos.lnum = lp;
X }
X while (n < Rows - 1 && lp >= 1 && lp <= line_count)
X {
X n += plines(lp);
X lp += dir;


X }
X if (dir == FORWARD)
X {

X if (--lp > 1)
X --lp;
X Topline = Curpos.lnum = lp;
X }
X else
X Topline = lp + 1;
X }
X beginline(TRUE);
X updateScreen(VALID);


X return TRUE;
X}
X
X void

Xstuff_inserted(c, count, no_esc)
X int c;
X long count;
X int no_esc;
X{
X u_char *esc_ptr = NULL;
X u_char *ptr;
X
X if (last_insert == NULL)


X {
X beep();
X return;
X }

X if (c)
X stuffReadbuff(mkstr(c));
X if (no_esc && (esc_ptr = (u_char *)strrchr((char *)last_insert, 27)) != NULL)
X *esc_ptr = NUL; /* remove the ESC */
X
X /* skip the command */
X ptr = last_insert + last_insert_skip;
X
X do
X stuffReadbuff((char *)ptr);
X while (--count > 0);
X
X if (no_esc && esc_ptr)
X *esc_ptr = 27; /* put the ESC back */
X}
END_OF_FILE
if test 16324 -ne `wc -c <'vim/src/edit.c'`; then
echo shar: \"'vim/src/edit.c'\" unpacked with wrong size!
fi
# end of 'vim/src/edit.c'
fi
if test -f 'vim/src/param.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/param.c'\"
else
echo shar: Extracting \"'vim/src/param.c'\" \(16498 characters\)
sed "s/^X//" >'vim/src/param.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * Code to handle user-settable parameters. This is all pretty much table-
X * driven. To add a new parameter, put it in the params array, and add a
X * variable for it in param.h. If it's a numeric parameter, add any necessary
X * bounds checks to doset().
X */
X
X#include "vim.h"


X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X

Xstruct param
X{
X char *fullname; /* full parameter name */
X char *shortname; /* permissible abbreviation */
X int flags; /* see below */
X char *var; /* pointer to variable */
X};
X
X/*
X * Flags
X */
X#define P_BOOL 0x01 /* the parameter is boolean */
X#define P_NUM 0x02 /* the parameter is numeric */
X#define P_STRING 0x04 /* the parameter is a string */
X#define P_CHANGED 0x08 /* the parameter has been changed */
X
X/*
X * The param structure is initialized here.
X * The order of the parameters should be alfabetic
X */
Xstruct param params[] =
X{
X {"autoindent", "ai", P_BOOL, (char *)&p_ai},
X/* {"autoprint", "ap", P_BOOL, (char *)&p_ap}, */
X {"autowrite", "aw", P_BOOL, (char *)&p_aw},
X {"backspace", "bs", P_NUM, (char *)&p_bs},
X {"backup", "bk", P_BOOL, (char *)&p_bk},
X#ifdef UNIX
X {"backupdir", "bdir", P_STRING, (char *)&p_bdir},
X#endif
X/* {"beautify", "bf", P_BOOL, (char *)&p_bf}, */
X {"columns", "co", P_NUM, (char *)&Columns},
X {"compatible", "cp", P_BOOL, (char *)&p_cp},
X#ifdef DIGRAPHS
X {"digraph", "dg", P_BOOL, (char *)&p_dg},
X#endif /* DIGRAPHS */
X {"directory", "dir", P_STRING, (char *)&p_dir},
X {"equalprg", "ep", P_STRING, (char *)&p_ep},
X {"errorbells", "eb", P_BOOL, (char *)&p_eb},
X {"errorfile", "ef", P_STRING, (char *)&p_ef},
X {"expandtab", "et", P_BOOL, (char *)&p_et},
X {"graphic", "gr", P_BOOL, (char *)&p_gr},
X/* {"hardtabs", "ht", P_NUM, (char *)&p_ht}, */
X {"helpfile", "hf", P_STRING, (char *)&p_hf},
X {"history", "hi", P_NUM, (char *)&p_hi},
X {"ignorecase", "ic", P_BOOL, (char *)&p_ic},
X {"insertmode", "im", P_BOOL, (char *)&p_im},
X {"joinspaces", "js", P_BOOL, (char *)&p_js},
X {"keywordprg", "kp", P_STRING, (char *)&p_kp},
X {"lines", NULL, P_NUM, (char *)&Rows},
X/* {"lisp", NULL, P_BOOL (char *)&p_lisp}, */
X {"list", NULL, P_BOOL, (char *)&p_list},
X {"magic", NULL, P_BOOL, (char *)&p_magic},
X {"modelines", "ml", P_NUM, (char *)&p_ml},
X {"number", "nu", P_BOOL, (char *)&p_nu},
X/* {"open", NULL, P_BOOL, (char *)&p_open}, */
X/* {"optimize", "opt", P_BOOL, (char *)&p_opt}, */
X {"paragraphs", "para", P_STRING, (char *)&p_para},
X/* {"prompt", NULL, P_BOOL, (char *)&p_prompt}, */
X {"readonly", "ro", P_BOOL, (char *)&p_ro},
X/* {"redraw", NULL, P_BOOL, (char *)&p_redraw}, */
X {"remap", NULL, P_BOOL, (char *)&p_remap},
X {"repdel", "rd", P_BOOL, (char *)&p_rd},
X {"report", NULL, P_NUM, (char *)&p_report},
X {"ruler", "ru", P_BOOL, (char *)&p_ru},
X {"scroll", NULL, P_NUM, (char *)&p_scroll},
X {"scrolljump", "sj", P_NUM, (char *)&p_sj},
X {"sections", NULL, P_STRING, (char *)&p_sections},
X {"shell", "sh", P_STRING, (char *)&p_sh},
X {"shelltype", "st", P_NUM, (char *)&p_st},
X {"shiftround", "sr", P_BOOL, (char *)&p_sr},
X {"shiftwidth", "sw", P_NUM, (char *)&p_sw},
X#ifndef MSDOS
X {"shortname", "sn", P_BOOL, (char *)&p_sn},
X#endif
X {"showcmd", "sc", P_BOOL, (char *)&p_sc},
X {"showmatch", "sm", P_BOOL, (char *)&p_sm},
X {"showmode", "mo", P_BOOL, (char *)&p_mo},
X/* {"slowopen", "slow", P_BOOL, (char *)&p_slow}, */
X {"smartindent", "si", P_BOOL, (char *)&p_si},
X {"suffixes", "su", P_STRING, (char *)&p_su},
X {"tabstop", "ts", P_NUM, (char *)&p_ts},
X {"taglength", "tl", P_NUM, (char *)&p_tl},
X {"tags", NULL, P_STRING, (char *)&p_tags},
X {"term", NULL, P_STRING, (char *)&term_strings.t_name},
X {"terse", NULL, P_BOOL, (char *)&p_terse},
X#ifdef MSDOS
X {"textmode", "tx", P_BOOL, (char *)&p_tx},
X#endif
X {"textwidth", "tw", P_NUM, (char *)&p_tw},
X {"tildeop", "to", P_BOOL, (char *)&p_to},
X {"timeout", NULL, P_BOOL, (char *)&p_timeout},
X {"ttimeout", NULL, P_BOOL, (char *)&p_ttimeout},
X {"undolevels", "ul", P_NUM, (char *)&p_ul},
X {"updatecount", "uc", P_NUM, (char *)&p_uc},
X {"updatetime", "ut", P_NUM, (char *)&p_ut},
X {"visualbell", "vb", P_BOOL, (char *)&p_vb},
X {"warn", NULL, P_BOOL, (char *)&p_warn},
X/* {"window", NULL, P_NUM, (char *)&p_window}, */
X/* {"w300", NULL, P_NUM, (char *)&p_w300}, */
X/* {"w1200", NULL, P_NUM, (char *)&p_w1200}, */
X/* {"w9600", NULL, P_NUM, (char *)&p_w9600}, */
X {"wrapscan", "ws", P_BOOL, (char *)&p_ws},
X {"wrapmargin", "wm", P_NUM, (char *)&p_wm},
X {"writeany", "wa", P_BOOL, (char *)&p_wa},
X {"writebackup", "wb", P_BOOL, (char *)&p_wb},
X {"yankendofline", "ye", P_BOOL, (char *)&p_ye},
X
X/* terminal output codes */
X {"t_el", NULL, P_STRING, (char *)&term_strings.t_el},
X {"t_il", NULL, P_STRING, (char *)&term_strings.t_il},
X {"t_cil", NULL, P_STRING, (char *)&term_strings.t_cil},
X {"t_dl", NULL, P_STRING, (char *)&term_strings.t_dl},
X {"t_cdl", NULL, P_STRING, (char *)&term_strings.t_cdl},
X {"t_ed", NULL, P_STRING, (char *)&term_strings.t_ed},
X {"t_ci", NULL, P_STRING, (char *)&term_strings.t_ci},
X {"t_cv", NULL, P_STRING, (char *)&term_strings.t_cv},
X {"t_tp", NULL, P_STRING, (char *)&term_strings.t_tp},
X {"t_ti", NULL, P_STRING, (char *)&term_strings.t_ti},
X {"t_cm", NULL, P_STRING, (char *)&term_strings.t_cm},
X {"t_sr", NULL, P_STRING, (char *)&term_strings.t_sr},
X {"t_cri", NULL, P_STRING, (char *)&term_strings.t_cri},
X {"t_vb", NULL, P_STRING, (char *)&term_strings.t_vb},
X {"t_ks", NULL, P_STRING, (char *)&term_strings.t_ks},
X {"t_ke", NULL, P_STRING, (char *)&term_strings.t_ke},
X {"t_ts", NULL, P_STRING, (char *)&term_strings.t_ts},
X {"t_te", NULL, P_STRING, (char *)&term_strings.t_te},
X
X/* terminal key codes */
X {"t_ku", NULL, P_STRING, (char *)&term_strings.t_ku},
X {"t_kd", NULL, P_STRING, (char *)&term_strings.t_kd},
X {"t_kr", NULL, P_STRING, (char *)&term_strings.t_kr},
X {"t_kl", NULL, P_STRING, (char *)&term_strings.t_kl},
X {"t_sku", NULL, P_STRING, (char *)&term_strings.t_sku},
X {"t_skd", NULL, P_STRING, (char *)&term_strings.t_skd},
X {"t_skr", NULL, P_STRING, (char *)&term_strings.t_skr},
X {"t_skl", NULL, P_STRING, (char *)&term_strings.t_skl},
X {"t_f1", NULL, P_STRING, (char *)&term_strings.t_f1},
X {"t_f2", NULL, P_STRING, (char *)&term_strings.t_f2},
X {"t_f3", NULL, P_STRING, (char *)&term_strings.t_f3},
X {"t_f4", NULL, P_STRING, (char *)&term_strings.t_f4},
X {"t_f5", NULL, P_STRING, (char *)&term_strings.t_f5},
X {"t_f6", NULL, P_STRING, (char *)&term_strings.t_f6},
X {"t_f7", NULL, P_STRING, (char *)&term_strings.t_f7},
X {"t_f8", NULL, P_STRING, (char *)&term_strings.t_f8},
X {"t_f9", NULL, P_STRING, (char *)&term_strings.t_f9},
X {"t_f10", NULL, P_STRING, (char *)&term_strings.t_f10},
X {"t_sf1", NULL, P_STRING, (char *)&term_strings.t_sf1},
X {"t_sf2", NULL, P_STRING, (char *)&term_strings.t_sf2},
X {"t_sf3", NULL, P_STRING, (char *)&term_strings.t_sf3},
X {"t_sf4", NULL, P_STRING, (char *)&term_strings.t_sf4},
X {"t_sf5", NULL, P_STRING, (char *)&term_strings.t_sf5},
X {"t_sf6", NULL, P_STRING, (char *)&term_strings.t_sf6},
X {"t_sf7", NULL, P_STRING, (char *)&term_strings.t_sf7},
X {"t_sf8", NULL, P_STRING, (char *)&term_strings.t_sf8},
X {"t_sf9", NULL, P_STRING, (char *)&term_strings.t_sf9},
X {"t_sf10", NULL, P_STRING, (char *)&term_strings.t_sf10},
X {"t_help", NULL, P_STRING, (char *)&term_strings.t_help},
X {"t_undo", NULL, P_STRING, (char *)&term_strings.t_undo},
X {NULL, NULL, 0, NULL} /* end marker */
X};
X
Xstatic void showparams __ARGS((int));
Xstatic void showonep __ARGS((struct param *));
Xstatic int istermparam __ARGS((struct param *));
X
X/*
X * Initialize the shell parameter and scroll size.
X */
X void
Xset_init()


X{
X char *p;
X

X if ((p = (char *)vimgetenv("SHELL")) != NULL)
X p_sh = strsave(p);
X p_scroll = (Rows >> 1);
X}
X
X void
Xdoset(arg)
X char *arg; /* parameter string */


X{
X register int i;

X char *s;
X char *errmsg;
X char *startarg;
X int prefix; /* 0: nothing, 1: "no", 2: "inv" in front of name */
X int nextchar;


X int len = 0;

X int flags;
X int olduc = p_uc; /* remember old update count */
X
X if (*arg == NUL)
X {
X showparams(0);
X return;
X }
X
X while (*arg) /* loop to process all parameters */
X {
X errmsg = NULL;
X startarg = arg; /* remember for error message */
X if (strncmp(arg, "all", (size_t)3) == 0)
X showparams(1);
X else if (strncmp(arg, "termcap", (size_t)7) == 0)
X showparams(2);
X else
X {
X prefix = 1;
X if (strncmp(arg, "no", (size_t)2) == 0)
X {
X prefix = 0;
X arg += 2;
X }
X else if (strncmp(arg, "inv", (size_t)3) == 0)
X {
X prefix = 2;
X arg += 3;
X }
X for (i = 0; (s = params[i].fullname) != NULL; i++)
X {
X if (strncmp(arg, s, (size_t)(len = strlen(s))) == 0) /* match full name */
X break;
X }
X if (s == NULL)
X {
X for (i = 0; params[i].fullname != NULL; i++)
X {
X s = params[i].shortname;
X if (s != NULL && strncmp(arg, s, (size_t)(len = strlen(s))) == 0) /* match short name */
X break;
X s = NULL;
X }
X }
X
X if (s == NULL) /* found a mismatch: skip the rest */
X {
X errmsg = "Unknown option: "; /* must be 18 chars */


X goto skip;
X }
X

X flags = params[i].flags;
X nextchar = arg[len];
X /*
X * allow '=' and ':' as MSDOS command.com allows only one
X * '=' character per "set" command line. grrr. (jw)
X */
X if (nextchar == '?' ||
X (prefix == 1 && nextchar != '=' &&
X nextchar != ':' && !(flags & P_BOOL)))
X { /* print value */
X gotocmdline(TRUE, NUL);
X showonep(&params[i]);
X }
X else if (nextchar != NUL && strchr("=: \t", nextchar) == NULL)
X {
X errmsg = e_setarg;
X goto skip;
X }
X else if (flags & P_BOOL) /* boolean */
X {
X if (nextchar == '=' || nextchar == ':')
X {
X errmsg = e_setarg;
X goto skip;
X }
X if (prefix == 2)
X *(int *)(params[i].var) ^= 1; /* invert it */
X else
X *(int *)(params[i].var) = prefix;
X if ((int *)params[i].var == &p_cp && p_cp) /* handle cp here */
X {
X p_bs = 0; /* normal backspace */
X p_bk = 0; /* no backup file */
X#ifdef DIGRAPHS
X p_dg = 0; /* no digraphs */
X#endif /* DIGRAPHS */
X p_et = 0; /* no expansion of tabs */
X p_hi = 0; /* no history */
X p_im = 0; /* do not start in insert mode */
X p_js = 1; /* insert 2 spaces after period */
X p_ml = 0; /* no modelines */
X p_rd = 1; /* del replaces char */
X p_ru = 0; /* no ruler */
X p_sj = 1; /* no scrolljump */
X p_sr = 0; /* do not round indent to shiftwidth */
X p_sc = 0; /* no showcommand */
X p_mo = 0; /* no showmode */
X p_si = 0; /* no smartindent */
X p_tw = 9999; /* maximum textwidth */
X p_to = 0; /* no tilde operator */
X p_ttimeout = 0; /* no terminal timeout */
X p_ul = 0; /* no multilevel undo */
X p_uc = 0; /* no autoscript file */
X p_wb = 0; /* no backup file */
X p_ye = 0; /* no yank to end of line */
X }
X }
X else /* numeric or string */
X {
X if ((nextchar != '=' && nextchar != ':') || prefix != 1)
X {
X errmsg = e_setarg;
X goto skip;
X }
X if (flags & P_NUM) /* numeric */
X {
X len = atoi(arg + len + 1);
X if ((long *)params[i].var == &p_wm) /* wrapmargin is translated into textlength */
X {
X if (len >= Columns)
X len = Columns - 1;
X p_tw = Columns - len;
X }
X *(long *)(params[i].var) = len;
X }
X else /* string */
X {
X arg += len + 1;
X s = alloc((unsigned)(strlen(arg) + 1)); /* get a bit too much */
X if (s == NULL)
X break;
X if (flags & P_CHANGED)
X free(*(char **)(params[i].var));
X *(char **)(params[i].var) = s;
X /* copy the string */
X while (*arg && *arg != ' ' && *arg != '\t')
X {
X if (*arg == '\\' && *(arg + 1)) /* skip over escaped chars */
X ++arg;
X *s++ = *arg++;
X }
X *s = NUL;
X /*
X * options that need some action
X * to perform when changed (jw)
X */
X if (params[i].var == (char *)&term_strings.t_name)
X set_term(term_strings.t_name);
X else if (istermparam(&params[i]))
X ttest(FALSE);
X }
X }
X params[i].flags |= P_CHANGED;
X }
X
Xskip:
X if (errmsg)
X {
X strcpy(IObuff, errmsg);
X s = IObuff + 18;
X while (*startarg && !isspace(*startarg))
X *s++ = *startarg++;
X *s = NUL;
X emsg(IObuff);
X arg = startarg; /* skip to next argument */
X }
X
X skiptospace(&arg); /* skip to next white space */
X skipspace(&arg); /* skip spaces */
X }
X
X /*
X * Check the bounds for numeric parameters here
X */
X if (Rows < 2)
X {
X Rows = 2;
X emsg("Need at least 2 lines");
X }
X if (p_ts <= 0 || p_ts > 16)
X {
X emsg(e_tabsize);
X p_ts = 8;
X }
X if (p_scroll <= 0 || p_scroll > Rows)
X {
X emsg(e_scroll);
X p_scroll = Rows >> 1;
X }
X if (p_report < 0)
X {
X emsg(e_positive);
X p_report = 1;
X }
X if (p_sj < 0 || p_sj >= Rows)
X {
X emsg(e_scroll);
X p_sj = 1;
X }
X if (p_ul < 0)
X {
X emsg(e_positive);
X p_ul = 100;
X }
X if (p_uc < 0)
X {
X emsg(e_positive);
X p_uc = 100;
X }
X if (p_uc == 0 && olduc != 0) /* p_uc changed from on to off */
X stopscript();
X if (p_uc > 0 && olduc == 0) /* p_uc changed from off to on */
X startscript();
X#ifdef MSDOS
X textfile(p_tx);
X#endif
X if (p_ut < 0)
X {
X emsg(e_positive);
X p_ut = 2000;
X }
X
X /*
X * Update the screen in case we changed something like "tabstop" or
X * "lines" or "list" that will change its appearance.
X */
X updateScreen(NOT_VALID);
X}
X
X/*
X * if 'all' == 0: show changed parameters
X * if 'all' == 1: show all normal parameters
X * if 'all' == 2: show all terminal parameters


X */
X static void

Xshowparams(all)
X int all;
X{
X struct param *p;
X int col = 0;
X int inc;
X int isterm;
X
X gotocmdline(TRUE, NUL);
X outstrn("Parameters:\n");
X
X#ifdef AMIGA
X settmode(0); /* set cooked mode so output can be halted */
X#endif
X for (p = &params[0]; p->fullname != NULL; p++)
X {
X isterm = istermparam(p);
X if ((all == 2 && isterm) ||
X (all == 1 && !isterm) ||
X (all == 0 && (p->flags & P_CHANGED)))
X {
X if ((p->flags & P_STRING) && *(char **)(p->var) != NULL)
X inc = strlen(p->fullname) + strsize(*(char **)(p->var)) + 1;
X else
X inc = 1;
X if (col + inc >= Columns)


X {
X outchar('\n');

X col = 0;
X }
X
X showonep(p);
X col += inc;
X col += 19 - col % 19;
X if (col < Columns - 19)
X windgoto((int)Rows - 1, col); /* make columns */
X else
X {
X col = 0;


X outchar('\n');
X }

X flushbuf();
X }
X }
X
X if (col)
X outchar('\n');


X#ifdef AMIGA
X settmode(1);
X#endif
X wait_return(TRUE);

X}
X
X static void

Xshowonep(p)
X struct param *p;
X{
X char buf[64];
X
X if ((p->flags & P_BOOL) && !*(int *)(p->var))
X outstrn("no");
X outstrn(p->fullname);
X if (!(p->flags & P_BOOL))
X {
X outchar('=');
X if (p->flags & P_NUM)
X {
X sprintf(buf, "%ld", *(long *)(p->var));
X outstrn(buf);
X }
X else if (*(char **)(p->var) != NULL)
X outtrans(*(char **)(p->var), -1);
X }
X}
X
X/*
X * Write modified parameters as set command to a file.
X * Return 1 on error.
X */
X int
Xmakeset(fd)
X FILE *fd;
X{
X struct param *p;
X char *s;
X int e;
X
X for (p = &params[0]; p->fullname != NULL; p++)
X if (p->flags & P_CHANGED)
X {
X if (p->flags & P_BOOL)
X e = fprintf(fd, "set %s%s\n", *(int *)(p->var) ? "" : "no", p->fullname);
X else if (p->flags & P_NUM)
X e = fprintf(fd, "set %s=%ld\n", p->fullname, *(long *)(p->var));
X else
X {
X fprintf(fd, "set %s=", p->fullname);
X s = *(char **)(p->var);


X if (s != NULL)

X for ( ; *s; ++s)

X {
X if (*s < ' ' || *s > '~')
X putc(Ctrl('V'), fd);
X putc(*s, fd);
X }
X e = putc('\n', fd);
X }
X if (e < 0)
X return 1;
X }


X return 0;
X}
X
X/*

X * Clear all the terminal parameters.
X * If the parameter has been changed, free the allocated memory.
X * Reset the "changed" flag, so the new value will not be freed.
X */
X void
Xclear_termparam()
X{
X struct param *p;
X
X for (p = &params[0]; p->fullname != NULL; p++)
X if (istermparam(p))
X {
X if (p->flags & P_CHANGED)
X free(*(char **)(p->var));
X *(char **)(p->var) = NULL;
X p->flags &= ~P_CHANGED;
X }


X}
X
X static int

Xistermparam(p)
X struct param *p;
X{
X return (p->fullname[0] == 't' && p->fullname[1] == '_');
X}
END_OF_FILE
if test 16498 -ne `wc -c <'vim/src/param.c'`; then
echo shar: \"'vim/src/param.c'\" unpacked with wrong size!
fi
# end of 'vim/src/param.c'
fi
if test -f 'vim/src/unix.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/unix.c'\"
else
echo shar: Extracting \"'vim/src/unix.c'\" \(15625 characters\)
sed "s/^X//" >'vim/src/unix.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */

X/*
X * unix.c -- BSD and SYSV code
X *
X * A lot of this file was written by Juergen Weigert.
X */
X
X#include "vim.h"


X#include "globals.h"
X#include "param.h"
X#include "proto.h"
X

X#include <fcntl.h>
X#if !defined(pyr) && !defined(NOT_BOTH_TIME)
X# include <time.h> /* on some systems time.h should not be
X included together with sys/time.h */
X#endif
X#include <sys/ioctl.h>
X#ifndef M_XENIX
X# include <sys/types.h>
X#endif
X#include <signal.h>
X
X#ifdef SYSV
X# ifdef M_XENIX
X# include <sys/select.h>
X# define bzero(a, b) memset((a), 0, (b))
X# else
X# include <poll.h>
X# endif
X# include <termio.h>
X#else /* SYSV */
X# include <sys/time.h>
X# ifdef hpux
X# include <termio.h>
X# define SIGWINCH SIGWINDOW
X# else
X# include <sgtty.h>
X# endif /* hpux */
X#endif /* SYSV */
X
X#if (defined(pyr) || defined(NO_FD_ZERO)) && defined(SYSV) && defined(FD_ZERO)
X# undef FD_ZERO
X#endif
X
X#ifdef ESIX
X# ifdef SIGWINCH
X# undef SIGWINCH
X# endif
X# ifdef TIOCGWINSZ
X# undef TIOCGWINSZ
X# endif
X#endif
X
Xstatic int Read __ARGS((char *, long));
Xstatic int WaitForChar __ARGS((int));
Xstatic int RealWaitForChar __ARGS((int));
Xstatic void fill_inbuf __ARGS((void));
X#if defined(SIGWINCH) && !defined(linux)
Xstatic void sig_winch __ARGS((int, int, struct sigcontext *));
X#endif
X
Xstatic int do_resize = FALSE;
X
X/*
X * At this point TRUE and FALSE are defined as 1L and 0L, but we want 1 and 0.
X */
X#undef TRUE
X#define TRUE 1
X#undef FALSE
X#define FALSE 0


X
X/*
X * the number of calls to Write is reduced by using the buffer "outbuf"
X */
X#define BSIZE 2048
Xstatic u_char outbuf[BSIZE];
Xstatic int bpos = 0;
X

X/*
X * flushbuf(): flush the output buffer
X */
X void
Xflushbuf()
X{
X if (bpos != 0)

X write(1, (char *)outbuf, (long)bpos);

X bpos = 0;
X}
X
X/*
X * outchar(c): put a character into the output buffer. Flush it if it becomes full.


X */
X void
Xoutchar(c)
X unsigned c;
X{

X if (c == '\n') /* turn LF into CR-LF (CRMOD does not seem to do this) */
X outchar('\r');


X outbuf[bpos] = c;
X ++bpos;
X if (bpos >= BSIZE)
X flushbuf();

X}
X
X/*
X * GetChars(): low level input funcion.
X * Get a characters from the keyboard.


X * If type == T_PEEK do not wait for characters.
X * If type == T_WAIT wait a short time for characters.
X * If type == T_BLOCK wait for characters.
X */
X int
XGetChars(buf, maxlen, type)
X char *buf;
X int maxlen;
X int type;
X{

X int len;


X int time = 1000; /* one second */
X

X switch (type)
X {
X case T_PEEK:

X time = 20;


X case T_WAIT:
X if (WaitForChar(time) == 0) /* no character available */
X return 0;
X break;
X
X case T_BLOCK:
X /*
X * If there is no character available within 2 seconds (default)
X * write the autoscript file to disk
X */
X if (WaitForChar((int)p_ut) == 0)
X updatescript(0);
X }
X

X for (;;) /* repeat until we got a character */
X {
X /*
X * we want to be interrupted by the winch signal
X */
X WaitForChar(-1);
X if (do_resize)
X {
X debug("do_resize!\n");
X set_winsize(0, 0, FALSE);
X do_resize = FALSE;
X continue;
X }
X len = Read(buf, (long)maxlen);
X if (len > 0)


X return len;
X }
X}

X
X void
Xvim_delay()
X{

X#if defined(SYSV) && !defined(M_XENIX)
X poll(0, 0, 500);
X#else
X struct timeval tv;
X
X tv.tv_sec = 25 / 50;
X tv.tv_usec = (25 % 50) * (1000000/50);
X select(0, 0, 0, 0, &tv);
X#endif


X}
X
X static void

Xsig_winch(sig, code, scp)
X int sig;
X int code;
X struct sigcontext *scp;
X{
X#if defined(SIGWINCH) && (defined(SYSV) || defined(linux) || defined(hpux))
X signal(SIGWINCH, sig_winch);
X#endif
X do_resize = TRUE;
X}
X
X/*
X * If the machine has job control, use it to suspend the program,
X * otherwise fake it by starting a new shell.


X */
X void
Xmch_suspend()
X{

X#ifdef SIGTSTP
X settmode(0);
X stoptermcap();
X kill(0, SIGTSTP); /* send ourselves a STOP signal */
X settmode(1);
X starttermcap();
X#else


X outstr("new shell started\n");
X stoptermcap();
X call_shell(NULL, 0);
X starttermcap();

X#endif
X}
X
X void

Xmch_windinit()
X{


X Columns = 80;
X Rows = 24;
X

X flushbuf();
X
X mch_get_winsize();
X#if defined(SIGWINCH)
X signal(SIGWINCH, sig_winch);
X#endif
X}
X
X/*
X * Check_win checks whether we have an interactive window.
X * If not, a new window is opened with the newcli command.
X * If we would open a window ourselves, the :sh and :! commands would not
X * work properly (Why? probably because we are then running in a background CLI).
X * This also is the best way to assure proper working in a next Workbench release.
X *
X * For the -e option (quickfix mode) we open our own window and disable :sh.
X * Otherwise we would never know when editing is finished.
X */
X#define BUF2SIZE 320 /* lenght of buffer for argument with complete path */
X
X void
Xcheck_win(argc, argv)


X int argc;
X char **argv;
X{

X if (!isatty(0) || !isatty(1))
X {
X fprintf(stderr, "VIM: no controlling terminal\n");
X exit(2);
X }

X}
X
X/*


X * fname_case(): Set the case of the filename, if it already exists.

X * This will cause the filename to remain exactly the same.


X */
X void
Xfname_case(name)
X char *name;
X{
X}
X

X void
Xsettitle(str)
X char *str;
X{
X}
X
X void
Xresettitle()
X{

X}
X
X/*


X * get name of current directory into buffer 'buf' of length 'len' bytes
X */
X int
Xdirname(buf, len)
X char *buf;
X int len;
X{

X#if defined(SYSV) || defined(hpux)
X extern int errno;
X extern char *sys_errlist[];
X
X if (getcwd(buf,len) == NULL)
X {
X strcpy(buf, sys_errlist[errno]);
X return 1;
X }
X return 0;
X#else
X return (int)getwd(buf);
X#endif
X}
X
X/*


X * get absolute filename into buffer 'buf' of length 'len' bytes
X */
X int
XFullName(fname, buf, len)
X char *fname, *buf;

X int len;
X{
X *buf = 0;
X#if defined(linux) || defined(UNIX_WITHOUT_AMD)
X {
X int l;
X
X if (*fname != '/')
X {
X#if defined(SYSV) || defined(hpux)
X (void)getcwd(buf,len);
X#else
X (void)getwd(buf);
X#endif
X l = strlen(buf);
X if (l && buf[l-1] != '/')
X strcat(buf, "/");
X }
X }
X#endif /* UNIX_WITHOUT_AMD */
X strcat(buf, fname);


X return 0;
X}
X
X/*

X * get file permissions for 'name'

X */
X long
Xgetperm(name)
X char *name;
X{

X struct stat statb;
X
X if (stat(name, &statb))
X return -1;
X return statb.st_mode;
X}
X
X/*


X * set file permission for 'name' to 'perm'
X */
X int
Xsetperm(name, perm)
X char *name;
X int perm;
X{

X return chmod(name, perm);
X}
X
X/*


X * check if "name" is a directory
X */
X int
Xisdir(name)
X char *name;
X{

X struct stat statb;
X
X if (stat(name, &statb))
X return -1;
X return (statb.st_mode & S_IFMT) != S_IFREG;
X}
X


X void
Xmch_windexit(r)
X int r;
X{
X settmode(0);
X stoptermcap();
X flushbuf();
X stopscript(); /* remove autoscript file */
X exit(r);
X}
X

X void
Xmch_settmode(raw)
X int raw;
X{

X#if defined(ECHOE) && defined(ICANON)
X /* for "new" tty systems */
X static struct termio told;
X struct termio tnew;


X
X if (raw)
X {

X ioctl(0, TCGETA, &told);
X tnew = told;
X tnew.c_iflag &= ~ICRNL; /* enables typing ^V^M */
X tnew.c_iflag &= ~IXON; /* enables typing ^Q */
X tnew.c_lflag &= ~(ICANON | ECHO | ISIG | ECHOE);
X tnew.c_cc[VMIN] = 1; /* return after 1 char */
X tnew.c_cc[VTIME] = 0; /* don't wait */
X ioctl(0, TCSETA, &tnew);
X }
X else
X ioctl(0, TCSETA, &told);
X#else
X# ifndef TIOCSETN
X# define TIOCSETN TIOCSETP /* for hpux 9.0 */
X# endif
X /* for "old" tty systems */
X static struct sgttyb ttybold;
X struct sgttyb ttybnew;


X
X if (raw)
X {

X ioctl(0, TIOCGETP, &ttybold);
X ttybnew = ttybold;
X ttybnew.sg_flags &= ~(CRMOD | ECHO);
X ttybnew.sg_flags |= RAW;
X ioctl(0, TIOCSETN, &ttybnew);
X }
X else
X ioctl(0, TIOCSETN, &ttybold);
X#endif


X}
X
X int
Xmch_get_winsize()
X{

X int old_Rows = Rows;
X int old_Columns = Columns;
X char *p;
X
X Columns = 0;
X Rows = 0;
X
X/*
X * when called without a signal, get winsize from environment
X */
X if (!do_resize)
X {
X if ((p = (char *)getenv("LINES")))
X Rows = atoi(p);
X if ((p = (char *)getenv("COLUMNS")))
X Columns = atoi(p);
X if (Columns <= 0 || Rows <= 0)
X do_resize = TRUE;
X }
X
X/*
X * when got a signal, or no size in environment, try using an ioctl
X */
X if (do_resize)
X {
X# ifdef TIOCGSIZE
X struct ttysize ts;
X
X if (ioctl(0, TIOCGSIZE, &ts) == 0)
X {
X if (Columns == 0)
X Columns = ts.ts_cols;
X if (Rows == 0)
X Rows = ts.ts_lines;
X }
X# else /* TIOCGSIZE */
X# ifdef TIOCGWINSZ
X struct winsize ws;
X
X if (ioctl(0, TIOCGWINSZ, &ws) == 0)
X {
X if (Columns == 0)
X Columns = ws.ws_col;
X if (Rows == 0)
X Rows = ws.ws_row;
X }
X# endif /* TIOCGWINSZ */
X# endif /* TIOCGSIZE */
X do_resize = FALSE;
X }
X
X#ifdef TERMCAP
X/*
X * if previous work fails, try reading the termcap
X */
X if (Columns == 0 || Rows == 0)
X {
X extern void getlinecol();
X
X getlinecol(); /* get "co" and "li" entries from termcap */
X }
X#endif
X
X/*
X * If everything fails, use the old values
X */
X if (Columns <= 0 || Rows <= 0)
X {
X Columns = old_Columns;
X Rows = old_Rows;
X return 1;
X }
X debug2("mch_get_winsize: %dx%d\n", (int)Columns, (int)Rows);
X
X check_winsize();
X script_winsize();
X
X/* if size changed: screenalloc will allocate new screen buffers */
X return (0);


X}
X
X void
Xmch_set_winsize()
X{
X /* should try to set the window size to Rows and Columns */
X}

X
X int
Xcall_shell(cmd, dummy)
X char *cmd;
X int dummy;
X{
X int x;
X char newcmd[1024];


X
X flushbuf();
X
X settmode(0); /* set to cooked mode */
X
X if (cmd == NULL)
X x = system(p_sh);
X else

X { /* we use "sh" to start the shell, slow but easy */
X sprintf(newcmd, "%s -c \"%s\"", p_sh, cmd);


X x = system(newcmd);
X }

X if (x == 127)
X {
X smsg("Cannot execute shell sh");


X outchar('\n');
X }

X else if (x)


X {
X smsg("%d returned", x);
X outchar('\n');
X }
X
X settmode(1); /* set to raw mode */

X return x;
X}
X
X/*
X * The input characters are buffered to be able to check for a CTRL-C.
X * This should be done with signals, but I don't know how to do that in
X * a portable way for a tty in RAW mode.
X */
X
X#define INBUFLEN 50
Xstatic char inbuf[INBUFLEN]; /* internal typeahead buffer */
Xstatic int inbufcount = 0; /* number of chars in inbuf[] */
X
X static int
XRead(buf, maxlen)
X char *buf;
X long maxlen;
X{
X if (inbufcount == 0) /* if the buffer is empty, fill it */
X fill_inbuf();
X if (maxlen > inbufcount)
X maxlen = inbufcount;
X memmove(buf, inbuf, maxlen);
X inbufcount -= maxlen;
X if (inbufcount)
X memmove(inbuf, inbuf + maxlen, inbufcount);
X return (int)maxlen;
X}
X
X void
Xbreakcheck()
X{
X/*
X * check for CTRL-C typed by reading all available characters
X */
X if (RealWaitForChar(0)) /* if characters available */
X fill_inbuf();


X}
X
X static void

Xfill_inbuf()
X{
X int len;
X
X if (inbufcount >= INBUFLEN) /* buffer full */
X return;
X len = read(0, inbuf + inbufcount, (long)(INBUFLEN - inbufcount));
X if (len <= 0) /* cannot read input??? */
X {
X fprintf(stderr, "Vim: Error reading input, exiting...\n");
X exit(1);
X }
X while (len-- > 0)
X {
X /*
X * if a CTRL-C was typed, remove it from the buffer and set got_int
X */
X if (inbuf[inbufcount] == 3)
X {
X /* remove everything typed before the CTRL-C */
X memmove(inbuf, inbuf + inbufcount, len + 1);
X inbufcount = 0;
X got_int = TRUE;
X flush_buffers(); /* remove all typeahead */
X }
X ++inbufcount;
X }
X}
X
X/*
X * Wait "ticks" until a character is available from the keyboard or from inbuf[]
X * ticks = -1 will block forever


X */
X
X static int

XWaitForChar(ticks)
X int ticks;
X{
X if (inbufcount) /* something in inbuf[] */
X return 1;
X return RealWaitForChar(ticks);
X}
X
X/*
X * Wait "ticks" until a character is available from the keyboard
X * ticks = -1 will block forever


X */
X static int

XRealWaitForChar(ticks)
X int ticks;
X{
X#ifndef FD_ZERO
X struct pollfd fds;
X
X fds.fd = 0;
X fds.events = POLLIN;
X return (poll(&fds, 1, ticks));
X#else
X struct timeval tv;
X fd_set fdset;
X
X if (ticks >= 0)
X {
X tv.tv_sec = ticks / 1000;
X tv.tv_usec = (ticks % 1000) * (1000000/1000);
X }
X
X FD_ZERO(&fdset);
X FD_SET(0, &fdset);
X return (select(1, &fdset, NULL, NULL, (ticks >= 0) ? &tv : NULL));


X#endif
X}
X
X int

Xremove(buf)
X#ifdef linux
X const
X#endif
X char *buf;
X{
X return unlink(buf);
X}
X
X#ifdef WILD_CARDS
X/*
X * ExpandWildCard() - this code does wild-card pattern matching using the shell
X *
X * Mool: return 0 for success, 1 for error (you may loose some memory) and
X * put an error message in *file.
X *
X * num_pat is number of input patterns
X * pat is array of pointers to input patterns
X * num_file is pointer to number of matched file names
X * file is pointer to array of pointers to matched file names
X * On Unix we do not check for files only yet
X * list_notfound is ignored
X */
X
Xextern char *mktemp __ARGS((char *));
X#ifndef SEEK_SET
X# define SEEK_SET 0
X#endif
X#ifndef SEEK_END
X# define SEEK_END 2
X#endif


X
X int
XExpandWildCards(num_pat, pat, num_file, file, files_only, list_notfound)
X int num_pat;
X char **pat;

X int *num_file;
X char ***file;
X int files_only;
X int list_notfound;
X{
X char tmpname[TMPNAMELEN];
X char *command;
X int i;
X size_t len;
X FILE *fd;
X char *buffer;
X char *p;
X
X *num_file = 0; /* default: no files found */
X *file = (char **)"";
X
X/*
X * get a name for the temp file
X */
X strcpy(tmpname, TMPNAME2);
X if (*mktemp(tmpname) == NUL)
X {
X emsg(e_notmp);


X return 1;
X }
X

X/*
X * let the shell expand the patterns and write the result into the temp file
X */
X len = TMPNAMELEN + 10;
X for (i = 0; i < num_pat; ++i) /* count the length of the patterns */
X len += strlen(pat[i]) + 3;
X command = (char *)alloc(len);
X if (command == NULL)
X return 1;
X strcpy(command, "echo > "); /* built the shell command */
X strcat(command, tmpname);
X for (i = 0; i < num_pat; ++i)
X {
X strcat(command, " \"");
X strcat(command, pat[i]);
X strcat(command, "\"");
X }
X i = call_shell(command, 0); /* execute it */
X free(command);
X if (i) /* call_shell failed */
X {
X remove(tmpname);
X sleep(1); /* give the user a chance to read error messages */
X updateScreen(CLEAR); /* probably messed up screen */


X return 1;
X }
X

X/*
X * read the names from the file into memory
X */
X fd = fopen(tmpname, "r");
X if (fd == NULL)
X {
X emsg(e_notopen);
X return 1;
X }
X fseek(fd, 0L, SEEK_END);
X len = ftell(fd); /* get size of temp file */
X fseek(fd, 0L, SEEK_SET);
X buffer = (char *)alloc(len + 1);
X if (buffer == NULL)
X {
X remove(tmpname);
X fclose(fd);
X return 1;
X }
X i = fread(buffer, 1, len, fd);
X fclose(fd);
X remove(tmpname);
X if (i != len)
X {
X emsg(e_notread);
X free(buffer);
X return 1;
X }
X buffer[len] = '\n'; /* make sure the buffers ends in NL */
X
X p = buffer;
X for (i = 0; *p != '\n'; ++i) /* get number of entries */
X {
X while (*p != ' ' && *p != '\n') /* skip entry */
X ++p;
X skipspace(&p); /* skip to next entry */
X }
X *num_file = i;
X *file = (char **)alloc(sizeof(char *) * i);
X if (*file == NULL)
X {
X free(buffer);
X *file = (char **)"";
X return 1;
X }
X p = buffer;
X for (i = 0; i < *num_file; ++i)
X {
X (*file)[i] = p;
X while (*p != ' ' && *p != '\n')
X ++p;
X if (*p == '\n')
X {
X *p = NUL;
X break;
X }
X *p++ = NUL;
X skipspace(&p);


X }
X return 0;
X}
X

X void
XFreeWild(num, file)
X int num;
X char **file;
X{
X if (file == NULL || num <= 0)
X return;

X free(file[0]);
X free(file);
X}
X
X int
Xhas_wildcard(p)
X char *p;
X{
X for ( ; *p; ++p)
X if (strchr("*?[{`~$", *p) != NULL)
X return 1;
X return 0;
X}
X#endif /* WILD_CARDS */
X
X#ifdef M_XENIX
X/*
X * Scaled-down version of rename, which is missing in Xenix.
X * This version can only move regular files and will fail if the
X * destination exists.
X */
X int
Xrename(src, dst)
X char *src, *dst;
X{
X struct stat st;
X
X if (stat(dest, &st) >= 0) /* fail if destination exists */
X return -1;
X if (link(src, dest) != 0) /* link file to new name */
X return -1;
X if (unlink(src) == 0) /* delete link to old name */
X return 0;
X return -1;
X}
X#endif /* M_XENIX */
END_OF_FILE
if test 15625 -ne `wc -c <'vim/src/unix.c'`; then
echo shar: \"'vim/src/unix.c'\" unpacked with wrong size!
fi
# end of 'vim/src/unix.c'
fi
echo shar: End of archive 8 \(of 23\).
cp /dev/null ark8isdone

Bram Moolenaar

unread,
Apr 23, 1993, 1:37:02 PM4/23/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 9
Archive-name: vim/part09
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 9 (of 23)."
# Contents: vim/macros/maze/maze.mac.uue vim/src/buffers.c
# vim/src/fileio.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:09 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/macros/maze/maze.mac.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/maze/maze.mac.uue'\"
else
echo shar: Extracting \"'vim/macros/maze/maze.mac.uue'\" \(17071 characters\)
sed "s/^X//" >'vim/macros/maze/maze.mac.uue' <<'END_OF_FILE'
X
Xbegin 644 maze.mac
XM(B!4:&5S92!M86-R;W,@)W-O;'9E)R!A;GD@;6%Z92!P<F]D=6-E9"!B>2!TQ
XM:&4@82UM87IE+6EN9R!M87IE+F,@<')O9W)A;2X*(B`*(B!&:7)S="P@82!B&
XM:70@;V8@;6%Z92!T:&5O<GDN"B(@268@>6]U('=E<F4@<'5T(&EN=&\@82!MT
XM87IE+"!A(&=U87)A;G1E960@;65T:&]D(&]F(&9I;F1I;F<@>6]U<B!W87D*L
XM(B!O=70@;V8@=&AE(&UA>F4@:7,@=&\@<'5T('EO=7(@;&5F="!H86YD(&]NG
XM=&\@82!W86QL(&%N9"!J=7-T(&ME97`@=V%L:VEN9RP*(B!N979E<B!T86MI@
XM;F<@>6]U<B!H86YD(&]F9B!T:&4@=V%L;"X@5&AI<R!T96-H;FEQ=64@:7,@S
XM;VYL>2!G=6%R86YT965D('1O"B(@=V]R:R!I9B!T:&4@;6%Z92!D;V5S(&YOY
XM="!H879E(&%N>2`G:7-L86YD<R<L(&]R(&EF('1H92`G97AI="<@:7,@;VX@Z
XM=&AE"B(@<V%M92!I<VQA;F0@87,@>6]U<B!S=&%R=&EN9R!P;VEN="X@5&AEV
XM<V4@8V]N9&ET:6]N<R!H;VQD(&9O<B!T:&4@;6%Z97,*(B!U;F1E<B!C;VYS^
XM:61E<F%T:6]N+@HB(`HB($%S<W5M:6YG('1H870@=&AE(&UA>F4@:7,@;6%D9
XM92!U<"!O9B!H;W)I>F]N=&%L(&%N9"!V97)T:6-A;"!W86QL<R!S<&%C960*S
XM(B!O;F4@<W1E<"!A<&%R="!A;F0@=&AA="!Y;W4@8V%N(&UO=F4@96ET:&5R#
XM(&YO<G1H+"!S;W5T:"P@96%S="!O<B!W97-T+`HB('1H96X@>6]U(&-A;B!A>
XM=71O;6%T92!T:&ES('!R;V-E9'5R92!B>2!C87)R>6EN9R!O=70@=&AE(&9O(
XM;&QO=VEN9R!S=&5P<RX*(B`*(B`Q+B!0=70@>6]U<G-E;&8@<V]M97=H97)E1
XM(&EN('1H92!M87IE(&YE87(@82!W86QL+@HB(#(N($-H96-K(&EF('EO=2!H(
XM879E(&$@=V%L;"!O;B!Y;W5R(&QE9G0N($EF('-O+"!G;R!T;R!S=&5P(#0N&
XM"B(@,RX@5&AE<F4@:7,@;F\@=V%L;"!O;B!Y;W5R(&QE9G0L('-O('1U<FX@\
XM;VX@=&AE('-P;W0@=&\@>6]U<B!L969T(&%N9"!S=&5P"B(@("`@9F]R=V%R-
XM9"!B>2!O;F4@<W1E<"!A;F0@<F5P96%T('-T97`@,BX*(B`T+B!#:&5C:R!WP
XM:&%T(&ES(&1I<F5C=&QY(&EN(&9R;VYT(&]F('EO=2X@268@:70@:7,@82!WY
XM86QL+"!T=7)N(&]N('1H90HB("`@('-P;W0@=&\@>6]U<B!R:6=H="!B>2`YB
XM,"!D96=R965S(&%N9"!R97!E870@<W1E<"`T+@HB(#4N(%1H97)E(&ES(&YO!
XM('=A;&P@:6X@9G)O;G0@;V8@>6]U+"!S;R!S=&5P(&9O<G=A<F0@;VYE('-T*
XM97`@86YD"B(@("`@9V\@=&\@<W1E<"`R+@HB(`HB($EN('1H:7,@=V%Y('EOI
XM=2!W:6QL(&-O=F5R(&%L;"!T:&4@8V]R<FED;W)S(&]F('1H92!M87IE("AU=
XM;G1I;"!Y;W4@9V5T(&)A8VL*(B!T;R!W:&5R92!Y;W4@<W1A<G1E9"!F<F]M7
XM+"!I9B!Y;W4@9&\@;F]T('-T;W`I+@HB(`HB($)Y(&5X86UI;FEN9R!A(&UA;
XM>F4@<')O9'5C960@8GD@=&AE(&UA>F4N8R!P<F]G<F%M('EO=2!W:6QL('-ET
XM92!T:&%T(`HB(&5A8V@@<W%U87)E(&]F('1H92!M87IE(&ES(&]N92!C:&%RC
XM86-T97(@:&EG:"!A;F0@='=O(&-H87)A8W1E<G,@=VED92X*(B!4;R!G;R!NF
XM;W)T:"!O<B!S;W5T:"P@>6]U(&UO=F4@8GD@82!O;F4@8VAA<F%C=&5R('-T#
XM97`L(&)U="!T;R!M;W9E(&5A<W0@;W(*(B!W97-T('EO=2!M;W9E(&)Y(&$@3
XM='=O(&-H87)A8W1E<B!S=&5P+B!!;'-O(&YO=&4@=&AA="!I;B!A;GD@<&]S8
XM:71I;VX*(B!T:&5R92!A<F4@9F]U<B!P;&%C97,@=VAE<F4@=V%L;',@8V]UX
XM;&0@8F4@<'5T("T@=&\@=&AE(&YO<G1H+"!T;R!T:&4@<V]U=&@L"B(@=&\@*
XM=&AE(&5A<W0@86YD('1O('1H92!W97-T+@HB($$@=V%L;"!E>&ES=',@=&\@6
XM=&AE(&YO<G1H(&]F('EO=2!I9B!T:&4@8VAA<F%C=&5R('1O('1H92!N;W)TB
XM:"!O9@HB('EO=2!I<R!A(%\@*&]T:&5R=VES92!I="!I<R!A('-P86-E*2X*K
XM(B!!('=A;&P@97AI<W1S('1O('1H92!E87-T(&]F('EO=2!I9B!T:&4@8VAA2
XM<F%C=&5R('1O('1H92!E87-T(&]F('EO=0HB(&ES(&$@?"`H;W1H97)W:7-E+
XM(&ET(&ES(&$@+BDN"B(@02!W86QL(&5X:7-T<R!T;R!T:&4@=V5S="!O9B!Y1
XM;W4@:68@=&AE(&-H87)A8W1E<B!T;R!T:&4@=V5S="!O9B!Y;W4*(B!I<R!AC
XM('P@*&]T:&5R=VES92!I="!I<R!A("XI+@HB($$@=V%L;"!E>&ES=',@=&\@=
XM=&AE('-O=71H(&]F('EO=2!I9B!T:&4@8VAA<F%C=&5R('=H97)E('EO=2!A<
XM<F4*(B!I<R!A(%\@*&]T:&5R=VES92!I="!I<R!A('-P86-E*2X*(B`*(B!.$
XM;W1E('1H92!D:69F97)E;F-E(&9O<B!D:7)E8W1I;VX@<V]U=&@L('=H97)E6
XM('=E(&UU<W0@97AA;6EN92!T:&4@8VAA<F%C=&5R"B(@=VAE<F4@=&AE(&-U:
XM<G-O<B!I<R!R871H97(@=&AA;B!A;B!A9&IA8V5N="!C96QL+@HB(`HB($EFQ
XM('EO=2!W97)E(&EM<&QE;65N=&EN9R!T:&4@86)O=F4@<')O8V5D=7)E(&ESL
XM(&$@;F]R;6%L(&-O;7!U=&5R(&QA;F=U86=E"B(@>6]U(&-O=6QD('5S92!AK
XM(&QO;W`@=VET:"!I9B!S=&%T96UE;G1S(&%N9"!C;VYT:6YU92!S=&%T96UEX
XM;G1S+"`*(B!(;W=E=F5R+"!T:&5S92!C;VYS=')U8W1S(&%R92!N;W0@879A+
XM:6QA8FQE(&EN('9I(&UA8W)O<R!S;R!)(&AA=F4@=7-E9`HB(&$@<W1A=&4@2
XM;6%C:&EN92!W:71H(#@@<W1A=&5S+B!%86-H('-T871E('-I9VYI9FEE<R!TR
XM:&4@9&ER96-T:6]N('EO=0HB(&%R92!G;VEN9R!I;B!A;F0@=VAE=&AE<B!O3
XM<B!N;W0@>6]U(&AA=F4@8VAE8VME9"!I9B!T:&5R92!I<R!A('=A;&P@;VX*&
XM(B!Y;W5R(&QE9G0N"B(@"B(@5&AE('1R86YS:71I;VX@9G)O;2!S=&%T92!T7
XM;R!S=&%T92!A;F0@=&AE(&%C=&EO;G,@=&%K96X@;VX@96%C:"!T<F%N<VET[
XM:6]N"B(@87)E(&=I=F5N(&EN('1H92!S=&%T92!T86)L92!B96QO=RX*(B!4+
XM:&4@;F%M97,@;V8@=&AE('-T871E<R!A<F4@3C$L($XR+"!3,2P@4S(L($4QQ
XM+"!%,BP@5S$L(%<R+"!W:&5R92!E86-H(&QE='1E<@HB('-T86YD<R!F;W(@4
XM82!D:7)E8W1I;VX@;V8@=&AE(&-O;7!A<W,L('1H92!N=6UB97(@,2!I;F1IY
XM8V%T97,@=&AA="!T:&4@=V4*(B!H879E(&YO="!Y970@8VAE8VME9"!T;R!S.
XM964@:68@=&AE<F4@:7,@82!W86QL(&]N(&]U<B!L969T(&%N9"!T:&4@;G5M@
XM8F5R(#(*(B!I;F1I8V%T97,@=&AA="!W92!H879E(&-H96-K960@86YD('1H2
XM97)E(&ES(&$@=V%L;"!O;B!O=7(@;&5F="X*(B`*(B!&;W(@96%C:"!S=&%T!
XM92!W92!M=7-T(&-O;G-I9&5R('1H92!E>&ES=&5N8V4@;W(@;F]T(&]F(&$@2
XM=V%L;"!I;B!A"B(@<&%R=&EC=6QA<B!D:7)E8W1I;VXN(%1H:7,@9&ER96-T-
XM:6]N(&ES(&=I=F5N(&EN('1H92!F;VQL;W=I;F<@=&%B;&4N"B(@"B(@3F5X=
XM=$-H87(@=&%B;&4Z"B(@<W1A=&4@("`@("`@(&1I<F5C=&EO;B`@("`@("!V8
XM:2!C;VUM86YD<PHB("!.,2`@("`@("`@("`@("`@5R`@("`@("`@("`@("`@=
XM(&A&"B(@($XR("`@("`@("`@("`@("!.("`@("`@("`@("`@("`@:T8*(B`@%
XM4S$@("`@("`@("`@("`@($4@("`@("`@("`@("`@("!L1@HB("!3,B`@("`@L
XM("`@("`@("`@4R`@("`@("`@("`@("`@($8*(B`@13$@("`@("`@("`@("`@;
XM($X@("`@("`@("`@("`@("!K1@HB("!%,B`@("`@("`@("`@("`@12`@("`@'
XM("`@("`@("`@(&Q&"B(@(%<Q("`@("`@("`@("`@("!3("`@("`@("`@("`@Y
XM("`@1@HB("!7,B`@("`@("`@("`@("`@5R`@("`@("`@("`@("`@(&A&"B(@,
XM"B(@=VAE<F4@1B!I<R!A(&UA8W)O('=H:6-H('EA;FMS('1H92!C:&%R86-T,
XM97(@=6YD97(@=&AE(&-U<G-O<B!I;G1O"B(@=&AE($YE>'1#:&%R(')E9VES2
XM=&5R("AN*2X*(B`*(B!3=&%T92!T86)L93H*(B!);B!T:&4@)W9I(&-O;6UA*
XM;F1S)R!C;VQU;6X@:7,@9VEV96X@=&AE(&%C=&EO;G,@=&\@8V%R<GD@;W5T]
XM('=H96X@:6X*(B!T:&ES('-T871E(&%N9"!T:&4@3F5X=$-H87(@:7,@87,@/
XM9VEV96XN(%1H92!C;VUM86YD<R!K+"!J+"!L;"P@:&@@;6]V90HB('1H92!CB
XM=7)R96YT('!O<VET:6]N(&YO<G1H+"!S;W5T:"P@96%S="!A;F0@=V5S="!R`
XM97-P96-T:79E;'DN(%1H90HB(&-O;6UA;F0@;6T@:7,@=7-E9"!A<R!A(&YO`
XM+6]P(&-O;6UA;F0N"B(@26X@=&AE("=N97AT('-T871E)R!C;VQU;6X@:7,@5
XM9VEV96X@=&AE(&YE=R!S=&%T92!O9B!T:&4@;6%C:&EN92!A9G1E<@HB('1H*
XM92!A8W1I;VX@:7,@8V%R<FEE9"!O=70N"B(@"B(@8W5R<F5N="!S=&%T92`@[
XM("`@("`@3F5X=$-H87(@("`@=FD@8V]M;6%N9',@(&YE>'0@<W1A=&4*(B`@:
XM("`@($XQ("`@("`@("`@("`@("`@("`N("`@("`@("`@("`@:&@@("`@("`@]
XM("`@5S$*(B`@("`@($XQ("`@("`@("`@("`@("`@("!\("`@("`@("`@("`@O
XM;6T@("`@("`@("`@3C(*(B`@("`@($XR("`@("`@("`@("`@("`@("!?("`@E
XM("`@("`@("`@;6T@("`@("`@("`@13$*(B`@("`@($XR("`@("`@("`@("`@<
XM("`@<W!A8V4@("`@("`@("`@:R`@("`@("`@("`@3C$*(B`@("`@(%,Q("`@&
XM("`@("`@("`@("`@("`N("`@("`@("`@("`@;&P@("`@("`@("`@13$*(B`@H
XM("`@(%,Q("`@("`@("`@("`@("`@("!\("`@("`@("`@("`@;6T@("`@("`@:
XM("`@4S(*(B`@("`@(%,R("`@("`@("`@("`@("`@("!?("`@("`@("`@("`@5
XM;6T@("`@("`@("`@5S$*(B`@("`@(%,R("`@("`@("`@("`@("`@<W!A8V4@?
XM("`@("`@("`@:B`@("`@("`@("`@4S$*(B`@("`@($4Q("`@("`@("`@("`@0
XM("`@<W!A8V4@("`@("`@("`@:R`@("`@("`@("`@3C$*(B`@("`@($4Q("`@X
XM("`@("`@("`@("`@("!?("`@("`@("`@("`@;6T@("`@("`@("`@13(*(B`@<
XM("`@($4R("`@("`@("`@("`@("`@("!\("`@("`@("`@("`@;6T@("`@("`@-
XM("`@4S$*(B`@("`@($4R("`@("`@("`@("`@("`@("`N("`@("`@("`@("`@5
XM;&P@("`@("`@("`@13$*(B`@("`@(%<Q("`@("`@("`@("`@("`@<W!A8V4@.
XM("`@("`@("`@:B`@("`@("`@("`@4S$*(B`@("`@(%<Q("`@("`@("`@("`@B
XM("`@("!?("`@("`@("`@("`@;6T@("`@("`@("`@5S(*(B`@("`@(%<R("`@W
XM("`@("`@("`@("`@("!\("`@("`@("`@("`@;6T@("`@("`@("`@3C$*(B`@!
XM("`@(%<R("`@("`@("`@("`@("`@("`N("`@("`@("`@("`@:&@@("`@("`@'
XM("`@5S$*(@HB(`HB($-O;7!L86EN="!A8F]U="!V:2!M86-R;W,Z"B(@270@5
XM<V5E;7,@=&AA="!Y;W4@8V%N;F]T(&AA=F4@;6]R92!T:&%N(&]N92`G=6YD@
XM;RUA8FQE)R!V:2!C;VUM86YD"B(@:6X@=&AE(&]N92!M86-R;RP@<V\@>6]U8
XM(&AA=F4@=&\@;6%K92!L;W1S(&]F(&QI='1L92!M86-R;W,@86YD"B(@<'5TG
XM('1H96T@=&]G971H97(N"B(*(B!))VQL(&5X<&QA:6X@=VAA="!)(&UE86X@M
XM8GD@86X@97AA;7!L92X@161I="!A(&9I;&4@86YD"B(@='EP92`G.FUA<"!1\
XM(')862<N(%1H:7,@<VAO=6QD(&UA<"!T:&4@42!K97D@=&\@)W)E<&QA8V4@>
XM=&AE"B(@8VAA<F%C=&5R('5N9&5R('1H92!C=7)S;W(@=VET:"!8(&%N9"!Y7
XM86YK('1H92!L:6YE)RX*(B!"=70@=VAE;B!)('1Y<&4@42P@=FD@=&5L;',@,
XM;64@)T-A;B=T('EA;FL@:6YS:61E(&=L;V)A;"]M86-R;R<@86YD"B(@9V]E(
XM<R!I;G1O(&5X(&UO9&4N($AO=V5V97(@:68@22!T>7!E("<Z;6%P(%$@<EA4E
XM)R!A;F0@)SIM87`@5"!9)RP*(B!E=F5R>71H:6YG(&ES($]++B!)8&T@9&]I`
XM;F<@86QL('1H:7,@;VX@82!3<&%R8W-T871I;VXN"B(@268@86YY;VYE(')EI
XM861I;F<@=&AI<R!H87,@86X@86YS=V5R('1O('1H:7,@<')O8FQE;2P@=&AE/
XM(&%U=&AO<B!W;W5L9`HB(&QO=F4@=&\@9FEN9"!O=70N($UA:6P@=&\@9W)EN
XM9VU`;W1C+F]T8V$N;WHN874N"B(*(B!4:&4@;6%C<F]S.@HB(%1H92!M86-R@
XM;R!T;R!R=6X@=&AE(&UA>F4@<V]L=F5R(&ES("=G)RX@5&AI<R!S:6UP;'D@E
XM8V%L;',@='=O(&]T:&5R"B(@;6%C<F]S.B!)+"!T;R!I;FET:6%L:7-E(&5VT
XM97)Y=&AI;F<L(&%N9"!,+"!T;R!L;V]P(&9O<F5V97(@<G5N;FEN9PHB('1H`
XM<F]U9V@@=&AE('-T871E('1A8FQE+@HB($)O=&@@;V8@=&AE<V4@;6%C<F]S)
XM(&%R92!L;VYG('-E<75E;F-E<R!O9B!C86QL<R!T;R!O=&AE<B!M86-R;W,N0
XM($%L;`HB(&]F('1H97-E(&]T:&5R(&UA8W)O<R!A<F4@<75I=&4@<VEM<&QE$
XM(&%N9"!S;R!T;R!U;F1E<G-T86YD(&AO=R!T:&ES"B(@=V]R:W,L(&%L;"!Y6
XM;W4@;F5E9"!T;R!D;R!I<R!E>&%M:6YE(&UA8W)O<R!)(&%N9"!,(&%N9"!L%
XM96%R;B!W:&%T('1H97D*(B!D;R`H82!S:6UP;&4@<V5Q=65N8V4@;V8@=FD@3
XM86-T:6]N<RD@86YD(&AO=R!,(&QO;W!S("AB>2!C86QL:6YG(%4L('=H:6-H%
XM"B(@<VEM<&QY(&-A;&QS($P@86=A:6XI+@HB"B(@36%C<F\@22!S971S('5PS
XM('1H92!S=&%T92!T86)L92!A;F0@3F5X=$-H87(@=&%B;&4@870@=&AE(&5N+
XM9"!O9B!T:&4@9FEL92X*(B!-86-R;R!,('1H96X@<V5A<F-H97,@=&AE<V4@H
XM=&%B;&5S('1O(&9I;F0@;W5T('=H870@86-T:6]N<R!T;R!P97)F;W)M(&%NI
XM9`HB('=H870@<W1A=&4@8VAA;F=E<R!T;R!M86ME+@HB"B(@5&AE(&5N=')IH
XM97,@:6X@=&AE('-T871E('1A8FQE(&%L;"!B96=I;B!W:71H(&$@:V5Y(&-O/
XM;G-I<W1I;F<@;V8@=&AE"B(@;&5T=&5R("=S)RP@=&AE(&-U<G)E;G0@<W1A:
XM=&4@86YD('1H92!.97AT0VAA<BX@($%F=&5R('1H:7,@:7,@=&AE"B(@86-TC
XM:6]N('1O('1A:V4@:6X@=&AI<R!S=&%T92!A;F0@869T97(@=&AI<R!I<R!T+
XM:&4@;F5X="!S=&%T92!T;R!C:&%N9V4@=&\N"B(*(B!4:&4@96YT<FEE<R!IC
XM;B!T:&4@3F5X=$-H87(@=&%B;&4@8F5G:6X@=VET:"!A(&ME>2!C;VYS:7-T"
XM:6YG(&]F('1H90HB(&QE='1E<B`G;B<@86YD('1H92!C=7)R96YT('-T871ED
XM+B!!9G1E<B!T:&ES(&ES('1H92!A8W1I;VX@=&\@=&%K92!T;PHB(&]B=&%IY
XM;B!.97AT0VAA<B`M('1H92!C:&%R86-T97(@=&AA="!M=7-T(&)E(&5X86UI[
XM;F5D('1O(&-H86YG92!S=&%T92X*(@HB($]N92!W87D@=&\@<V5E('=H870@.
XM96%C:"!P87)T(&]F('1H92!M86-R;W,@:7,@9&]I;F<@:7,@=&\@='EP92!IZ
XM;B!T:&4*(B!B;V1Y(&]F('1H92!M86-R;W,@22!A;F0@3"!M86YU86QL>2`HW
XM:6YS=&5A9"!O9B!T>7!I;F<@)V<G*2!A;F0@<V5E"B(@=VAA="!H87!P96YS5
XM(&%T(&5A8V@@<W1E<"X*(@HB($=O;V0@;'5C:RX*(@HB(%)E9VES=&5R<R!US
XM<V5D(&)Y('1H92!M86-R;W,Z"B(@<R`H4W1A=&4I("`@("`@("`M(&AO;&1S/
XM('1H92!S=&%T92!T:&4@;6%C:&EN92!I<R!I;@HB(&,@*$-H87(I("`@("`@)
XM("`@+2!H;VQD<R!T:&4@8VAA<F%C=&5R('5N9&5R('1H92!C=7)R96YT('!OV
XM<VET:6]N"B(@;2`H36%C<F\I("`@("`@("`M(&AO;&1S(&$@=FD@8V]M;6%NT
XM9"!S=')I;F<@=&\@8F4@97AE8W5T960@;&%T97(*(B!N("A.97AT0VAA<BD@<
XM("`@("T@:&]L9',@=&AE(&-H87)A8W1E<B!W92!M=7-T(&5X86UI;F4@=&\@D
XM8VAA;F=E('-T871E"B(@<B`H4V5C;VYD($UA8W)O*2`M(&AO;&1S(&$@<V5CG
XM;VYD('9I(&-O;6UA;F0@<W1R:6YG('1O(&)E(&5X96-U=&5D(&QA=&5R"B(*%
XM<V5T(')E;6%P"G-E="!N;VUA9VEC"G-E="!N;W1E<G-E"G-E="!W<F%P<V-AR
XM;@HB"B(]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T].
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]"B(@9R`M(&=O(')U;G,@=&AE('=HV
XM;VQE('-H;W<*(B`@("`@("`@22`M(&EN:71I86QI<V4*(B`@("`@("`@3"`MS
XM('1H96X@;&]O<"!F;W)E=F5R"FUA<"!G("`@24P*(@HB/3T]/3T]/3T]/3T]Z
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/0HB($D@+2!I;FET:6%L:7-E(&5V97)Y=&AI;F<@8F5F;W)E(')U7
XM;FYI;F<@=&AE(&QO;W`*(B`@($<D/RY>32`M(&9I;F0@=&AE(&QA<W0@+B!I^
XM;B!T:&4@;6%Z90HB("`@("`@("!>("T@<F5P;&%C92!I="!W:71H(&%N(%@@/
XM*'1H92!G;V%L*0HB("`@1UE+9410("T@<')I;G0@=&AE('-T871E('1A8FQEI
XM(&%N9"!N97AT(&-H87(@=&%B;&4@870@=&AE(&5N9"!O9B!T:&4@9FEL90HB'
XM("`@("`@(#!3("T@:6YI=&EA;&ES92!T:&4@<W1A=&4@;V8@=&AE(&UA8VAI5
XM;F4@=&\@13$*(B`@("`@(#)';"`M(&UO=F4@=&\@=&AE('1O<"!L969T(&-EK
XM;&P@;V8@=&AE(&UA>F4*;6%P($D@("!')#\N#5Y'64ME1%`P4S)';`HB"B(]P
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]/3T]/3T]/3T]"B(@3"`M('1H92!L;V]P('=H:6-H(&ES(&5X6
XM96-U=&5D(&9O<F5V97(*(B`@("`@("`@42`M('-A=F4@=&AE(&-U<G)E;G0@0
XM8VAA<F%C=&5R(&EN('1H92!#:&%R(')E9VES=&5R"B(@("`@("`@($$@+2!RT
XM97!L86-E('1H92!C=7)R96YT(&-H87)A8W1E<B!W:71H(&%N("=/)PHB("`@/
XM("`@(&UA("T@;6%R:R!T:&4@8W5R<F5N="!P;W-I=&EO;B!W:71H(&UA<FL@&
XM)V$G"B(@("`@("!'3D(@+2!O;B!B;W1T;VT@;&EN92P@8W)E871E(&$@8V]M9
XM;6%N9"!T;R!S96%R8V@@=&AE($YE>'1#:&%R('1A8FQE"B(@("`@("`@("`@K
XM("!F;W(@=&AE(&-U<G)E;G0@<W1A=&4*(B`P33!%0&U>32`M('EA;FL@=&AEC
XM(&-O;6UA;F0@:6YT;R!T:&4@36%C<F\@<F5G:7-T97(@86YD(&5X96-U=&4@7
XM:70*(B`@("`@("!W6"`M('=E(&AA=F4@;F]W(&9O=6YD('1H92!E;G1R>2!IQ
XM;B!T:&4@=&%B;&4L(&YO=R!Y86YK('1H90HB("`@("`@("`@("`@9F]L;&]W*
XM:6YG('=O<F0@:6YT;R!T:&4@36%C<F\@<F5G:7-T97(*(B`@("`@8&%`;2`MS
XM(&=O(&)A8VL@=&\@=&AE(&-U<G)E;G0@<&]S:71I;VX@86YD(&5X96-U=&4@)
XM=&AE(&UA8W)O+"!T:&ES('=I;&P*(B`@("`@("`@("`@('EA;FL@=&AE($YEB
XM>'1#:&%R(&EN(')E9VES=&5R(&X*(B`@($=4)$(D4B`M(&]N(&)O='1O;2!L"
XM:6YE+"!C<F5A=&4@82!C;VUM86YD('1O('-E87)C:"!T:&4@<W1A=&4@=&%B.
XM;&4*(B`@("`@("`@("`@(&9O<B!T:&4@8W5R<F5N="!S=&%T92!A;F0@3F5XG
XM=$-H87(*(B`P33!%0&U>32`M('EA;FL@=&AE(&-O;6UA;F0@:6YT;R!T:&4@C
XM36%C<F\@<F5G:7-T97(@86YD(&5X96-U=&4@:70*(B`@("`@(#)74R`M('=EK
XM(&AA=F4@;F]W(&9O=6YD('1H92!E;G1R>2!I;B!T:&4@=&%B;&4L(&YO=R!Y@
XM86YK('1H90HB("`@("`@("`@("`@;F5X="!S=&%T92!I;G1O('1H92!3=&%T^
XM92!M86-R;PHB("`@("`@(&)8("T@86YD('EA;FL@=&AE(&%C=&EO;B!C;W)RE
XM97-P;VYD:6YG('1O('1H:7,@<W1A=&4@=&%B;&4@96YT<GD*(B`@("`@("`@)
XM("`@(&EN=&\@=&AE($UA8W)O(')E9VES=&5R"B(@("`@("!'5DH@+2!O;B!B1
XM;W1T;VT@;&EN92P@8W)E871E(&$@8V]M;6%N9"!T;R!R97-T;W)E('1H92!C&
XM=7)R96YT(&-H87)A8W1E<@HB("`@("`@(#!(("T@86YD('-A=F4@=&AE(&-OS
XM;6UA;F0@:6YT;R!T:&4@<V5C;VYD($UA8W)O(')E9VES=&5R"B(@("`@(&!A(
XM0'(@+2!G;R!B86-K('1O('1H92!C=7)R96YT('!O<VET:6]N(&%N9"!E>&5C:
XM='5T92!T:&4@;6%C<F\@=&\@<F5S=&]R90HB("`@("`@("`@("`@=&AE(&-UA
XM<G)E;G0@8VAA<F%C=&5R"B(@("`@("`@0&T@+2!E>&5C=71E('1H92!A8W1IS
XM;VX@87-S;V-I871E9"!W:71H('1H:7,@<W1A=&4*(B`@("`@("`@52`M(&%N/
XM9"!R97!E870*;6%P($P@("!106UA1TY",$TP14!M#7=88&%`;4=4)$(D4C!-M
XM,$5`;0TR5U-B6$=62C!(8&%`<D!M50HB"B(]/3T]/3T]/3T]/3T]/3T]/3T]X
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM"B(@52`M(&YO('1A:6P@<F5C=7)S:6]N(&%L;&]W960@:6X@=FD@;6%C<F]S2
XM('-O(&-H96%T(&%N9"!S970@52`]($P*;6%P(%4@("!,"B(*(CT]/3T]/3T]-
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]/3T*(B!3("T@>6%N:R!T:&4@;F5X="!T=V\@8VAA<F%C=&5RE
XM<R!I;G1O('1H92!3=&%T92!R96=I<W1E<@IM87`@4R`@(")S>3)L"B(*(CT]M
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]/3T]/3T]/3T*(B!1("T@<V%V92!T:&4@8W5R<F5N="!C:&%R(
XM86-T97(@:6X@=&AE($-H87(@<F5G:7-T97(*;6%P(%$@("`B8WEL"B(*(CT]?
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]/3T]/3T]/3T*(B!!("T@<F5P;&%C92!T:&4@8W5R<F5N="!CJ
XM:&%R86-T97(@=VET:"!A;B`G3R<*;6%P($$@("!R3PHB"B(]/3T]/3T]/3T]6
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]"B(@3B`M(')E<&QA8V4@=&AI<R!L:6YE('=I=&@@=&AE('-TL
XM<FEN9R`G;B<*;6%P($X@("!#+VX;"B(*(CT]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T*&
XM(B!"("T@<'5T('1H92!C=7)R96YT('-T871E"FUA<"!"("`@(G-P"B(*(CT]P
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]/3T]/3T]/3T*(B!-("T@>6%N:R!T:&ES(&QI;F4@:6YT;R!T4
XM:&4@36%C<F\@<F5G:7-T97(*;6%P($T@("`B;7DD"B(*(CT]/3T]/3T]/3T]<
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T*(B!%("T@9&5L971E('1O('1H92!E;F0@;V8@=&AE(&QI;F4*\
XM;6%P($4@("!D)`HB"B(]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]&
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]"B(@6"`M('EA;FL@!
XM=&AI<R!W;W)D(&EN=&\@=&AE($UA8W)O(')E9VES=&5R"FUA<"!8("`@(FUY.
XM="`*(@HB/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]W
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/0HB(%0@+2!R97!L86-E('1H:7,@6
XM;&EN92!W:71H('1H92!S=')I;F<@)W,G"FUA<"!4("`@0R]S&PHB"B(]/3T]E
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]/3T]/3T]"B(@4B`M('!U="!.97AT0VAA<@IM87`@4B`@(")N>
XM<`HB"B(]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]0
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]"B(@5B`M(&%D9"!T:&4@;&5T=&5R!
XM("=R)R`H=&AE(')E<&QA8V4@=FD@8V]M;6%N9"D*;6%P(%8@("!A<AL*(@HBP
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]/3T]/3T]/3T]/0HB($H@+2!R97-T;W)E('1H92!C=7)R96YT2
XM(&-H87)A8W1E<@IM87`@2B`@(")C<`HB"B(]/3T]/3T]/3T]/3T]/3T]/3T]S
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM"B(@2"`M('EA;FL@=&AI<R!L:6YE(&EN=&\@=&AE('-E8V]N9"!-86-R;R!R/
XM96=I<W1E<@IM87`@2"`@(")R>20*(@HB/3T]/3T]/3T]/3T]/3T]/3T]/3T]-
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/0HBK
XM($8@+2!Y86YK($YE>'1#:&%R("AT:&ES(&UA8W)O(&ES(&-A;&QE9"!F<F]M*
XM('1H92!-86-R;R!R96=I<W1E<BD*;6%P($8@("`B;GEL"B(*(CT]/3T]/3T]D
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]/3T]/3T]/3T*(B!>("T@<F5P;&%C92!T:&4@8W5R<F5N="!C:&%R86-T,
XM97(@=VET:"!A;B`G6"<*;6%P(%X@("!R6`HB"B(]/3T]/3T]/3T]/3T]/3T]`
XM/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]Y
XM/3T]"B(@64ME1%`@+2!C<F5A=&4@=&AE('-T871E('1A8FQE+"!.97AT0VAA"
XM<B!T86)L92!A;F0@:6YI=&EA;"!S=&%T90HB($YO=&4@=&AA="!Y;W4@:&%V'
XM92!T;R!E<V-A<&4@=&AE(&)A<B!C:&%R86-T97(L('-I;F-E(&ET(&ES('-P6
XM96-I86P@=&\*(B!T:&4@;6%P(&-O;6UA;F0@*&ET(&EN9&EC871E<R!A(&YE8
XM=R!L:6YE*2X*;6%P(%D@("!O<T4Q("!K("!.,2`@("`@("!S13%?(&UM($4RR
XM("`@("`@('-%,A9\(&UM(%,Q("`@("`@('-%,BX@;&P@13$;"FUA<"!+("`@N
XM;W-7,2`@:B`@4S$@("`@("`@<U<Q7R!M;2!7,B`@("`@("!S5S(6?"!M;2!.+
XM,2`@("`@("!S5S(N(&AH(%<Q&PIM87`@92`@(&]S3C$N(&AH(%<Q("`@("`@"
XM('-.,19\(&UM($XR("`@("`@('-.,B`@:R`@3C$@("`@("`@<TXR7R!M;2!%,
XM,1L*;6%P($0@("!O<U,Q+B!L;"!%,2`@("`@("!S4S$6?"!M;2!3,B`@("`@B
XM("!S4S(@(&H@(%,Q("`@("`@('-3,E\@;6T@5S$;"FUA<"!0("`@;VY%,2!K0
XM1B!N13(@;$8@;E<Q($<D2D8@;E<R(&A&(&Y.,2!H1B!N3C(@:T8@;E,Q(&Q&1
X/(&Y3,B!')$I&(`U%,1L*V
X``
Xend
Xsize 12165
END_OF_FILE
if test 17071 -ne `wc -c <'vim/macros/maze/maze.mac.uue'`; then
echo shar: \"'vim/macros/maze/maze.mac.uue'\" unpacked with wrong size!
fi
# end of 'vim/macros/maze/maze.mac.uue'
fi
if test -f 'vim/src/buffers.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/buffers.c'\"
else
echo shar: Extracting \"'vim/src/buffers.c'\" \(17483 characters\)
sed "s/^X//" >'vim/src/buffers.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * buffers.c
X *
X * manipulations with redo buffer and stuff buffer


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X
X

X/*
X * structure used to store one block of the stuff/redo/macro buffers
X */
Xstruct bufblock
X{
X struct bufblock *b_next; /* pointer to next bufblock */
X u_char b_str[1]; /* contents (actually longer) */
X};
X
X#define MINIMAL_SIZE 20 /* minimal size for b_str */
X
X/*
X * header used for the stuff buffer and the redo buffer
X */
Xstruct buffheader
X{
X struct bufblock bh_first; /* first (dummy) block of list */
X struct bufblock *bh_curr; /* bufblock for appending */
X int bh_index; /* index for reading */
X int bh_space; /* space in bh_curr for appending */
X};
X
Xstatic struct buffheader stuffbuff = {{NULL, {NUL}}, NULL, 0, 0};
Xstatic struct buffheader redobuff = {{NULL, {NUL}}, NULL, 0, 0};
Xstatic struct buffheader recordbuff = {{NULL, {NUL}}, NULL, 0, 0};
X
X /*
X * when block_redo is TRUE redo buffer will not be changed
X * used by edit() to repeat insertions and 'V' command for redoing
X */
Xstatic int block_redo = FALSE;
X
Xstruct mapblock
X{
X struct mapblock *m_next; /* next mapblock */
X char *m_keys; /* mapped from */
X char *m_str; /* mapped to */
X int m_mode; /* valid mode */
X int m_noremap; /* no re-mapping for this one */
X};
X
X/* variables used by vgetorpeek() and flush_buffers */
X#define MAXMAPLEN 10 /* maximum length of key sequence to be mapped */
Xstatic char typeahead[MAXMAPLEN + 2];
Xstatic int typelen = 0; /* number of characters in typeahead[] */
Xstatic char *mapstr = NULL; /* mapped characters */
Xstatic int maplen = 0; /* number of characters in mapstr */
X
Xstatic void free_buff __ARGS((struct buffheader *));
Xstatic void add_buff __ARGS((struct buffheader *, char *));
Xstatic void add_num_buff __ARGS((struct buffheader *, long));
Xstatic u_char read_stuff __ARGS((int));
Xstatic int start_stuff __ARGS((void));
Xstatic int read_redo __ARGS((int));
Xstatic u_char vgetorpeek __ARGS((int));
Xstatic void showmap __ARGS((struct mapblock *));
X
X/*
X * free and clear a buffer


X */
X static void

Xfree_buff(buf)
X struct buffheader *buf;
X{
X register struct bufblock *p, *np;
X
X for (p = buf->bh_first.b_next; p != NULL; p = np)
X {
X np = p->b_next;
X free((char *)p);
X }
X buf->bh_first.b_next = NULL;
X}
X
X/*
X * return the contents of a buffer as a single string
X */
X u_char *
Xget_bufcont(buffer)
X struct buffheader *buffer;
X{
X unsigned count = 0;
X u_char *p = NULL;
X struct bufblock *bp;
X
X/* compute the total length of the string */
X for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next)
X count += strlen((char *)bp->b_str);
X
X if (count != 0 && (p = (u_char *)alloc(count + 1)) != NULL)


X {
X *p = NUL;

X for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next)
X strcat((char *)p, (char *)bp->b_str);
X }
X return (p);
X}
X
X/*
X * return the contents of the record buffer as a single string
X * and clear the record buffer
X */
X u_char *
Xget_recorded()
X{
X u_char *p;
X
X p = get_bufcont(&recordbuff);
X free_buff(&recordbuff);
X return (p);
X}
X
X/*
X * return the contents of the redo buffer as a single string
X */
X u_char *
Xget_inserted()
X{
X return(get_bufcont(&redobuff));
X}
X
X/*
X * add string "s" after the current block of buffer "buf"


X */
X static void

Xadd_buff(buf, s)
X register struct buffheader *buf;
X char *s;
X{
X struct bufblock *p;
X int n;
X int len;
X
X if ((n = strlen(s)) == 0) /* don't add empty strings */
X return;
X
X if (buf->bh_first.b_next == NULL) /* first add to list */
X {
X buf->bh_space = 0;
X buf->bh_curr = &(buf->bh_first);
X }
X else if (buf->bh_curr == NULL) /* buffer has already been read */
X {
X emsg("Add to read buffer");
X return;
X }
X else if (buf->bh_index != 0)
X strcpy((char *)buf->bh_first.b_next->b_str, (char *)buf->bh_first.b_next->b_str + buf->bh_index);
X buf->bh_index = 0;
X
X if (buf->bh_space >= n)
X {
X strcat((char *)buf->bh_curr->b_str, s);
X buf->bh_space -= n;
X }
X else
X {
X if (n < MINIMAL_SIZE)
X len = MINIMAL_SIZE;
X else
X len = n;
X p = (struct bufblock *)alloc((unsigned)(sizeof(struct bufblock) + len));
X if (p == NULL)
X return; /* no space, just forget it */
X buf->bh_space = len - n;
X strcpy((char *)p->b_str, s);
X
X p->b_next = buf->bh_curr->b_next;
X buf->bh_curr->b_next = p;
X buf->bh_curr = p;
X }
X return;
X}
X
X static void
Xadd_num_buff(buf, n)
X struct buffheader *buf;
X long n;
X{
X char number[32];
X
X sprintf(number, "%ld", n);
X add_buff(buf, number);
X}
X
X/*
X * get one character from the stuff buffer
X * If advance == TRUE go to the next char.
X */
X static u_char
Xread_stuff(advance)
X int advance;
X{
X register u_char c;
X register struct bufblock *curr;
X
X
X if (stuffbuff.bh_first.b_next == NULL) /* buffer is empty */
X return NUL;
X
X curr = stuffbuff.bh_first.b_next;
X c = curr->b_str[stuffbuff.bh_index];
X
X if (advance)
X {
X if (curr->b_str[++stuffbuff.bh_index] == NUL)
X {
X stuffbuff.bh_first.b_next = curr->b_next;
X free((char *)curr);
X stuffbuff.bh_index = 0;
X }
X }
X return c;
X}
X
X/*
X * prepare stuff buffer for reading (if it contains something)


X */
X static int

Xstart_stuff()
X{
X if (stuffbuff.bh_first.b_next == NULL)
X return FALSE;
X stuffbuff.bh_curr = &(stuffbuff.bh_first);
X stuffbuff.bh_space = 0;


X return TRUE;
X}
X

X/*
X * check if the stuff buffer is empty
X */
X int
Xstuff_empty()
X{
X if (stuffbuff.bh_first.b_next == NULL)
X return TRUE;


X return FALSE;
X}
X

X/*
X * remove all typeahead characters (used in case of an error).
X */
X void
Xflush_buffers()
X{
X start_stuff();
X while (read_stuff(TRUE) != NUL)
X ;
X typelen = 0;
X maplen = 0;
X if (mapstr)
X *mapstr = 0;
X}
X
X void
XResetBuffers()
X{
X if (!block_redo)
X free_buff(&redobuff);
X}
X
X void
XAppendToRedobuff(s)
X char *s;
X{
X if (!block_redo)
X add_buff(&redobuff, s);
X}
X
X void
XAppendNumberToRedobuff(n)
X long n;
X{
X if (!block_redo)
X add_num_buff(&redobuff, n);
X}
X
X void
XstuffReadbuff(s)
X char *s;
X{
X add_buff(&stuffbuff, s);
X}
X
X void
XstuffnumReadbuff(n)
X long n;
X{
X add_num_buff(&stuffbuff, n);
X}
X
X/*
X * Read a character from the redo buffer.
X * The redo buffer is left as it is.


X */
X static int

Xread_redo(init)
X int init;
X{
X static struct bufblock *bp;
X static u_char *p;
X int c;
X
X if (init)
X {
X if ((bp = redobuff.bh_first.b_next) == NULL)
X return TRUE;
X p = bp->b_str;
X return FALSE;
X }
X if ((c = *p) != NUL)
X {
X if (*++p == NUL && bp->b_next != NULL)
X {
X bp = bp->b_next;
X p = bp->b_str;
X }
X }
X return c;
X}
X
X/*
X * copy the rest of the redo buffer into the stuff buffer (could be done faster)
X */
X void
Xcopy_redo()


X{
X register int c;

X
X while ((c = read_redo(FALSE)) != NUL)
X stuffReadbuff(mkstr(c));
X}
X
Xextern int redo_Quote_busy; /* this is in normal.c */
X
X/*
X * Stuff the redo buffer into the stuffbuff.
X * Insert the redo count into the command.
X */
X int
Xstart_redo(count)
X long count;
X{
X register int c;
X
X if (read_redo(TRUE)) /* init the pointers; return if nothing to redo */
X return FALSE;
X
X c = read_redo(FALSE);
X
X/* copy the buffer name, if present */
X if (c == '"')
X {
X add_buff(&stuffbuff, "\"");
X c = read_redo(FALSE);
X
X /* if a numbered buffer is used, increment the number */
X if (c >= '1' && c < '9')
X ++c;
X add_buff(&stuffbuff, mkstr(c));
X c = read_redo(FALSE);
X }
X
X if (c == 'q') /* redo Quoting */
X {
X Quote = Curpos;
X redo_Quote_busy = TRUE;
X c = read_redo(FALSE);
X }
X
X/* try to enter the count (in place of a previous count) */
X if (count)
X {
X while (isdigit(c)) /* skip "old" count */
X c = read_redo(FALSE);
X add_num_buff(&stuffbuff, count);
X }
X
X/* copy from the redo buffer into the stuff buffer */
X add_buff(&stuffbuff, mkstr(c));
X copy_redo();


X return TRUE;
X}
X

X/*
X * Repeat the last insert (R, o, O, a, A, i or I command) by stuffing the redo buffer
X * into the stuffbuff.
X */
X int
Xstart_redo_ins()
X{
X register u_char c;
X
X if (read_redo(TRUE))
X return FALSE;
X start_stuff();
X
X/* skip the count and the command character */
X while ((c = read_redo(FALSE)) != NUL)
X {
X c = toupper(c);
X if (strchr("AIRO", c) != NULL)
X {
X if (c == 'O')
X stuffReadbuff(NL_STR);


X break;
X }
X }
X

X/* copy the typed text from the redo buffer into the stuff buffer */
X copy_redo();
X block_redo = TRUE;


X return TRUE;
X}
X
X void

Xset_redo_ins()
X{
X block_redo = TRUE;
X}
X
X void
Xstop_redo_ins()
X{
X block_redo = FALSE;
X}
X
Xstruct mapblock maplist = {NULL, NULL, NULL}; /* first dummy entry in maplist */
X
X/*
X * insert a string in front of the map-buffer (for '@' command and vgetorpeek)
X */
X int
Xins_mapbuf(str)
X char *str;
X{
X register char *s;
X register int newlen;
X
X newlen = maplen + strlen(str) + 1;
X if (newlen < 0) /* string is getting too long */
X {
X emsg(e_toocompl); /* also calls flush_buffers */
X setcursor();
X return -1;
X }
X s = alloc(newlen);


X if (s == NULL)

X return -1;
X strcpy(s, str);
X if (mapstr)
X {
X strcat(s, mapstr);
X free(mapstr);
X }
X mapstr = s;
X maplen = strlen(mapstr);


X return 0;
X}
X

Xextern int arrow_used; /* this is in edit.c */
X
X/*
X * get a character: 1. from the stuffbuffer
X * 2. from the user
X *
X * KeyTyped is set to TRUE in the case the user typed the key.
X * If advance is TRUE, we really get the character. Otherwise we just look
X * whether there is a character available.
X */
X static u_char
Xvgetorpeek(advance)
X int advance;


X{
X register int c;

X int n = 0; /* init for GCC */
X char *str;
X int len;
X struct mapblock *mp;
X int mode = State;
X static int nomapping = 0; /* number of characters that should
X not be mapped */
X int timedout = FALSE; /* waited for more than 1 second
X for mapping to complete */
X int mapdepth = 0; /* check for recursive mapping */
X
X if (mode == REPLACE || mode == CMDLINE)
X mode = INSERT; /* treat replace mode just like insert mode */
X else if (mode == NORMAL_BUSY)
X mode = NORMAL;
X
X start_stuff();
X do
X {
X c = read_stuff(advance);
X if (c != NUL)
X KeyTyped = FALSE;


X else
X {
X /*

X * Loop until we either find a matching mapped key, or we
X * are sure that it is not a mapped key.
X * We do this first for mapstr and then for typeahead.
X * If a mapped key sequence is found we go back to mapstr to
X * try re-mapping.
X */
X if (maplen) /* first try mapstr */
X {
X str = mapstr;
X len = maplen;
X }
X else /* no mapped chars, try typeahead[] */
X {
X str = typeahead;
X len = typelen;
X }
X
X for (;;) /* loop until we got a character */
X {
X breakcheck(); /* check for CTRL-C */
X if (got_int)
X {
X typelen = 0; /* flush all typeahead */
X maplen = 0;
X len = 0;
X }
X else if (len > 0) /* see if we have a mapped key sequence */
X {
X /*
X * walk through the maplist until we find an
X * entry that matches (if not timed out).
X */
X mp = NULL;
X if (!timedout && (str != mapstr || (p_remap && nomapping == 0)))
X {
X for (mp = maplist.m_next; mp; mp = mp->m_next)
X {
X if (mp->m_mode != mode)
X continue;
X n = strlen(mp->m_keys);
X if (!strncmp(mp->m_keys, str, (size_t)(n > len ? len : n)))
X break;
X }
X }
X if (mp == NULL || (str == mapstr && n > len))
X { /* no match found */
X c = str[0] & 255;
X if (str == mapstr)
X KeyTyped = FALSE;
X else
X KeyTyped = TRUE;
X if (advance)
X {
X strncpy(&str[0], &str[1], (size_t)len);
X if (str == mapstr)
X --maplen;
X else
X --typelen;
X if (nomapping)
X --nomapping;
X }
X break;
X }
X if (n <= len) /* complete match */
X {
X /* remove the mapped keys */
X len -= n;
X strncpy(&str[0], &str[n], (size_t)(len + 1));
X if (str == mapstr)
X maplen = len;
X else
X typelen = len;
X
X /*
X * Put the replacement string in front of mapstr.
X * The depth check catches ":map x y" and ":map y x".
X */
X if (++mapdepth == 1000)
X {
X emsg("recursive mapping");
X setcursor();
X maplen = 0;
X c = -1;
X break;
X }
X if (ins_mapbuf(mp->m_str) < 0)
X {
X c = -1;
X break;
X }
X if (mp->m_noremap)
X nomapping += strlen(mp->m_str);
X str = mapstr;
X len = maplen;
X continue;
X }
X }
X /* inchar() will reset got_int */
X c = inchar(!advance, len == 0 || !p_timeout);
X if (c <= NUL || !advance) /* no character available or async */
X {
X if (!advance)
X break;
X if (len) /* timed out */
X {
X timedout = TRUE;
X continue;
X }
X }
X else
X {
X typeahead[typelen++] = c;
X updatescript(c);
X if (Recording)
X add_buff(&recordbuff, mkstr(c));
X
X /* do not sync in insert mode, unless cursor key has
X * been used */
X if (mode != INSERT || arrow_used)
X u_sync();
X }
X len = typelen;
X str = typeahead;
X }
X }
X } while (c < 0 || (advance && c == NUL));
X /* if advance is FALSE don't loop on NULs */
X
X return (u_char) c;
X}
X
X u_char
Xvgetc()
X{
X return (vgetorpeek(TRUE));
X}
X
X u_char
Xvpeekc()
X{
X return (vgetorpeek(FALSE));
X}
X
X/*
X * unmap[!] {lhs} : remove key mapping for {lhs}
X * map[!] : show all key mappings
X * map[!] {lhs} : show key mapping for {lhs}
X * map[!] {lhs} {rhs} : set key mapping for {lhs} to {rhs}
X * noremap[!] {lhs} {rhs} : same, but no remapping for {rhs}
X *
X * maptype == 1 for unmap command, 2 for noremap command.
X * arg is pointer to any arguments.
X * mode is INSERT if [!] is present.
X *
X * Return 0 for success
X * 1 for invalid arguments
X * 2 for no match
X * 3 for ambiguety
X * 4 for out of mem
X */
X int
Xdomap(maptype, keys, mode)
X int maptype;
X char *keys;
X int mode;
X{
X struct mapblock *mp, *mprev;
X char *arg;
X char *p;
X int n = 0; /* init for GCC */
X int len = 0; /* init for GCC */
X char *newstr;
X int hasarg;
X
X/*
X * find end of keys and remove CTRL-Vs in it
X */
X p = keys;
X while (*p && *p != ' ' && *p != '\t')
X {
X if (*p == Ctrl('V') && p[1] != NUL)
X strcpy(p, p + 1); /* remove CTRL-V */
X ++p;


X }
X if (*p != NUL)

X *p++ = NUL;
X skipspace(&p);

X hasarg = (*p != NUL);
X arg = p;
X/*
X * remove CTRL-Vs from argument
X */
X while (*p)
X {
X if (*p == Ctrl('V') && p[1] != NUL)
X strcpy(p, p + 1); /* remove CTRL-V */
X ++p;
X }
X
X/*
X * check arguments and translate function keys
X */
X if (*keys != NUL)
X {
X if (maptype == 1 && hasarg) /* unmap has no arguments */
X return 1;
X if (*keys == '#' && isdigit(*(keys + 1))) /* function key */
X {
X if (*++keys == '0')
X *(u_char *)keys = K_F10;
X else
X *keys += K_F1 - '1';
X }
X len = strlen(keys);
X if (len > MAXMAPLEN) /* maximum lenght of 10 chars */
X return 2;
X }
X
X/*
X * Find an entry in the maplist that matches.
X */
X#ifdef AMIGA
X if (*keys == NUL || (maptype != 1 && !hasarg))


X settmode(0); /* set cooked mode so output can be halted */
X#endif

X for (mp = maplist.m_next, mprev = &maplist; mp; mprev = mp, mp = mp->m_next)
X {
X if (mp->m_mode != mode)
X continue;
X n = strlen(mp->m_keys);
X if (*keys == NUL)
X showmap(mp);
X else if (!strncmp(mp->m_keys, keys, (size_t)(n < len ? n : len)))
X {
X if (maptype != 1 && !hasarg)
X showmap(mp);
X else
X break;
X }
X }
X if (*keys == NUL || (maptype != 1 && !hasarg))
X {


X#ifdef AMIGA
X settmode(1);
X#endif
X wait_return(TRUE);

X return 0; /* listing finished */
X }
X
X if (mp == NULL) /* new entry or nothing to remove */
X {
X if (maptype == 1)
X return 2; /* no match */
X
X /* allocate a new entry for the maplist */
X mp = (struct mapblock *)alloc((unsigned)sizeof(struct mapblock));
X if (mp == NULL)
X return 4; /* no mem */
X mp->m_keys = strsave(keys);
X mp->m_str = strsave(arg);
X if (mp->m_keys == NULL || mp->m_str == NULL)
X {
X free(mp->m_keys);
X free(mp->m_str);
X free(mp);
X return 4; /* no mem */
X }
X mp->m_noremap = maptype;
X
X /* add the new entry in front of the maplist */
X mp->m_next = maplist.m_next;
X mp->m_mode = mode;
X maplist.m_next = mp;
X return 0; /* added OK */
X }
X if (n != len)
X return 3; /* ambigious */
X
X if (maptype == 1)
X {
X free(mp->m_keys);
X free(mp->m_str);
X mprev->m_next = mp->m_next;
X free(mp);
X return 0; /* removed OK */
X }
X
X/*
X * replace existing entry
X */
X newstr = strsave(arg);
X if (newstr == NULL)
X return 4; /* no mem */
X free(mp->m_str);
X mp->m_str = newstr;
X mp->m_noremap = maptype;
X
X return 0; /* replaced OK */


X}
X
X static void

Xshowmap(mp)
X struct mapblock *mp;
X{
X int len;
X
X len = outtrans(mp->m_keys, -1); /* get length of what we have written */
X while (len < MAXMAPLEN)
X {
X outchar(' '); /* padd with blanks */
X ++len;
X }
X if (mp->m_noremap)
X outchar('*');
X else
X outchar(' ');
X outtrans(mp->m_str, -1);
X outchar('\n');


X flushbuf();
X}
X
X/*

X * Write map commands for the current mapping to an .exrc file.


X * Return 1 on error.
X */
X int

Xmakemap(fd)
X FILE *fd;
X{
X struct mapblock *mp;
X
X for (mp = maplist.m_next; mp; mp = mp->m_next)
X {
X if (fprintf(fd, "map%c %s %s\n", mp->m_mode == INSERT ? '!' : ' ',
X mp->m_keys, mp->m_str) < 0)


X return 1;
X }
X return 0;
X}

END_OF_FILE
if test 17483 -ne `wc -c <'vim/src/buffers.c'`; then
echo shar: \"'vim/src/buffers.c'\" unpacked with wrong size!
fi
# end of 'vim/src/buffers.c'
fi
if test -f 'vim/src/fileio.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/fileio.c'\"
else
echo shar: Extracting \"'vim/src/fileio.c'\" \(17623 characters\)
sed "s/^X//" >'vim/src/fileio.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * fileio.c: read from and write to a file
X */
X
X/*
X * special feature of this version: NUL characters in the file are
X * replaced by newline characters in memory. This allows us to edit
X * binary files!


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"

X#include "fcntl.h"
X
X#ifdef LATTICE
X# include <proto/dos.h> /* for Lock() and UnLock() */
X#endif
X
X#define BUFSIZE 4096
Xstatic void do_mlines __ARGS((void));
X
X void
Xfilemess(name, s)
X char *name;
X char *s;
X{
X smsg("\"%s\" %s", ((name == NULL) ? "" : name), s);
X}
X
X/*
X * Read lines from file 'fname' into the buffer after line 'from'.
X *
X * 1. We allocate blocks with m_blockalloc, as big as possible.
X * 2. Each block is filled with characters from the file with a single read().
X * 3. The lines are inserted in the buffer with appendline().
X *
X * (caller must check that fname != NULL)
X */
X int
Xreadfile(fname, from, newfile)
X char *fname;
X linenr_t from;
X int newfile;
X{
X#ifdef UNIX
X int fd = -1;
X#else
X int fd;
X#endif
X register u_char c;
X register linenr_t lnum = from;
X register u_char *ptr = NULL; /* pointer into read buffer */
X register u_char *buffer = NULL; /* read buffer */
X register long size;
X long filesize;
X#define UNKNOWN 0x0fffffff /* file size is unknown */
X linenr_t linecnt = line_count;
X int incomplete = FALSE; /* was the last line incomplete? */
X int error = 0; /* read errors encountered */
X long linerest = 0; /* remaining characters in line */
X long filerest; /* remaining characters in file */
X
X if (bufempty()) /* special case: buffer has no lines */
X linecnt = 0;
X
X if (
X#ifdef UNIX
X !(getperm(fname) & 0200) || /* root's way to check RO */
X#endif
X (fd = open(fname, O_RDWR)) == -1) /* cannot open r/w */
X {
X if ((fd = open(fname, O_RDONLY)) == -1) /* cannot open at all */
X {
X if (newfile)
X filemess(fname, "[New File]");
X
X#ifdef MSDOS /* the screen may be messed up by the "insert disk
X in drive b: and hit return" message */
X updateScreen(CLEAR);
X#endif
X return TRUE;
X }
X if (newfile) /* set file readonly */
X p_ro = TRUE;
X }
X else if (newfile && !readonlymode) /* set file not readonly */
X p_ro = FALSE;
X
X if (
X#ifdef MSDOS
X /* the CR characters disappear in read(), so the file lenght is wrong */
X p_tx == TRUE ||
X#endif
X (filesize = lseek(fd, 0L, 2)) < 0) /* get length of file */
X filesize = UNKNOWN;
X lseek(fd, 0L, 0);
X
X filemess(fname, "");
X
X for (filerest = filesize; !error && !got_int && filerest != 0; breakcheck())
X {
X /*
X * We allocate as much space for the file as we can get, plus
X * space for the old line, one NUL in front and one NUL at the tail.
X * The amount is limited by the fact that read() only can read
X * upto max_unsigned characters.
X * If we don't know the file size, just get one Kbyte.
X */
X if (filesize >= UNKNOWN)
X size = 1024;
X else if (filerest > 0xff00L)
X size = 0xff00L;
X else if (filerest < 10)
X size = 10;
X else
X size = filerest;
X
X for ( ; size >= 10; size /= 2)
X {
X if ((buffer = (u_char *)m_blockalloc((u_long)(size + linerest + 4), FALSE))
X != NULL)
X break;
X }


X if (buffer == NULL)
X {

X emsg(e_outofmem);
X error = 1;
X break;
X }
X buffer[0] = NUL; /* make sure there is a NUL in front of the first line */
X ++buffer;
X if (linerest) /* copy characters from the previous buffer */
X {
X ptr -= linerest;
X memmove((char *)buffer, (char *)ptr, linerest);
X memset((char *)ptr, 1, linerest); /* fill with non-NULs */
X ptr[linerest - 1] = NUL; /* add a NUL on the end */
X free_line((char *)ptr); /* free the space we don't use */
X }
X ptr = buffer + linerest;
X
X if ((size = (unsigned)read(fd, (char *)ptr, (size_t)size)) <= 0)
X {
X error = 2;
X break;
X }
X if (filesize >= UNKNOWN) /* if we don't know the file size */
X filesize += size; /* .. count the number of characters */
X else /* .. otherwise */
X filerest -= size; /* .. compute the remaining length */
X
X /*
X * This loop is executed once for every character read.
X * Keep it fast!
X */
X --ptr;
X while (++ptr, --size >= 0)
X {
X if ((c = *ptr) != NUL && c != NL) /* catch most common case */
X continue;


X if (c == NUL)

X *ptr = NL; /* NULs are replaced by newlines! */
X else
X {
X *ptr = NUL; /* end of line */
X if (!appendline(lnum, (char *)buffer))
X {
X error = 1;
X break;
X }
X ++lnum;
X buffer = ptr + 1;
X }
X }
X linerest = ptr - buffer;
X }
X if (error != 1 && linerest != 0)
X {
X /*
X * If we get EOF in the middle of a line, note the fact and
X * complete the line ourselves.
X */
X incomplete = TRUE;
X *ptr = NUL;
X if (!appendline(lnum, (char *)buffer))
X error = 1;
X }
X if (error == 2 && filesize >= UNKNOWN) /* no error, just EOF encountered */
X {
X filesize -= UNKNOWN;
X error = 0;
X }
X
X close(fd);
X
X#ifdef MSDOS /* the screen may be messed up by the "insert disk
X in drive b: and hit return" message */
X updateScreen(CLEAR);
X#endif


X
X if (got_int)
X {

X filemess(fname, e_interr);
X return FALSE; /* an interrupt isn't really an error */
X }
X
X linecnt = line_count - linecnt;
X smsg("\"%s\" %s%s%s%ld line%s, %ld character%s",
X fname,
X p_ro ? "[readonly] " : "",
X incomplete ? "[Incomplete last line] " : "",
X error ? "[READ ERRORS] " : "",
X (long)linecnt, plural((long)linecnt),
X filesize, plural(filesize));
X
X u_clearline(); /* cannot use "U" command after adding lines */
X
X if (newfile) /* edit a new file: read mode from lines */
X do_mlines();
X if (from < line_count)
X {
X Curpos.lnum = from + 1; /* put cursor at first new line */


X Curpos.col = 0;
X }
X

X return FALSE;
X}
X

X/*
X * writeit - write to file 'fname' lines 'start' through 'end'
X *
X * We do our own buffering here because fwrite() is so slow.
X *
X * If forceit is true, we don't care for errors when attempting backups (jw).
X * In case of an error everything possible is done to restore the original file.
X * But when forceit is TRUE, we risk loosing it.
X */
X int
Xwriteit(fname, start, end, append, forceit)
X char *fname;
X linenr_t start, end;
X int append;
X int forceit;
X{
X int fd;
X char *backup = NULL;
X register char *s;
X register u_char *ptr;
X register u_char c;
X register int len;
X register linenr_t lnum;
X long nchars;
X char *errmsg = NULL;
X char *buffer;
X long perm = -1; /* file permissions */
X int retval = TRUE;
X int newfile = FALSE; /* TRUE if file does not exist yet */
X#ifdef UNIX
X struct stat old;
X int made_writable = FALSE; /* 'w' bit has been set */
X#endif
X#ifdef AMIGA
X BPTR flock;
X#endif
X
X if (fname == NULL || *fname == NUL) /* safety check */
X return FALSE;
X
X /*
X * Disallow writing from .exrc and .vimrc in current directory for
X * security reasons.
X */
X if (secure)
X {
X secure = 2;
X emsg(e_curdir);


X return FALSE;
X }
X

X filemess(fname, ""); /* show that we are busy */
X
X buffer = alloc(BUFSIZE);


X if (buffer == NULL)

X return FALSE;
X
X#ifdef UNIX
X /* get information about original file (if there is one) */
X old.st_dev = old.st_ino = 0;
X if (stat(fname, &old))
X newfile = TRUE;
X else
X perm = old.st_mode;
X/*
X * If we are not appending, the file exists, and the 'writebackup' or
X * 'backup' option is set, try to make a backup copy of the file.
X */
X if (!append && perm >= 0 && (p_wb || p_bk) &&
X (fd = open(fname, O_RDONLY)) >= 0)
X {
X int bfd, buflen, wlen;
X char buf[BUFSIZE + 1], *wp;
X int some_error = FALSE;
X struct stat new;
X
X new.st_dev = new.st_ino = 0;
X
X /*
X * Unix semantics has it, that we may have a writable file,
X * that cannot be recreated with a simple open(..., O_CREATE, ) e.g:
X * - the directory is not writable,
X * - the file may be a symbolic link,
X * - the file may belong to another user/group, etc.
X *
X * For these reasons, the existing writable file must be truncated and
X * reused. Creation of a backup COPY will be attempted.
X */
X if ((backup = modname(fname, ".bak")) == NULL)
X {
X some_error = TRUE;
X goto nobackup;
X }
X stat(backup, &new);
X if (new.st_dev == old.st_dev && new.st_ino == old.st_ino)
X {
X /*
X * may happen when modname gave the same file back.
X * E.g. silly link, or filename-length reached.
X * If we don't check here, we either ruin the file when
X * copying or erase it after writing. jw.
X */
X errmsg = "Invalid backup file";
X free(backup);
X backup = NULL; /* there is no backup file to delete */
X goto nobackup;
X }
X remove(backup); /* remove old backup, if present */
X if ((bfd = open(backup, O_WRONLY | O_CREAT, 0666)) < 0)
X {
X char *home;
X
X /*
X * oops, no write/create permission here?
X * try again in p_bdir directory.
X */
X for (wp = fname + strlen(fname); wp >= fname; wp--)
X if (*wp == '/')
X break;
X ++wp;
X if (p_bdir[0] == '~' && p_bdir[1] == '/' &&
X (home = (char *)vimgetenv("HOME")) != NULL)
X sprintf(buf, "%s/%s/%s", home, p_bdir + 2, wp);
X else
X sprintf(buf, "%s/%s", p_bdir, wp);
X free(backup);
X if ((backup = modname(buf, ".bak")) == NULL)
X {
X some_error = TRUE;
X goto nobackup;
X }
X stat(backup, &new);
X if (new.st_dev == old.st_dev && new.st_ino == old.st_ino)
X {
X errmsg = "Invalid backup file";
X free(backup);
X backup = NULL; /* there is no backup file to delete */
X goto nobackup;
X }
X remove(backup);
X if ((bfd = open(backup, O_WRONLY | O_CREAT, 0666)) < 0)
X {
X free(backup);
X backup = NULL; /* there is no backup file to delete */
X errmsg = "Can't make backup file";
X goto nobackup;
X }
X }
X /* set file protection same as original file, but strip s-bit */
X setperm(backup, perm & 0777);
X
X /* copy the file. */
X while ((buflen = read(fd, buf, BUFSIZE)) > 0)
X {
X wp = buf;
X do
X {
X if ((wlen = write(bfd, wp, buflen)) <= 0)
X {
X errmsg = "Can't write to backup file";
X goto writeerr;
X }
X wp += wlen;
X buflen -= wlen;
X }
X while (buflen > 0);
X }
Xwriteerr:
X close(bfd);
X if (buflen < 0)
X errmsg = "Can't read file for backup";
Xnobackup:
X close(fd);
X /* ignore errors when forceit is TRUE */
X if ((some_error || errmsg) && !forceit)
X {
X retval = FALSE;
X goto fail;


X }
X errmsg = NULL;
X }

X /* if forceit and the file was read-only: make it writable */
X if (forceit && (old.st_uid == getuid()) && perm >= 0 && !(perm & 0200))
X {
X perm |= 0200;
X made_writable = TRUE;
X setperm(fname, perm);
X }
X#else /* UNIX */
X
X/*
X * If we are not appending, the file exists, and the 'writebackup' or
X * 'backup' option is set, make a backup.
X * Do not make any backup, if "writebackup" and "backup" are
X * both switched off. This helps when editing large files on
X * almost-full disks. (jw)
X */
X perm = getperm(fname);
X if (perm < 0)
X newfile = TRUE;
X if (!append && perm >= 0 && (p_wb || p_bk))
X {
X /*
X * Form the backup file name - change path/fo.o.h to path/fo.o.h.bak
X */
X backup = modname(fname, ".bak");
X if (backup == NULL)
X {
X if (!forceit)
X goto fail;


X }
X else
X {
X /*

X * Delete any existing backup and move the current version to the backup.
X * For safety, we don't remove the backup until the write has finished
X * successfully. And if the 'backup' option is set, leave it around.
X */
X#ifdef AMIGA
X /*
X * With MSDOS-compatible filesystems (crossdos, messydos) it is
X * possible that the name of the backup file is the same as the
X * original file. To avoid the chance of accidently deleting the
X * original file (horror!) we lock it during the remove.
X * This should not happen with ":w", because startscript() should
X * detect this problem and set thisfile_sn, causing modname to
X * return a correct ".bak" filename. This problem does exist with
X * ":w filename", but then the original file will be somewhere else
X * so the backup isn't really important. If autoscripting is off
X * the rename may fail.
X */
X flock = Lock((UBYTE *)fname, (long)ACCESS_READ);
X#endif
X remove(backup);
X#ifdef AMIGA
X if (flock)
X UnLock(flock);
X#endif
X len = rename(fname, backup);
X if (len != 0)
X {
X if (forceit)
X {
X free(backup); /* don't do the rename below */
X backup = NULL;
X }
X else
X {
X errmsg = "Can't make backup file";
X goto fail;
X }
X }
X }
X }
X#endif /* UNIX */
X
X /*
X * We may try to open the file twice: If we can't write to the
X * file and forceit is TRUE we delete the existing file and try to create
X * a new one. If this still fails we may have lost the original file!
X * (this may happen when the user reached his quotum for number of files).
X */
X while ((fd = open(fname, O_WRONLY | (append ? O_APPEND : (O_CREAT | O_TRUNC)), 0666)) < 0)
X {
X /*
X * A forced write will try to create a new file if the old one is
X * still readonly. This may also happen when the directory is
X * read-only. In that case the remove() will fail.
X */
X if (!errmsg)
X {
X errmsg = "Can't open file for writing";
X if (forceit)
X {
X#ifdef UNIX
X /* we write to the file, thus it should be marked
X writable after all */
X perm |= 0200;
X made_writable = TRUE;
X if (old.st_uid != getuid() || old.st_gid != getgid())
X perm &= 0777;
X#endif /* UNIX */
X remove(fname);
X continue;
X }
X }
X/*
X * If we failed to open the file, we don't need a backup. Throw it away.
X * If we moved or removed the original file try to put the backup in its place.
X */
X if (backup)
X {
X#ifdef UNIX


X struct stat st;
X

X /*
X * There is a small chance that we removed the original, try
X * to move the copy in its place.
X * This won't work if the backup is in another file system!
X * In that case we leave the copy around.
X */
X if (stat(fname, &st) < 0) /* file does not exist */
X rename(backup, fname); /* put the copy in its place */
X if (stat(fname, &st) >= 0) /* original file does exist */
X remove(backup); /* throw away the copy */
X#else
X rename(backup, fname); /* try to put the original file back */
X#endif
X }
X goto fail;


X }
X errmsg = NULL;
X

X len = 0;
X s = buffer;
X nchars = 0;
X for (lnum = start; lnum <= end; ++lnum)
X {
X /*
X * The next loop is done once for each character written.
X * Keep it fast!
X */
X ptr = (u_char *)nr2ptr(lnum) - 1;
X while ((c = *++ptr) != NUL)
X {
X if (c == NL)
X *s = NUL; /* replace newlines with NULs */
X else
X *s = c;
X ++s;
X if (++len != BUFSIZE)
X continue;
X if (write(fd, buffer, (size_t)BUFSIZE) == -1)
X {
X end = 0; /* write error: break loop */
X break;
X }
X nchars += BUFSIZE;
X s = buffer;


X len = 0;
X }

X *s = NL;
X ++s;
X if (++len == BUFSIZE)
X {
X if (write(fd, buffer, (size_t)BUFSIZE) == -1)
X end = 0; /* write error: break loop */
X nchars += BUFSIZE;
X s = buffer;
X len = 0;
X }
X }
X if (len)
X {
X if (write(fd, buffer, (size_t)len) == -1)
X end = 0; /* write error */
X nchars += len;
X }
X
X if (close(fd) != 0)
X {
X errmsg = "Close failed";
X goto fail;
X }
X#ifdef UNIX
X if (made_writable)
X perm &= ~0200; /* reset 'w' bit for security reasons */
X#endif
X if (perm >= 0)
X setperm(fname, perm); /* set permissions of new file same as old file */
X
X if (end == 0)
X {
X errmsg = "write error (file system full?)";
X goto fail;
X }
X
X#ifdef MSDOS /* the screen may be messed up by the "insert disk
X in drive b: and hit return" message */
X updateScreen(CLEAR);
X#endif
X
X lnum -= start; /* compute number of written lines */
X smsg("\"%s\"%s %ld line%s, %ld character%s",
X fname,
X newfile ? " [New File]" : " ",
X (long)lnum, plural((long)lnum),
X nchars, plural(nchars));
X if (start == 1 && end == line_count) /* when written everything */
X {
X UNCHANGED;
X startscript(); /* re-start auto script file */
X }
X
X /*
X * Remove the backup unless 'backup' option is set
X */
X if (!p_bk && backup != NULL && remove(backup) != 0)
X emsg("Can't delete backup file");
X
X goto nofail;
X
Xfail:
X#ifdef MSDOS /* the screen may be messed up by the "insert disk
X in drive b: and hit return" message */
X updateScreen(CLEAR);
X#endif
Xnofail:
X
X free((char *) backup);
X free(buffer);
X
X if (errmsg != NULL)
X {
X filemess(fname, errmsg);
X retval = FALSE;
X }
X return retval;
X}
X
X/*
X * do_mlines() - process mode lines for the current file
X *
X * Returns immediately if the "ml" parameter isn't set.
X */
Xstatic void chk_mline __ARGS((linenr_t));
X
X static void
Xdo_mlines()
X{
X linenr_t lnum;
X int nmlines;
X
X if ((nmlines = p_ml) == 0)
X return;
X
X for (lnum = 1; lnum <= line_count && lnum <= nmlines; ++lnum)
X chk_mline(lnum);
X
X for (lnum = line_count; lnum > 0 && lnum > nmlines &&
X lnum > line_count - nmlines; --lnum)
X chk_mline(lnum);
X}
X
X/*
X * chk_mline() - check a single line for a mode string


X */
X static void

Xchk_mline(lnum)
X linenr_t lnum;
X{
X register char *s;
X register char *e;
X char *cs; /* local copy of any modeline found */
X char prev;
X int end;
X
X prev = ' ';
X for (s = nr2ptr(lnum); *s != NUL; ++s)
X {
X if (isspace(prev) && (strncmp(s, "vi:", (size_t)3) == 0 || strncmp(s, "ex:", (size_t)3) == 0))
X {
X s += 3;
X end = FALSE;
X s = cs = strsave(s);
X if (cs == NULL)
X break;
X while (end == FALSE)
X {
X while (*s == ' ' || *s == TAB)
X ++s;


X if (*s == NUL)

X break;
X for (e = s; *e != ':' && *e != NUL; ++e)
X ;
X if (*e == NUL)
X end = TRUE;
X *e = NUL;
X doset(s);
X s = e + 1;
X }
X free(cs);
X break;
X }
X prev = *s;
X }
X}
END_OF_FILE
if test 17623 -ne `wc -c <'vim/src/fileio.c'`; then
echo shar: \"'vim/src/fileio.c'\" unpacked with wrong size!
fi
# end of 'vim/src/fileio.c'
fi
echo shar: End of archive 9 \(of 23\).
cp /dev/null ark9isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:32:49 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 10
Archive-name: vim/part10
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 10 (of 23)."
# Contents: vim/src/tags vim/src/term.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:10 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/tags' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/tags'\"
else
echo shar: Extracting \"'vim/src/tags'\" \(17914 characters\)
sed "s/^X//" >'vim/src/tags' <<'END_OF_FILE'
XAppendNumberToRedobuff buffers.c /^AppendNumberToRedobuff(n)$/
XAppendToRedobuff buffers.c /^AppendToRedobuff(s)$/
XChk_Abort amiga.c /^Chk_Abort()$/
XCtrl ascii.h /^#define Ctrl(x) ((x) & 0x1f)$/
XDoOneCmd cmdline.c /^DoOneCmd(buff)$/
XExpandOne cmdline.c /^ExpandOne(str, list_notfound, mode)$/
XExpandWildCards amiga.c /^ExpandWildCards(num_pat, pat, num_file, file, file/
XFAIL regexp.c /^#define FAIL(m) { emsg(m); return NULL; }$/
XFreeWild amiga.c /^FreeWild(num, file)$/
XFullName amiga.c /^FullName(fname, buf, len)$/
XGetChars amiga.c /^GetChars(buf, maxlen, type)$/
XINIT normal.c /^#define INIT(x) x$/
XISSPECIAL edit.c /^#define ISSPECIAL(c) ((c) < ' ' || (c) >= DEL)$/
XMP amiga.c /^#define MP(xx) ((struct MsgPort *)((struct FileHan/
XMaddcr addcr.c /^main(argc, argv)$/
XMagic regexp.c /^#define Magic(x) ((x)|('\\\\'<<8))$/
XMmain main.c /^main(argc, argv)$/
XMmkcmdtab mkcmdtab.c /^main(argc, argv)$/
XNEXT regexp.c /^#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&/
XOP regexp.c /^#define OP(p) (*(p))$/
XOPENDEBUG debug.h /^# define OPENDEBUG(file)\\$/
XOPERAND regexp.c /^#define OPERAND(p) ((p) + 3)$/
XOpencmd misccmds.c /^Opencmd(dir, redraw)$/
XPeekChr regexp.c /^#define PeekChr() curchr \/* shortcut only when las/
XRead unix.c /^Read(buf, maxlen)$/
XRealWaitForChar unix.c /^RealWaitForChar(ticks)$/
XResetBuffers buffers.c /^ResetBuffers()$/
XSupdatescript script.c /^Supdatescript(str)$/
XTTEST term.c /^# define TTEST(a) debug1("%s: ", "a"); if (a) {deb/
XUCHARAT regexp.c /^#define UCHARAT(p) ((int)*(unsigned char *)(p))$/
XWaitForChar msdos.c /^WaitForChar(msec)$/
X__ARGS regsub.c /^# define __ARGS(a) a$/
X__PARMS vim.h /^# define __PARMS(x) x$/
X_addfmt termlib.c /^_addfmt(buf, fmt, val) \/* add val to b/
X_find termlib.c /^_find(s, set) \/* finds next c in s that's a memb/
X_match termlib.c /^_match(s1, s2) \/* returns length o/
Xadd_buff buffers.c /^add_buff(buf, s)$/
Xadd_num_buff buffers.c /^add_num_buff(buf, n)$/
Xaddfile msdos.c /^addfile(fl, f)$/
Xaddstar cmdline.c /^addstar(fname, len)$/
XadjustCurpos linefunc.c /^adjustCurpos()$/
Xadjust_lnum normal.c /^adjust_lnum()$/
Xadjustmark mark.c /^adjustmark(old, new)$/
Xalloc alloc.c /^alloc(size)$/
Xalloc_block storage.c /^alloc_block()$/
Xalloc_line storage.c /^alloc_line(size)$/
Xappendline storage.c /^appendline(after, s)$/
Xask_yesno misccmds.c /^ask_yesno(str)$/
Xautowrite cmdline.c /^autowrite()$/
Xbck_word search.c /^bck_word(count, type)$/
Xbeep misccmds.c /^beep()$/
Xbeginline edit.c /^beginline(flag)$/
Xblink msdos.c /^blink(n)$/
Xblock_prep ops.c /^block_prep(lnum, delete)$/
Xbreakcheck amiga.c /^breakcheck()$/
Xbsdmemset alloc.c /^bsdmemset(ptr, c, size)$/
Xbuf1line macros.h /^#define buf1line() (line_count == 1)$/
Xbufempty macros.h /^#define bufempty() (buf1line() && lineempty((linen/
Xbzero unix.c /^# define bzero(a, b) memset((a), 0, (b))$/
Xcall_shell amiga.c /^call_shell(cmd, filter)$/
Xcanincrease storage.c /^canincrease(n)$/
Xcatch_cbrk msdos.c /^catch_cbrk()$/
Xcatch_cint msdos.c /^catch_cint(bp, di, si, ds, es, dx, cx, bx, ax)$/
Xcbrk_handler msdos.c /^cbrk_handler()$/
Xcharsize charset.c /^charsize(c)$/
Xchartabsize charset.c /^chartabsize(c, col)$/
Xcheck_changed cmdline.c /^check_changed(checkaw)$/
Xcheck_fname cmdline.c /^check_fname()$/
Xcheck_list storage.c /^check_list()$/
Xcheck_more cmdline.c /^check_more()$/
Xcheck_readonly cmdline.c /^check_readonly()$/
Xcheck_win amiga.c /^check_win(argc, argv)$/
Xcheck_winsize term.c /^check_winsize()$/
Xcheckclearop normal.c /^checkclearop()$/
Xcheckclearopq normal.c /^checkclearopq()$/
Xchk_mline fileio.c /^chk_mline(lnum)$/
Xclear_line screen.c /^clear_line()$/
Xclear_termparam param.c /^clear_termparam()$/
Xclearmarked storage.c /^clearmarked()$/
Xclearopbeep normal.c /^clearopbeep()$/
Xclrallmarks mark.c /^clrallmarks()$/
Xclrtags tag.c /^clrtags()$/
Xcls search.c /^cls()$/
Xcmdchecklen cmdline.c /^cmdchecklen()$/
Xcoladvance linefunc.c /^coladvance(wcol)$/
Xcomp_Botline screen.c /^comp_Botline()$/
Xcopy_redo buffers.c /^copy_redo()$/
Xcopy_spaces alloc.c /^copy_spaces(ptr, count)$/
Xcstrchr regexp.c /^cstrchr(s, c)$/
Xcstrncmp regexp.c /^cstrncmp(s1, s2, n)$/
Xcurs_columns screen.c /^curs_columns()$/
Xcursorcmd cmdline.c /^cursorcmd()$/
Xcursupdate screen.c /^cursupdate()$/
Xdebug debug.h /^# define debug(x) {fprintf(debugfp,x);fflush(debug/
Xdebug1 debug.h /^# define debug1(x,a) {fprintf(debugfp,x,a);fflush(/
Xdebug2 debug.h /^# define debug2(x,a,b) {fprintf(debugfp,x,a,b);ffl/
Xdebug3 debug.h /^# define debug3(x,a,b,c) {fprintf(debugfp,x,a,b,c)/
Xdec linefunc.c /^dec(lp)$/
XdecCurpos linefunc.c /^decCurpos()$/
Xdecl linefunc.c /^decl(lp)$/
Xdecrmarks mark.c /^decrmarks()$/
Xdecrtags tag.c /^decrtags()$/
Xdelchar misccmds.c /^delchar(fixpos)$/
Xdellines misccmds.c /^dellines(nlines, can_update)$/
Xdelmode screen.c /^delmode()$/
Xdelsline storage.c /^delsline(nr, delmarks)$/
Xdirname amiga.c /^dirname(buf, len)$/
Xdo_Lower regsub.c /^do_Lower(d, c)$/
Xdo_Upper regsub.c /^do_Upper(d, c)$/
Xdo_copy regsub.c /^do_copy(d, c)$/
Xdo_lower regsub.c /^do_lower(d, c)$/
Xdo_mlines fileio.c /^do_mlines()$/
Xdo_upper regsub.c /^do_upper(d, c)$/
Xdoaddsub ops.c /^doaddsub(c, Prenum1)$/
Xdoarglist cmdline.c /^doarglist(str)$/
Xdobang cmdline.c /^dobang(addr_count, arg)$/
Xdochange ops.c /^dochange()$/
Xdocmdline cmdline.c /^docmdline(cmdline)$/
Xdodelete ops.c /^dodelete()$/
Xdodis ops.c /^dodis()$/
Xdodojoin ops.c /^dodojoin(count, flag, redraw)$/
Xdoecmd cmdline.c /^doecmd(arg)$/
Xdoexecbuf ops.c /^doexecbuf(c)$/
Xdofilter cmdline.c /^dofilter(buff, do_in, do_out)$/
Xdoformat ops.c /^doformat()$/
Xdoglob csearch.c /^doglob(type, lp, up, cmd)$/
Xdojoin ops.c /^dojoin(insert_space)$/
Xdojumps mark.c /^dojumps()$/
Xdomap buffers.c /^domap(maptype, keys, mode)$/
Xdomarks mark.c /^domarks()$/
Xdoput ops.c /^doput(dir, count)$/
Xdorecord ops.c /^dorecord(c)$/
Xdos_packet amiga.c /^dos_packet(pid, action, arg)$/
Xdosearch search.c /^dosearch(dir, str, reverse, count, echo)$/
Xdoset param.c /^doset(arg)$/
Xdoshell cmdline.c /^doshell(cmd)$/
Xdoshift ops.c /^doshift(op)$/
Xdosource cmdline.c /^dosource(fname)$/
Xdosub csearch.c /^dosub(lp, up, cmd, nextcommand)$/
Xdotag tag.c /^dotag(tag, type, count)$/
Xdotags tag.c /^dotags()$/
Xdotilde ops.c /^dotilde()$/
Xdowrite cmdline.c /^dowrite(arg, append)$/
Xdoyank ops.c /^doyank(deleting)$/
Xedit edit.c /^edit(count)$/
Xemsg message.c /^emsg(s)$/
Xend_word search.c /^end_word(count, type, stop)$/
Xequal macros.h /^#define equal(a, b) (((a).lnum == (b).lnum) && ((a/
Xexpand_env misccmds.c /^expand_env(src, dst, dstlen)$/
Xexpandpath msdos.c /^expandpath(fl, path, fonly, donly, notf)$/
Xfilealloc storage.c /^filealloc()$/
Xfileinfo misccmds.c /^fileinfo()$/
Xfilemess fileio.c /^filemess(name, s)$/
Xfill_inbuf unix.c /^fill_inbuf()$/
Xfindfunc search.c /^findfunc(dir, what, count)$/
Xfindpar search.c /^findpar(dir, count, what)$/
Xfindsent search.c /^findsent(dir, count)$/
Xfindtag tag.c /^findtag(tag)$/
Xfirstmarked storage.c /^firstmarked()$/
Xfirsttaborspace tag.c /^firsttaborspace(str)$/
Xflush_buffers buffers.c /^flush_buffers()$/
Xflushbuf amiga.c /^flushbuf()$/
Xfm_getname mark.c /^fm_getname(fmark)$/
Xfname_case amiga.c /^fname_case(name)$/
Xfnamecmp vim.h /^# define fnamecmp(x, y) stricmp((x), (y))$/
Xfree vim.h /^# define free(x) nofreeNULL(x)$/
Xfree_buff buffers.c /^free_buff(buf)$/
Xfree_line storage.c /^free_line(ptr)$/
Xfree_yank ops.c /^free_yank(n)$/
Xfree_yank_all ops.c /^free_yank_all()$/
Xfreeall storage.c /^freeall()$/
Xfreefiles amiga.c /^freefiles()$/
Xfullpathcmp misccmds.c /^fullpathcmp(s1, s2)$/
Xfwd_word search.c /^fwd_word(count, type)$/
Xgchar misccmds.c /^gchar(pos)$/
XgcharCurpos misccmds.c /^gcharCurpos()$/
Xget_address cmdline.c /^get_address(ptr)$/
Xget_bufcont buffers.c /^get_bufcont(buffer)$/
Xget_fib amiga.c /^get_fib(fname)$/
Xget_indent misccmds.c /^get_indent()$/
Xget_inserted buffers.c /^get_inserted()$/
Xget_literal edit.c /^get_literal(nextc)$/
Xget_recorded buffers.c /^get_recorded()$/
Xget_yank_buffer ops.c /^get_yank_buffer(writing)$/
Xgetaltfile cmdline.c /^getaltfile(n, lnum, setpm)$/
Xgetaltfname cmdline.c /^getaltfname(n)$/
Xgetchr regexp.c /^getchr()$/
Xgetcmdline cmdline.c /^getcmdline(firstc, buff)$/
Xgetdigits misccmds.c /^getdigits(pp)$/
Xgetdigraph digraph.c /^getdigraph(char1, char2)$/
Xgetent termlib.c /^getent(tbuf, term, termcap, buflen)$/
Xgetfile cmdline.c /^getfile(fname, setpm)$/
Xgetlinecol term.c /^getlinecol()$/
Xgetmark mark.c /^getmark(c, changefile)$/
Xgetout main.c /^getout(r)$/
Xgetperm amiga.c /^getperm(name)$/
Xgetvcol screen.c /^getvcol(pos, type)$/
Xgotocmdline cmdline.c /^gotocmdline(clr, firstc)$/
Xhas_wildcard amiga.c /^has_wildcard(p)$/
Xhelp help.c /^help()$/
Xinc linefunc.c /^inc(lp)$/
XincCurpos linefunc.c /^incCurpos()$/
Xinchar term.c /^inchar(async, waitforever)$/
Xincl linefunc.c /^incl(lp)$/
Xincrmarks mark.c /^incrmarks()$/
Xincrtags tag.c /^incrtags()$/
Xinindent misccmds.c /^inindent()$/
Xinit_yank ops.c /^init_yank()$/
Xinitchr regexp.c /^initchr(str)$/
Xinmacro search.c /^inmacro(opt, s)$/
Xins_mapbuf buffers.c /^ins_mapbuf(str)$/
Xinschar misccmds.c /^inschar(c)$/
Xinsertbuf ops.c /^insertbuf(c)$/
Xinsertchar edit.c /^insertchar(c)$/
Xinsfile amiga.c /^insfile(name)$/
Xinsstr misccmds.c /^insstr(s)$/
Xisdir amiga.c /^isdir(name)$/
Xisidchar charset.c /^isidchar(c)$/
Xismult regexp.c /^ismult(c)$/
Xistermparam param.c /^istermparam(p)$/
Xlalloc alloc.c /^lalloc(size, message)$/
Xlineempty macros.h /^#define lineempty(p) (*nr2ptr(p) == NUL)$/
Xlistdigraphs digraph.c /^listdigraphs()$/
Xlock2name amiga.c /^lock2name(lock, buf, len)$/
Xlt macros.h /^#define lt(a, b) (((a).lnum != (b).lnum) \\$/
Xltoreq macros.h /^#define ltoreq(a, b) (((a).lnum != (b).lnum) \\$/
Xm_blockalloc storage.c /^m_blockalloc(size, message)$/
Xm_blockfree storage.c /^m_blockfree()$/
Xm_error storage.c /^m_error()$/
Xmakemap buffers.c /^makemap(fd)$/
Xmakescriptname script.c /^makescriptname()$/
Xmakeset param.c /^makeset(fd)$/
Xmaketitle misccmds.c /^maketitle()$/
Xmark2pos mark.c /^mark2pos(markp)$/
Xmch_get_winsize amiga.c /^mch_get_winsize()$/
Xmch_set_winsize amiga.c /^mch_set_winsize()$/
Xmch_settmode amiga.c /^mch_settmode(raw)$/
Xmch_suspend amiga.c /^mch_suspend()$/
Xmch_windexit amiga.c /^mch_windexit(r)$/
Xmch_windinit amiga.c /^mch_windinit()$/
Xmemmove unix.h /^#define memmove(to, from, len) memcpy(to, from, le/
Xmemset vim.h /^#define memset(ptr, c, size) bsdmemset(ptr, c, siz/
Xmkstr alloc.c /^mkstr(c)$/
Xmktemp cmdline.c /^# define mktemp(a) tmpnam(a)$/
Xmkup regexp.c /^#define mkup(c) (reg_ic ? toupper(c) : (c))$/
Xmodname script.c /^modname(fname, ext)$/
Xmovemark mark.c /^movemark(count)$/
Xmsg message.c /^msg(s)$/
Xmsgmore misccmds.c /^msgmore(n)$/
Xmyregcomp search.c /^myregcomp(pat)$/
Xnextent termlib.c /^nextent(tbuf, termcap, buflen) \/* Read 1 e/
XnofreeNULL alloc.c /^nofreeNULL(x)$/
Xnormal normal.c /^normal()$/
Xnr2ptr storage.c /^nr2ptr(nr)$/
Xonedown edit.c /^onedown(n)$/
Xoneleft edit.c /^oneleft()$/
Xonepage edit.c /^onepage(dir, count)$/
Xoneright edit.c /^oneright()$/
Xoneup edit.c /^oneup(n)$/
Xopenrecover script.c /^openrecover()$/
Xopenscript script.c /^openscript(name)$/
Xotherfile misccmds.c /^otherfile(s)$/
Xoutchar amiga.c /^outchar(c)$/
Xoutnum term.c /^outnum(n)$/
Xoutstr msdos.c /^outstr(s)$/
Xoutstrn term.c /^outstrn(s)$/
Xouttrans charset.c /^outtrans(str, len)$/
Xparse_builtin_tcap term.c /^parse_builtin_tcap(tc, s)$/
Xpchar macros.h /^#define pchar(lp, c) (*(nr2ptr((lp).lnum) + (lp).c/
Xpeekchr regexp.c /^peekchr()$/
Xpeekpeekchr regexp.c /^peekpeekchr()$/
Xplines misccmds.c /^plines(p)$/
Xplines_m misccmds.c /^plines_m(first, last)$/
Xplural misccmds.c /^plural(n)$/
Xpos2ptr storage.c /^pos2ptr(pos)$/
Xpremsg normal.c /^premsg(c1, c2)$/
Xprep_redo normal.c /^prep_redo(num, cmd, c, nchar)$/
Xprintdigraph digraph.c /^printdigraph(p)$/
Xprt_line screen.c /^prt_line(s)$/
Xpstrcmp msdos.c /^pstrcmp(a, b)$/
Xptr2nr storage.c /^ptr2nr(ptr, start)$/
Xputdigraph digraph.c /^putdigraph(str)$/
Xqf_adjustmark quickfix.c /^qf_adjustmark(old, new)$/
Xqf_clrallmarks quickfix.c /^qf_clrallmarks()$/
Xqf_free quickfix.c /^qf_free()$/
Xqf_init quickfix.c /^qf_init(fname)$/
Xqf_jump quickfix.c /^qf_jump(errornr)$/
Xqf_list quickfix.c /^qf_list()$/
Xread_redo buffers.c /^read_redo(init)$/
Xread_stuff buffers.c /^read_stuff(advance)$/
Xreadfile fileio.c /^readfile(fname, from, newfile)$/
Xredrawcmd cmdline.c /^redrawcmd()$/
Xredrawcmdline cmdline.c /^redrawcmdline()$/
Xredrawhelp help.c /^redrawhelp()$/
Xreg regexp.c /^reg(paren, flagp)$/
Xregatom regexp.c /^regatom(flagp)$/
Xregbranch regexp.c /^regbranch(flagp)$/
Xregc regexp.c /^regc(b)$/
Xregcomp regexp.c /^regcomp(exp)$/
Xregdump regexp.c /^regdump(r)$/
Xregexec regexp.c /^regexec(prog, string, at_bol)$/
Xreginsert regexp.c /^reginsert(op, opnd)$/
Xregmatch regexp.c /^regmatch(prog)$/
Xregnext regexp.c /^regnext(p)$/
Xregnode regexp.c /^regnode(op)$/
Xregoptail regexp.c /^regoptail(p, val)$/
Xregpiece regexp.c /^regpiece(flagp)$/
Xregprop regexp.c /^regprop(op)$/
Xregrepeat regexp.c /^regrepeat(p)$/
Xregsub regsub.c /^regsub(prog, source, dest, copy, magic)$/
Xregtail regexp.c /^regtail(p, val)$/
Xregtry regexp.c /^regtry(prog, string)$/
Xremove msdos.c /^remove(name)$/
Xrename unix.c /^rename(src, dst)$/
Xreplaceline storage.c /^replaceline(lnum, new)$/
Xresettitle amiga.c /^resettitle()$/
Xs_del screen.c /^s_del(row, nlines, invalid)$/
Xs_ins screen.c /^s_ins(row, nlines, invalid)$/
Xsamealtfile cmdline.c /^samealtfile(n)$/
Xsave_line storage.c /^save_line(src)$/
Xscreenalloc screen.c /^screenalloc()$/
Xscreenchar screen.c /^screenchar(p, row, col)$/
Xscreenclear screen.c /^screenclear()$/
Xscreenfill screen.c /^screenfill(srow, c)$/
Xscreenline screen.c /^screenline(lnum, startrow, endrow)$/
Xscript_winsize script.c /^script_winsize()$/
Xscript_winsize_pp script.c /^script_winsize_pp()$/
Xscrolldown screen.c /^scrolldown(nlines)$/
Xscrollup screen.c /^scrollup(nlines)$/
Xsearchc search.c /^searchc(c, dir, type, count)$/
Xsearchit search.c /^searchit(pos, dir, str, count, end)$/
Xset_Changed misccmds.c /^set_Changed()$/
Xset_indent misccmds.c /^set_indent(size, delete)$/
Xset_init param.c /^set_init()$/
Xset_keymap amiga.c /^set_keymap(name)$/
Xset_redo_ins buffers.c /^set_redo_ins()$/
Xset_term term.c /^set_term(term)$/
Xset_winsize term.c /^set_winsize(width, height, mustset)$/
Xsetaltfname cmdline.c /^setaltfname(arg, lnum, newfile)$/
Xsetcursor term.c /^setcursor()$/
Xsetfname misccmds.c /^setfname(s)$/
Xsetmark mark.c /^setmark(c)$/
Xsetmarked storage.c /^setmarked(lnum)$/
Xsetpcmark mark.c /^setpcmark()$/
Xsetperm amiga.c /^setperm(name, perm)$/
Xsettitle amiga.c /^settitle(str)$/
Xsettmode term.c /^settmode(raw)$/
Xshift_line ops.c /^shift_line(left)$/
Xshowmap buffers.c /^showmap(mp)$/
Xshowmatch search.c /^showmatch()$/
Xshowmatches cmdline.c /^showmatches(file, len)$/
Xshowmode screen.c /^showmode()$/
Xshowonep param.c /^showonep(p)$/
Xshowparams param.c /^showparams(all)$/
Xshowruler screen.c /^showruler(always)$/
Xsig_winch unix.c /^sig_winch(sig, code, scp)$/
Xskip_chars search.c /^skip_chars(class, dir)$/
Xskipchr regexp.c /^skipchr()$/
Xskipspace misccmds.c /^skipspace(pp)$/
Xskiptospace misccmds.c /^skiptospace(pp)$/
Xsleep amiga.c /^sleep(n)$/
Xsmsg message.c /^smsg(s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)$/
XstartPS search.c /^startPS(lnum, para)$/
Xstart_arrow edit.c /^start_arrow()$/
Xstart_redo buffers.c /^start_redo(count)$/
Xstart_redo_ins buffers.c /^start_redo_ins()$/
Xstart_stuff buffers.c /^start_stuff()$/
Xstartinsert ops.c /^startinsert(initstr, startln, count)$/
Xstartscript script.c /^startscript()$/
Xstarttermcap term.c /^starttermcap()$/
Xstop_arrow edit.c /^stop_arrow()$/
Xstop_insert edit.c /^stop_insert()$/
Xstop_redo_ins buffers.c /^stop_redo_ins()$/
Xstopscript script.c /^stopscript()$/
Xstoptermcap term.c /^stoptermcap()$/
Xstrchr vim.h /^#define strchr(ptr, c) index(ptr, c)$/
Xstrcspn regexp.c /^strcspn(s1, s2)$/
Xstrlowcpy msdos.c /^strlowcpy(d, s)$/
Xstrnfcpy regsub.c /^strnfcpy(f, d, s, n)$/
Xstrnsave alloc.c /^strnsave(string, len)$/
Xstrrchr vim.h /^#define strrchr(ptr, c) rindex(ptr, c)$/
Xstrsave alloc.c /^strsave(string)$/
Xstrsize charset.c /^strsize(s)$/
XstuffReadbuff buffers.c /^stuffReadbuff(s)$/
Xstuff_empty buffers.c /^stuff_empty()$/
Xstuff_inserted edit.c /^stuff_inserted(c, count, no_esc)$/
Xstuff_yank ops.c /^stuff_yank(bufname, p)$/
XstuffnumReadbuff buffers.c /^stuffnumReadbuff(n)$/
Xswapchar ops.c /^swapchar(pos)$/
Xtermcapinit term.c /^termcapinit(term)$/
Xtextfile msdos.c /^textfile(on)$/
Xtgetent termlib.c /^tgetent(tbuf, term)$/
Xtgetflag termlib.c /^tgetflag(id)$/
Xtgetnum termlib.c /^tgetnum(id)$/
Xtgetstr termlib.c /^tgetstr(id, buf)$/
Xtgoto term.c /^tgoto(cm, x, y)$/
Xtinit termlib.c /^tinit(name)$/
Xtltoa term.c /^tltoa(i)$/
Xtputs termlib.c /^tputs(cp, affcnt, outc)$/
Xtranschar charset.c /^transchar(c)$/
Xttest term.c /^ttest(pairs)$/
Xu_clearall undo.c /^u_clearall()$/
Xu_clearline undo.c /^u_clearline()$/
Xu_freeentry undo.c /^u_freeentry(uep, n)$/
Xu_freelist undo.c /^u_freelist(uhp)$/
Xu_getbot undo.c /^u_getbot()$/
Xu_redo undo.c /^u_redo(count)$/
Xu_save undo.c /^u_save(top, bot)$/
Xu_saveCurpos undo.c /^u_saveCurpos()$/
Xu_savecommon undo.c /^u_savecommon(top, bot, flag, ptr)$/
Xu_savedel undo.c /^u_savedel(lnum, ptr)$/
Xu_saveline undo.c /^u_saveline(lnum)$/
Xu_savesub undo.c /^u_savesub(lnum, ptr)$/
Xu_sync undo.c /^u_sync()$/
Xu_undo undo.c /^u_undo(count)$/
Xu_undoline undo.c /^u_undoline()$/
Xu_undoredo undo.c /^u_undoredo()$/
Xungetchr regexp.c /^ungetchr()$/
Xunregc regexp.c /^unregc()$/
XupdateScreen screen.c /^updateScreen(type)$/
Xupdateline screen.c /^updateline()$/
Xupdatescript script.c /^updatescript(c)$/
Xusage main.c /^usage(n)$/
Xvgetc buffers.c /^vgetc()$/
Xvgetorpeek buffers.c /^vgetorpeek(advance)$/
Xvim_delay amiga.c /^vim_delay()$/
Xvimgetenv amiga.c /^vimgetenv(var)$/
Xvpeekc buffers.c /^vpeekc()$/
Xwait_return message.c /^wait_return(redraw)$/
Xwin_resize_off amiga.c /^win_resize_off()$/
Xwin_resize_on amiga.c /^win_resize_on()$/
Xwindgoto term.c /^windgoto(row, col)$/
Xwriteit fileio.c /^writeit(fname, start, end, append, forceit)$/
END_OF_FILE
if test 17914 -ne `wc -c <'vim/src/tags'`; then
echo shar: \"'vim/src/tags'\" unpacked with wrong size!
fi
# end of 'vim/src/tags'
fi
if test -f 'vim/src/term.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/term.c'\"
else
echo shar: Extracting \"'vim/src/term.c'\" \(18112 characters\)
sed "s/^X//" >'vim/src/term.c' <<'END_OF_FILE'
X/* vi:sw=4:ts=4:
X *
X * term.c -- VIM - Vi IMitation
X *
X * primitive termcap support added
X *
X * NOTE: padding and variable substitution is not performed,
X * when compiling without TERMCAP, we use tputs() and tgoto() dummies.
X *
X * 14.6.92


X */
X
X#include "vim.h"
X#include "globals.h"

X#include "param.h"
X#include "proto.h"
X#ifdef TERMCAP
X# ifdef linux
X# include <termcap.h>
X# define TPUTSFUNCAST (outfuntype)
X# else
X# define TPUTSFUNCAST
X# ifdef AMIGA
X# include "proto/termlib.pro"
X# endif
X# endif
X#endif
X
X#ifdef DEBUG
X# define TTEST(a) debug1("%s: ", "a"); if (a) {debug2("%02x %s\n", *a, a + 1);} else debug("NULL\n");
X#endif
X
Xstatic void parse_builtin_tcap __ARGS((Tcarr *tc, char *s));
X
X/*
X * Builtin_tcaps must always contain DFLT_TCAP as the first entry!
X * DFLT_TCAP is used, when no terminal is specified with -T option or $TERM.
X * The entries are compact, therefore they normally are included even when
X * TERMCAP is defined.
X * When TERMCAP is defined, the builtin entries can be accessed with
X * "builtin_amiga", "builtin_ansi", "builtin_debug", etc.
X */
Xstatic char *builtin_tcaps[] =
X{
X#ifndef NO_BUILTIN_TCAPS
X DFLT_TCAP, /* almost allways included */
X# if !defined(UNIX) && (defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS))
X ANSI_TCAP, /* default for unix */
X# endif
X# if !defined(AMIGA) && (defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS))
X AMIGA_TCAP, /* default for amiga */
X# endif
X# if !defined(MSDOS) && (defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS))
X PCTERM_TCAP, /* default for MSdos */
X# endif
X# if !defined(ATARI) && defined(ALL_BUILTIN_TCAPS)
X ATARI_TCAP, /* default for Atari */
X# endif
X# if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS)
X XTERM_TCAP, /* always included on unix */
X# endif
X# ifdef ALL_BUILTIN_TCAPS
X VT52_TCAP,
X# endif
X# if defined(DEBUG) || defined(ALL_BUILTIN_TCAPS)
X DEBUG_TCAP, /* always included when debugging */
X# endif
X#else /* NO_BUILTIN_TCAPS */
X "dump\0\0\0",
X#endif /* NO_BUILTIN_TCAPS */
X NULL,
X};
X
X/*
X * Term_strings contains currently used terminal strings.
X * It is initialized with the default values by parse_builtin_tcap().
X * The values can be changed by setting the parameter with the same name.
X */
XTcarr term_strings;
X
X/*
X * Parsing of the builtin termcap entries.
X * The terminal's name is not set, as this is already done in termcapinit().
X * Chop builtin termcaps, string entries are already '\0' terminated.
X * not yet implemented:
X * boolean entries could be empty strings;
X * numeric entries would need a flag (e.g. high bit of the skip byte),
X * so that parse_builtin_tcap can handle them.


X */
X static void

Xparse_builtin_tcap(tc, s)
X Tcarr *tc;
X char *s;
X{
X char **p = &tc->t_name;
X
X p++;


X for (;;)
X {

X while (*s++)
X ;
X p += *s++;
X if (!*s)
X return;
X *p++ = s;
X }
X}
X
X#ifdef TERMCAP
X# ifndef linux /* included in <termlib.h> */
X# ifndef AMIGA /* included in proto/termlib.pro */
Xint tgetent();
Xint tgetnum();
Xchar *tgetstr();
Xint tputs();


X# endif /* AMIGA */

X# ifndef hpux
Xextern short ospeed;
X# endif
X# endif /* linux */
X# ifndef hpux
Xextern char *UP, *BC, PC;
X# endif
X#endif /* TERMCAP */
X
X void
Xset_term(term)
X char *term;
X{
X char **p = builtin_tcaps;
X#ifdef TERMCAP
X int builtin = 0;
X#endif
X int width = 0, height = 0;
X
X clear_termparam(); /* clear old parameters */
X if (!strncmp(term, "builtin_", (size_t)8))
X {
X term += 8;
X#ifdef TERMCAP
X builtin = 1;
X#endif
X }
X#ifdef TERMCAP
X else


X {
X for (;;)

X {
X char *p;
X static char tstrbuf[TBUFSZ];
X char tbuf[TBUFSZ];
X char *tp = tstrbuf;
X int i;
X
X i = tgetent(tbuf, term);


X if (i == -1)

X {
X emsg("Cannot open termcap file");
X builtin = 1;
X break;
X }
X if (i == 0)
X {
X emsg("terminal entry not found");
X builtin = 1;
X break;
X }
X
X /* output strings */
X T_EL = tgetstr("ce", &tp);
X T_IL = tgetstr("al", &tp);
X T_CIL = tgetstr("AL", &tp);
X T_DL = tgetstr("dl", &tp);
X T_CDL = tgetstr("DL", &tp);
X T_ED = tgetstr("cl", &tp);
X T_CI = tgetstr("vi", &tp);
X T_CV = tgetstr("ve", &tp);
X T_TP = tgetstr("me", &tp);
X T_TI = tgetstr("mr", &tp);
X T_CM = tgetstr("cm", &tp);
X T_SR = tgetstr("sr", &tp);
X T_CRI = tgetstr("RI", &tp);
X T_VB = tgetstr("vb", &tp);
X T_KS = tgetstr("ks", &tp);
X T_KE = tgetstr("ke", &tp);
X T_TS = tgetstr("ti", &tp);
X T_TE = tgetstr("te", &tp);
X
X /* key codes */
X term_strings.t_ku = tgetstr("ku", &tp);
X term_strings.t_kd = tgetstr("kd", &tp);
X term_strings.t_kl = tgetstr("kl", &tp);
X term_strings.t_kr = tgetstr("kr", &tp);
X /* term_strings.t_sku = tgetstr("", &tp); termcap code unknown */
X /* term_strings.t_skd = tgetstr("", &tp); termcap code unknown */
X term_strings.t_sku = NULL;
X term_strings.t_skd = NULL;
X term_strings.t_skl = tgetstr("#4", &tp);
X term_strings.t_skr = tgetstr("%i", &tp);
X term_strings.t_f1 = tgetstr("k1", &tp);
X term_strings.t_f2 = tgetstr("k2", &tp);
X term_strings.t_f3 = tgetstr("k3", &tp);
X term_strings.t_f4 = tgetstr("k4", &tp);
X term_strings.t_f5 = tgetstr("k5", &tp);
X term_strings.t_f6 = tgetstr("k6", &tp);
X term_strings.t_f7 = tgetstr("k7", &tp);
X term_strings.t_f8 = tgetstr("k8", &tp);
X term_strings.t_f9 = tgetstr("k9", &tp);
X term_strings.t_f10 = tgetstr("k;", &tp);
X term_strings.t_sf1 = tgetstr("F1", &tp); /* really function keys 11-20 */
X term_strings.t_sf2 = tgetstr("F2", &tp);
X term_strings.t_sf3 = tgetstr("F3", &tp);
X term_strings.t_sf4 = tgetstr("F4", &tp);
X term_strings.t_sf5 = tgetstr("F5", &tp);
X term_strings.t_sf6 = tgetstr("F6", &tp);
X term_strings.t_sf7 = tgetstr("F7", &tp);
X term_strings.t_sf8 = tgetstr("F8", &tp);
X term_strings.t_sf9 = tgetstr("F9", &tp);
X term_strings.t_sf10 = tgetstr("FA", &tp);
X term_strings.t_help = tgetstr("%1", &tp);
X term_strings.t_undo = tgetstr("&8", &tp);
X
X height = tgetnum("li");
X width = tgetnum("co");
X
X# ifndef hpux
X BC = tgetstr("bc", &tp);
X UP = tgetstr("up", &tp);
X p = tgetstr("pc", &tp);
X if (p)
X PC = *p;
X ospeed = 0;
X# endif
X break;
X }
X }
X if (builtin)
X#endif
X {
X while (*p && strcmp(term, *p))
X p++;
X if (!*p)
X {
X fprintf(stderr, "'%s' not builtin. Available terminals are:\n", term);
X for (p = builtin_tcaps; *p; p++)
X fprintf(stderr, "\t%s\n", *p);
X sleep(2);
X fprintf(stderr, "defaulting to '%s'\n", *builtin_tcaps);
X sleep(2);
X p = builtin_tcaps;
X free(term_strings.t_name);
X term_strings.t_name = strsave(term = *p);
X }
X parse_builtin_tcap(&term_strings, *p);
X }
X#if defined(AMIGA) || defined(MSDOS)
X /* DFLT_TCAP indicates that it is the machine console. */
X if (strcmp(term, *builtin_tcaps))
X term_console = FALSE;
X else
X {
X term_console = TRUE;
X# ifdef AMIGA
X win_resize_on(); /* enable window resizing reports */
X# endif
X }
X#endif
X ttest(TRUE);
X /* display initial screen after ttest() checking. jw. */
X if (width <= 0 || height <= 0)
X {
X /* termcap failed to report size */
X /* set defaults, in case mch_get_winsize also fails */
X width = 80;
X height = 24;
X }
X set_winsize(width, height, FALSE);
X}
X
X#if defined(TERMCAP) && defined(UNIX)
X/*
X * Get Columns and Rows from the termcap. Used after a window signal if the
X * ioctl() fails. It doesn't make sense to call tgetent each time if the "co"
X * and "li" entries never change. But this may happen on some systems.
X */
X void
Xgetlinecol()
X{
X char tbuf[TBUFSZ];
X
X if (term_strings.t_name && tgetent(tbuf, term_strings.t_name) > 0)


X {
X if (Columns == 0)

X Columns = tgetnum("co");


X if (Rows == 0)

X Rows = tgetnum("li");
X }
X}
X#endif
X
Xstatic char *tltoa __PARMS((unsigned long));


X
X static char *

Xtltoa(i)
X unsigned long i;
X{
X static char buf[16];
X char *p;
X
X p = buf + 15;
X *p = '\0';
X do
X {
X --p;
X *p = i % 10 + '0';
X i /= 10;
X }
X while (i > 0 && p > buf);


X return p;
X}
X

X#ifndef TERMCAP
X
X/*
X * minimal tgoto() implementation.
X * no padding and we only parse for %i %d and %+char


X */
X
X char *

Xtgoto(cm, x, y)
X char *cm;
X int x, y;
X{
X static char buf[30];


X char *p, *s, *e;

X
X if (!cm)
X return "OOPS";

X e = buf + 29;
X for (s = buf; s < e && *cm; cm++)
X {
X if (*cm != '%')
X {
X *s++ = *cm;
X continue;
X }
X switch (*++cm)
X {
X case 'd':
X p = tltoa((unsigned long)y);
X y = x;
X while (*p)
X *s++ = *p++;


X break;
X case 'i':

X x++;
X y++;


X break;
X case '+':

X *s++ = (char)(*++cm + y);
X y = x;


X break;
X case '%':

X *s++ = *cm;
X break;
X default:


X return "OOPS";
X }
X }

X *s = '\0';


X return buf;
X}
X

X#endif /* TERMCAP */
X
X/*
X * Termcapinit is called from main() to initialize the terminal.
X * The optional argument is given with the -T command line option.
X */
X void
Xtermcapinit(term)
X char *term;
X{
X if (!term)
X term = (char *)vimgetenv("TERM");
X if (!term || !*term)
X term = *builtin_tcaps;
X term_strings.t_name = strsave(term);
X set_term(term);
X}
X
X/*
X * a never-padding outstr.
X * use this whenever you don't want to run the string through tputs.
X * tputs above is harmless, but tputs from the termcap library
X * is likely to strip off leading digits, that it mistakes for padding
X * information. (jw)
X */
X void
Xoutstrn(s)
X char *s;
X{
X while (*s)
X outchar(*s++);
X}
X
X#ifndef MSDOS /* there is a special version of outstr() in msdos.c */


X/*
X * outstr(s): put a string character at a time into the output buffer.

X * If TERMCAP is defined use the termcap parser. (jw)


X */
X void
Xoutstr(s)

X register char *s;
X{
X if (s)
X#ifdef TERMCAP
X tputs(s, 1, TPUTSFUNCAST outchar);


X#else
X while (*s)
X outchar(*s++);
X#endif
X}

X#endif /* MSDOS */
X
X/*
X * cursor positioning using termcap parser. (jw)
X */
X void
Xwindgoto(row, col)
X int row;
X int col;
X{
X#ifdef TERMCAP
X tputs(tgoto(T_CM, col, row), 1, TPUTSFUNCAST outchar);
X#else
X outstr(tgoto(T_CM, col, row));
X#endif
X}
X
X/*
X * Set cursor to current position.
X * Should be optimized for minimal terminal output.


X */
X
X void

Xsetcursor()
X{
X if (!RedrawingDisabled)
X windgoto(Cursrow, Curscol);
X}
X
X void
Xttest(pairs)
X int pairs;
X{
X char buf[70];
X char *s = "terminal capability %s required.\n";
X char *t = NULL;
X
X#ifdef TTEST
X TTEST(T_EL);
X TTEST(T_IL);
X TTEST(T_CIL);
X TTEST(T_DL);
X TTEST(T_CDL);
X TTEST(T_ED);
X TTEST(T_CI);
X TTEST(T_CV);
X TTEST(T_TP);
X TTEST(T_TI);
X TTEST(T_CM);
X TTEST(T_SR);
X TTEST(T_CRI);
X#endif /* TTEST */
X
X /* hard requirements */
X if (!T_ED || !*T_ED) /* erase display */
X t = "cl";
X if (!T_CM || !*T_CM) /* cursor motion */
X t = "cm";
X
X if (t)
X {
X sprintf(buf, s, t);
X emsg(buf);
X }
X
X if (pairs)
X {
X /* optional pairs */
X if ((!T_TP || !*T_TP) ^ (!T_TI || !*T_TI))
X {
X debug2("cap :me=%s:mr=%s: ignored\n", T_TP, T_TI);
X T_TP = T_TI = NULL;
X }
X if ((!T_CI || !*T_CI) ^ (!T_CV || !*T_CV))
X {
X debug2("cap :vi=%s:ve=%s: ignored\n", T_CI, T_CV);
X T_CI = T_CV = NULL;
X }
X }
X}
X
X/*
X * inchar() - get a character from
X * 1. a scriptfile
X * 2. the keyboard - take care of interpreting escape sequences
X *
X * If we got an interrupt all input is read until none is available.
X * If async is TRUE there is no waiting for the char and we keep the
X * character.
X * If waitforever is FALSE we wait for 1 second for a character to arrive.
X */
X
X#define INBUFLEN 50 /* buffer lengt, must be enough to contain an
X Amiga raw keycode report */
X
X int
Xinchar(async, waitforever)
X int async;
X int waitforever;
X{
X static u_char buf[INBUFLEN+1]; /* already entered characters */
X static int len = 0; /* number of valid chars in buf */
X static int lastc = -1; /* last character from script file */
X register int c;
X register int slen = 0;
X register char **p;
X#ifdef AMIGA
X char *s;
X#endif /* AMIGA */
X int first;
X int mode_deleted = FALSE;
X
X if (!async)
X flushbuf();
X
X/*
X * Check for interrupt.
X */
X breakcheck();
X
X/*
X * first try script file
X * If interrupted: Stop reading script files.
X */
Xretry:
X if (scriptin[curscript] != NULL)
X {
X if (!got_int && lastc >= 0)
X c = lastc;
X else if (got_int || (c = getc(scriptin[curscript])) < 0) /* reached EOF */
X {
X lastc = -1;
X fclose(scriptin[curscript]);
X scriptin[curscript] = NULL;
X if (curscript > 0)
X --curscript;
X /* recovery may be delayed till after reading a script file */
X if (recoverymode)
X openrecover();
X goto retry; /* may read other script if this one was nested */
X }
X if (c == 0)
X c = K_ZERO; /* replace ^@ with special code */
X if (async)
X lastc = c;
X else
X lastc = -1;


X return c;
X }
X
X/*

X * If we got an interrupt, skip all previously typed characters and
X * reset interrupt flag.
X */
X if (got_int) /* skip typed characters */
X {
X while (GetChars((char *)buf, INBUFLEN, T_PEEK))
X ;
X got_int = FALSE;


X len = 0;
X }

X/*
X * get character(s) from the keyboard
X * this is repeated until we have found that
X * - it is not an escape sequence, return the first char
X * - it is the start of an escape sequence, but it is not completed within
X * a short time, return the first char
X * - it is an escape seqence, translate it into a single byte code
X */
X first = TRUE;


X for (;;)
X {

X if (!first || len == 0)
X {
X /*
X * special case: if we get an <ESC> in insert mode and there are
X * no more characters at once, we pretend to go out of insert mode.
X * This prevents the one second delay after typing an <ESC>.
X * If we get something after all, we may have to redisplay the
X * mode. That the cursor is in the wrong place does not matter.
X */
X if (!async && len == 1 && buf[0] == ESC && (State == INSERT || State == REPLACE) && (p_timeout || p_ttimeout))
X {
X slen = GetChars((char *)buf + len, INBUFLEN - len, T_PEEK);
X if (slen != 0)
X {
X len += slen;
X goto gotchar;
X }
X if (p_mo)
X {
X delmode();
X mode_deleted = TRUE;
X }
X if (Curscol) /* move cursor one left if possible */
X --Curscol;
X else if (Curpos.col != 0 && Cursrow)
X {
X --Cursrow;
X Curscol = Columns - 1;
X }
X setcursor();
X flushbuf();
X }
X /*
X * When async == TRUE do not wait for characters to arrive: T_PEEK
X * When getting the first character wait until one arrives: T_BLOCK
X * When waiting for a key sequence to complete
X * and 'timeout' or !waitforever set wait a short time: T_WAIT
X * and 'timeout' not set wait until one arrives: T_BLOCK
X */
X slen = GetChars((char *)buf + len, INBUFLEN - len,
X async ? T_PEEK : ((len == 0 || !(p_timeout || p_ttimeout))
X && waitforever) ? T_BLOCK : T_WAIT);
X if (got_int)
X goto retry; /* CTRL-C typed, flush input buffer */
X len += slen;
X if ((async || !waitforever) && len == 0) /* nothing typed */
X return NUL;
X if (slen == 0) /* escape sequence not completed in time */
X break;
X }
X first = FALSE;
X
X if (async) /* when we get here: len != 0 */
X return (int)buf[0];
X
Xgotchar:
X if (State != NOMAPPING)
X {
X /* search in the escape sequences for the characters we have */
X for (p = (char **)&term_strings.t_ku; p != (char **)&term_strings.t_undo + 1; ++p)
X {
X if (*p == NULL)
X continue;
X slen = strlen(*p);
X if (strncmp(*p, (char *)buf, (size_t)(slen > len ? len : slen)) == 0)
X break;
X }
X }
X if (State == NOMAPPING || p == (char **)&term_strings.t_undo + 1) /* no match */
X {
X#ifdef AMIGA /* check for window bounds report */
X buf[len] = 0;
X if ((buf[0] & 0xff) == CSI && ((s = strchr((char *)buf, 'r')) || (s = strchr((char *)buf, '|'))))
X {
X slen = s - buf + 1;
X p = NULL;
X }
X else
X#endif
X break;
X }
X if (slen <= len) /* got the complete sequence */
X {
X if (mode_deleted)
X showmode();
X len -= slen;
X memmove((char *)buf, (char *)buf + slen, (size_t)len);
X#ifdef AMIGA
X if (p == NULL) /* got window bounds report */
X {
X set_winsize(0, 0, FALSE); /* get size and redraw screen */
X continue;
X }
X#endif
X
X /* this relies on the Key numbers to be consecutive! */
X return (int)(K_UARROW + (p - (char **)&term_strings.t_ku));
X }
X /*
X * get here when we got an incomplete sequence,
X * we need some more characters
X */
X }
X c = buf[0];
X memmove((char *)buf, (char *)buf+1, (size_t)--len);


X if (c == 0)

X c = K_ZERO; /* replace ^@ with special code */
X /* delete "INSERT" message if we return an ESC */
X if (c == ESC && p_mo && !mode_deleted && (State == INSERT || State == REPLACE))
X delmode();


X return c;
X}
X
X/*

X * outnum - output a (big) number fast
X */
X void
Xoutnum(n)


X register long n;
X{

X outstrn(tltoa((unsigned long)n));
X}
X
X void
Xcheck_winsize()
X{
X if (Columns < 5)
X Columns = 5;
X else if (Columns > MAX_COLUMNS)
X Columns = MAX_COLUMNS;
X if (Rows < 2)
X Rows = 2;


X p_scroll = Rows >> 1;

X}
X
X/*
X * set window size
X * If 'mustset' is TRUE, we must set Rows and Columns, do not get real
X * window size (this is used for the :win command during recovery).
X * If 'mustset' is FALSE, we may try to get the real window size and if
X * it fails use 'width' and 'height'.
X */
X void
Xset_winsize(width, height, mustset)
X int width, height;
X int mustset;
X{
X register int tmp;
X
X if (width < 0 || height < 0) /* just checking... */
X return;
X
X if (State == HITRETURN) /* postpone the resizing */
X {
X State = SETWINSIZE;
X return;
X }
X screenclear();
X#ifdef AMIGA
X flushbuf(); /* must do this before mch_get_winsize for some obscure reason */
X#endif /* AMIGA */
X if (mustset || mch_get_winsize())
X {
X debug("mch_get_win failed\n");
X Rows = height;
X Columns = width;
X mch_set_winsize();
X }
X check_winsize(); /* always check, to get p_scroll right */
X if (State == HELP)
X redrawhelp();
X else if (!starting)
X {
X tmp = RedrawingDisabled;
X RedrawingDisabled = FALSE;
X comp_Botline();
X updateScreen(CURSUPD);
X RedrawingDisabled = tmp;
X if (State == CMDLINE)
X redrawcmdline();
X else
X setcursor();


X }
X flushbuf();
X}
X

X void
Xsettmode(raw)
X int raw;
X{
X static int oldraw = FALSE;
X
X if (oldraw == raw) /* skip if already in desired mode */
X return;
X oldraw = raw;
X
X mch_settmode(raw); /* machine specific function */
X}
X
X void
Xstarttermcap()
X{
X outstr(T_KS); /* start "keypad transmit" mode */
X outstr(T_TS); /* start termcap mode */
X}
X
X void
Xstoptermcap()
X{
X outstr(T_KE); /* stop "keypad transmit" mode */
X outstr(T_TE); /* stop termcap mode */
X}
END_OF_FILE
if test 18112 -ne `wc -c <'vim/src/term.c'`; then
echo shar: \"'vim/src/term.c'\" unpacked with wrong size!
fi
# end of 'vim/src/term.c'
fi
echo shar: End of archive 10 \(of 23\).
cp /dev/null ark10isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:33:53 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 11
Archive-name: vim/part11
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 11 (of 23)."
# Contents: vim/doc/index vim/src/storage.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:10 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/index' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/index'\"
else
echo shar: Extracting \"'vim/doc/index'\" \(18631 characters\)
sed "s/^X//" >'vim/doc/index' <<'END_OF_FILE'
Xindex of vim commands for
X 1. insert mode
X 2. VI commands (normal mode)
X 3. command line editing
X 4. EX commands
X
X(for an overview of options see the end of reference.doc)
X
X1. INSERT MODE
X==============
X
Xchar action
X-----------------------------------------------------------------------
X^@ insert previously inserted text and stop insert {vi: up to 128
X chars}
X^A insert previously inserted text {vi: no ^A}
X^B <0-9a-z> insert contents of register <0-9a-z> {not in vi}
X^D delete one shiftwidth of indent in the current line {vi:
X only after auto-indent}
X^E insert the character which is below the cursor
X^H <BS> delete character before the cursor {vi: does not cross lines,
X does not delete autoindents}
X^J <LF> begin new line
X^K {char1} {char2} enter digraph (only when compiled with it) {vi: no digraphs}
X^O execute a single command and return to insert mode
X^M <CR> begin new line
X^R insert the character which is above the cursor
X^T insert one shiftwidth of indent in current line {vi: only in
X autoindent}
X^U delete all entered characters in the current line
X^V insert next non-digit literally, insert three digit decimal
X number as a single byte.
X^W delete word before the cursor
X^[ <ESC> end insert mode
X<DEL> same as ^H <BS>
X<C_UP> cursor one line up
X<C_DOWN> cursor one line down
X<C_LEFT> cursor one character left
X<C_RIGHT> cursor one character right
X<SC_UP> one screenfull backward
X<SC_DOWN> one screenfull forward
X<SC_LEFT> cursor one word left
X<SC_RIGHT> cursor one word right
X{char1}<BS>{char2} enter digraph (only when compiled with it and 'digraph'
X option set) {vi: no digraphs}
X
X
X2. VI COMMANDS
X==============
X
XCHAR means non-blank char
XWORD means sequences of non-blank chars
XN is number entered before the command
X<move> is a cursor movement command
XNmove is the text that is moved over with a cursor movement command
XSECTION is a section that possibly starts with '}' instead of '{'
X
Xnote: 1 = cursor movement command; 2 = can be undone/redone
X
Xchar note vim normal mode (vi: what the unix vi does)
X------------------------------------------------------------------------------
X^@ error
X^A 2 add N to number at/after cursor {vi: no ^A}
X^B 1 scroll N screens Backwards
X^C interrupt current (search) command
X^D scroll Down N lines (default: half a screen)
X^E scroll N lines upwards (N lines Extra)
X^F 1 scroll N screens Forward
X^G display current file name and position
X^H <BS> 1 cursor N chars to the left
X^I <TAB> 1 go to N newer entry in jump list
X^J <LF> 1 cursor N lines downward
X^K error
X^L redraw screen
X^M <CR> 1 cursor to the first CHAR N lines lower
X^N 1 cursor N lines downward
X^O 1 go to N older entry in jump list
X^P 1 cursor N lines upward
X^Q start blockwise quoting (vi: no quoting)
X^R 2 redo changes which were undone with 'u' (vi: no redo)
X^S 2 subtract N from number at/after cursor {vi: no ^S}
X^T jump to N older Tag in tag list
X^U scroll N lines Upwards (default: half a screen)
X^V error
X^W error
X^X error
X^Y scroll N lines downwards
X^Z suspend program (or start new shell)
X^[ <ESC> error
X^\ error
X^] :ta to ident under cursor
X^^ edit Nth alternate file (equivalent to :e #N)
X^_ error
X
X<SPACE> 1 cursor N chars to the right
X!<move><filter> filter Nmove text through the "filter" command
X!!<filter> filter N lines through the "filter" command
X"<a-zA-Z0-9.> use buffer <a-zA-Z0-9.> for next delete, yank or put
X (upper case to append)(<.> only works for put)
X# 1 search backward for the Nth occurrence of the ident under
X the cursor {not in vi}
X$ 1 cursor to the end of line N from the cursor
X% 1 find the next (curly/square) bracket on this line and go
X to its match. With count: go to N percentage in the file.
X& 2 repeat last :s
X'<a-zA-Z> 1 cursor to the first CHAR on the line with mark <a-zA-Z>
X'[ 1 cursor to the first CHAR on the line of the start of
X last operated text or start of putted text
X'] 1 cursor to the first CHAR on the line of the end of
X last operated text or end of putted text
X'' 1 cursor to the first CHAR of the line where the cursor was
X before the latest jump.
X( 1 cursor N sentences backward
X) 1 cursor N sentences forward
X* 1 search forward for the Nth occurrence of the ident under
X the cursor {not in vi}
X+ 1 cursor to the first CHAR N lines lower
X, 1 repeat latest f, t, F or T in opposite direction N times
X- 1 cursor to the first CHAR N lines higher
X. 2 repeat last change with count replaced by N
X/<pattern> 1 search forward for the Nth occurrence of <pattern>
X0 1 cursor to the first char of the line
X1 prepend to command to give a count
X2 "
X3 "
X4 "
X5 "
X6 "
X7 "
X8 "
X9 "
X: Ex command (see below)
X; 1 repeat latest f, t, F or T N times
X<<move> 2 shift the Nmove lines one shiftwidth leftwards
X<< 2 shift N lines one shiftwidth leftwards
X=<move> 2 filter Nmove lines through "indent" (vi: when option
X 'lisp' is set autoindent Nmove lines)
X== 2 filter N lines through "indent"
X><move> 2 shift Nmove lines one shiftwidth rightwards
X>> 2 shift N lines one shiftwidth rightwards
X?<pattern> 1 search backward for the Nth previous occurrence of
X <pattern>
X@<a-z> 2 execute the contents of named buffer <a-z> N times
X@@ 2 repeat the previous @<a-z> N times
XA 2 append text at the end of the line N times
XB 1 cursor N WORDS backward
X<"x>C 2 change from the cursor position to the end of the line,
X and N-1 more lines [into buffer x]; synonym for c$
X<"x>D 2 delete the characters under the cursor until the end of
X the line and N-1 more lines [into buffer x]; synonym for d$
XE 1 cursor forward to the end of WORD N
XF<char> cursor to the Nth occurrence of <char> to the left
XG 1 cursor to line N, default last line
XH 1 cursor to line N from top of screen
XI 2 insert text before the first CHAR on the line N times
XJ 2 Join N lines; default is 2
XK lookup Keyword under the cursor with "keywordprg"
XL 1 cursor to line N from bottom of screen
XM 1 cursor to middle line of screen
XN 1 repeat the latest '/' or '?' N times in opposite
X direction
XO 2 begin a new line above the cursor and insert text, repeat
X N times (vi: blank N screen lines)
X<"x>P 2 put the text [from buffer x] before the cursor N times
XQ start quoting lines (vi: go to Ex mode)
XR 2 enter replace mode: overtype existing characters, repeat the
X entered text N-1 times
X<"x>S 2 delete N lines [into buffer x] and start insert; synonym
X for ^cc or 0cc, depending on autoindent
XT<char> 1 cursor till after Nth occurrence of <char> to the left
XU 2 undo all latest changes on one line (vi: while not moved
X off of it)
X While quoting: make lowercase
XV<move> 2 Join N lines and re-format them
XW 1 cursor N WORDS forward
X<"x>X 2 delete N characters before the cursor [into buffer x]
X<"x>Y yank N lines [into buffer x]; synonym for yy
XZZ store current file, if modified, and exit
X[[ 1 cursor N sections backward
X[] 1 cursor N SECTIONS backward
X\ error
X]] 1 cursor N sections forward
X][ 1 cursor N SECTIONS forward
X^ 1 cursor to the first CHAR of the line
X_ 1 cursor to the first CHAR N - 1 lines lower
X`<a-zA-Z> 1 cursor to the mark <a-zA-Z>
X`[ 1 cursor to the start of last operated text or start of
X putted text
X`] 1 cursor to the end of last operated text or end of
X putted text
X`` 1 cursor to the position before latest jump
Xa 2 append text after the cursor N times
Xb 1 cursor N words backward
X<"x>c<move> 2 delete Nmove text [into buffer x] and start insert
X<"x>cc 2 delete N lines [into buffer x] and start insert
X<"x>d<move> 2 delete Nmove text [into buffer x]
X<"x>dd 2 delete N lines [into buffer x]
Xe 1 cursor forward to the end of word N
Xf<char> 1 cursor to Nth occurrence of <char> to the right
Xg error
Xh 1 cursor N chars to the left
Xi 2 insert text before the cursor N times
Xj 1 cursor N lines downward
Xk 1 cursor N lines upward
Xl 1 cursor N chars to the right
Xm<a-z> set mark <a-z> at cursor position
Xn 1 repeat the latest '/' or '?' N times
Xo 2 begin a new line below the cursor and insert text, repeat
X N times (vi: blank N screen lines)
X While quoting: cursor moves other end
X<"x>p 2 put the text [from buffer x] after the cursor N times
Xq start quoting characters
Xr<char> 2 replace N chars by <char>
X<"x>s 2 (substitute) delete N characters [into buffer x] and
X start insert
Xt<char> 1 cursor till before Nth occurrence of <char> to the right
Xu 2 undo changes (vi: only one level)
X While quoting: make uppercase
Xv<a-zA-Z> record typed characters into named buffer <a-zA-Z>
X (upper case to append)
Xv stops recording (vi: no recording)
Xw 1 cursor N words forward
X<"x>x 2 delete N characters under and after the cursor [into
X buffer x]
X<"x>y<move> yank Nmove text [into buffer x]
X<"x>yy yank N lines [into buffer x]
Xz<CR> redraw, cursor line to top of window
Xz. redraw, cursor line to center of window
Xz- redraw, cursor line at bottom of window
X{ 1 cursor N paragraphs backward
X| 1 cursor to column N
X} 1 cursor N paragraphs forward
X~ 2 option notildeop: switch case of N characters under
X cursor and move the cursor N characters to the right
X (vi: no count)
X~<move> option tildeop: switch case of Nmove text (vi: no tildeop
X option)
X<DEL> when entering a number: remove the last digit
X<HELP> show the file vim:vim.hlp page by page (vi: no help)
X<C_UP> 1 move cursor N lines upwards
X<C_DOWN> 1 move cursor N lines downwards
X<C_LEFT> 1 move cursor N chars to the left
X<C_RIGHT> 1 move cursor N chars to the right
X<SC_UP> 1 scroll N screens Backwards (same as ^B)
X<SC_DOWN> 1 scroll N screens Forwards (same as ^F)
X<SC_LEFT> 1 cursor N words backward (same as b)
X<SC_RIGHT> 1 cursor N words forward (same as w)
X
X
X3. command line editing
X=======================
X
XGet to the command line with the ':', '!', '/' or '?' commands.
XNormal characters are inserted at the current cursor position.
X(vi: can only alter last character in the line)
X
X^D list filenames that match the pattern in front of the cursor
X^H delete the character in front of the cursor
X^N only after an <ESC> with multiple matches: go to next match
X^P only after an <ESC> with multiple matches: go to previous match
X^V insert next non-digit literally, insert three digit decimal
X number as a single byte. {Vi: type the CTRL-V twice to get one}
X<ESC> do filename completion on the pattern in front of the cursor
X@ remove all characters
X<DEL> delete the character under the cursor
X<C_UP> recall previous command line from history
X<C_DOWN> recall next command line from history
X<C_LEFT> cursor left
X<C_RIGHT> cursor right
X<SC_LEFT> cursor one word left
X<SC_RIGHT> cursor one word right
X
X
X4. EX commands
X==============
X
Xlines that start with " or # are ignored
X
X<range> stands for a series of line specifiers, separated with ',' or ';'.
XWhen separated with ';' the cursor position will be set to that line before
Xinterpreting the next line specifier.
XThe default line specifier (for most commands) is the Cursor position.
Xline numbers may be specified with:
X <number> the absolute line number
X . the current line
X $ the last line in the file
X % equal to 1,$ (the entire file)
X 't position of mark t
X /<pattern> the next line where <pattern> matches
X ?<pattern> the previous line where <pattern> matches
XEach may be followed (several times) by '+' or '-' and an optional number.
XThis number is added or subtracted from the preceding line number.
Xif the number is omitted, 1 is used.
XExamples:
X .+3 three lines below the cursor
X /that+1 the line below the next line containing "that"
X .,$ from current line until end of file
X
XIn the commands below the characters in square brackets are optional.
X
X:<range> set the cursor on the (last) specified line number
X
X:a[ppend] {vi: append text}
X
X:ar[gs] print the file list, with the current file in []
X
X:cc [nr] Display error [nr] (default is same error)
X
X:cd print the current directory name {vi: no such command}
X:cd <path> change the current directory to <path>
X
X:cf read error file (from errorfile option)
X
X:c[hange] {vi: replace lines}
X
X:ch[dir] same as :cd
X
X:cn display next error
X
X:[range]co[py] {address} copy lines from [range] to {address}
X
X:cp display previous error
X
X:cq Quit without writing and return an error code
X
X:[<range>]d[elete] [x] [count]
X delete <range> lines (default: current line)
X
X:dig[raph] display currently defined digraphs {not in vi}
X
X:dig[raph] {char1}{char2} {number} ...
X define the character pair {char1} {char2} to be the
X digraph for character {number}. {number} is entered
X as digits.
X
X:di[splay] display the contents of numbered and named buffers
X {vi: no such command}
X
X:e[dit] [file] edit 'file' (default: current file), unless changes have
X been made {vi: allow +n to start at certain position}
X:e[dit]! [file] edit 'file' (default: current file) always
X
X:ex same as :edit
X
X:f[ile] prints the current file name and some more info
X:f[ile] <name> sets current file name to <name>
X:files lists the alternate file names
X
X:<range>g[lobal]/<pattern>/<cmd>
X execute the EX command <cmd> on the lines where <pattern>
X matches
X:<range>g[lobal]!/<pattern>/<cmd>
X execute the EX command <cmd> on the lines where <pattern>
X does not match
X
X:h[elp] show the help file page by page {vi: no help}
X
X:i[nsert] {vi: insert text}
X
X:<range>j[oin] join <range> lines
X
X:ju[mps] print jump list {vi: no such command}
X
X:[range]k<a-z> set mark without a space
X
X:l[ist] {vi: list lines}
X
X:map <lhs> <rhs> map the key sequence <lhs> to <rhs> in normal mode
X:map! <lhs> <rhs> map the key sequence <lhs> to <rhs> in insert mode
X
X:[range]ma[rk] <a-z> set mark
X
X:marks list all marks {vi: no such command}
X
X:mk[exrc] write options to .exrc file
X:mkv[imrc] write options to .vimrc file {not in vi}
X
X:[range]m[ove] {address} move lines from [range] to {address}
X
X:n[ext] edit next file, unless changes have been made
X:n[ext]! edit next file
X:n[ext] <filelist> define <filelist> as the new list of files and edit
X the first one, unless changes have been made
X:n[ext]! <filelist> define <filelist> as the new list of files and edit
X the first one {vi: +command to start editing at a
X specified position}
X
X:noremap <lhs> <rhs> map the key sequence <lhs> to <rhs> in normal mode,
X disallow remapping of <rhs> {not in vi}
X:noremap! <lhs> <rhs> map the key sequence <lhs> to <rhs> in insert mode,
X disallow remapping of <rhs> {not in vi}
X
X:nu[mber] {vi: print specified lines with their line number}
X
X:N[ext] edit previous file in file list, unless changes have
X been made
X:N[ext]! edit previous file in file list
X
X:o[pen] {vi: start editing in open mode}
X
X:[count]po[p][!] jump to [count] older tag in tag list {vi: no such command}
X
X:pres[erve] {vi: emergency exit}
X
X:<range>p[rint] print the specified lines
X
X:pu[t] [x] insert text from buffer [x] below current line
X:pu[t]! [x] insert text from buffer [x] above current line
X
X:pr[evious] same as :Next
X
X:q[uit] quit, unless changes have been made
X:q[uit]! quit always, without writing
X
X:r[ead] <name> insert the file <name> below the cursor
X:r[ead]!<cmd> excute <cmd> and insert its standard output below the
X cursor
X
X:rec[over] {vi: recover a file after a crash or :preserve}
X
X:rew[ind] start editing the first file in the file list, unless
X changes have been made
X:rew[ind]! start editing the first file in the file list
X
X:se[t] show all modified options {vi: non-default options}
X:se[t] all show all options
X:se[t] <option> set toggle option on, show value of string or number
X option
X:se[t] no<option> set toggle option off
X:se[t] inv<option> invert toggle option
X:se[t] <option>=<value> set string or number option to <value>
X:se[t] <option>? show value of <option>
X
X:sh[ell] escape to a shell {vi: shell name from option 'shell'}
X
X:so[urce] <file> read EX commands from <file>
X:so[urce]! <file> read VI commands from <file> {vi: no such command}
X
X:st[op][!] suspend the editor
X
X:<range>s[ubstitute]/<pattern>/<string>/<option>
X for each line in <range> replace the first occurrence of
X <pattern> by <string>; with <option> 'g' all occurrences
X on the line are replaced; with <option> 'c' each
X replace has to be confirmed
X:<range>s[ubstitute] repeat last :substitute
X
X:t synonym for copy
X
X:ta[g] <ident> search for <indent> in the tags file and execute
X the accompanying command, unless changes have been made
X:ta[g]! <ident> search for <indent> in the tags file and execute
X the accompanying command
X
X:[count]ta[g][!] jump to [count] newer tag in tag list {vi: no such command}
X
X:tags print the tag list {vi: no such command}
X
X:una[bbreviate] {vi: remove from abbreviation list}
X
X:u[ndo] undo last change
X
X:unm[ap] <lhs> remove the mapping of <lhs> for normal mode
X:unm[ap]! <lhs> remove the mapping of <lhs> for insert mode
X
X:ve[rsion] print the version number of the editor
X
X:<range>v[global]/<pattern>/<cmd>
X execute the EX command <cmd> on the lines where <pattern>
X does not match
X
X:vi[sual] {vi: switch from EX or open to visual mode}
X
X:wi[nsize] <width> <height>
X Set effective window size to <width> columns and <height>
X rows. Does not change actual window size. Should only be
X used from script files. {vi: no such command}
X
X:<range>w[rite][!] write the specified lines to the current file
X:<range>w[rite] <file> write the specified lines to <file>, unless it
X already exists
X:<range>w[rite]! <file> write the specified lines to <file>
X:<range>w[rite][!] >> append the specified lines to the current file
X:<range>w[rite][!] >> <file>
X append the specified lines to <file>
X:<range>w[rite] !<cmd> execute <cmd> with <range> lines as standard input
X
X:wq write the current file and exit if no more files
X:wq! write the current file and exit
X:wq <file> write to <file> and exit if no more files
X:wq! <file> write to <file> and exit
X
X:x[it][!] [file] same as :wq, but write only when changes have been made
X
X:y[ank] [x] copy lines into buffer [x]
X
X:z {vi: print some lines}
X
X:@<reg> execute contents of buffer <reg> as an Ex command
X {only in some versions of vi}
X
X:@@ repeat last :@<reg> command.
X
X:![!]<cmd> [!][<arg>] execute <cmd> with the shell, replace the optional bangs
X with the previously given command, append the optional
X <arg>
X:<range>![!]<cmd> [!][<arg>]
X filter <range> lines through <cmd>, replace the optional bangs
X with the previously given command, append the optional
X <arg>
X
X:< shift left
X
X:> shift right
X
X:= print the line number
X
X:& same as :substitute
X
X:~ {vi: do a substitute on the previous regular expression}
END_OF_FILE
if test 18631 -ne `wc -c <'vim/doc/index'`; then
echo shar: \"'vim/doc/index'\" unpacked with wrong size!
fi
# end of 'vim/doc/index'
fi
if test -f 'vim/src/storage.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/storage.c'\"
else
echo shar: Extracting \"'vim/src/storage.c'\" \(19504 characters\)
sed "s/^X//" >'vim/src/storage.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * storage.c: allocation of lines and management of them
X *
X * part 1: storage allocation for the lines and blocks of the current file
X * part 2: managing of the pointer blocks


X */
X
X#include "vim.h"
X#include "globals.h"

X#include "proto.h"
X
X/***************************************************************************
X * part 1: storage allocation for the lines and blocks of the current file *
X ***************************************************************************/
X
X/*
X * Memory is allocated in relatively large blocks. These blocks are linked
X * in the allocated block list, headed by m_ahead. They are all freed
X * when abandoning a file.
X *
X * The available chunks of memory are kept in the free chunk list, headed
X * by m_fhead. This is a circular list. m_search points to the chunk before the
X * chunk that was freed/allocated the last time. alloc_line() gets a chunk
X * from the free list; free_line() returns a chunk to the free list.
X */
X
X /* on the Amiga the blocksize must not be a multiple of 256 */
X /* with MS-Dos the blocksize must be larger than 255 */
X /* For Unix it does not really matter */
X#define MEMBLOCKSIZE 2044
X
Xtypedef struct m_info info_t;
X
X/*
X * There are two types of in-use memory chunks:
X * 1. those that are allocated by readfile(). These are always preceded
X * by a NUL character and end in a NUL character. The chunk must not
X * contain other NUL characters. The preceding NUL is used to
X * determine the chunk type. The ending NUL is used to determine the
X * end of the chunk. The preceding NUL is not part of the chunk, the
X * ending NUL is.
X * 2. the other chunks have been allocated with alloc_line(). They are
X * preceded by a non-NUL character. This is used to determine the chunk
X * type. The non-NUL may be part of a size field or may be an extra 0xff
X * byte. The chunk always ends in a NUL character and may also contain
X * a NUL character. The size field contains the size of the chunk,
X * including the size field. The trailing NUL may be used by a possibly
X * follwing type 1 chunk. The preceding size, the optional 0xff and the
X * trailing NUL are all part of the chunk.
X *
X * When the chunk is not in-use it is preceded with the m_info structure.
X * The m_next field links it in the free chunk list. It must still end in
X * a NUL byte, because it may be followed by a type 1 chunk!
X *
X * When in-use we must make sure there is a non-NUL byte in front of type
X * 2 chunks.
X *
X * On the Amiga this means that the size must not be a multiple of 256.
X * This is done by multiplying the size by 2 and adding one.
X *
X * On MS-DOS the size must be larger than 255. This is done by adding 256
X * to the size.
X *
X * On Unix systems an extra 0xff byte is added. This costs 4 bytes because
X * pointers must be kept long-aligned.
X *
X * On most unix systems structures have to be longword aligned.
X * On most other systems they are short (16 bit) aligned.
X */
X
X#ifdef UNIX
X# define ALIGN_LONG /* 32 bit alignment and use filler byte */
X#else
X# ifdef AMIGA
X# define LOWBYTE /* size must not be multiple of 256 */


X# else
X# ifdef MSDOS

X# define HIGHBYTE /* size must be larger than 255 */
X# else
X you must define something!


X# endif
X# endif
X#endif
X

Xstruct m_info
X{
X#ifdef ALIGN_LONG
X u_long m_size; /* size of the chunk (including m_info) */
X#else
X u_short m_size; /* size of the chunk (including m_info) */
X#endif
X info_t *m_next; /* pointer to next free chunk in the list */
X};
X
X#ifdef ALIGN_LONG
X /* size of m_size + room for 0xff byte */
X# define M_OFFSET (sizeof(u_long) * 2)
X#else
X /* size of m_size */
X# define M_OFFSET (sizeof(u_short))
X#endif
X
Xstatic char *m_ahead = NULL; /* head of allocated memory block list */
X
Xstatic info_t m_fhead = {0, NULL}; /* head of free chunk list */
X
Xstatic info_t *m_search = NULL; /* pointer to chunk before previously
X allocated/freed chunk */
X
X#ifdef DEBUG
X# ifdef AMIGA
Xm_error()
X{
X printf("list error\n");
X}
X# endif
X
Xcheck_list()
X{
X# ifdef AMIGA
X register info_t *mp;
X
X for (mp = &m_fhead; ; )
X {
X /*
X * adjust these addresses for the actual available memory!
X */
X if (mp >= 0x080000L && mp < 0x200000L ||
X mp >= 0x400000L && mp < 0xc00000 ||
X mp >= 0xc80000 || mp->m_next->m_size > 23000)
X {
X m_error();
X return 1;
X }
X mp = mp->m_next;
X if (mp == &m_fhead)
X break;
X }
X# endif
X return 0;
X}
X#endif /* DEBUG */
X
X/*
X * Allocate a block of memory and link it in the allocated list, so that
X * the block will be freed when abandoning the file.
X */
X char *
Xm_blockalloc(size, message)


X u_long size;
X int message;

X{
X char *p;
X

X p = lalloc(size + sizeof(char *), message);
X if (p != NULL)
X {
X *(char **)p = m_ahead;
X m_ahead = p;
X p += sizeof(char *);
X }


X return p;
X}
X

X/*
X * free all allocated memory blocks
X */
X void
Xm_blockfree()
X{
X char *p, *np;
X
X for (p = m_ahead; p != NULL; p = np)
X {
X np = *(char **)p;
X free(p);
X }
X m_ahead = NULL;
X m_search = NULL;
X}
X
X/*
X * Free a chunk of memory which was
X * 1. inserted with readfile(); these are preceded with a NUL byte
X * 2. allocated with alloc_line(); these are preceded with a non-NUL byte
X * Insert the chunk into the free list, keeping it sorted on address.
X */
X void
Xfree_line(ptr)
X char *ptr;
X{
X info_t *mp;
X register info_t *next;
X info_t *prev, *curr;
X long len;
X
X#ifdef DEBUG
X if (check_list())
X return;
X#endif
X if (ptr == NULL || ptr == IObuff)
X return; /* illegal address can happen in out-of-memory situations */
X
X if (*(ptr - 1) == NUL) /* type 1 chunk: no size field */
X {
X#ifdef ALIGN_LONG /* use longword alignment */
X long c;
X
X len = strlen(ptr) + 1;
X if ((c = ((long)ptr & 3)) != 0) /* lose some bytes */
X {
X c = 4 - c;
X ptr += c;
X len -= c;
X }
X#else /* use short (16 bit) alignment */
X len = strlen(ptr) + 1;
X if ((long)ptr & 1) /* lose a byte */
X {
X ++ptr;
X --len;
X }
X#endif /* ALIGN_LONG */
X
X /* we must be able to store size, pointer and a trailing NUL */
X /* otherwise we can't fit it in the free list */
X if (len <= (long)sizeof(info_t))
X return; /* these bytes are not used until you quit the file */
X mp = (info_t *)ptr;
X mp->m_size = len;
X }
X#ifdef ALIGN_LONG
X else if ((*(ptr - 1) & 0xff) == 0xff) /* type 2 chunk: has size field */
X {
X mp = (info_t *)(ptr - M_OFFSET);
X }
X else
X {
X emsg("Illegal chunk");
X return;
X }
X#endif
X#ifdef LOWBYTE
X else /* type 2 chunk: has size field */
X {
X mp = (info_t *)(ptr - M_OFFSET);
X mp->m_size >>= 1;
X }
X#endif
X#ifdef HIGHBYTE
X else /* type 2 chunk: has size field */
X {
X mp = (info_t *)(ptr - M_OFFSET);
X mp->m_size -= 256;
X }
X#endif
X
X curr = NULL;
X /* if mp is smaller than m_search->m_next we start at m_fhead */
X if (mp < (m_search->m_next))
X next = &m_fhead;
X else
X next = m_search;
X do
X {
X prev = curr;
X curr = next;
X next = next->m_next;
X }
X while (mp > next && next != &m_fhead);
X
X/* if *mp and *next are concatenated, join them into one chunk */
X if ((char *)mp + mp->m_size == (char *)next)
X {
X mp->m_size += next->m_size;
X mp->m_next = next->m_next;
X }
X else
X mp->m_next = next;
X
X/* if *curr and *mp are concatenated, join them */
X if (prev != NULL && (char *)curr + curr->m_size == (char *)mp)
X {
X curr->m_size += mp->m_size;
X curr->m_next = mp->m_next;
X m_search = prev;
X }
X else
X {
X curr->m_next = mp;
X m_search = curr; /* put m_search before freed chunk */
X }
X#ifdef DEBUG
X check_list();
X#endif
X}
X
X/*
X * Allocate and initialize a new line structure with room for at least
X * 'size' characters.


X */
X char *

Xalloc_line(size)
X register unsigned size;
X{
X register info_t *mp, *mprev, *mp2;
X int size_align;
X
X#ifdef DEBUG
X if (m_search != NULL && check_list())
X return NULL;
X#endif
X/*
X * Add room for size field, optional 0xff byte and trailing NUL byte.
X * Adjust for minimal size (must be able to store info_t
X * plus a trailing NUL, so the chunk can be released again)
X */
X size += M_OFFSET + 1;
X if (size < sizeof(info_t) + 1)
X size = sizeof(info_t) + 1;
X
X/*
X * round size up for alignment
X */
X#ifdef ALIGN_LONG /* use longword alignment */
X size_align = (size + 3) & ~3;
X#else /* ALIGN_LONG */ /* use short (16 bit) alignment */
X size_align = (size + 1) & ~1;
X#endif /* ALIGN_LONG */
X
X/* if m_search is NULL we have to initialize the free list */
X if (m_search == NULL)
X {
X m_search = &m_fhead;
X m_fhead.m_next = &m_fhead;
X }
X
X/* search for space in free list */
X mprev = m_search;
X for (mp = m_search->m_next; mp->m_size < size; mp = mp->m_next)
X {
X if (mp == m_search)
X {
X int n = (size_align > (MEMBLOCKSIZE / 4) ? size_align : MEMBLOCKSIZE);
X
X mp = (info_t *)m_blockalloc((u_long)n, TRUE);


X if (mp == NULL)

X return (NULL);
X#ifdef HIGHBYTE
X mp->m_size = n + 256;
X#endif
X#ifdef LOWBYTE
X mp->m_size = (n << 1) + 1;
X#endif
X#ifdef ALIGN_LONG
X mp->m_size = n;
X *((u_char *)mp + M_OFFSET - 1) = 0xff;
X#endif
X free_line((char *)mp + M_OFFSET);
X mp = m_search;
X }
X mprev = mp;
X }
X
X/* if the chunk we found is large enough, split it up in two */
X if ((long)mp->m_size - size_align >= (long)(sizeof(info_t) + 1))
X {
X mp2 = (info_t *)((char *)mp + size_align);
X mp2->m_size = mp->m_size - size_align;
X mp2->m_next = mp->m_next;
X mprev->m_next = mp2;
X mp->m_size = size_align;
X }
X else /* remove *mp from the free list */
X {


X mprev->m_next = mp->m_next;
X }

X m_search = mprev;
X
X#ifdef HIGHBYTE
X mp->m_size += 256;
X#endif
X#ifdef LOWBYTE
X mp->m_size = (mp->m_size << 1) + 1;
X#endif
X mp = (info_t *)((char *)mp + M_OFFSET);
X#ifdef ALIGN_LONG
X *((u_char *)mp - 1) = 0xff; /* mark type 2 chunk */
X#endif
X *(char *)mp = NUL; /* set the first byte to NUL */
X#ifdef DEBUG
X check_list();
X#endif
X
X return ((char *)mp);
X}
X
X/*
X * save_line(): allocate memory with alloc_line() and copy the
X * string 'src' into it.


X */
X char *

Xsave_line(src)
X register char *src;
X{
X register char *dst;
X register unsigned len;
X
X len = strlen(src);
X if ((dst = alloc_line(len)) != NULL)
X memmove(dst, src, (size_t)(len + 1));
X return (dst);
X}
X
X/******************************************
X * part 2: managing of the pointer blocks *
X ******************************************/
X
Xtypedef struct block block_t;
X
X#ifdef BLOCK_SIZE
X# undef BLOCK_SIZE /* for Linux: is in limits.h */
X#endif
X
X#define BLOCK_SIZE 40
X
Xstruct block
X{
X u_short b_count; /* current number of pointers in b_ptr */
X block_t *b_next; /* pointer to next block */
X block_t *b_prev; /* pointer to previous block */
X char *b_ptr[BLOCK_SIZE]; /* pointers to the lines */
X char b_flags[BLOCK_SIZE]; /* see below */
X};
X
X#define B_MARKED 0x01 /* mark for :global command */
X
Xstatic block_t *first_block; /* pointer to first block in block list */
Xstatic block_t *last_block; /* pointer to last block in block list */
X
Xstatic block_t *curr_block; /* block used by nr2ptr */
Xstatic linenr_t curr_count; /* first line number of block curr_block */
X
Xstatic block_t *alloc_block __ARGS((void));
X
X static block_t *
Xalloc_block()
X{
X block_t *p;
X
X p = (block_t *)(alloc_line((unsigned)sizeof(block_t)));


X if (p != NULL)
X {

X memset((char *)p, 0, sizeof(block_t));
X }
X return (p);
X}
X
X/*
X * filealloc() - construct an initial empty file buffer
X */
X void
Xfilealloc()
X{
X first_block = last_block = alloc_block();
X if (first_block == NULL || (first_block->b_ptr[0] = alloc_line(0)) == NULL)
X getout(1);
X first_block->b_count = 1;
X Curpos.lnum = 1;
X Curswant = Curpos.col = 0;
X Topline = 1;
X Botline = 2;
X line_count = 1;
X curr_count = 0;
X clrallmarks();
X clrtags();
X}
X
X/*
X * freeall() - free the current buffer
X *
X * Free all lines in the current buffer.
X */
X void
Xfreeall()
X{
X m_blockfree();
X line_count = 0;
X s_ins(0, 0, TRUE); /* invalidate Line arrays */
X u_clearall();
X}
X
X/*
X * Get the pointer to the line 'nr'.
X * This function is used a lot for sequential access (writeit, search),
X * so that is what it is optimized for.


X */
X char *

Xnr2ptr(nr)
X register linenr_t nr;
X{
X register linenr_t count;
X register block_t *bp = NULL;
X
X if ((count = curr_count) == 0 || nr >= count + (bp = curr_block)->b_count || nr < count)
X {
X if (nr < 1 || nr > line_count)
X {
X emsg("nr2ptr: illegal nr");
X return (IObuff); /* always return a valid ptr */
X }
X
X /*
X * three ways to find the pointer:
X * 1. first pointer in the next block (fast for sequential access)
X * 2. search forward
X * 3. search backward
X */
X if (count && nr == count + bp->b_count) /* in next block */
X {
X count = nr;


X bp = bp->b_next;
X }

X else if (nr <= (count + line_count) / 2 ||
X (nr <= count && nr <= count / 2))
X {
X /* search forward */
X if (nr < count || count == 0)
X {
X count = 1;
X bp = first_block;
X }
X while (bp != NULL)
X {
X count += bp->b_count;
X if (nr < count)
X {
X count -= bp->b_count;
X break;


X }
X bp = bp->b_next;
X }

X }
X else
X { /* search backward */
X if (nr < count)
X bp = bp->b_prev;
X else
X {
X bp = last_block;
X count = line_count + 1;
X }
X while (bp != NULL)
X {
X count -= bp->b_count;
X if (nr >= count)
X break;
X bp = bp->b_prev;
X }
X }
X
X if (bp == NULL)
X {
X emsg("nr2ptr: strorage corrupt");
X curr_count = 0;
X return (IObuff);
X }
X curr_count = count;
X curr_block = bp;
X }
X return (bp->b_ptr[nr - count]);
X}
X
X/*
X * pos2ptr: get pointer to position 'pos'


X */
X char *

Xpos2ptr(pos)
X FPOS *pos;
X{
X return (nr2ptr(pos->lnum) + pos->col);
X}
X
X/*
X * set the B_MARKED flag for line 'lnum'
X */
X void
Xsetmarked(lnum)
X linenr_t lnum;
X{
X nr2ptr(lnum);
X curr_block->b_flags[lnum - curr_count] |= B_MARKED;
X}
X
X/*
X * find the first line with its B_MARKED flag set
X */
X linenr_t
Xfirstmarked()
X{
X register block_t *bp;
X register linenr_t lnum;


X register int i;
X

X for (bp = first_block, lnum = 1; bp != NULL; bp = bp->b_next)
X for (i = 0; i < bp->b_count; ++i, ++lnum)
X if (bp->b_flags[i] & B_MARKED)
X {
X bp->b_flags[i] &= ~B_MARKED;
X return lnum;
X }
X return (linenr_t) 0;
X}
X
X/*
X * clear all B_MARKED flags
X */
X void
Xclearmarked()
X{
X register block_t *bp;


X register int i;
X

X for (bp = first_block; bp != NULL; bp = bp->b_next)
X for (i = bp->b_count; --i >= 0; )
X bp->b_flags[i] &= ~B_MARKED;
X}
X
X/*
X * a pointer to a line is converted into a line number
X * we start at line number 'start'
X * this is a bit slow, but it is used for marks and undo only
X */
X linenr_t
Xptr2nr(ptr, start)
X char *ptr;
X linenr_t start;
X{
X block_t *bp;
X register linenr_t nr;
X register char **pp;


X register int i;
X

X if (ptr == NULL)
X return (linenr_t)0;
X
X if (start == 0)
X start = 1;
X nr2ptr(start); /* set curr_block and curr_count */
X
X for (nr = curr_count, bp = curr_block; bp != NULL; bp = bp->b_next)
X for (pp = bp->b_ptr, i = bp->b_count; --i >= 0; ++nr)
X if (*pp++ == ptr)
X return (nr);
X return (linenr_t)0;
X}
X
X/*
X * appendline: add a line
X * return TRUE when succesful
X */
X int
Xappendline(after, s)
X linenr_t after;
X char *s;
X{
X register block_t *bp;
X block_t *nbp;
X linenr_t count;


X register int i;
X

X if (s == NULL) /* don't insert NULL pointers! */
X return FALSE;
X if (after == 0) /* insert in front of first line */
X {
X bp = first_block;
X count = 1;
X if (bufempty()) /* simply replace dummy line */
X {
X free_line(bp->b_ptr[0]);
X bp->b_ptr[0] = s;
X return TRUE;
X }
X curr_count = 0; /* curr_block will become invalid */
X }
X else
X {
X (void)nr2ptr(after); /* find block */
X bp = curr_block;
X count = curr_count;
X }
X
X ++line_count;
X i = bp->b_count;
X if (i < BLOCK_SIZE) /* there is place in the current block */
X/* move ptrs one place forward to make space for new one */
X {
X register char **pp;
X register char *fp;
X
X pp = &(bp->b_ptr[i]);
X fp = &(bp->b_flags[i]);
X for (i += count - after - 1; --i >= 0; --pp, --fp)
X {
X *pp = *(pp - 1);
X *fp = *(fp - 1);
X }
X *pp = s;
X *fp = 0;
X ++bp->b_count;


X return TRUE;
X }
X

X/* need to allocate a new block */
X nbp = alloc_block();
X if (nbp == NULL)
X {
X --line_count;
X free_line(s);


X return FALSE;
X }
X

X/* put new block in linked list */
X if (after == 0) /* put new block in front of linked list */
X {
X bp->b_prev = nbp;
X nbp->b_next = bp;
X first_block = nbp;
X nbp->b_ptr[0] = s;
X nbp->b_count = 1;


X return TRUE;
X }
X

X /* insert new block in linked list after bp */
X nbp->b_next = bp->b_next;
X bp->b_next = nbp;
X nbp->b_prev = bp;
X if (nbp->b_next == NULL)
X last_block = nbp;
X else
X nbp->b_next->b_prev = nbp;
X
X if (after - count + 1 == BLOCK_SIZE) /* put s in new block */
X {
X nbp->b_ptr[0] = s;
X nbp->b_count = 1;


X return TRUE;
X }
X

X /* move some ptrs from full block to new block */
X {
X register int j = 0;
X
X bp->b_count = after - count + 1; /* number of ptrs remaining */
X i = BLOCK_SIZE - bp->b_count; /* number of ptrs to be moved */
X nbp->b_count = i;
X while (--i >= 0)
X {
X j = bp->b_count + i;
X nbp->b_ptr[i] = bp->b_ptr[j];
X nbp->b_flags[i] = bp->b_flags[j];
X }
X bp->b_ptr[j] = s;
X bp->b_flags[j] = 0;
X ++bp->b_count;
X return TRUE;
X }
X}
X
X/*
X * delsline: delete line from storage
X *
X * the line is turned over to the caller


X */
X char *

Xdelsline(nr, delmarks)
X linenr_t nr;
X int delmarks;
X{
X char *ptr;
X register block_t *bp;
X register char **pp;
X register char *fp;


X register int i;
X

X if (nr < 1 || nr > line_count)
X {
X emsg("delsline: nr wrong");
X return (alloc_line(0));
X }
X ptr = nr2ptr(nr);
X if (delmarks)
X adjustmark(ptr, NULL); /* remove marks for this line */
X bp = curr_block;
X if (line_count == 1) /* don't delete the last line in the file */
X {
X bp->b_ptr[0] = alloc_line(0);
X return (ptr);
X }
X --line_count;
X
X /* move the rest of the ptrs in this block one down */
X pp = &(bp->b_ptr[nr - curr_count]);
X fp = &(bp->b_flags[nr - curr_count]);
X for (i = bp->b_count + curr_count - nr - 1; --i >= 0; ++pp, ++fp)
X {
X *pp = *(pp + 1);
X *fp = *(fp + 1);
X }
X if (--bp->b_count == 0) /* the block became empty, remove it from the list */
X {
X if (bp->b_prev == NULL)
X first_block = bp->b_next;
X else
X bp->b_prev->b_next = bp->b_next;
X if (bp->b_next == NULL)
X last_block = bp->b_prev;
X else
X bp->b_next->b_prev = bp->b_prev;
X free_line((char *)bp);
X curr_count = 0; /* curr_block invalid */
X }
X return (ptr);
X}
X
X/*
X * replace the line "lnum" with the line "new".
X * return the old line (which should be freed by the caller)


X */
X char *

Xreplaceline(lnum, new)
X linenr_t lnum;
X char *new;
X{
X char *old;
X
X old = nr2ptr(lnum);
X if (new == NULL || curr_count == 0) /* we don't want NULL pointers in the list */
X return (alloc_line(0)); /* be friendly to the caller */
X
X curr_block->b_ptr[lnum - curr_count] = new;
X curr_block->b_flags[lnum - curr_count] = 0;
X adjustmark(old, new);
X return (old);
X}
X
X/*
X * canincrease(n) - returns TRUE if the current line can be increased 'n'
X * bytes
X *
X * This routine returns immediately if the requested space is available. If not,
X * it attempts to allocate the space and adjust the data structures
X * accordingly. If everything fails it returns FALSE.
X */
X int
Xcanincrease(n)
X int n;
X{
X register char *old;
X register char *new; /* pointer to new space */
X register unsigned newsize;
X
X old = nr2ptr(Curpos.lnum);
X newsize = strlen(old) + n;
X
X new = alloc_line(newsize);
X if (new == NULL)
X return FALSE;
X
X strcpy(new, old);
X adjustmark(old, new);
X free_line(old);
X curr_block->b_ptr[Curpos.lnum - curr_count] = new;
X curr_block->b_flags[Curpos.lnum - curr_count] = 0;
X
X return TRUE;
X}
END_OF_FILE
if test 19504 -ne `wc -c <'vim/src/storage.c'`; then
echo shar: \"'vim/src/storage.c'\" unpacked with wrong size!
fi
# end of 'vim/src/storage.c'
fi
echo shar: End of archive 11 \(of 23\).
cp /dev/null ark11isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:34:18 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 12
Archive-name: vim/part12
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 12 (of 23)."
# Contents: vim/src/ops.c vim/src/search.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:10 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/ops.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/ops.c'\"
else
echo shar: Extracting \"'vim/src/ops.c'\" \(28332 characters\)
sed "s/^X//" >'vim/src/ops.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * ops.c: implementation of various operators: doshift, dodelete, dotilde,
X * dochange, doyank, doput, dojoin


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"

X#include "param.h"
X#include "ops.h"
X
X/*
X * We have one yank buffer for normal yanks and puts, nine yank buffers for
X * deletes and 26 yank buffers for use by name.
X * Each yank buffer is an array of pointers to lines.
X */
Xstatic struct yankbuf
X{
X char **y_array; /* pointer to array of line pointers */
X linenr_t y_size; /* number of lines in y_array */
X char y_type; /* MLINE, MCHAR or MBLOCK */
X} y_buf[36]; /* 0..9 = number buffers, 10..35 = char buffers */
X
Xstatic struct yankbuf *y_current; /* ptr to current yank buffer */
Xstatic int yankappend; /* TRUE when appending */
Xstatic struct yankbuf *y_previous = NULL; /* ptr to last written yank buffer */
X
Xstatic void get_yank_buffer __ARGS((int));
Xstatic int stuff_yank __ARGS((int, char *));
Xstatic void free_yank __ARGS((long));
Xstatic void free_yank_all __ARGS((void));
Xstatic void block_prep __ARGS((linenr_t, int));
X
X/* variables use by block_prep, dodelete and doyank */
Xstatic int startspaces;
Xstatic int endspaces;
Xstatic int textlen;
Xstatic char *textstart;
Xstatic colnr_t textcol;
X
X/*
X * doshift - handle a shift operation
X */
X void
Xdoshift(op)
X int op;
X{


X register int i;
X

X if (!u_save((linenr_t)(Curpos.lnum - 1), (linenr_t)(Curpos.lnum + nlines)))
X return;
X
X Curpos.lnum += nlines; /* start with last line, leave cursor on first */
X for (i = nlines; --i >= 0; )
X if (lineempty(--Curpos.lnum))
X Curpos.col = 0;
X else
X shift_line(op == LSHIFT);
X
X updateScreen(CURSUPD);
X
X if (nlines > p_report)
X smsg("%ld line%s %ced", nlines, plural(nlines),
X (op == RSHIFT) ? '>' : '<');
X}
X
X/*
X * shift the current line one shiftwidth left (if left != 0) or right
X * leaves cursor on first blank in the line
X */
X void
Xshift_line(left)
X int left;
X{
X register int count;
X register int i, j;
X
X count = get_indent(); /* get current indent */
X
X if (p_sr) /* round off indent */
X {
X i = count / p_sw; /* compute new indent */
X j = count % p_sw;
X if (j)
X {
X if (!left)
X ++i;
X }
X else if (left)
X {
X if (i)
X --i;
X }
X else
X ++i;
X count = i * p_sw;
X }
X else /* original vi indent */
X {
X if (left)
X {
X count -= p_sw;
X if (count < 0)
X count = 0;
X }
X else
X count += p_sw;
X }
X set_indent(count, TRUE); /* set new indent */
X}
X
X/*
X * Set y_current and yankappend, according to the value of yankbuffer.


X */
X static void

Xget_yank_buffer(writing)
X int writing;
X{


X register int i;
X

X yankappend = FALSE;
X if (yankbuffer == 0 && y_previous != NULL && !writing)
X {
X y_current = y_previous;
X return;
X }
X i = yankbuffer;
X if (isdigit(i))
X i -= '0';
X else if (islower(i))
X i -= 'a' - 10;
X else if (isupper(i))
X {
X i -= 'A' - 10;
X yankappend = TRUE;
X }
X else /* not 0-9, a-z or A-Z: use buffer 0 */
X i = 0;
X y_current = &(y_buf[i]);
X if (writing) /* remember the buffer we write into for doput() */
X y_previous = y_current;
X}
X
X/*
X * (stop) recording into a yank buffer
X */
X int
Xdorecord(c)
X int c;
X{
X char *p, *lp;
X static int bufname;
X
X if (Recording == FALSE) /* start recording */
X {
X if (!isalpha(c))
X return FALSE;
X Recording = TRUE;
X showmode();
X bufname = c;
X return TRUE;
X }
X else /* stop recording */
X {
X Recording = FALSE;
X if (p_mo)
X msg("");
X p = (char *)get_recorded();
X if (p == NULL)
X return FALSE;
X lp = strrchr(p, 'v'); /* delete the trailing 'v' */
X if (lp != NULL)
X *lp = NUL;
X return (stuff_yank(bufname, p));
X }
X}
X
X/*
X * stuff string 'p' into yank buffer 'bufname' (append if uppercase)
X * 'p' is assumed to be alloced.


X */
X static int

Xstuff_yank(bufname, p)
X int bufname;
X char *p;
X{
X char *lp;
X char **pp;
X
X yankbuffer = bufname;
X if (yankbuffer == '.') /* read-only buffer */
X return FALSE;
X get_yank_buffer(TRUE);
X if (yankappend && y_current->y_array != NULL)
X {
X pp = &(y_current->y_array[y_current->y_size - 1]);
X lp = alloc((unsigned)(strlen(*pp) + strlen(p) + 1));
X if (lp == NULL)
X {
X free(p);
X return FALSE;
X }
X strcpy(lp, *pp);
X strcat(lp, p);
X free(p);
X free(*pp);
X *pp = lp;
X }
X else
X {
X free_yank_all();
X if ((y_current->y_array = (char **)alloc((unsigned)sizeof(char *))) == NULL)
X {
X free(p);
X return FALSE;
X }
X y_current->y_array[0] = p;
X y_current->y_size = 1;
X y_current->y_type = MCHAR; /* used to be MLINE, why? */


X }
X return TRUE;
X}

X
X/*
X * execute a yank buffer: copy it into the stuff buffer
X */
X int
Xdoexecbuf(c)
X int c;
X{
X static int lastc = NUL;
X long i;
X
X if (c == '@') /* repeat previous one */


X c = lastc;
X

X lastc = c;
X if (!isalnum(c)) /* registers 0-9 and a-z are allowed */
X return FALSE;
X
X yankbuffer = c;
X get_yank_buffer(FALSE);
X if (y_current->y_array == NULL)
X return FALSE;
X
X for (i = y_current->y_size; --i >= 0; )
X {
X /* insert newline between lines and after last line if type is MLINE */
X if (y_current->y_type == MLINE || i < y_current->y_size - 1)
X {
X if (ins_mapbuf("\n") < 0)
X return FALSE;
X }
X if (ins_mapbuf(y_current->y_array[i]) < 0)


X return FALSE;
X }
X

X return TRUE;
X}
X
X/*

X * insert a yank buffer: copy it into the Read buffer
X */
X int
Xinsertbuf(c)
X int c;
X{
X long i;
X
X if (!isalnum(c)) /* registers 0-9 and a-z are allowed */
X return FALSE;
X
X yankbuffer = c;
X get_yank_buffer(FALSE);
X if (y_current->y_array == NULL)
X return FALSE;
X
X for (i = 0; i < y_current->y_size; ++i)
X {
X stuffReadbuff(y_current->y_array[i]);
X /* insert newline between lines and after last line if type is MLINE */
X if (y_current->y_type == MLINE || i < y_current->y_size - 1)
X stuffReadbuff("\n");


X }
X return TRUE;
X}

X
X/*
X * dodelete - handle a delete operation
X */
X void
Xdodelete()
X{
X register int n;
X linenr_t lnum;
X char *ptr;
X
X /*
X * Do a yank of whatever we're about to delete. If there's too much stuff
X * to fit in the yank buffer, then get a confirmation before doing the
X * delete. This is crude, but simple. And it avoids doing a delete of
X * something we can't put back if we want.
X */
X if (yankbuffer == 0) /* normal delete: shift number buffers */
X {
X y_current = &y_buf[9];
X free_yank_all(); /* free buffer nine */
X for (n = 9; n > 1; --n)
X y_buf[n] = y_buf[n - 1];
X y_previous = y_current = &y_buf[1];
X y_buf[1].y_array = NULL; /* set buffer one to empty */
X }
X else if (yankbuffer == '.') /* read-only buffer */
X {
X beep();
X return;
X }
X else /* yank into specified buffer */
X get_yank_buffer(TRUE);
X
X if (!doyank(TRUE))
X {
X if (ask_yesno("cannot yank; delete anyway") != 'y')
X {
X emsg(e_abort);
X return;
X }
X }
X
X if (!u_save((linenr_t)(startop.lnum - 1), (linenr_t)(endop.lnum + 1)))
X return;
X
X/*
X * block mode
X */
X if (Quote_block)
X {
X for (lnum = Curpos.lnum; Curpos.lnum <= endop.lnum; ++Curpos.lnum)
X {
X block_prep(Curpos.lnum, TRUE);
X if (textlen == 0) /* nothing to delete */
X continue;
X
X /*
X * If we delete a TAB, it may be replaced by several characters.
X * Thus the number of characters may increase!
X */
X n = textlen - startspaces - endspaces;
X /* number of characters increases - make room */
X if (n < 0 && !canincrease(-n))
X continue;
X ptr = nr2ptr(Curpos.lnum) + textcol;
X /* copy the part after the deleted part */
X memmove(ptr + startspaces + endspaces, ptr + textlen, strlen(ptr + textlen) + 1);
X /* insert spaces */
X copy_spaces(ptr, (size_t)(startspaces + endspaces));
X if (n > 0)
X canincrease(0);


X }
X Curpos.lnum = lnum;

X CHANGED;
X updateScreen(VALID_TO_CURSCHAR);
X nlines = 0; /* no lines deleted */
X }
X else if (mtype == MLINE)
X {
X u_clearline(); /* "U" command should not be possible after "dd" */
X if (operator == CHANGE)
X {
X dellines((long)(nlines - 1), TRUE);
X Curpos.col = 0;
X while (delchar(TRUE));
X }
X else
X {
X dellines(nlines, TRUE);
X }
X }
X else if (nlines == 1) /* del. within line */
X {
X n = endop.col - startop.col + 1 - oneless;
X while (n--)
X if (!delchar(TRUE))
X break;
X }
X else /* del. between lines */
X {
X n = Curpos.col;
X while (Curpos.col >= n)
X if (!delchar(TRUE))
X break;
X
X startop = Curpos; /* remember Curpos */
X ++Curpos.lnum;
X dellines((long)(nlines - 2), TRUE);
X n = endop.col - oneless;
X
X while (n-- >= 0)
X if (!delchar(TRUE))
X break;
X Curpos = startop; /* restore Curpos */
X dojoin(FALSE);
X }
X
X if ((mtype == MCHAR && nlines <= 2 /* && p_nu == FALSE */) || operator == CHANGE)
X {


X cursupdate();
X updateline();
X }

X else
X updateScreen(CURSUPD);
X
X if (mtype == MCHAR)
X --nlines;
X msgmore(-nlines);
X
X /* correct endop for deleted text (for "']" command) */
X if (Quote_block)
X endop.col = startop.col;
X else
X endop = startop;
X}
X
X/*
X * dotilde - handle the (non-standard vi) tilde operator
X */
X void
Xdotilde()
X{
X FPOS pos;
X
X if (!u_save((linenr_t)(startop.lnum - 1), (linenr_t)(endop.lnum + 1)))
X return;
X
X pos = startop;
X if (Quote_block) /* block mode */
X {
X for (; pos.lnum <= endop.lnum; ++pos.lnum)
X {
X block_prep(pos.lnum, FALSE);
X pos.col = textcol;
X for (; --textlen >= 0; inc(&pos))
X swapchar(&pos);
X }
X }
X else /* not block mode */
X {
X if (mtype == MLINE)
X {
X pos.col = 0;
X endop.col = strlen(nr2ptr(endop.lnum));
X if (endop.col)
X --endop.col;
X }
X else if (oneless)
X dec(&endop);
X
X for ( ; ltoreq(pos, endop); inc(&pos))
X swapchar(&pos);
X }
X
X if (mtype == MCHAR && nlines == 1 && !Quote_block)
X {


X cursupdate();
X updateline();
X }

X else
X updateScreen(CURSUPD);
X
X if (nlines > p_report)
X smsg("%ld line%s ~ed", nlines, plural(nlines));
X}
X
X/*
X * If operator == UPPER: make uppercase,
X * if operator == LOWER: make lowercase,
X * else swap case of character at 'pos'
X */
X void
Xswapchar(pos)
X FPOS *pos;
X{
X int c;
X
X c = gchar(pos);
X if (islower(c) && operator != LOWER)
X {
X pchar(*pos, toupper(c));
X CHANGED;
X }
X else if (isupper(c) && operator != UPPER)
X {
X pchar(*pos, tolower(c));
X CHANGED;
X }
X}
X
X/*
X * dochange - handle a change operation
X */
X void
Xdochange()
X{
X register colnr_t l;
X
X l = startop.col;
X
X dodelete();
X
X if ((l > Curpos.col) && !lineempty(Curpos.lnum))
X incCurpos();
X
X startinsert(NUL, FALSE, (linenr_t)1);
X}
X
X/*
X * set all the yank buffers to empty (called from main())
X */
X void
Xinit_yank()
X{


X register int i;
X

X for (i = 0; i < 36; ++i)
X y_buf[i].y_array = NULL;
X}
X
X/*
X * Free "n" lines from the current yank buffer.
X * Called for normal freeing and in case of error.


X */
X static void

Xfree_yank(n)
X long n;
X{
X if (y_current->y_array != NULL)
X {
X register long i;
X
X for (i = n; --i >= 0; )
X {
X if (i % 1000 == 999) /* this may take a while */
X smsg("freeing %ld lines", i + 1);
X free(y_current->y_array[i]);
X }
X free((char *)y_current->y_array);
X y_current->y_array = NULL;
X if (n >= 1000)
X msg("");
X }


X}
X
X static void

Xfree_yank_all()
X{
X free_yank(y_current->y_size);
X}
X
X/*
X * Yank the text between Curpos and startpos into a yank buffer.
X * If we are to append ("uppercase), we first yank into a new yank buffer and
X * then concatenate the old and the new one (so we keep the old one in case
X * of out-of-memory).
X */
X int
Xdoyank(deleting)
X int deleting;
X{
X long i; /* index in y_array[] */
X struct yankbuf *curr; /* copy of y_current */
X struct yankbuf new; /* new yank buffer when appending */
X char **new_ptr;
X register linenr_t lnum; /* current line number */
X long j;
X
X char *pnew;
X
X if (yankbuffer == '.') /* read-only buffer */
X {
X beep();
X return FALSE;
X }
X if (!deleting) /* dodelete() already set y_current */
X get_yank_buffer(TRUE);
X
X curr = y_current;
X if (yankappend && y_current->y_array != NULL) /* append to existing contents */
X y_current = &new;
X else
X free_yank_all(); /* free previously yanked lines */
X
X y_current->y_size = nlines;
X y_current->y_type = mtype; /* set the yank buffer type */
X y_current->y_array = (char **)alloc((unsigned)(sizeof(char *) * nlines));
X
X if (y_current->y_array == NULL)
X {
X y_current = curr;


X return FALSE;
X }
X

X i = 0;
X lnum = startop.lnum;
X
X if (Quote_block)
X {
X/*
X * block mode
X */
X y_current->y_type = MBLOCK; /* set the yank buffer type */
X for ( ; lnum <= endop.lnum; ++lnum)
X {
X block_prep(lnum, FALSE);
X if ((pnew= alloc(startspaces + endspaces + textlen + 1)) == NULL)
X goto fail;
X y_current->y_array[i++] = pnew;
X copy_spaces(pnew, (size_t)startspaces);
X pnew += startspaces;
X strncpy(pnew, textstart, (size_t)textlen);
X pnew += textlen;
X copy_spaces(pnew, (size_t)endspaces);
X pnew += endspaces;
X *pnew = NUL;


X }
X }
X else
X {

X/*
X * there are three parts for non-block mode:
X * 1. if mtype != MLINE yank last part of the top line
X * 2. yank the lines between startop and endop, inclusive when mtype == MLINE
X * 3. if mtype != MLINE yank first part of the bot line
X */
X if (mtype != MLINE)
X {
X if (nlines == 1) /* startop and endop on same line */
X {
X j = endop.col - startop.col + 1 - oneless;
X if ((y_current->y_array[0] = strnsave(nr2ptr(lnum) + startop.col, (int)j)) == NULL)
X {
X fail:
X free_yank(i); /* free the lines that we allocated */
X y_current = curr;
X return FALSE;
X }
X goto success;
X }
X if ((y_current->y_array[0] = strsave(nr2ptr(lnum++) + startop.col)) == NULL)
X goto fail;
X ++i;
X }
X
X while (mtype == MLINE ? (lnum <= endop.lnum) : (lnum < endop.lnum))
X {
X if ((y_current->y_array[i] = strsave(nr2ptr(lnum++))) == NULL)
X goto fail;
X ++i;
X }
X if (mtype != MLINE)
X {
X if ((y_current->y_array[i] = strnsave(nr2ptr(endop.lnum), endop.col + 1 - oneless)) == NULL)


X goto fail;
X }
X }
X

Xsuccess:
X if (curr != y_current) /* append the new block to the old block */
X {
X new_ptr = (char **)alloc((unsigned)(sizeof(char *) * (curr->y_size + y_current->y_size)));
X if (new_ptr == NULL)
X goto fail;
X for (j = 0; j < curr->y_size; ++j)
X new_ptr[j] = curr->y_array[j];
X free(curr->y_array);
X curr->y_array = new_ptr;
X
X if (mtype == MLINE) /* MLINE overrides MCHAR and MBLOCK */
X curr->y_type = MLINE;
X if (curr->y_type == MCHAR) /* concatenate the last line of the old
X block with the first line of the new block */
X {
X new_ptr = (char **)alloc((unsigned)(strlen(curr->y_array[curr->y_size - 1]) + strlen(y_current->y_array[0]) + 1));
X if (new_ptr == NULL)
X {
X i = y_current->y_size - 1;
X goto fail;
X }
X strcpy((char *)new_ptr, curr->y_array[--j]);
X strcat((char *)new_ptr, y_current->y_array[0]);
X free(curr->y_array[j]);
X free(y_current->y_array[0]);
X curr->y_array[j++] = (char *)new_ptr;


X i = 1;
X }

X else
X i = 0;
X while (i < y_current->y_size)
X curr->y_array[j++] = y_current->y_array[i++];
X curr->y_size = j;
X free(y_current->y_array);
X y_current = curr;
X }
X if (operator == YANK) /* don't do this when deleting */
X {
X if (mtype == MCHAR)
X --nlines;
X if (nlines > p_report)
X {
X cursupdate(); /* redisplay now, so message is not deleted */
X smsg("%ld line%s yanked", nlines, plural(nlines));
X }
X }


X
X return TRUE;
X}

X
X void
Xdoput(dir, count)
X int dir;
X long count;
X{
X char *ptr, *ep;
X int newlen;
X int totlen = 0; /* init for gcc */
X linenr_t lnum;
X int col;
X long i; /* index in y_array[] */
X int y_type;
X long y_size;
X char **y_array;
X long nlines = 0;
X int vcol;
X int delchar;
X int incr = 0;
X long j;
X FPOS newCurpos;
X
X startop = Curpos; /* default for "'[" command */


X if (dir == FORWARD)

X startop.col++;
X endop = Curpos; /* default for "']" command */
X if (yankbuffer == '.') /* use inserted text */
X {
X stuff_inserted(dir == FORWARD ? (count == -1 ? 'o' : 'a') : (count == -1 ? 'O' : 'i'), count, FALSE);
X return;
X }
X get_yank_buffer(FALSE);
X
X y_type = y_current->y_type;
X y_size = y_current->y_size;
X y_array = y_current->y_array;
X
X if (count == -1) /* :put command */
X {
X y_type = MLINE;


X count = 1;
X }

X
X if (y_size == 0 || y_array == NULL)
X {
X beep();
X return;
X }
X
X if (y_type == MBLOCK)
X {
X lnum = Curpos.lnum + y_size + 1;
X if (lnum > line_count)
X lnum = line_count + 1;
X if (!u_save(Curpos.lnum - 1, lnum))
X return;
X }
X else if (!u_saveCurpos())
X return;
X
X newlen = strlen(y_array[0]);
X CHANGED;
X
X lnum = Curpos.lnum;
X col = Curpos.col;
X
X/*
X * block mode
X */
X if (y_type == MBLOCK)
X {
X if (dir == FORWARD && gcharCurpos() != NUL)
X {
X col = getvcol(&Curpos, 3) + 1;


X ++Curpos.col;
X }
X else

X col = getvcol(&Curpos, 2);
X for (i = 0; i < y_size; ++i)
X {
X startspaces = 0;
X endspaces = 0;
X textcol = 0;
X vcol = 0;
X delchar = 0;
X
X /* add a new line */
X if (Curpos.lnum > line_count)
X {
X ep = alloc_line(0);
X if (ep == NULL)
X goto error;
X appendline(line_count, ep);
X ++nlines;


X }
X ptr = nr2ptr(Curpos.lnum);

X while (vcol < col && *ptr)
X {


X /* Count a tab for what it's worth (if list mode not on) */

X incr = chartabsize(*ptr, vcol);
X vcol += incr;
X ++ptr;
X ++textcol;
X }
X if (vcol < col) /* line too short, padd with spaces */
X {
X startspaces = col - vcol;
X }
X else if (vcol > col)
X {
X endspaces = vcol - col;
X startspaces = incr - endspaces;
X --textcol;
X delchar = 1;
X }
X newlen = strlen(y_array[i]);
X totlen = count * newlen + startspaces + endspaces;
X if (!canincrease(totlen))
X break;
X ptr = nr2ptr(Curpos.lnum) + textcol;
X
X /* move the text after the cursor to the end of the line. */
X memmove(ptr + totlen - delchar, ptr, strlen(ptr) + 1);
X /* may insert some spaces before the new text */
X copy_spaces(ptr, (size_t)startspaces);
X ptr += startspaces;
X /* insert the new text */
X for (j = 0; j < count; ++j)
X {
X strncpy(ptr, y_array[i], (size_t)newlen);
X ptr += newlen;
X }
X /* may insert some spaces after the new text */
X copy_spaces(ptr, (size_t)endspaces);
X
X ++Curpos.lnum;


X if (i == 0)

X Curpos.col += startspaces;
X }
X endop.lnum = Curpos.lnum - 1; /* for "']" command */
X endop.col = textcol + totlen - 1;
X Curpos.lnum = lnum;


X cursupdate();
X updateScreen(VALID_TO_CURSCHAR);
X }

X else /* not block mode */
X {
X if (y_type == MCHAR)
X {
X /* if type is MCHAR, FORWARD is the same as BACKWARD on the next character */
X if (dir == FORWARD && gcharCurpos() != NUL)
X {
X ++col;
X if (newlen)
X {
X ++Curpos.col;
X ++endop.col;
X }
X }
X newCurpos = Curpos;
X }
X else if (dir == BACKWARD)
X /* if type is MLINE, BACKWARD is the same as FORWARD on the previous line */
X --lnum;
X else /* type == MLINE, dir == FORWARD */
X {
X startop.col = 0;
X startop.lnum++;
X }
X
X/*
X * simple case: insert into current line
X */
X if (y_type == MCHAR && y_size == 1)
X {
X i = count * newlen;
X if (!canincrease((int)i))
X return; /* alloc() will give error message */
X ep = nr2ptr(lnum) + col;
X memmove(ep + i, ep, strlen(ep) + 1);
X Curpos.col += i - 1; /* put cursor on last putted char */
X for (i = 0; i < count; ++i)
X {
X strncpy(ep, y_array[0], (size_t)newlen);
X ep += newlen;
X }
X endop = Curpos;
X updateline();
X }
X else
X {
X if (y_type == MCHAR)
X --y_size;
X while (--count >= 0)
X {
X i = 0;
X if (y_type == MCHAR)
X {
X /*
X * Split the current line in two at the insert position.
X * Append y_array[0] to first line.
X * Insert y_array[size - 1] in front of second line.
X */
X ptr = nr2ptr(lnum) + col;
X col = strlen(y_array[y_size]);
X ep = alloc_line((unsigned)(strlen(ptr) + col));
X if (ep == NULL)
X goto error;
X strcpy(ep, y_array[y_size]);
X strcat(ep, ptr);
X appendline(lnum, ep); /* insert in second line */
X ++nlines;
X *ptr = NUL;
X Curpos.lnum = lnum;
X if (!canincrease(newlen)) /* lnum == Curpos.lnum! */
X goto error;
X strcat(nr2ptr(lnum), y_array[0]);/* append to first line */


X i = 1;
X }

X
X while (i < y_size)
X {
X ep = save_line(y_array[i++]);
X if (ep == NULL)
X goto error;
X appendline(lnum++, ep);
X ++nlines;
X }
X if (y_type == MCHAR)
X ++lnum; /* lnum is now number of line below inserted lines */
X }
X
X endop.lnum = lnum; /* for "']" command */
X if (y_type == MLINE)
X {
X Curpos.col = 0;
X endop.col = 0;
X if (dir == FORWARD)
X {
X updateScreen(NOT_VALID); /* recompute Botline */
X ++Curpos.lnum;
X }
X /* put cursor on first non-blank in last inserted line */
X beginline(TRUE);
X }
X else /* put cursor on first inserted character */
X {
X if (col > 1)
X endop.col = col - 1;
X else
X endop.col = 0;
X Curpos = newCurpos;
X }
X
Xerror:


X updateScreen(CURSUPD);
X }
X }
X

X msgmore(nlines);
X set_want_col = TRUE;
X}
X
X/*
X * display the contents of the yank buffers
X */
X void
Xdodis()
X{
X register int i, n;
X register long j;
X register char *p;
X register struct yankbuf *yb;
X
X#ifdef AMIGA


X settmode(0); /* set cooked mode so output can be halted */
X#endif

X for (i = -1; i < 36; ++i)
X {
X if (i == -1)
X {
X if (y_previous != NULL)
X yb = y_previous;
X else
X yb = &(y_buf[0]);
X }
X else
X yb = &(y_buf[i]);
X if (yb->y_array != NULL)
X {
X if (i == -1)
X outstrn("pP");
X else
X {
X outchar('"');
X if (i < 10)
X outchar(i + '0');
X else
X outchar(i + 'a' - 10);
X }
X outchar(' ');
X
X n = Columns - 4;
X for (j = 0; j < yb->y_size && n > 0; ++j)
X {
X if (j)
X {
X outstrn("^J");
X n -= 2;
X }
X for (p = yb->y_array[j]; *p && n > 0; ++p)
X {
X outstrn(transchar(*p));
X n -= charsize(*p);
X }
X }


X outchar('\n');
X flushbuf();
X }
X }

X#ifdef AMIGA
X settmode(1);
X#endif
X wait_return(TRUE);

X}
X
X/*
X * join 'count' lines (minimal 2), including u_save()
X */
X void
Xdodojoin(count, flag, redraw)
X long count;
X int flag;
X int redraw;
X{
X if (!u_save((linenr_t)(Curpos.lnum - 1), (linenr_t)(Curpos.lnum + count)))
X return;
X
X while (--count > 0)
X if (!dojoin(flag))
X {
X beep();
X break;
X }
X
X if (redraw)
X updateScreen(VALID_TO_CURSCHAR);
X}
X
X int
Xdojoin(insert_space)
X int insert_space;
X{
X char *curr;
X char *next;
X char *endcurr;
X int currsize; /* size of the current line */
X int nextsize; /* size of the next line */
X int spaces; /* number of spaces to insert */
X int rows_to_del; /* number of rows on screen to delete */
X linenr_t t;
X
X if (Curpos.lnum == line_count) /* on last line */
X return FALSE;
X
X rows_to_del = plines_m(Curpos.lnum, Curpos.lnum + 1);
X curr = nr2ptr(Curpos.lnum);
X currsize = strlen(curr);
X next = nr2ptr((linenr_t)(Curpos.lnum + 1));
X spaces = 0;
X if (insert_space)
X {
X skipspace(&next);
X spaces = 1;
X if (*next == ')' || currsize == 0)
X spaces = 0;
X else
X {
X endcurr = curr + currsize - 1;
X if (*endcurr == ' ' || *endcurr == TAB)
X {
X spaces = 0;
X if (currsize > 1)
X --endcurr;
X }
X if (p_js && strchr(".!?", *endcurr) != NULL)
X ++spaces;
X }
X }
X nextsize = strlen(next);
X if (!canincrease(nextsize + spaces))
X return FALSE;
X
X curr = nr2ptr(Curpos.lnum); /* canincrease() will have changed the pointer */
X
X while (spaces)
X {
X *(curr + currsize++) = ' ';
X --spaces;
X }
X strcpy(curr + currsize, next);
X
X /*
X * Delete the following line. To do this we move the cursor there
X * briefly, and then move it back.
X */
X t = Curpos.lnum;
X ++Curpos.lnum;
X dellines(1L, FALSE);
X Curpos.lnum = t;
X
X /*
X * the number of rows on the screen is reduced by the difference
X * in number of rows of the two old lines and the one new line
X */
X rows_to_del -= plines(Curpos.lnum);
X if (rows_to_del > 0)
X s_del(Cursrow, rows_to_del, TRUE);
X
X if (currsize == 0)
X Curpos.col = 0;
X else
X {
X Curpos.col = currsize - 1;
X oneright(); /* go to first char. of joined line */
X }
X CHANGED;


X
X return TRUE;
X}

X
X/*
X * implementation of the format operator 'V'
X */
X void
Xdoformat()
X{
X /* prepare undo and join the lines */
X dodojoin((long)endop.lnum - (long)startop.lnum + 1, TRUE, FALSE);
X
X /* put cursor on last non-space */
X coladvance(29999);
X while (Curpos.col && isspace(gcharCurpos()))
X decCurpos();


X curs_columns(); /* update Cursvcol */
X

X /* do the formatting */
X State = INSERT; /* for Opencmd() */
X insertchar(NUL);
X State = NORMAL;
X updateScreen(NOT_VALID);
X}
X
X void
Xstartinsert(initstr, startln, count)
X int initstr;
X int startln; /* if set, insert at start of line */
X long count;
X{
X Insstart = Curpos;
X if (startln)
X Insstart.col = 0;
X
X if (initstr != NUL)
X {
X ResetBuffers();
X AppendNumberToRedobuff(count);
X AppendToRedobuff(mkstr(initstr));
X }
X
X if (initstr == 'R')
X State = REPLACE;
X else
X State = INSERT;
X
X if (p_mo)
X showmode();
X
X edit(count);
X}
X
X/*
X * prepare a few things for block mode yank/delete/tilde
X *
X * for delete:
X * - textlen includes the first/last char to be (partly) deleted
X * - start/endspaces is the number of columns that are taken by the
X * first/last deleted char minus the number of columns that have to be deleted.
X * for yank and tilde:
X * - textlen includes the first/last char to be wholly yanked
X * - start/endspaces is the number of columns of the first/last yanked char
X * that are to be yanked.


X */
X static void

Xblock_prep(lnum, delete)
X linenr_t lnum;
X int delete;
X{
X int vcol;
X int incr = 0;
X char *pend;
X
X startspaces = 0;
X endspaces = 0;
X textlen = 0;
X textcol = 0;
X vcol = 0;
X textstart = nr2ptr(lnum);
X while (vcol < startvcol && *textstart)
X {


X /* Count a tab for what it's worth (if list mode not on) */

X incr = chartabsize(*textstart, vcol);
X vcol += incr;
X ++textstart;
X ++textcol;
X }
X if (vcol < startvcol) /* line too short */
X {
X if (!delete)
X endspaces = endvcol - startvcol + 1;
X }
X else /* vcol >= startvcol */
X {
X startspaces = vcol - startvcol;
X if (delete && vcol > startvcol)
X startspaces = incr - startspaces;
X pend = textstart;
X while (vcol <= endvcol && *pend)
X {


X /* Count a tab for what it's worth (if list mode not on) */

X incr = chartabsize(*pend, vcol);
X vcol += incr;
X ++pend;
X }
X if (vcol < endvcol && !delete) /* line too short */
X {
X endspaces = endvcol - vcol;
X }
X else if (vcol > endvcol)
X {
X if (delete)
X endspaces = vcol - endvcol - 1;
X else if (pend != textstart)
X {
X endspaces = incr - (vcol - endvcol);
X if (endspaces)
X --pend;
X }
X }
X if (delete && startspaces)
X {
X --textstart;
X --textcol;
X }
X textlen = pend - textstart;


X }
X}
X
X int

Xdoaddsub(c, Prenum1)
X int c;
X linenr_t Prenum1;
X{
X register int col;
X char buf[30];
X int hex; /* 'x' or 'X': hexadecimal; '0': octal */
X static int hexupper = FALSE; /* 0xABC */
X long n;
X char *ptr;
X
X ptr = nr2ptr(Curpos.lnum);
X col = Curpos.col;
X
X /* first check if we are on a hexadecimal number */
X while (col > 0 && isxdigit(ptr[col]))
X --col;
X if (col > 0 && toupper(ptr[col]) == 'X' && ptr[col - 1] == '0' && isxdigit(ptr[col + 1]))
X --col; /* found hexadecimal number */
X else
X {
X /* first search forward and then backward for start of number */
X col = Curpos.col;
X
X while (ptr[col] != NUL && !isdigit(ptr[col]))
X ++col;
X
X while (col > 0 && isdigit(ptr[col - 1]))
X --col;
X }
X
X if (isdigit(ptr[col]) && u_saveCurpos())
X {
X set_want_col = TRUE;
X
X if (ptr[col] != '0')
X hex = 0; /* decimal */
X else
X {
X hex = toupper(ptr[col + 1]); /* assume hexadecimal */
X if (hex != 'X' || !isxdigit(ptr[col + 2]))
X {
X if (isdigit(hex))
X hex = '0'; /* octal */
X else
X hex = 0; /* 0 by itself is decimal */
X }
X }
X
X if (!hex && col > 0 && ptr[col - 1] == '-')
X --col;
X
X ptr += col;
X if (hex == '0')
X sscanf(ptr, "%lo", &n);
X else if (hex)
X sscanf(ptr, "%lx", &n); /* "%X" doesn't work! */
X else
X n = atol(ptr);
X
X if (c == Ctrl('A'))
X n += Prenum1;
X else
X n -= Prenum1;
X
X if (hex == 'X') /* skip the '0x' */
X col += 2;
X Curpos.col = col;
X do /* delete the old number */
X {
X if (isalpha(c))
X {
X if (isupper(c))
X hexupper = TRUE;
X else
X hexupper = FALSE;
X }
X delchar(FALSE);
X c = gcharCurpos();
X }
X while (hex ? (hex == '0' ? c >= '0' && c <= '7' : isxdigit(c)) : isdigit(c));
X
X if (hex == '0')
X sprintf(buf, "0%lo", n);
X else if (hexupper)
X sprintf(buf, "%lX", n);
X else if (hex)
X sprintf(buf, "%lx", n);
X else
X sprintf(buf, "%ld", n);
X insstr(buf); /* insert the new number */
X --Curpos.col;
X updateline();
X return TRUE;
X }
X else


X {
X beep();
X return FALSE;

X }
X}
END_OF_FILE
if test 28332 -ne `wc -c <'vim/src/ops.c'`; then
echo shar: \"'vim/src/ops.c'\" unpacked with wrong size!
fi
# end of 'vim/src/ops.c'
fi
if test -f 'vim/src/search.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/search.c'\"
else
echo shar: Extracting \"'vim/src/search.c'\" \(21652 characters\)
sed "s/^X//" >'vim/src/search.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */

X/*
X * search.c: code for normal mode searching commands


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"

X#include "param.h"
X
X/* modified Henry Spencer's regular expression routines */
X#include "regexp.h"
X
Xstatic int inmacro __ARGS((char *, char *));
Xstatic int cls __ARGS((void));
X
X/*
X * This file contains various searching-related routines. These fall into
X * three groups:
X * 1. string searches (for /, ?, n, and N)
X * 2. character searches within a single line (for f, F, t, T, etc)
X * 3. "other" kinds of searches like the '%' command, and 'word' searches.
X */
X
X/*
X * String searches
X *
X * The string search functions are divided into two levels:
X * lowest: searchit(); called by dosearch() and docmdline().
X * Highest: dosearch(); changes Curpos, called by normal().
X *
X * The last search pattern is remembered for repeating the same search.
X * This pattern is shared between the :g, :s, ? and / commands.
X * This is in myregcomp().
X *
X * The actual string matching is done using a heavily modified version of
X * Henry Spencer's regular expression library.
X */
X
Xstatic char *search_pattern = NULL; /* previous search pattern */
Xstatic int want_start; /* looking for start of line? */
X
X/*
X * translate search pattern for regcomp()
X */
X regexp *
Xmyregcomp(pat)
X char *pat;
X{
X regexp *retval;
X
X if (pat == NULL || *pat == NUL) /* use previous search pattern */
X {
X if (search_pattern == NULL)
X {
X emsg(e_noprevre);
X return (regexp *) NULL;
X }
X pat = search_pattern;
X }
X else
X {
X if (search_pattern != NULL)
X free(search_pattern);
X search_pattern = strsave(pat);
X reg_magic = p_magic; /* Magic sticks with the r.e. */
X }
X want_start = (*pat == '^'); /* looking for start of line? */
X reg_ic = p_ic; /* tell the regexec routine how to search */
X retval = regcomp(pat);
X return retval;
X}
X
X/*
X * lowest level search function.
X * Search for 'count'th occurrence of 'str' in direction 'dir'.
X * Start at position 'pos' and return the found position in 'pos'.
X * Return 1 for success, 0 for failure.
X */
X int
Xsearchit(pos, dir, str, count, end)
X FPOS *pos;
X int dir;
X char *str;
X long count;
X int end;
X{
X int found;
X linenr_t lnum;
X linenr_t startlnum;
X regexp *prog;
X register char *s;
X char *ptr;
X register int i;
X register char *match, *matchend;
X int loop;
X
X if ((prog = myregcomp(str)) == NULL)
X {
X emsg(e_invstring);
X return 0;
X }
X/*
X * find the string
X */
X found = 1;
X while (count-- && found) /* stop after count matches, or no more matches */
X {
X startlnum = pos->lnum; /* remember start of search for detecting no match */
X found = 0; /* default: not found */
X
X i = pos->col + dir; /* search starts one postition away */
X lnum = pos->lnum;
X
X if (dir == BACKWARD)
X {
X if (i < 0)
X --lnum;
X }
X
X for (loop = 0; loop != 2; ++loop) /* do this twice if 'wrapscan' is set */
X {
X for ( ; lnum > 0 && lnum <= line_count; lnum += dir, i = -1)
X {
X s = ptr = nr2ptr(lnum);
X if (dir == FORWARD && i > 0) /* first line for forward search */
X {
X if (want_start || strlen(s) <= (size_t)i) /* match not possible */
X continue;
X s += i;
X }
X
X if (regexec(prog, s, dir == BACKWARD || i <= 0))
X { /* match somewhere on line */
X match = prog->startp[0];
X matchend = prog->endp[0];
X if (dir == BACKWARD && !want_start)
X {
X /*
X * Now, if there are multiple matches on this line, we have to
X * get the last one. Or the last one before the cursor, if we're
X * on that line.
X */
X while (regexec(prog, prog->startp[0] + 1, (int)FALSE))
X {
X if ((i >= 0) && ((prog->startp[0] - s) > i))
X break;
X match = prog->startp[0];
X matchend = prog->endp[0];
X }
X
X if ((i >= 0) && ((match - s) > i))
X continue;
X }
X
X pos->lnum = lnum;
X if (end)
X pos->col = (int) (matchend - ptr - 1);
X else
X pos->col = (int) (match - ptr);
X found = 1;
X break;
X }
X /* breakcheck is slow, do it only once in 16 lines */


X if ((lnum & 15) == 0)

X breakcheck(); /* stop if ctrl-C typed */
X if (got_int)
X break;
X
X if (loop && lnum == startlnum) /* if second loop stop where started */
X break;
X }
X /* stop the search if wrapscan isn't set, after an interrupt and after a match */
X if (!p_ws || got_int || found)
X break;
X
X if (dir == BACKWARD) /* start second loop at the other end */
X lnum = line_count;
X else
X lnum = 1;
X }
X if (got_int)
X break;
X }
X
X free((char *) prog);
X
X if (!found) /* did not find it */
X {
X if (got_int)
X emsg(e_interr);
X else
X emsg(e_patnotf);


X return 0;
X }
X

X return 1;
X}
X

X/*
X * Highest level string search function.
X * Search for the 'count'th occurence of string 'str' in direction 'dir'
X * If 'dir' is 0: use previous dir.
X * If 'str' is 0 or 'str' is empty: use previous string.
X * If 'reverse' is TRUE: go in reverse of previous dir.
X * If 'echo' is TRUE: echo the search command
X */
X int
Xdosearch(dir, str, reverse, count, echo)
X int dir;
X char *str;
X int reverse;
X long count;
X int echo;
X{
X FPOS pos; /* position of the last match */
X int dirc;
X static int lastsdir = FORWARD; /* previous search direction */
X static int lastoffline;/* previous/current search has line offset */
X static int lastend; /* previous/current search set cursor at end */
X static long lastoff; /* previous/current line or char offset */
X static int nosetpm; /* do not call setpcmark() */
X register char *p;
X register long c;
X char *dircp = NULL;
X
X if (dir == 0)
X dir = lastsdir;
X else
X lastsdir = dir;
X if (reverse)
X dir = -dir;
X
X dirc = (dir == FORWARD ? '/' : '?');
X if (str == NULL || *str == NUL) /* use previous string and options */
X {
X if (search_pattern == NULL)
X {
X emsg(e_noprevre);
X return 0;
X }
X str = "";
X }
X else
X {
X /* If there is a matching '/' or '?', toss it */
X for (p = str; *p; ++p)
X {
X if (*p == dirc)
X {
X dircp = p; /* remember where we put the NUL */
X *p++ = NUL;
X break;
X }
X if (*p == '\\' && p[1] != NUL)
X ++p; /* skip next character */
X }
X
X lastoffline = FALSE;
X lastend = FALSE;
X nosetpm = FALSE;
X lastoff = 0;
X switch (*p)
X {
X case 'n': nosetpm = TRUE; /* do not call setpcmark() */
X ++p;


X break;
X case '+':

X case '-': /* got a line offset */
X lastoffline = TRUE;
X break;
X case 'e': /* position cursor at end */
X lastend = TRUE;
X case 's': /* got a character offset from start */
X ++p;
X }
X if (*p == '+' || *p == '-') /* got an offset */
X {
X lastoff = atol(p);
X ++p; /* skip number */
X while (isdigit(*p))
X ++p;
X }
X searchcmdlen = p - str; /* compute lenght of search command
X for get_address() */
X }
X
X if (echo)
X {
X smsg("%c%s", dirc, *str == NUL ? search_pattern : str);
X if (lastoffline || lastend || lastoff || nosetpm)
X {
X outchar(dirc);
X if (nosetpm)
X outchar('n');
X else if (lastend)
X outchar('e');
X else if (!lastoffline)
X outchar('s');
X if (lastoff < 0)
X {
X outchar('-');
X outnum((long)-lastoff);
X }
X else if (lastoff > 0 || lastoffline)
X {
X outchar('+');
X outnum((long)lastoff);
X }
X }
X
X gotocmdline(FALSE, NUL);
X flushbuf();
X }
X
X pos = Curpos;
X
X c = searchit(&pos, dir, str, count, lastend);
X if (dircp)
X *dircp = dirc; /* put second '/' or '?' back for normal() */
X if (!c)
X return 0;
X
X if (!lastoffline) /* add the character offset to the column */
X {
X if (lastoff > 0) /* offset to the right, check for end of line */
X {
X p = pos2ptr(&pos) + 1;
X c = lastoff;
X while (c-- && *p++ != NUL)
X ++pos.col;
X }
X else /* offset to the left, check for start of line */
X {
X if ((c = pos.col + lastoff) < 0)
X c = 0;
X pos.col = c;
X }
X }
X
X if (!nosetpm)
X setpcmark();
X Curpos = pos;
X set_want_col = TRUE;
X
X if (!lastoffline)
X return 1;
X
X/*
X * add the offset to the line number.
X */
X c = Curpos.lnum + lastoff;
X if (c < 1)
X Curpos.lnum = 1;
X else if (c > line_count)
X Curpos.lnum = line_count;
X else
X Curpos.lnum = c;
X Curpos.col = 0;
X
X return 2;
X}
X
X
X/*
X * Character Searches
X */
X
X/*
X * searchc(c, dir, type, count)
X *
X * Search for character 'c', in direction 'dir'. If 'type' is 0, move to the
X * position of the character, otherwise move to just before the char.
X * Repeat this 'count' times.
X */
X int
Xsearchc(c, dir, type, count)
X int c;
X register int dir;
X int type;
X long count;
X{
X static char lastc = NUL; /* last character searched for */
X static int lastcdir; /* last direction of character search */
X static int lastctype; /* last type of search ("find" or "to") */
X register int col;
X char *p;
X int len;
X
X if (c != NUL) /* normal search: remember args for repeat */
X {
X lastc = c;
X lastcdir = dir;
X lastctype = type;
X }
X else /* repeat previous search */
X {
X if (lastc == NUL)
X return FALSE;
X if (dir) /* repeat in opposite direction */
X dir = -lastcdir;
X else
X dir = lastcdir;
X }


X
X p = nr2ptr(Curpos.lnum);

X col = Curpos.col;
X len = strlen(p);
X
X /*
X * On 'to' searches, skip one to start with so we can repeat searches in
X * the same direction and have it work right.
X * REMOVED to get vi compatibility
X * if (lastctype)
X * col += dir;
X */
X
X while (count--)


X {
X for (;;)
X {

X if ((col += dir) < 0 || col >= len)
X return FALSE;
X if (p[col] == lastc)
X break;
X }
X }
X if (lastctype)
X col -= dir;
X Curpos.col = col;


X return TRUE;
X}
X
X/*

X * "Other" Searches
X */
X
X/*
X * showmatch - move the cursor to the matching paren or brace


X */
X FPOS *

Xshowmatch()


X{
X static FPOS pos;

X char initc; /* char under cursor */
X char findc; /* matching char */
X char c;


X int count = 0;

X int i;
X static char table[6] = {'(', ')', '[', ']', '{', '}'};
X int inquote = 0;
X register char *p;
X
X pos = Curpos;
X
X for (p = nr2ptr(pos.lnum); ;++pos.col)
X {
X if ((initc = p[pos.col]) == NUL)
X return (FPOS *) NULL;
X for (i = 0; i < 6; ++i)
X if (table[i] == initc)
X goto foundit;
X }
X
Xfoundit:
X if (i & 1) /* backward search */
X findc = table[i - 1];
X else /* forward search */
X findc = table[i + 1];
X i &= 1;
X
X /* we only do a breakcheck() once for every 16 lines */
X while (!got_int)
X {
X /* we could use inc() and dec() here, but that is much slower */
X if (i) /* backward search */
X {
X if (pos.col == 0) /* at start of line, go to previous one */
X {
X if (pos.lnum == 1) /* start of file */
X break;
X --pos.lnum;
X p = nr2ptr(pos.lnum);
X pos.col = strlen(p);
X if ((pos.lnum & 15) == 0)
X breakcheck();
X }
X else
X --pos.col;
X }
X else /* forward search */
X {
X if (p[pos.col] == NUL) /* at end of line, go to next one */
X {
X if (pos.lnum == line_count) /* end of file */
X break;
X ++pos.lnum;
X pos.col = 0;
X p = nr2ptr(pos.lnum);
X if ((pos.lnum & 15) == 0)
X breakcheck();
X }
X else
X ++pos.col;
X }
X
X /*
X * anything that is preceded with a backslash is ignored
X */
X if (pos.col == 0 || p[pos.col - 1] != '\\')
X {
X /*
X * Things inside quotes are ignored by setting 'inquote'.
X * If we find a quote without a preceding '\' invert 'inquote'.
X * At the end of a line not ending in '\' we reset 'inquote'.
X */
X switch (c = p[pos.col])
X {
X case NUL:
X inquote = FALSE;
X break;
X
X case '"':
X inquote = !inquote;
X break;
X
X /*
X * Skip things in single quotes: 'x' or '\x'.
X * Be careful for single single quotes, eg jon's.
X * Things like '\233' or '\x3f' are ok, there is no brace in it.
X */
X case '\'':
X if (i) /* backward search */
X {
X if (pos.col > 1)
X {
X if (p[pos.col - 2] == '\'')
X pos.col -= 2;
X else if (p[pos.col - 2] == '\\' && pos.col > 2 && p[pos.col - 3] == '\'')
X pos.col -= 3;
X }
X }
X else if (p[pos.col + 1]) /* forward search */
X {
X if (p[pos.col + 1] == '\\' && p[pos.col + 2] && p[pos.col + 3] == '\'')
X pos.col += 3;
X else if (p[pos.col + 2] == '\'')
X pos.col += 2;
X }
X break;
X
X default:
X if (!inquote) /* only check for match outside of quotes */
X {
X if (c == initc)
X count++;
X else if (c == findc)
X {
X if (count == 0)
X return &pos;
X count--;


X }
X }
X }
X }
X }

X return (FPOS *) NULL; /* never found it */
X}
X
X/*
X * findfunc(dir, what) - Find the next line starting with 'what' in direction 'dir'
X *
X * Return TRUE if a line was found.
X */
X int
Xfindfunc(dir, what, count)
X int dir;
X int what;
X long count;
X{
X linenr_t curr;
X
X curr = Curpos.lnum;


X
X for (;;)
X {

X if (dir == FORWARD)
X {

X if (curr++ == line_count)
X break;
X }
X else
X {
X if (curr-- == 1)
X break;
X }
X
X if (*nr2ptr(curr) == what)


X {
X if (--count > 0)

X continue;
X setpcmark();
X Curpos.lnum = curr;
X Curpos.col = 0;


X return TRUE;
X }
X }
X

X return FALSE;
X}
X
X/*

X * findsent(dir, count) - Find the start of the next sentence in direction 'dir'
X * Sentences are supposed to end in ".", "!" or "?" followed by white space,
X * or at an empty line.
X * Return TRUE if the next sentence was found.
X */
X int
Xfindsent(dir, count)
X int dir;
X long count;
X{
X FPOS pos, tpos;
X register int c;
X int (*func) __PARMS((FPOS *));
X int startlnum;
X
X pos = Curpos;


X if (dir == FORWARD)

X func = incl;
X else
X func = decl;


X
X while (count--)
X {

X /* if on an empty line, skip upto a non-empty line */
X if (gchar(&pos) == NUL)
X {
X do
X if ((*func)(&pos) == -1)
X break;
X while (gchar(&pos) == NUL);


X if (dir == FORWARD)

X goto found;
X }
X /* if on the start of a paragraph or a section and searching
X * forward, go to the next line */
X else if (dir == FORWARD && pos.col == 0 && startPS(pos.lnum, NUL))
X {
X if (pos.lnum == line_count)
X return FALSE;
X ++pos.lnum;
X goto found;
X }
X else if (dir == BACKWARD)
X decl(&pos);
X
X /* go back to the previous non-blank char */
X while ((c = gchar(&pos)) == ' ' || c == '\t' ||
X (dir == BACKWARD && strchr(".!?)]\"'", c) != NULL))
X if (decl(&pos) == -1)
X break;
X
X /* remember the line where the search started */
X startlnum = pos.lnum;
X
X for (;;) /* find end of sentence */
X {
X if ((c = gchar(&pos)) == NUL ||
X (pos.col == 0 && startPS(pos.lnum, NUL)))
X {
X if (dir == BACKWARD && pos.lnum != startlnum)
X ++pos.lnum;
X break;
X }
X if (c == '.' || c == '!' || c == '?')
X {
X tpos = pos;
X do
X if ((c = inc(&tpos)) == -1)
X break;
X while (strchr(")}\"'", c = gchar(&tpos)) != NULL);
X if (c == -1 || c == ' ' || c == '\t' || c == NUL)
X {
X pos = tpos;
X if (gchar(&pos) == NUL) /* skip NUL at EOL */
X inc(&pos);
X break;
X }
X }
X if ((*func)(&pos) == -1)
X {
X if (count)
X return FALSE;
X break;
X }
X }
Xfound:
X /* skip white space */
X while ((c = gchar(&pos)) == ' ' || c == '\t')
X if (incl(&pos) == -1)
X break;
X }
X
X Curpos = pos;
X setpcmark();


X return TRUE;
X}
X
X/*

X * findpar(dir, count, what) - Find the next paragraph in direction 'dir'
X * Paragraphs are currently supposed to be separated by empty lines.
X * Return TRUE if the next paragraph was found.
X * If 'what' is '{' or '}' we go to the next section.
X */
X int
Xfindpar(dir, count, what)
X register int dir;
X long count;
X int what;
X{
X register linenr_t curr;
X int did_skip; /* TRUE after separating lines have
X been skipped */
X int first; /* TRUE on first line */
X
X curr = Curpos.lnum;


X
X while (count--)
X {

X did_skip = FALSE;
X for (first = TRUE; ; first = FALSE)
X {
X if (*nr2ptr(curr) != NUL)
X did_skip = TRUE;
X
X if (!first && did_skip && startPS(curr, what))
X break;
X
X if ((curr += dir) < 1 || curr > line_count)
X {
X if (count)
X return FALSE;
X curr -= dir;


X break;
X }
X }
X }

X setpcmark();
X Curpos.lnum = curr;
X if (curr == line_count)
X {
X if ((Curpos.col = strlen(nr2ptr(curr))) != 0)
X --Curpos.col;
X }
X else
X Curpos.col = 0;


X return TRUE;
X}
X
X/*

X * check if the string 's' is a nroff macro that is in option 'opt'


X */
X static int

Xinmacro(opt, s)
X char *opt;
X register char *s;
X{
X register char *macro;
X
X for (macro = opt; macro[0]; ++macro)
X {
X if (macro[0] == s[0] && (((s[1] == NUL || s[1] == ' ')
X && (macro[1] == NUL || macro[1] == ' ')) || macro[1] == s[1]))
X break;
X ++macro;
X if (macro[0] == NUL)
X break;
X }
X return (macro[0] != NUL);
X}
X
X/*
X * startPS: return TRUE if line 'lnum' is the start of a section or paragraph.
X * If 'para' is '{' or '}' only check for sections.
X */
X int
XstartPS(lnum, para)
X linenr_t lnum;
X int para;
X{


X register char *s;
X

X s = nr2ptr(lnum);
X if ((para == NUL && *s == '{') || *s == para || *s == '\f')
X return TRUE;
X if (*s++ != '.')
X return FALSE;
X if (inmacro(p_sections, s) || (!para && inmacro(p_para, s)))


X return TRUE;
X else

X return FALSE;
X}
X
X/*

X * The following routines do the word searches performed by the 'w', 'W',
X * 'b', 'B', 'e', and 'E' commands.
X */
X
X/*
X * To perform these searches, characters are placed into one of three
X * classes, and transitions between classes determine word boundaries.
X *
X * The classes are:
X *
X * 0 - white space
X * 1 - letters, digits and underscore
X * 2 - everything else
X */
X
Xstatic int stype; /* type of the word motion being performed */
X
X/*
X * cls() - returns the class of character at Curpos
X *
X * The 'type' of the current search modifies the classes of characters if a 'W',
X * 'B', or 'E' motion is being done. In this case, chars. from class 2 are
X * reported as class 1 since only white space boundaries are of interest.


X */
X static int

Xcls()
X{


X register int c;
X

X c = gcharCurpos();
X if (c == ' ' || c == '\t' || c == NUL)
X return 0;
X
X if (isidchar(c))
X return 1;
X
X /*
X * If stype is non-zero, report these as class 1.
X */
X return (stype == 0) ? 2 : 1;
X}
X
X
X/*
X * fwd_word(count, type) - move forward one word
X *
X * Returns TRUE if end of the file was reached.
X */
X int
Xfwd_word(count, type)
X long count;
X int type;
X{
X int sclass; /* starting class */
X
X stype = type;
X while (--count >= 0)
X {
X sclass = cls();
X
X /*
X * We always move at least one character.
X */
X if (incCurpos() == -1)
X return TRUE;
X
X if (sclass != 0)
X if (skip_chars(sclass, FORWARD))
X return TRUE;
X
X /*
X * go to next non-white
X */
X while (cls() == 0)
X {
X /*
X * We'll stop if we land on a blank line
X */
X if (Curpos.col == 0 && *nr2ptr(Curpos.lnum) == NUL)
X break;
X
X if (incCurpos() == -1)


X return TRUE;
X }
X }

X return FALSE;
X}
X
X/*

X * bck_word(count, type) - move backward 'count' words
X *
X * Returns TRUE if top of the file was reached.
X */
X int
Xbck_word(count, type)
X long count;
X int type;
X{
X int sclass; /* starting class */
X
X stype = type;
X while (--count >= 0)
X {
X sclass = cls();
X
X if (decCurpos() == -1)
X return TRUE;
X
X if (cls() != sclass || sclass == 0)
X {
X /*
X * We were at the start of a word. Go back to the end of the prior
X * word.
X */
X while (cls() == 0) /* skip any white space */
X {
X /*
X * We'll stop if we land on a blank line
X */
X if (Curpos.col == 0 && *nr2ptr(Curpos.lnum) == NUL)
X goto finished;
X
X if (decCurpos() == -1)
X return TRUE;
X }
X sclass = cls();
X }
X
X /*
X * Move backward to start of this word.
X */
X if (skip_chars(sclass, BACKWARD))
X return TRUE;
X
X incCurpos(); /* overshot - forward one */
Xfinished:
X ;
X }


X return FALSE;
X}
X
X/*

X * end_word(count, type, stop) - move to the end of the word
X *
X * There is an apparent bug in the 'e' motion of the real vi. At least on the
X * System V Release 3 version for the 80386. Unlike 'b' and 'w', the 'e'
X * motion crosses blank lines. When the real vi crosses a blank line in an
X * 'e' motion, the cursor is placed on the FIRST character of the next
X * non-blank line. The 'E' command, however, works correctly. Since this
X * appears to be a bug, I have not duplicated it here.
X *
X * Returns TRUE if end of the file was reached.
X *
X * If stop is TRUE and we are already on the end of a word, move one less.
X */
X int
Xend_word(count, type, stop)
X long count;
X int type;
X int stop;
X{
X int sclass; /* starting class */
X
X stype = type;
X while (--count >= 0)
X {
X sclass = cls();
X if (incCurpos() == -1)
X return TRUE;
X
X /*
X * If we're in the middle of a word, we just have to move to the end of it.
X */
X if (cls() == sclass && sclass != 0)
X {
X /*
X * Move forward to end of the current word
X */
X if (skip_chars(sclass, FORWARD))
X return TRUE;
X }
X else if (!stop || sclass == 0)
X {
X /*
X * We were at the end of a word. Go to the end of the next word.
X */
X
X if (skip_chars(0, FORWARD)) /* skip any white space */
X return TRUE;
X
X /*
X * Move forward to the end of this word.
X */
X if (skip_chars(cls(), FORWARD))
X return TRUE;
X }
X decCurpos(); /* overshot - backward one */
X stop = FALSE; /* we move only one word less */
X }


X return FALSE;
X}
X

X int
Xskip_chars(class, dir)
X int class;
X int dir;
X{
X while (cls() == class)
X if ((dir == FORWARD ? incCurpos() : decCurpos()) == -1)
X return 1;


X return 0;
X}
END_OF_FILE

if test 21652 -ne `wc -c <'vim/src/search.c'`; then
echo shar: \"'vim/src/search.c'\" unpacked with wrong size!
fi
# end of 'vim/src/search.c'
fi
echo shar: End of archive 12 \(of 23\).
cp /dev/null ark12isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:34:42 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 13
Archive-name: vim/part13
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 13 (of 23)."
# Contents: vim/doc/vim.hlp.uue
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:11 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/vim.hlp.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/vim.hlp.uue'\"
else
echo shar: Extracting \"'vim/doc/vim.hlp.uue'\" \(28611 characters\)
sed "s/^X//" >'vim/doc/vim.hlp.uue' <<'END_OF_FILE'
X
Xbegin 644 vim.hlp
XM"0E624T@:&5L<"!F:6QE(&EN9&5X"@I215154DX)<75I="!H96QP"0E624T@F
XM<W1A;F1S(&9O<B!6:2!)36ET871I;VXN"E-004-%"6]N92!P86=E(&9O<G=AL
XM<F0)36]S="!O9B!624T@=V%S(&UA9&4@8GD@0G)A;2!-;V]L96YA87(N"B`@X
XM("!A"6=O('1O('1H:7,@:6YD97@)5DE-(&ES(&)A<V5D(&]N(%-T979I92P@\
XM=V]R:V5D(&]N(&)Y.B!4:6T*("`@(&();VYE('!A9V4@8F%C:W=A<F0@("`@;
XM("`@5&AO;7!S;VXL(%1O;GD@06YD<F5W<RP@1RY2+B`H1G)E9"D@5V%L=&5RD
XM"@IC("`@;&5F="UR:6=H="!A;F0@=7`M9&]W;B!M;W1I;VYS("`@;@D@:V5YS
XM(&UA<'!I;F<[(&]P=&EO;B!C;VUM86YD<PID("`@=V]R9"!A;F0@=&5X="!O#
XM8FIE8W0@;6]T:6]N<R`@("`@;PD@;W!T:6]N<R!A+6P*92`@('!A='1E<FX@\
XM<V5A<F-H97,)"2`@("`@<`D@;W!T:6]N<R!L+7,*9B`@('9A<FEO=7,@;6]T:
XM:6]N<SL@=7-I;F<@=&%G<R`@("`@('$)(&]P=&EO;G,@<RUZ"F<@("!S8W)OQ
XM;&QI;F<)"0D@("`@('()('5N9&\[('-H96QL.R!Q=6EC:V9I>#L@=F%R:6]U%
XM<PIH("`@:6YS97)T:6YG('1E>'0[(&1I9W)A<&AS"2`@("`@<PD@8V]M;6%NJ
XM9"!L:6YE(&5D:71I;F<[($5X(&-H87)A8W1E<G,*:2`@(&EN<V5R="!M;V1EU
XM(`D)("`@("!T"2!%>"!R86YG97,*:B`@(&-H86YG:6YG('1E>'0)"2`@("`@V
XM=0D@961I=&EN9R!F:6QE<SL@=7-I;F<@=&AE(&9I;&4@;&ES=`IK("`@8V]M'
XM<&QE>"!C:&%N9V5S"0D@("`@('8)('=R:71I;F<@86YD('%U:71T:6YG"FP@%
XM("!D96QE=&EN9RP@8V]P>6EN9RP@;6]V:6YG('1E>'0@("!W"2!S=&%R=&EN7
XM9R!624T*;2`@(')E<&5A=&EN9R!C;VUM86YD<PH*4F5A9"`B<F5F97)E;F-E\
XM+F1O8R(@9F]R(&$@;6]R92!C;VUP;&5T92!E>'!L86YA=&EO;BX*#`),969T.
XM+7)I9VAT(&UO=&EO;G,%"DX@(&@)"6QE9G0@*'-A;64@87,@0U123"U(+"!"P
XM4R!A;F0@8W5R<V]R+6QE9G0@:V5Y*0I.("!L"0ER:6=H="`H<V%M92!A<R!37
XM4$%#12!A;F0@8W5R<V]R+7)I9VAT(&ME>2D*("`@,`D)=&\@9FER<W0@8VAAJ
XM<F%C=&5R(&EN('1H92!L:6YE"B`@(%X)"71O(&9I<G-T(&YO;BUB;&%N:R!C)
XM:&%R86-T97(@:6X@=&AE(&QI;F4*3B`@)`D)=&\@=&AE(&QA<W0@8VAA<F%C2
XM=&5R(&EN('1H92!L:6YE("A.+3$@;&EN97,@;&]W97(I"DX@('P)"71O(&-O'
XM;'5M;B!."DX@(&8\8VAA<CX)=&\@=&AE($YT:"!O8V-U<G)E;F-E(&]F(#QC4
XM:&%R/B!T;R!T:&4@<FEG:'0*3B`@1CQC:&%R/@ET;R!T:&4@3G1H(&]C8W5RD
XM<F5N8V4@;V8@/&-H87(^('1O('1H92!L969T"DX@('0\8VAA<CX)=&EL;"!B-
XM969O<F4@=&AE($YT:"!O8V-U<G)E;F-E(&]F(#QC:&%R/B!T;R!T:&4@<FEGX
XM:'0*3B`@5#QC:&%R/@ET:6QL(&)E9F]R92!T:&4@3G1H(&]C8W5R<F5N8V4@%
XM;V8@/&-H87(^('1O('1H92!L969T"DX@(#L)"7)E<&5A="!T:&4@;&%S="!F=
XM+"!&+"!T(&]R(%0@3B!T:6UE<PI.("`L"0ER97!E870@=&AE(&QA<W0@9BP@5
XM1BP@="!O<B!4($X@=&EM97,@:6X@;W!P;W-I=&4@9&ER96-T:6]N"@H"57`M>
XM9&]W;B!M;W1I;VYS!0I.("!K"0EU<"`H<V%M92!A<R!#5%),+5`@86YD(&-U?
XM<G-O<BUU<"!K97DI"DX@(&H)"61O=VX@*'-A;64@87,@0U123"U*+"!#5%),E
XM+4XL($Q&(&%N9"!C=7)S;W(M9&]W;B!K97DI"DX@("T)"75P+"!O;B!T:&4@'
XM9FER<W0@;F]N+6)L86YK(&-H87)A8W1E<@I.("`K"0ED;W=N+"!O;B!T:&4@,
XM9FER<W0@;F]N+6)L86YK(&-H87(N("AS86UE(&%S($-44DPM32!A;F0@0U(I6
XM"DX@(%\)"4X@+2`Q(&QI;F5S(&1O=VXL(&]N('1H92!F:7)S="!N;VXM8FQAA
XM;FL@8VAA<F%C=&5R"DX@($<)"6=O=&\@;&EN92!.("AD969A=6QT(&QA<W0@G
XM;&EN92DL(&]N('1H92!F:7)S="!N;VXM8FQA;FL@8VAA<BX*3B`@)0D)9V]T(
XM;R!L:6YE($X@<&5R8V5N=&%G92!D;W=N(&EN('1H92!F:6QE+@H,`E=O<F0@5
XM;6]T:6]N<P4*3B`@=PD)3B!W;W)D<R!F;W)W87)D"DX@(%<)"4X@8FQA;FLM%
XM<V5P87)A=&5D('=O<F1S(&9O<G=A<F0*3B`@90D)9F]R=V%R9"!T;R!T:&4@E
XM96YD(&]F('1H92!.=&@@=V]R9`I.("!%"0EF;W)W87)D('1O('1H92!E;F0@R
XM;V8@=&AE($YT:"!B;&%N:RUS97!A<F%T960@=V]R9`I.("!B"0E.('=O<F1S3
XM(&)A8VMW87)D"DX@($()"4X@8FQA;FLM<V5P87)A=&5D('=O<F1S(&)A8VMW>
XM87)D"@H"5&5X="!O8FIE8W0@;6]T:6]N<P4*3B`@*0D)3B!S96YT96YC97,@@
XM9F]R=V%R9`I.("`H"0E.('-E;G1E;F-E<R!B86-K=V%R9`I.("!]"0E.('!A"
XM<F%G<F%P:',@9F]R=V%R9`I.("!["0E.('!A<F%G<F%P:',@8F%C:W=A<F0*2
XM3B`@75T)"4X@<V5C=&EO;G,@9F]R=V%R9`I.("!;6PD)3B!S96-T:6]N<R!B]
XM86-K=V%R9`I.("!=6PD)3B!S96-T:6]N<R`H<W1A<G1I;F<@=VET:"!A(#Q]_
XM/BD@9F]R=V%R9`I.("!;70D)3B!S96-T:6]N<R`H<W1A<G1I;F<@=VET:"!A%
XM(#Q]/BD@8F%C:W=A<F0*"@P"4&%T=&5R;B!S96%R8VAE<P4*3B`@+WMP871T-
XM97)N?5LO70ES96%R8V@@9F]R=V%R9"!F;W(@=&AE($YT:"!O8V-U<G)E;F-E8
XM(&]F('MP871T97)N?0I.("`_>W!A='1E<FY]6S]="7-E87)C:"!B86-K=V%R)
XM9"!F;W(@=&AE($YT:"!O8V-U<G)E;F-E(&]F('MP871T97)N?0I.("`O"0D)L
XM<F5P96%T(&QA<W0@<V5A<F-H+"!I;B!T:&4@9F]R=V%R9"!D:7)E8W1I;VX*O
XM3B`@/PD)"7)E<&5A="!L87-T('-E87)C:"P@:6X@=&AE(&)A8VMW87)D(&1IC
XM<F5C=&EO;@I.("!N"0D)<F5P96%T(&QA<W0@<V5A<F-H"DX@($X)"0ER97!EM
XM870@;&%S="!S96%R8V@L(&EN(&]P<&]S:71E(&1I<F5C=&EO;@I.("`J"0D)S
XM<V5A<F-H(&9O<G=A<F0@9F]R('1H92!I9&5N="!U;F1E<B!T:&4@8W5R<V]RD
XM"DX@(",)"0ES96%R8V@@8F%C:W=A<F0@9F]R('1H92!I9&5N="!U;F1E<B!TY
XM:&4@8W5R<V]R"@H"<W!E8VEA;"!C:&%R86-T97)S(&EN('-E87)C:"!P871TH
XM97)N<P4@("`@("!M86=I8PEN;VUA9VEC"@D@("!M871C:&5S(&%N>2!S:6YGV
XM;&4@8VAA<F%C=&5R"2`@("`@+@D)("!<+@H)"2`@;6%T8VAE<R!S=&%R="!OO
XM9B!L:6YE"2`@("`@7@D)("!>"@D)("`@(&UA=&-H97,@96YD(&]F(&QI;F4)#
XM("`@("`D"0D@("0*"0D@(&UA=&-H97,@<W1A<G0@;V8@=V]R9`D@("`@(%P\;
XM"0D@(%P\"@D)("`@(&UA=&-H97,@96YD(&]F('=O<F0)("`@("!</@D)("!<$
XM/@H@("!M871C:&5S(&$@<VEN9VQE(&-H87(@9G)O;2!T:&4@<F%N9V4)("`@Y
XM("!;82UZ70D@(%Q;82UZ70H@;6%T8VAE<R!A('-I;F=L92!C:&%R(&YO="!I/
XM;B!T:&4@<F%N9V4)("`@("!;7F$M>ET)("!<6UYA+7I="FUA=&-H97,@,"!O4
XM<B!M;W)E(&]F('1H92!P<F5C961I;F<@871O;0D@("`@("H)"2`@7"H*;6%TT
XM8VAE<R`Q(&]R(&UO<F4@;V8@=&AE('!R96-E9&EN9R!A=&]M"2`@("`@7"L)Y
XM"2`@7"L*("`@;6%T8VAE<R`P(&]R(#$@;V8@=&AE('!R96-E9&EN9R!A=&]MY
XM"2`@("`@7#\)"2`@7#\*"0D@<V5P87)A=&5S('1W;R!B<F%N8VAE<PD@("`@>
XM(%Q\"0D@(%Q\"@D@("!G<F]U<"!A('!A='1E<FX@:6YT;R!A;B!A=&]M"2`@$
XM("`@7"A<*0D@(%PH7"D*#`)687)I;W5S(&UO=&EO;G,%"B`@(&T\82UZ02U:-
XM/@EM87)K(&-U<G)E;G0@<&]S:71I;VX@=VET:"!M87)K(#QA+7I!+5H^"B`@%
XM(&`\82UZ02U:/@EG;R!T;R!M87)K(#QA+7I!+5H^"B`@(&!@"0EG;R!T;R!T*
XM:&4@<&]S:71I;VX@8F5F;W)E('1H92!L87-T(&IU;7`*("`@8%L@;W(@8%T)2
XM9V\@=&\@=&AE('-T87)T(&]R(&5N9"!O9B!T:&4@<')E=FEO=7-L>2!O<&5R.
XM871E9"!O<B!P=70@=&5X=`H@("`G/&$M>D$M6EM=)SX)<V%M92!A<R!@+"!B(
XM=70@;VX@=&AE(&9I<G-T(&YO;BUB;&%N:R!I;B!T:&4@;&EN90HZ;6%R:W,)Z
XM"7!R:6YT('1H92!A8W1I=F4@;6%R:W,*3B`@0U123"U/"6=O('1O($X@;VQDI
XM97(@<&]S:71I;VX@:6X@:G5M<"!L:7-T"DX@($-44DPM20EG;R!T;R!.(&YEA
XM=V5R('!O<VET:6]N(&EN(&IU;7`@;&ES=`HZ:G5M<',)"7!R:6YT('1H92!JO
XM=6UP(&QI<W0*("`@)0D)9FEN9"!T:&4@;F5X="!B<F%C92!O<B!B<F%C:V5T*
XM(&EN('1H:7,@;&EN92P@9V\@=&\@:71S(&UA=&-H"DX@($@)"6=O('1O('1H@
XM92!.=&@@;&EN92!I;B!T:&4@=VEN9&]W+"!O;B!T:&4@9FER<W0@;F]N+6)L_
XM86YK"B`@($T)"6=O('1O('1H92!M:61D;&4@;&EN92!I;B!T:&4@=VEN9&]WD
XM+"!O;B!T:&4@9FER<W0@;F]N+6)L86YK"DX@($P)"6=O('1O('1H92!.=&@@,
XM;&EN92!F<F]M('1H92!B;W1T;VTL(&]N('1H92!F:7)S="!N;VXM8FQA;FL*.
XM"@)5<VEN9R!T86=S!0HZ=&%;9UT@>W1A9WT)"4IU;7`@=&\@=&%G('MT86=]3
XM+"!U;FQE<W,@8VAA;F=E<R!H879E(&)E96X@;6%D92X*.G1A6V==(2![=&%GR
XM?0D)2G5M<"!T;R!T86<@>W1A9WT@86QW87ES+B!$:7-C87)D(&%N>2!C:&%NY
XM9V5S+@H@("!#5%),+5T)"2(Z=&$B('1O('1H92!I9&5N=&EF:65R('5N9&5R@
XM(&-U<G-O<BX*3B`@0U123"U4"0E*=6UP('1O($X@;VQD97(@=&%G(&EN('1A7
XM9R!L:7-T"CI;8V]U;G1=<&];<%U;(5T)2G5M<"!T;R!;8V]U;G1=(&]L9&5RG
XM('1A9R!I;B!T86<@;&ES=`HZ6V-O=6YT771A6V==6R%="4IU;7`@=&\@6V-OR
XM=6YT72!N97=E<B!T86<@:6X@=&%G(&QI<W0*.G1A9W,)"0E0<FEN="!T86<@7
XM;&ES=`H,`E-C<F]L;&EN9P4*3B`@0U123"U%"7=I;F1O=R!.(&QI;F5S(&1O"
XM=VYW87)D<R`H3B!L:6YE<R!%>'1R82D*3B`@0U123"U$"7=I;F1O=R!.(&QIF
XM;F5S($1O=VYW87)D<R`H9&5F875L="!H86QF(&$@=VEN9&]W*0I.("!#5%),V
XM+48)=VEN9&]W($X@<&%G97,@1F]R=V%R9',@*&1O=VYW87)D<RD*3B`@0U12E
XM3"U9"7=I;F1O=R!.(&QI;F5S('5P=V%R9',*3B`@0U123"U5"7=I;F1O=R!.@
XM(&QI;F5S(%5P=V%R9',@*&1E9F%U;'0@:&%L9B!A('=I;F1O=RD*3B`@0U12,
XM3"U""7=I;F1O=R!.('!A9V5S($)A8VMW87)D<R`H=7!W87)D<RD*("`@>CQ#&
XM4CX)<F5D<F%W+"!C=7)R96YT(&QI;F4@870@=&]P(&]F('=I;F1O=PH@("!ZN
XM+@D)<F5D<F%W+"!C=7)R96YT(&QI;F4@870@8V5N=&5R(&]F('=I;F1O=PH@)
XM("!Z+0D)<F5D<F%W+"!C=7)R96YT(&QI;F4@870@8F]T=&]M(&]F('=I;F1OU
XM=PH,`DEN<V5R=&EN9R!T97AT!0I.("!A"0EA<'!E;F0@=&5X="!A9G1E<B!T:
XM:&4@8W5R<V]R("A.('1I;65S*0I.("!!"0EA<'!E;F0@=&5X="!A="!T:&4@*
XM96YD(&]F('1H92!L:6YE("A.('1I;65S*0I.("!I"0EI;G-E<G0@=&5X="!BE
XM969O<F4@=&AE(&-U<G-O<B`H3B!T:6UE<RD*3B`@20D):6YS97)T('1E>'0@^
XM8F5F;W)E('1H92!F:7)S="!N;VXM8FQA;FL@:6X@=&AE(&QI;F4@*$X@=&EM<
XM97,I"DX@(&\)"6]P96X@82!N97<@;&EN92!B96QO=R!T:&4@8W5R<F5N="!L(
XM:6YE+"!A<'!E;F0@=&5X="`H3B!T:6UE<RD*3B`@3PD);W!E;B!A(&YE=R!L(
XM:6YE(&%B;W9E('1H92!C=7)R96YT(&QI;F4L(&%P<&5N9"!T97AT("A.('1IQ
XM;65S*0H*`E-P96-I86P@:6YS97)T<P4*.G(@>V9I;&5]"6EN<V5R="!T:&4@_
XM8V]N=&5N=',@;V8@>V9I;&5](&)E;&]W('1H92!C=7)S;W(*.G(A>V-O;6UA2
XM;F1]"6EN<V5R="!T:&4@<W1A;F1A<F0@;W5T<'5T(&]F('MC;VUM86YD?2!B^
XM96QO=R!T:&4@8W5R<V]R"@H"1&EG<F%P:',%"CID:6=;<F%P:%T)<VAO=R!C+
XM=7)R96YT(&QI<W0@;V8@9&EG<F%P:',*.F1I9UMR87!H72![8VAA<C%]>V-HK
XM87(R?2![;G5M8F5R?2`N+BX*"0EA9&0@9&EG<F%P:"AS*2!T;R!T:&4@;&ESA
XM=`H,`F-H87(%"0D@`F%C=&EO;B!I;B!I;G-E<G0@;6]D904*0U123"U;(&]R?
XM(#Q%4T,^"65N9"!I;G-E<G0@;W(@<F5P;&%C92!M;V1E+"!B86-K('1O(&-O^
XM;6UA;F0@;6]D90I#5%),+4$)"6EN<V5R="!P<F5V:6]U<VQY(&EN<V5R=&5DF
XM('1E>'0*0U123"U"(#PP+3EA+7H^(&EN<V5R="!C;VYT96YT<R!O9B!R96=I*
XM<W1E<B`\,"TY82UZ/@I#5%),+4`)"6EN<V5R="!P<F5V:6]U<VQY(&EN<V5R,
XM=&5D('1E>'0@86YD('-T;W`@:6YS97)T"D-44DPM2B!O<B`\3$8^(&]R($-4K
XM4DPM32!O<B`\0U(^("`@8F5G:6X@;F5W(&QI;F4*0U123"U+('MC:&%R,7T@=
XM>V-H87(R?0EE;G1E<B!D:6=R87!H"D-44DPM4@D):6YS97)T('1H92!C:&%RR
XM86-T97(@=VAI8V@@:7,@86)O=F4@=&AE(&-U<G-O<@I#5%),+44)"6EN<V5RN
XM="!T:&4@8VAA<F%C=&5R('=H:6-H(&ES(&)E;&]W('1H92!C=7)S;W(*0U12<
XM3"U6"0EI;G-E<G0@8VAA<F%C=&5R(&QI=&5R86QL>2P@;W(@96YT97(@9&5CL
XM:6UA;"!B>71E('9A;'5E"D-44DPM2"!O<B`\0E,^(&]R(#Q$14P^(&1E;&5TV
XM92!T:&4@8VAA<F%C=&5R(&)E9F]R92!T:&4@8W5R<V]R"D-44DPM5PD)9&5L/
XM971E('=O<F0@8F5F;W)E('1H92!C=7)S;W(*0U123"U5"0ED96QE=&4@86QLK
XM(&5N=&5R960@8VAA<F%C=&5R<R!I;B!T:&4@8W5R<F5N="!L:6YE"D-44DPMV
XM5`D):6YS97)T(&]N92!S:&EF='=I9'1H(&]F(&EN9&5N="!I;B!T:&4@8W5R4
XM<F5N="!L:6YE"D-44DPM1`D)9&5L971E(&]N92!S:&EF='=I9'1H(&]F(&ENB
XM9&5N="!I;B!T:&4@8W5R<F5N="!L:6YE"GMC:&%R,7T@/$)3/B![8VAA<C)]6
XM"65N=&5R(&1I9W)A<&@*"0)K97ES('1H870@<W1O<"!I;G-E<G0L(&1O('-O$
XM;65T:&EN9R!A;F0@9V5T(&)A8VL@=&\@:6YS97)T.@4*8W5R<V]R(&ME>7,)4
XM;6]V92!C=7)S;W(@;&5F="]R:6=H="]U<"]D;W=N"G-H:69T+75P"6]N92!S@
XM8W)E96YF=6QL(&)A8VMW87)D"G-H:69T+61O=VX);VYE('-C<F5E;F9U;&P@J
XM9F]R=V%R9`IS:&EF="UL969T"6]N92!W;W)D(&QE9G0*<VAI9G0M<FEG:'0)C
XM;VYE('=O<F0@<FEG:'0*0U123"U/"0EE>&5C=71E(&]N92!C;VUM86YD"@P"5
XM0VAA;F=I;F<@=&5X=`4*3B`@4@D)96YT97(@<F5P;&%C92!M;V1E("AR97!E8
XM870@=&AE(&5N=&5R960@=&5X="!.('1I;65S*0I.("!C>VUO=&EO;GT)8VAAY
XM;F=E('1H92!T97AT('1H870@:7,@;6]V960@;W9E<B!W:71H('MM;W1I;VY]N
XM"GMQ=6]T97UC"6-H86YG92!T:&4@<75O=&5D('1E>'0*3B`@8V,)"6-H86YGK
XM92!.(&QI;F5S"DX@($,)"6-H86YG92!T;R!E;F0@;V8@;&EN92`H86YD($XM.
XM,2!M;W)E(&QI;F5S*0I.("!S"0EC:&%N9V4@3B!C:&%R86-T97)S"DX@(%,)-
XM"6-H86YG92!.(&QI;F5S"DX@('(\8VAA<CX)<F5P;&%C92!.(&-H87)A8W1EH
XM<G,@8GD@/&-H87(^"DX@('X)"7-W:71C:"!C87-E(&9O<B!.(&-H87)A8W1E^
XM<G,@86YD(&%D=F%N8V4@8W5R<V]R"GMQ=6]T97U^"7-W:71C:"!C87-E(&9OB
XM<B!Q=6]T960@=&5X=`I[<75O=&5]=0EM86ME('%U;W1E9"!T97AT('5P<&5RX
XM8V%S90I[<75O=&5]50EM86ME('%U;W1E9"!T97AT(&QO=V5R8V%S90I.("!#?
XM5%),+4$)861D($X@=&\@=&AE(&YU;6)E<B!A="!O<B!A9G1E<B!T:&4@8W5R`
XM<V]R"DX@($-44DPM4PES=6)T<F%C="!.(&9R;VT@=&AE(&YU;6)E<B!A="!OB
XM<B!A9G1E<B!T:&4@8W5R<V]R"DX@(#Q[;6]T:6]N?0EM;W9E('1H92!L:6YE.
XM<R!T:&%T(&%R92!M;W9E9"!O=F5R(&]N92!S:&EF='=I9'1H(&QE9G0*3B`@6
XM/#P)"6UO=F4@3B!L:6YE<R!O;F4@<VAI9G1W:61T:"!L969T"DX@(#Y[;6]T6
XM:6]N?0EM;W9E('1H92!L:6YE<R!T:&%T(&%R92!M;W9E9"!O=F5R(&]N92!S4
XM:&EF='=I9'1H(')I9VAT"DX@(#X^"0EM;W9E($X@;&EN97,@;VYE('-H:69TO
XM=VED=&@@<FEG:'0*3B`@5GMM;W1I;VY]"69O<FUA="!T:&4@;&EN97,@=&AAE
XM="!A<F4@;6]V960@;W9E<B!T;R`G=&5X='=I9'1H)R!L96YG=&@*#`)#;VUP"
XM;&5X(&-H86YG97,%"B`@('$)"7-T87)T('%U;W1I;F<@8VAA<F%C=&5R<R`@)
XM('T@;6]V92!C=7)S;W(@86YD('5S90H@("!1"0ES=&%R="!Q=6]T:6YG(&QI)
XM;F5W:7-E("`@("!](&]P97)A=&]R('1O(&%F9F5C=`H@("!#5%),+5$)<W1AN
XM<G0@<75O=&EN9R!B;&]C:W=I<V4@("`@?2!Q=6]T960@=&5X=`H@("!O"0EE4
XM>&-H86YG92!C=7)S;W(@<&]S:71I;VX@=VET:"!S=&%R="!O9B!Q=6]T:6YGW
XM"@I.("`A>VUO=&EO;GU[8V]M;6%N9'T*"0EF:6QT97(@=&AE(&QI;F5S('1HB
XM870@87)E(&UO=F5D(&]V97(@=&AR;W5G:"![8V]M;6%N9'T*3B`@(2%[8V]MP
XM;6%N9'T*"0EF:6QT97(@3B!L:6YE<R!T:')O=6=H('MC;VUM86YD?0HZ6W)AR
XM;F=E72%[8V]M;6%N9'T*"0EF:6QT97(@6W)A;F=E72!L:6YE<R!T:')O=6=HR
XM('MC;VUM86YD?0I.("`]>VUO=&EO;GU[8V]M;6%N9'T*"0EF:6QT97(@=&AET
XM(&QI;F5S('1H870@87)E(&UO=F5D(&]V97(@=&AR;W5G:"`B:6YD96YT(@I.:
XM("`]/7MC;VUM86YD?0H)"69I;'1E<B!.(&QI;F5S('1H<F]U9V@@(FEN9&5N-
XM="(*.EMR86YG95US6W5B<W1I='5T95TO>W!A='1E<FY]+WMS=')I;F=]+UMG'
XM75MC70H@("`)"7-U8G-T:71U=&4@>W!A='1E<FY](&)Y('MS=')I;F=](&EN'
XM(%MR86YG95T@;&EN97,[('=I=&@@6V=="@D)<F5P;&%C92!A;&P@;V-C=7)RU
XM96YC97,@;V8@>W!A='1E<FY].R!W:71H(%MC72!A<VL@9FER<W0*.EMR86YG9
XM95US6W5B<W1I='5T95T@6V==6V-="B`@(`D)<F5P96%T('!R979I;W5S(#IS7
XM('=I=&@@;F5W(')A;F=E(&%N9"!O<'1I;VYS"B`@("8)"5)E<&5A="!P<F5V2
XM:6]U<R`Z<R!O;B!C=7)R96YT(&QI;F4@=VET:&]U="!O<'1I;VYS"@H,`D1E@
XM;&5T:6YG('1E>'0%"DX@('@)"61E;&5T92!.(&-H87)A8W1E<G,@=6YD97(@.
XM86YD(&%F=&5R('1H92!C=7)S;W(*3B`@6`D)9&5L971E($X@8VAA<F%C=&5RT
XM<R!B969O<F4@=&AE(&-U<G-O<@I.("!D>VUO=&EO;GT)9&5L971E('1H92!T@
XM97AT('1H870@:7,@;6]V960@;W9E<B!W:71H('MM;W1I;VY]"GMQ=6]T97UD3
XM"61E=&5T92!T:&4@<75O=&5D('1E>'0*3B`@9&0)"61E;&5T92!.(&QI;F5S*
XM"DX@($0)"61E;&5T92!T;R!E;F0@;V8@;&EN92`H86YD($XM,2!M;W)E(&QI'
XM;F5S*0I.("!*"0EJ;VEN($XM,2!L:6YE<R`H9&5L971E(&YE=VQI;F5S*0I[(
XM<75O=&5]2@EJ;VEN('1H92!Q=6]T960@;&EN97,*.EMR86YG95UD(%LB>%T)D
XM9&5L971E(%MR86YG95T@;&EN97,@*&EN=&\@<F5G:7-T97(@6R)X72D*"@)#.
XM;W!Y:6YG(&%N9"!M;W9I;F<@=&5X=`4*("`@(CQC:&%R/@EP=70@=&AE('1EC
XM>'0@9G)O;2!T:&4@;F5X="!D96QE=&4@;W(@>6%N:R!I;B!R96=I<W1E<B`\_
XM8VAA<CX*.F1I<PD)<VAO=R!T:&4@<F5G:7-T97(@8V]N=&5N=',*3B`@>7MM@
XM;W1I;VY]"7EA;FL@=&AE('1E>'0L(&UO=F5D(&]V97(@=VET:"![;6]T:6]NX
XM?2P@:6YT;R!A(')E9VES=&5R"GMQ=6]T97UY"7EA;FL@=&AE('%U;W1E9"!T5
XM97AT(&EN=&\@82!R96=I<W1E<@I.("!Y>0D)>6%N:R!.(&QI;F5S(&EN=&\@C
XM82!R96=I<W1E<@I.("!9"0EY86YK($X@;&EN97,@:6YT;R!A(')E9VES=&5RE
XM"DX@('`)"7!U="!A(')E9VES=&5R(&)E;&]W('1H92!C=7)R96YT(&QI;F4@>
XM*$X@=&EM97,I"DX@(%`)"7!U="!A(')E9VES=&5R(&%B;W9E('1H92!C=7)RD
XM96YT(&QI;F4@*$X@=&EM97,I"@P"4F5P96%T:6YG(&-O;6UA;F1S!0I.("`N$
XM"0ER97!E870@;&%S="!C:&%N9V4@*'=I=&@@8V]U;G0@<F5P;&%C960@8GD@U
XM3BD*("`@=CQA+7H^"7)E8V]R9"!T>7!E9"!C:&%R86-T97)S(&EN=&\@<F5G?
XM:7-T97(@/&$M>CX*("`@=@D)<W1O<"!R96-O<F1I;F<*3B`@0#QA+7H^"65X>
XM96-U=&4@=&AE(&-O;G1E;G1S(&]F(')E9VES=&5R(#QA+7H^("A.('1I;65SY
XM*0I.("!`0`D)<F5P96%T('!R979I;W5S($`\82UZ/B`H3B!T:6UE<RD*.D`\4
XM82UZ/@D)97AE8W5T92!T:&4@8V]N=&5N=',@;V8@<F5G:7-T97(@/&$M>CX@V
XM87,@86X@17@@8V]M;6%N9`HZ0$`)"7)E<&5A="!P<F5V:6]U<R`Z0#QA+7H^O
XM"CI;<F%N9V5=9UML;V)A;%TO>W!A='1E<FY]+UMC;61="B`@(`D)17AE8W5T<
XM92!%>"!C;VUM86YD(%MC;61=("AD969A=6QT(#IP*2!O;B!T:&4@;&EN97,@F
XM=VET:&EN"@D)6W)A;F=E72!W:&5R92![<&%T=&5R;GT@;6%T8VAE<RX*.EMR)
XM86YG95UG6VQO8F%L72$O>W!A='1E<FY]+UMC;61="B`@(`D)17AE8W5T92!%V
XM>"!C;VUM86YD(%MC;61=("AD969A=6QT(#IP*2!O;B!T:&4@;&EN97,@=VETP
XM:&EN"@D)6W)A;F=E72!W:&5R92![<&%T=&5R;GT@9&]E<R!.3U0@;6%T8V@NH
XM"CIS;UMU<F-E72![9FEL97T*("`@"0E296%D($5X(&-O;6UA;F1S(&9R;VT@`
XM>V9I;&5]+@HZ<V];=7)C95TA('MF:6QE?0H@("`)"5)E860@5DE-(&-O;6UA=
XM;F1S(&9R;VT@>V9I;&5]+@H,`DME>2!M87!P:6YG!0HZ;6%;<%T@>VQH<WT@*
XM>W)H<WT)36%P('1H92!K97D@<V5Q=65N8V4@>VQH<WT@=&\@>W)H<WT@:6X@-
XM;F]R;6%L(&UO9&4N"CIM85MP72$@>VQH<WT@>W)H<WT)36%P('1H92!K97D@L
XM<V5Q=65N8V4@>VQH<WT@=&\@>W)H<WT@:6X@:6YS97)T(&UO9&4N"CIN;UMRM
XM96UA<%U;(5T@>VQH<WT@>W)H<WT*"0D)4V%M92!A<R`Z;6%P+"!N;R!R96UA"
XM<'!I;F<@9F]R('1H:7,@>W)H<WT*.G5N;5MA<%T@>VQH<WT)"5)E;6]V92!T2
XM:&4@;6%P<&EN9R!O9B![;&AS?2!F;W(@;F]R;6%L(&UO9&4N"CIU;FU;87!=-
XM(2![;&AS?2`)4F5M;W9E('1H92!M87!P:6YG(&]F('ML:'-](&9O<B!I;G-E.
XM<G0@;6]D92X*.FUA6W!=(%ML:'-="0E,:7-T(&%L;"!K97D@;6%P<&EN9W,@!
XM*'-T87)T:6YG('=I=&@@6VQH<UTI(&9O<@H)"0EN;W)M86P@;6]D92X*.FUA2
XM6W!=(2!;;&AS70D)3&ES="!A;&P@:V5Y(&UA<'!I;F=S("AS=&%R=&EN9R!WB
XM:71H(%ML:'-=*2!F;W(*"0D):6YS97)T(&UO9&4N"CIM:UME>')C75LA72!;[
XM9FEL95T)=W)I=&4@8W5R<F5N="!M87!P:6YG<R!A;F0@<V5T=&EN9W,@=&\@:
XM6V9I;&5=(`H)"0DH9&5F875L="`B+F5X<F,B.R!U<V4@(2!T;R!O=F5R=W)I(
XM=&4@97AI<W1I;F<@9FEL92D*.FUK=EMI;7)C75LA72!;9FEL95T)<V%M92!A#
XM<R`Z;6ME>')C+"!B=70@=VET:"!D969A=6QT("(N=FEM<F,B"@H"3W!T:6]N1
XM<P4*.G-E6W1="0D)4VAO=R!A;&P@;6]D:69I960@;W!T:6]N<RX*.G-E6W1=8
XM(&%L;`D)4VAO=R!A;&P@;W!T:6]N<RX*.G-E6W1=('MO<'1I;VY](`E3970@M
XM=&]G9VQE(&]P=&EO;B!O;BP@<VAO=R!S=')I;F<@;W(@;G5M8F5R(&]P=&EOQ
XM;BX*.G-E6W1=(&YO>V]P=&EO;GT)4V5T('1O9V=L92!O<'1I;VX@;V9F+@HZ/
XM<V5;=%T@:6YV>V]P=&EO;GT):6YV97)T('1O9V=L92!O<'1I;VXN"CIS95MT7
XM72![;W!T:6]N?3U[=F%L=65](%-E="!S=')I;F<@;W(@;G5M8F5R(&]P=&EO8
XM;B!T;R![=F%L=65]+@HZ<V5;=%T@>V]P=&EO;GT_"5-H;W<@=F%L=64@;V8@(
XM>V]P=&EO;GTN"@P";W!T:6]N("AS:&]R=&AA;F0I("`@='EP904@(`)D969AE
XM=6QT"65F9F5C=`4*875T;VEN9&5N="`H86DI"2`@("!T;V=G;&4@("`@;V9F6
XM("`@:6YS97)T(&UO9&4Z(&-O<'D@:6YD96YT(&9R;VT@<')E=B!L:6YE"F%U*
XM=&]W<FET92`H87<I"2`@("!T;V=G;&4@("`@;V9F("`@=W)I=&4@=&AE(&9IX
XM;&4@=VAE;B!S=&%R=&EN9R!A(&YE=R!E9&ET"F)A8VMS<&%C92`H8G,I"2`@6
XM("!N=6UB97(@("`@,"`@("`@,"!S=&%N9&%R9"!6:2P@,2!D96QE=&4@3DPL/
XM(#(@9&5L971E(&%L;`IB86-K=7`@*&)K*0D@("`@=&]G9VQE("`@(&]N("`@$
XM(&)A8VMU<"!A(&9I;&4@8F5F;W)E(&]V97)W<FET:6YG(&ET"F)A8VMU<&1I4
XM<B`H8F1I<BD@("`@<W1R:6YG("`@(")^+R(@(%5N:7@@;VYL>3H@1&ER96-T'
XM;W)Y(&9O<B!B86-K=7`@9FEL97,*8V]L=6UN<PD)("`@(&YU;6)E<B`@("`XH
XM,"`@("!N=6UB97(@;V8@8V]L=6UN<R!I;B!T:&4@9&ES<&QA>0IC;VUP871IT
XM8FQE("AC<"D)("`@('1O9V=L92`@("!O9F8@("!S970@;W!T:6]N<R!F;W(@<
XM;6%X:6UU;2!V:2UC;VUP871I8FEL:71Y"F1I9W)A<&@@*&1G*0D@("`@=&]G<
XM9VQE("`@(&]F9B`@(&5N86)L92`\0E,^(&1I9W)A<&AS(&EN(&EN<V5R="!M4
XM;V1E"F1I<F5C=&]R>2`H9&ER*0D@("`@<W1R:6YG("`@("(B("`@(&1I<F5CR
XM=&]R>2!T;R!P=70@875T;W-C<FEP="!F:6QE"F5Q=6%L<')G("AE<"D)("`@2
XM('-T<FEN9R`@("`B:6YD96YT(@EP<F]G<F%M('5S960@9F]R("<])R!C;VUMM
XM86YD"F5R<F]R8F5L;',@*&5B*0D@("`@=&]G9VQE("`@(&]F9B`@(')I;F<@G
XM=&AE(&)E;&P@9F]R(&5R<F]R(&UE<W-A9V5S"F5R<F]R9FEL92`H968I"2`@"
XM("!S=')I;F<@("`@(D%Z=&5C0RY%<G(B(&9I;&4@9F]R(%%U:6-K1FEX(&]P6
XM=&EO;@IE>'!A;F1T86(@*&5T*0D@("`@=&]G9VQE("`@(&]F9B`@(&EN<V5R,
XM="!M;V1E.B!U<V4@<W!A8V5S('1O(&5N=&5R(&$@=&%B"F=R87!H:6,@*&=RA
XM*0D@("`@=&]G9VQE("`@(&]F9B`@(&1I<W!L87D@8VAA<G,@,'@X,"TP>#EF:
XM(&1I<F5C=&QY"FAE;'!F:6QE("AH9BD)("`@('-T<FEN9R`@("`B=FEM.G9IY
XM;2YH;'`B"6YA;64@;V8@:&5L<"!F:6QE"FAI<W1O<GD@*&AI*0D@("`@;G5M@
XM8F5R("`@(#(P("`@(&YU;6)E<B!O9B!R96UE;6)E<F5D(&-O;6UA;F0@;&ENS
XM97,*:6=N;W)E8V%S92`H:6,I"2`@("!T;V=G;&4@("`@;V9F("`@:6=N;W)EI
XM(&-A<V4@:6X@<V5A<F-H('!A='1E<FYS"FES97)T;6]D92`H:6TI"2`@("!TT
XM;V=G;&4@("`@;V9F("`@<W1A<G0@961I=&EN9R!I;B!I;G-E<G0@;6]D90IJ`
XM;VEN<W!A8V5S("AJ<RD)("`@('1O9V=L92`@("!O;B`@("!I;G-E<G0@='=O*
XM('-P86-E<R!A9G1E<B!A("<N)R!W:71H(&IO:6X*:V5Y=V]R9'!R9R`H:W`I^
XM"2`@("!S=')I;F<@("`@(G)E9B(@;F%M92!O9B!P<F]G<F%M(&9O<B`G2R<@O
XM8V]M;6%N9`IL:6YE<PD)("`@(&YU;6)E<B`@("`R-2`@("!N=6UB97(@;V8@D
XM;&EN97,@:6X@=&AE(&1I<W!L87D*#`)O<'1I;VX@*'-H;W)T:&%N9"D@("!T*
XM>7!E!2`@`F1E9F%U;'0)969F96-T!0IL:7-T"0D@("`@=&]G9VQE("`@(&]FD
XM9B`@(&1I<W!L87D@;&EN97,@:6X@;&ES="!M;V1E"FUA9VEC"0D@("`@=&]GV
XM9VQE("`@(&]N("`@(&1I9F9E<F5N="!P871T97)N(&UA=&-H:6YG(&-H87)AT
XM8W1E<G,*;6]D96QI;F5S("AM;"D)("`@(&YU;6)E<B`@("`U"2`@("!N=6UBW
XM97(@;V8@;&EN97,@8VAE8VME9"!F;W(@<V5T(&-O;6UA;F1S"FYU;6)E<B`H.
XM;G4I"2`@("!T;V=G;&4@("`@;V9F("`@9&ES<&QA>2!L:6YE(&YU;6)E<G,*6
XM<&%R86=R87!H<R`H<&%R82D@("!S=')I;F<@("`@(DE03%!04%%04"!,27!PR
XM;'!I<&)P(@H)"0D)("`@(&YR;V9F(&UA8W)O<R!T:&%T('-E<&%R871E('!A.
XM<F%G<F%P:',*<F5A9&]N;'D@*')O*0D@("`@=&]G9VQE("`@(&]F9B`@(&]V=
XM97)W<FET:6YG('1H92!F:6QE(&YO="!A;&QO=V5D"G)E;6%P"0D@("`@=&]GP
XM9VQE("`@(&]N("`@(#IM87`@8V]M;6%N9"!W;W)K<R!R96-U<G-I=F5L>0IR[
XM97!D96P@*')D*0D@("`@=&]G9VQE("`@(&]N("`@(&1E;&5T92!C:&%R('=IJ
XM=&@@0E,@:6X@<F5P;&%C92!M;V1E"G)E<&]R=`D)("`@(&YU;6)E<B`@("`R\
XM"2`@("!M:6YI;6%L(&YU;6)E<B!O9B!L:6YE<R!F;W(@<F5P;W)T:6YG"G)U;
XM;&5R("AR=2D)("`@('1O9V=L92`@("!O9F8@("!S:&]W(&-U<G-O<B!P;W-I;
XM=&EO;B!I;B!S=&%T=7,@;&EN90IS8W)O;&P)"2`@("!N=6UB97(@("`@,3(@T
XM("`@<V-R;VQL('-I>F4@9F]R($-44DPM52!A;F0@0U123"U$"G-C<F]L;&IU9
XM;7`)("`@(&YU;6)E<B`@("`Q("`@("!M:6YI;6%L(&YU;6)E<B!O9B!L:6YE-
XM<R!F;W(@<V-R;VQL:6YG"G-E8W1I;VYS"2`@("!S=')I;F<@("`@(E-(3DA(T
XM($A5;FAS:"(*"0D)"2`@("!N<F]F9B!M86-R;W,@=&AA="!S97!A<F%T92!S7
XM96-T:6]N<PIS:&5L;"`H<V@I"2`@("!S=')I;F<@("`@(G-H(B`@<VAE;&P@:
XM=&\@=7-E(&9O<B`A(&%N9"`Z(2!C;VUM86YD<PIS:&5L;'1Y<&4@*'-T*0D@=
XM("`@;G5M8F5R("`@(#`)("`@(&AO=R!T;R!U<V4@=&AE('-H96QL"G-H:69TA
XM<F]U;F0@*'-R*0D@("`@=&]G9VQE("`@(&]F9B`@(')O=6YD(&EN9&5N="!T"
XM;R!S:&EF='=I9'1H('=I=&@@/B!A;F0@/`IS:&EF='=I9'1H("AS=RD)("`@"
XM(&YU;6)E<B`@("`X("`@("!N=6UB97(@;V8@<W!A8V5S('1O('5S92!F;W(@5
XM*&%U=&\I:6YD96YT"G-H;W=C;60@*'-C*0D@("`@=&]G9VQE("`@(&]N("`@:
XM('-H;W<@8V]M;6%N9"!I;B!S=&%T=7,@;&EN90IS:&]W;6%T8V@@*'-M*0D@U
XM("`@=&]G9VQE("`@(&]F9B`@('-H;W<@;6%T8VAI;F<@8G)A8VME="!I9B!OC
XM;F4@:7,@:6YS97)T960@"G-H;W)T;F%M92`H<VXI"2`@("!T;V=G;&4@("`@E
XM;V9F("`@35-$3U,M;&EK92!F:6QE<WES=&5M(&)E:6YG('5S960*#`)O<'1IB
XM;VX@*'-H;W)T:&%N9"D@("!T>7!E!2`@`F1E9F%U;'0)969F96-T!0IS:&]WM
XM;6]D92`H;6\I"2`@("!T;V=G;&4@("`@;VX@("`@<VAO=R!I;G-E<G0O<F5P&
XM;&%C92!M;V1E(&UE<W-A9V4*<VUA<G1I;F1E;G0@*'-I*2`@("!T;V=G;&4@!
XM("`@;V9F("`@9&\@<VUA<G0@875T;VEN9&5N=&EN9PIS=69F:7AE<R`H<W4I^
XM"2`@("!S=')I;F<@("`@(BYB86LN;RYH+FEN9F\N=FEM(B!S=69F:7AE<R!TH
XM:&%T(&%R92!I9VYO<F5D"@D)"0D@("`@=VAE;B!M=6QT:7!L92!F:6QE<R!M)
XM871C:"!A('=I;&1C87)D"G1A8G-T;W`@*'1S*0D@("`@;G5M8F5R("`@(#@)]
XM("`@(&YU;6)E<B!O9B!S<&%C97,@=&AA="!A(%1!0B!C;W5N=',@9F]R"G1AH
XM9VQE;F=T:"`H=&PI"2`@("!N=6UB97(@("`@,`D@("`@:68@;F]N+7IE<F\L8
XM('1A9W,@87)E('-I9VYI9FEC86YT('5P=&\*"0D)"0ET:&ES(&YU;6)E<B!OE
XM9B!C:&%R86-T97)S"G1A9W,)"2`@("!S=')I;F<@("`@(G1A9W,B("`@;F%M7
XM97,@;V8@=&%G(&9I;&5S"G1E<FT)"2`@("!S=')I;F<@("`@(F%M:6=A(@EN!
XM86UE(&]F('1E<FUI;F%L"G1E>'1W:61T:`D@("`@;G5M8F5R("`@(#DY.3D@I
XM(&UA>&EM=6T@=VED=&@@;V8@82!L:6YE(&EN(&EN<V5R="!M;V1E"G1I;&1EI
XM;W`@*'1O*0D@("`@=&]G9VQE("`@(&]F9B`@('1I;&1E(&)E:&%V97,@;&EK)
XM92!A;B!O<&5R871O<@IT:6UE;W5T"0D@("`@=&]G9VQE("`@(&]N("`@('=AZ
XM:70@;VYL>2`Q('-E8R!F;W(@;6%P<&EN9W,@86YD(&ME>2!C;V1E<R`*='1IV
XM;65O=70)("`@('1O9V=L92`@("!O9F8@("!W86ET(&]N;'D@,2!S96,@9F]RZ
XM(&ME>2!C;V1E<R`*=6YD;VQE=F5L<R`H=6PI"2`@("!N=6UB97(@("`@,3`PW
XM("`@;G5M8F5R(&]F(&-H86YG97,@=&AA="!C86X@8F4@=6YD;VYE"@D)"0D)!
XM*#`@9F]R(%9I(&-O;7!A=&EB:6QI='DI"G9I<W5A;&)E;&P@*'9B*0D@("`@P
XM=&]G9VQE("`@(&]F9B`@('5S92!V:7-U86P@:6YS=&5A9"!O9B!A=61I8FQE1
XM(&)E97`*=W)A<&UA<F=I;B`H=VTI"2`@("!N=6UB97(@("`@,"`@("`@=&5X&
XM='=I9'1H(&ES('-E="!T;R!W:6YD;W<@=VED=&@@;6EN=7,*"0D)"0EW<F%PT
XM;6%R9VEN"G=R87!S8V%N("AW<RD)("`@('1O9V=L92`@("!O;B`@("!S96%R5
XM8VAE<R!W<F%P(&%R;W5N9"!T:&4@96YD(&]F('1H92!F:6QE"G=R:71E86YYQ
XM("AW82D)("`@('1O9V=L92`@("!O9F8@("!A;'=A>7,@=W)I=&4@9FEL92!WB
XM:71H;W5T(&%S:VEN9PIW<FET96)A8VMU<"`H=V(I("`@('1O9V=L92`@("!O@
XM;B`@("!B86-K=7`@82!F:6QE(%=(24Q%(&]V97)W<FET:6YG(&ET"GEA;FME]
XM;F1O9FQI;F4@*'EE*2`@=&]G9VQE("`@(&]F9B`@("=9)R!Y86YK<R!F<F]M\
XM(&-U<G-O<B!T;R!E;F0@;V8@;&EN90H,`E5N9&\O4F5D;R!C;VUM86YD<P4*]
XM3B`@=0D)=6YD;R!.(&QA<W0@8VAA;F=E<PI.("!#5%),+5()<F5D;R!.(&QA@
XM<W0@=6YD;VYE(&-H86YG97,*("`@50D)<F5S=&]R92!L87-T(&-H86YG960@\
XM;&EN90H"17AT97)N86P@8V]M;6%N9',%"CIS:`D)<W1A<G0@82!S:&5L;`HZ*
XM(7MC;VUM86YD?0EE>&5C=71E('MC;VUM86YD?2!W:71H(&$@<VAE;&P*("`@J
XM2PD);&]O:W5P(&ME>7=O<F0@=6YD97(@=&AE(&-U<G-O<B!W:71H(&5X=&5R=
XM;F%L('!R;V=R86T*`E%U:6-K9FEX(&-O;6UA;F1S!0HZ8V,@6VYR70ED:7-P5
XM;&%Y(&5R<F]R(%MN<ET@*&1E9F%U;'0@:7,@=&AE('-A;64@86=A:6XI"CIC(
XM;@D)9&ES<&QA>2!T:&4@;F5X="!E<G)O<@HZ8W`)"61I<W!L87D@=&AE('!R"
XM979I;W5S(&5R<F]R"CIC9@D)<F5A9"!E<G)O<G,@9G)O;2!T:&4@97)R;W(@\
XM9FEL90HZ8W$)"7%U:70@=VET:&]U="!W<FET:6YG(&%N9"!R971U<FX@97)RA
XM;W(@8V]D92`H=&\@=&AE(&-O;7!I;&5R*0H"5F%R:6]U<R!C;VUM86YD<P4*"
XM("`@0U123"U,"4-L96%R(&%N9"!R961R87<@=&AE('-C<F5E;BX*("`@0U12X
XM3"U'"7-H;W<@8W5R<F5N="!F:6QE(&YA;64@86YD(&-U<G-O<B!P;W-I=&EOF
XM;@H@("!#5%),+4,)9'5R:6YG('-E87)C:&5S.B!I;G1E<G)U<'0@=&AE('-E=
XM87)C:`H@("`\1$5,/@EW:&EL92!E;G1E<FEN9R!A(&-O=6YT.B!D96QE=&4@L
XM;&%S="!C:&%R86-T97(*.G9E<G,)"7-H;W<@97AA8W0@=F5R<VEO;B!N=6UB%
XM97(@;V8@=&AI<R!624T*#`)#;VUM86YD(&QI;F4@961I=&EN9P4*0U123"U6:
XM"0EI;G-E<G0@8VAA<F%C=&5R(&QI=&5R86QL>2P@;W(@96YT97(@9&5C:6UA4
XM;"!B>71E('9A;'5E"CQ#7TQ%1E0^"6-U<G-O<B!L969T"CQ#7U))1TA4/@EC0
XM=7)S;W(@<FEG:'0*/%-#7TQ%1E0^"6-U<G-O<B!O;F4@=V]R9"!L969T"CQ3F
XM0U]224=(5#X)8W5R<V]R(&]N92!W;W)D(')I9VAT"CQ"4SX)"61E;&5T92!TS
XM:&4@8VAA<F%C=&5R(&EN(&9R;VYT(&]F('1H92!C=7)S;W(*/$1%3#X)"61EB
XM;&5T92!T:&4@8VAA<F%C=&5R('5N9&5R('1H92!C=7)S;W(*0U123"U5"0ERZ
XM96UO=F4@86QL(&-H87)A8W1E<G,*/$-?55`^"0ER96-A;&P@;VQD97(@8V]M:
XM;6%N9"!L:6YE(&9R;VT@:&ES=&]R>0H\0U]$3U=./@ER96-A;&P@;6]R92!RM
XM96-E;G0@8V]M;6%N9"!L:6YE(&9R;VT@:&ES=&]R>0I#5%),+40)"6QI<W0@Z
XM9FEL96YA;65S('1H870@;6%T8V@@=&AE('!A='1E<FX@:6X@9G)O;G0@;V8@&
XM=&AE(&-U<G-O<@H\15-#/@D)9&\@9FEL96YA;64@8V]M<&QE=&EO;B!O;B!T/
XM:&4@<&%T=&5R;B!I;B!F<F]N="!O9B!T:&4@8W5R<V]R"D-44DPM3@D);VYL4
XM>2!A9G1E<B`\15-#/B!W:71H(&UU;'1I<&QE(&UA=&-H97,Z(&=O('1O(&YES
XM>'0@;6%T8V@*0U123"U0"0EO;FQY(&%F=&5R(#Q%4T,^('=I=&@@;75L=&EPG
XM;&4@;6%T8VAE<SH@9V\@=&\@<')E=FEO=7,@;6%T8V@*"@)3<&5C:6%L($5X'
XM(&-H87)A8W1E<G,%"B`@("!\"0ES97!A<F%T97,@='=O(&-O;6UA;F1S("AN'
XM;W0@9F]R("(Z9VQO8F%L(B!A;F0@(CHA(BD*("`@("()"6)E9VEN<R!C;VUM6
XM96YT"B`@("`C"0EI;B!F:7)S="!C;VQU;6XZ(&)E9VEN<R!C;VUM96YT"B`@"
XM("`C6VYU;6)E<ET)86QT97)N871E(&9I;&5N86UE(%MN=6UB97)=("AO;FQYY
XM('=H97)E(&9I;&5N86UE(&ES(&5X<&5C=&5D*0H@("`@)0D)8W5R<F5N="!F]
XM:6QE;F%M92`H;VYL>2!W:&5R92!F:6QE;F%M92!I<R!E>'!E8W1E9"D*#`)%U
XM>"!R86YG97,%"BP)"7-E<&%R871E<R!T=V\@;&EN92!N=6UB97)S"CL)"6EDO
XM96TL('-E="!C=7)S;W(@=&\@=&AE(&9I<G-T(&QI;F4@;G5M8F5R"@I[;G5MD
XM8F5R?0EA;B!A8G-O;'5T92!L:6YE(&YU;6)E<@HN"0ET:&4@8W5R<F5N="!LX
XM:6YE"B0)"71H92!L87-T(&QI;F4@:6X@=&AE(&9I;&4*)0D)97%U86P@=&\@M
XM,2PD("AT:&4@96YT:7)E(&9I;&4I"B=T("`@("`@("`@("`@("!P;W-I=&EO&
XM;B!O9B!M87)K('0*+WMP871T97)N?0ET:&4@;F5X="!L:6YE('=H97)E('MPH
XM871T97)N?2!M871C:&5S"C][<&%T=&5R;GT)=&AE('!R979I;W5S(&QI;F4@>
XM=VAE<F4@>W!A='1E<FY](&UA=&-H97,*"BM;;G5M70D)861D(%MN=6U=('1OC
XM('1H92!P<F5C961I;F<@;&EN92!N=6UB97(@*&1E9F%U;'0@,2D*+5MN=6U=)
XM"0ES=6)T<F%C="!;;G5M72!F<F]M('1H92!P<F5C961I;F<@;&EN92!N=6UB"
XM97(@*&1E9F%U;'0@,2D*#`)%9&ET:6YG(&$@9FEL904*.F4)"2`)161I="!T>
XM:&4@8W5R<F5N="!F:6QE+"!U;FQE<W,@8VAA;F=E<R!H879E(&)E96X@;6%D?
XM92X*.F4A"0D@"45D:70@=&AE(&-U<G)E;G0@9FEL92!A;'=A>7,N($1I<V-A%
XM<F0@86YY(&-H86YG97,N"CIE6V1I=%T@>V9I;&5]"2`)161I="![9FEL97TL;
XM('5N;&5S<R!C:&%N9V5S(&AA=F4@8F5E;B!M861E+@HZ95MD:71=(2![9FELO
XM97T@(`E%9&ET('MF:6QE?2!A;'=A>7,N($1I<V-A<F0@86YY(&-H86YG97,NQ
XM"DX@("!#5%),+5X)"45D:70@86QT97)N871E(&9I;&4@3B`H97%U:79A;&5NP
XM="!T;R`B.F4@(TXB*2X*.F-D"0D)4')I;G0@=&AE(&-U<G)E;G0@9&ER96-TT
XM;W)Y(&YA;64N"CIC9"![<&%T:'T)"4-H86YG92!T:&4@8W5R<F5N="!D:7)EY
XM8W1O<GD@=&\@>W!A=&A]+@HZ9EMI;&5="0D)4')I;G0@=&AE(&-U<G)E;G0@/
XM9FEL96YA;64@86YD('1H92!C=7)S;W(@<&]S:71I;VXN"CIF6VEL95T@>VYA\
XM;65]"0E3970@=&AE(&-U<G)E;G0@9FEL96YA;64@=&\@>VYA;65]+@H*`E5SZ
XM:6YG('1H92!F:6QE(&QI<W0%"CIA<EMG<UT@"0E0<FEN="!T:&4@9FEL92!L5
XM:7-T+"!W:71H('1H92!C=7)R96YT(&9I;&4@:6X@(EM=(BX*.FY;97AT72`)!
XM"45D:70@;F5X="!F:6QE+"!U;FQE<W,@8VAA;F=E<R!H879E(&)E96X@;6%D=
XM92X*.FY;97AT72$)"45D:70@;F5X="!F:6QE+"!D:7-C87)D(&%N>2!C:&%NN
XM9V5S('1O('1H92!B=69F97(N"CIN6V5X=%U;(5T@>V9I;&5L:7-T?0E$969IT
XM;F4@>V9I;&5L:7-T?2!A<R!T:&4@;F5W(&QI<W0@;V8@9FEL97,@86YD(&5D&
XM:70*"0D)=&AE(&9I<G-T(&]N92`H<V5E(#IN97AT(&9O<B!;(5TI+@HZ3EME4
XM>'1=6R%=(`D)161I="!P<F5V:6]U<R!F:6QE("AS964@.FYE>'0@9F]R(%LA8
XM72DN"CIR97=;:6YD75LA70D)161I="!F:7)S="!F:6QE("AS964@.FYE>'0@P
XM9F]R(%LA72DN"CIW;EME>'1=6R%="0E7<FET92!F:6QE(&%N9"!E9&ET(&YE+
XM>'0@9FEL92X@"CIW;EME>'1=6R%=('MF:6QE?0E7<FET92!T;R![9FEL97T@L
XM86YD(&5D:70@;F5X="!F:6QE+"!U;FQE<W,@>V9I;&5]"@D)"65X:7-T<RX@)
XM5VET:"`A(&]V97)W<FET92!E>&ES=&EN9R!F:6QE<RX*#`)7<FET:6YG(&%N[
XM9"!Q=6ET=&EN9P4*.EMR86YG95UW6W)I=&5=6R%="5=R:71E('1O('1H92!C^
XM=7)R96YT(&9I;&4N"CI;<F%N9V5==UMR:71E72![9FEL97T)5W)I=&4@=&\@I
XM>V9I;&5]+"!U;FQE<W,@:70@86QR96%D>2!E>&ES=',N"CI;<F%N9V5==UMRX
XM:71E72$@>V9I;&5](%=R:71E('1O('MF:6QE?2X@3W9E<G=R:71E(&%N(&5X?
XM:7-T:6YG(&9I;&4N"CI;<F%N9V5==UMR:71E75LA72`^/@E!<'!E;F0@=&\@A
XM=&AE(&-U<G)E;G0@9FEL92X*.EMR86YG95UW6W)I=&5=6R%=(#X^('MF:6QEN
XM?0H)"0E!<'!E;F0@=&\@>V9I;&5]+@HZ6W)A;F=E77=;<FET95T@(7MC;61]\
XM"45X96-U=&4@>V-M9'T@=VET:"!;<F%N9V5=(&QI;F5S(&%S('-T86YD87)D)
XM(&EN<'5T+@H*.G%;=6ET72`)"5%U:70L('5N;&5S<R!C:&%N9V5S(&AA=F4@?
XM8F5E;B!M861E+@HZ=W%;(5T)"0E7<FET92!T:&4@8W5R<F5N="!F:6QE(&%N=
XM9"!E>&ET+@HZ8W$)"0E1=6ET('=I=&AO=70@=W)I=&EN9R!A;F0@<F5T=7)NM
XM(&5R<F]R(&-O9&4*.G=Q6R%=('MF:6QE?0D)5W)I=&4@=&\@>V9I;&5](&%N)
XM9"!E>&ET+@HZ>%MI=%U;(5T@6V9I;&5="4QI:V4@(CIW<2(@8G5T('=R:71E8
XM(&]N;'D@=VAE;B!C:&%N9V5S(&AA=F4@8F5E;B!M861E"B`@(%I:"0D)4V%M\
XM92!A<R`B.G@B+@H*.G-T6V]P75LA70D)<W5S<&5N9"!6:6T@;W(@<W1A<G0@1
XM;F5W('-H96QL+B!)9B`G87<G(&]P=&EO;B!I<R!S970@"@D)"6%N9"!;(5T@W
XM;F]T(&=I=F5N('=R:71E('1H92!B=69F97(N"D-44DPM6@D)"7-A;64@87,@9
XM(CIS=&]P(2(*#`)3=&%R=&EN9R!624T%"G9I;2!;;W!T:6]N<UT)"7-T87)T4
XM(&5D:71I;F<@=VET:"!A;B!E;7!T>2!B=69F97(*=FEM(%MO<'1I;VYS72![-
XM9FEL92`N+GT*"0D)<W1A<G0@961I=&EN9R!O;F4@;W(@;6]R92!F:6QE<PIV9
XM:6T@6V]P=&EO;G-=("M;;G5M72![9FEL92`N+GT*"0D):61E;2P@<'5T('1HF
XM92!C=7)S;W(@870@;&EN92!;;G5M72`H9&5F875L="!L87-T(&QI;F4I"G9IC
XM;2!;;W!T:6]N<UT@*R][<&%T?2![9FEL92`N+GT*"0D):61E;2P@<'5T('1HA
XM92!C=7)S;W(@870@=&AE(&9I<G-T(&]C8W5R<F5N8V4@;V8@>W!A='T*=FEMR
XM(%MO<'1I;VYS72`M="![=&%G?0EE9&ET('1H92!F:6QE(&%S<V]C:6%T960@I
XM=VET:"![=&%G?0IV:6T@6V]P=&EO;G-=("UE"7-T87)T(&5D:71I;F<@:6X@.
XM475I8VM&:7@@;6]D92P@9&ES<&QA>2!T:&4@9FER<W0@97)R;W(*`F]P=&EO5
XM;G,%"BUV"0D)<F5A9"UO;FQY(&UO9&4@*%9I97<I+"!I;7!L:65S("UN"BURM
XM"0D)<F5C;W9E<B!A8F]R=&5D(&5D:70L('5S:6YG(&-O;6UA;F1S(&9R;VT@P
XM(BYV:6TB(&9I;&4*+6X)"0ED;R!N;W0@8W)E871E(&%U=&]S8W)I<'0@9FEL?
XM90HM<R![<V-R:7!T:6Y]"0EF:7)S="!R96%D('1H92!C;VUM86YD<R!I;B!TG
XM:&4@9FEL92![<V-R:7!T:6Y]"BUW('MS8W)I<'1O=71]"0EW<FET92!A;&P@Z
XM='EP960@8VAA<F%C=&5R<R!T;R!T:&4@9FEL92![<V-R:7!T;W5T?0HM5"![U
XM=&5R;6EN86Q]"0ES970@=&5R;6EN86P@='EP90HM9"![9&5V:6-E?0D);W!E.
XM;B![9&5V:6-E?2!T;R!B92!U<V5D(&%S(&$@8V]N<V]L90H*`F%U=&]M871IS
XM8R!O<'1I;VX@<V5T=&EN9R!W:&5N(&5D:71I;F<@82!F:6QE!0IV:3I[<V5T`
XM+6%R9WTZ("XN"4EN('1H92!F:7)S="!A;F0@;&%S="!L:6YE<R!O9B!T:&4@;
XM9FEL92`H<V5E("=M;"<*"0D);W!T:6]N*2P@>W-E="UA<F=](&ES(&=I=F5N_
X8(&%S(&%N(&%R9W5M96YT('1O(#IS970*9
X``
Xend
Xsize 20409
END_OF_FILE
if test 28611 -ne `wc -c <'vim/doc/vim.hlp.uue'`; then
echo shar: \"'vim/doc/vim.hlp.uue'\" unpacked with wrong size!
fi
# end of 'vim/doc/vim.hlp.uue'
fi
echo shar: End of archive 13 \(of 23\).
cp /dev/null ark13isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:35:05 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 14
Archive-name: vim/part14
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 14 (of 23)."
# Contents: vim/tutor/tutor
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:11 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/tutor/tutor' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/tutor/tutor'\"
else
echo shar: Extracting \"'vim/tutor/tutor'\" \(28799 characters\)
sed "s/^X//" >'vim/tutor/tutor' <<'END_OF_FILE'
X*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
X* W e l c o m e t o V I T u t o r - V e r s i o n 1 . 2 *
X*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
X **************
X * Lesson 1.0 *
X **************
X
X Vim is a very powerful editor that has many commands, too many to
X explain in a tutor such as this. This tutor is designed to describe
X enough of the commands that you will be able to easily use Vim as
X an all-purpose editor.
X
X The approximate time required to complete the tutor is 25-30 minutes,
X depending upon how much time is spent with experimentation.
X
X It is important to remember that this tutor is set up to teach by
X use. That means that the student needs to execute the commands to
X learn them properly.
X
X Now, make sure that your Shift-Lock key is NOT depressed and press
X the j key enough times to move the cursor so that Lesson 1.1
X completely fills the screen.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 1.1 *
X **************
X =====>>>>> MOVING THE CURSOR <<<<<=====
X
X ** To move the cursor, press the h,j,k,l keys as indicated. **
X ^
X k
X < h l >
X j
X v
X 1. Move the cursor around the screen until you are comfortable.
X
X 2. Hold down the down key (j) until it repeats.
X---> Now you know how to move to the next lesson.
X
X 3. Using the down key, move to Lesson 1.2.
X
XNote: If you are ever unsure about something you typed, press <ESC> to place
X you in Command Mode. Then retype the command you wanted.
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 1.2 *
X **************
X =====>>>>> ENTERING AND EXITING VIM <<<<<=====
X
X !! NOTE: Before executing any of the steps below, read this entire lesson!!
X
X 1. Press the <ESC> key (to make sure you are in Command Mode).
X
X 2. Type :q! <RETURN>.
X
X---> This exits the editor WITHOUT saving any changes you have made.
X If you want to save the changes and exit type :wq <RETURN>
X
X 3. When you see the shell prompt (%) type: vim tutor <RETURN>.
X
X---> 'vim' means enter the vim editor, 'tutor' is the file you wish to edit.
X
X 4. If you have these steps memorized and are confident, execute steps
X 1 through 3 to exit and re-enter the editor. Then cursor down to
X Lesson 1.3.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 1.3 *
X **************
X =====>>>>> TEXT EDITING - DELETION <<<<<=====
X
X** While in Command Mode press x to delete the character under the cursor. **
X
X 1. Move the cursor to the line below marked --->.
X
X 2. To fix the errors, move the cursor until it is on top of the
X character to be deleted.
X
X 3. Press the x key to delete the unwanted character.
X
X 4. Repeat steps 2 through 4 until the sentence is correct.
X
X---> The ccow jumpedd ovverr thhe mooon.
X
X 5. Now that the line is correct, go on to Lesson 1.4.
X
XNOTE: As you go through this tutor, do not try to memorize, learn by usage.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 1.4 *
X **************
X =====>>>>> TEXT EDITING - INSERTION <<<<<=====
X
X ** While in Command Mode press i to insert text. **
X
X 1. Move the cursor to the first line below marked --->.
X
X 2. To make the first line the same as the second, move the cursor on top
X of the first character AFTER where the text is to be inserted.
X
X 3. Press i and type in the necessary additions.
X
X 4. As each error is fixed press <ESC> to return to Command Mode.
X Repeat steps 2 through 4 to correct the sentence.
X
X---> There is text misng this .
X---> There is some text missing from this line.
X
X 5. When you are comfortable inserting text move to the summary below.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X ********************
X * LESSON 1 SUMMARY *
X ********************
X
X 1. The cursor is moved using either the arrow keys or the h,j,k,l keys.
X h (left) j (down) k (up) l (right)
X
X 2. To enter Vim (from the % prompt) type: % vim FILENAME <RETURN>
X
X 3. To exit Vim type: <ESC> :q! <RETURN>
X OR type: <ESC> :wq <RETURN> to save the changes.
X
X 4. To delete a character under the cursor in Command Mode type: x
X
X 5. To insert text at the cursor while in Command Mode type:
X i type in text <ESC>
X
XNOTE: Pressing <ESC> will place you in Command Mode or will cancel
X an unwanted and partially completed command.
X
XNow continue with Lesson 2.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 2.1 *
X **************
X =====>>>>> DELETION COMMANDS <<<<<=====
X
X ** Type dw to delete to the end of a word. **
X
X 1. Press <ESC> to make sure you are in Command Mode.
X
X 2. Move the cursor to the line below marked --->.
X
X 3. Move the cursor to the beginning of a word that needs to be deleted.
X
X 4. Type dw to make the word disappear.
X
X NOTE: The letters dw will appear on the last line of the screen as you type
X them. If you typed something wrong, press <ESC> and start over.
X
X---> There are a some words fun that don't belong paper in this sentence.
X
X 5. Repeat steps 3 and 4 until the sentence is correct and go to Lesson 2.2.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 2.2 *
X **************
X =====>>>>> MORE DELETION COMMANDS <<<<<=====
X
X ** Type d$ to delete to the end of the line. **
X
X 1. Press <ESC> to make sure you are in Command Mode.
X
X 2. Move the cursor to the line below marked --->.
X
X 3. Move the cursor to the end of the correct line (AFTER the first . ).
X
X 4. Type d$ to delete to the end of the line.
X
X---> Somebody typed the end of this line twice. end of this line twice.
X
X
X 5. Move on to Lesson 2.3 to understand what is happening.
X
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 2.3 *
X **************
X =====>>>>> ON COMMANDS AND OBJECTS <<<<<=====
X
X The format for the d delete command is as follows:
X
X [number] d object OR d [number] object
X Where:
X number - is how many times to execute the command (optional, default=1).
X d - is the command to delete.
X object - is what the command will operate on (listed below).
X
X A short list of objects:
X w - from the cursor to the end of the word, including the space.
X e - from the cursor to the end of the word, NOT including the space.
X $ - from the cursor to the end of the line.
X
XNOTE: For the adventurous, pressing just the object while in Command Mode
X without a command will move the cursor as specified in the object list.
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 2.4 *
X **************
X =====>>>>> AN EXCEPTION TO 'COMMAND-OBJECT' <<<<<=====
X
X ** Type dd to delete a whole line. **
X
X Due to the frequency of whole line deletion, the designers of Vim decided
X it would be easier to simply type two d's in a row to delete a line.
X
X 1. Move the cursor to the second line in the phrase below.
X
X 2. Type dd to delete the line.
X
X 3. Now move to the fourth line.
X
X 4. Type 2dd (remember number-command-object) to delete the two lines.
X
X 1) Roses are red,
X 2) Mud is fun,
X 3) Violets are blue,
X 4) I have a car,
X 5) Clocks tell time,
X 6) Sugar is sweet
X 7) And so are you.
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 2.5 *
X **************
X =====>>>>> THE UNDO COMMAND <<<<<=====
X
X ** Press u to undo the last commands, U to fix a whole line. **
X
X 1. Move the cursor to the line below marked ---> and place it on the
X first error.
X 2. Type x to delete the first unwanted character.
X 3. Now type u to undo the last command executed.
X 4. This time fix all the errors on the line using the x command.
X 5. Now type a capital U to return the line to its original state.
X 6. Now type u a few times to undo the U and preceding commands.
X 7. Now type CTRL-R (keeping CTRL key pressed while hitting R) a few times
X to redo the commands (undo the undo's).
X
X---> Fiix the errors oon thhis line and reeplace them witth undo.
X
X 8. These are very useful commands. Now move on to the Lesson 2 Summary.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X ********************
X * LESSON 2 SUMMARY *
X ********************
X
X 1. To delete from the cursor to the end of a word type: dw
X
X 2. To delete from the cursor to the end of a line type: d$
X
X 3. To delete a whole line type: dd
X
X 4. The format for a command in command mode is:
X
X [number] command object OR command [number] object
X where:
X number - is how many times to repeat the command
X command - is what to do, such as d for delete
X object - is what the command should act upon, such as w (word),
X $ (to the end of line), etc.
X
X 5. To undo previous actions, type: u (lowercase u)
X To undo all the changes on a line type: U (capital U)
X To undo the undo's type: CTRL-R
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 3.1 *
X **************
X =====>>>>> THE PUT COMMAND <<<<<=====
X
X ** Type p to put the last deletion after the cursor. **
X
X 1. Move the cursor to the first line in the set below.
X
X 2. Type dd to delete the line and store it in Vim's buffer.
X
X 3. Move the cursor to the line ABOVE where the deleted line should go.
X
X 4. While in Command Mode, type p to replace the line.
X
X 5. Repeat steps 2 through 4 to put all the lines in correct order.
X
X d) Can you learn too?
X b) Violets are blue,
X c) Intelligence is learned,
X a) Roses are red,
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 3.2 *
X **************
X =====>>>>> THE REPLACE COMMAND <<<<<=====
X
X ** Type r and a character to replace the character under the cursor. **
X
X 1. Move the cursor to the first line below marked --->.
X
X 2. Move the cursor so that it is on top of the first error.
X
X 3. Type r and then the character which should replace the error.
X
X 4. Repeat steps 2 and 3 until the first line is correct.
X
X---> Whan this lime was tuoed in, someone presswd some wrojg keys!
X---> When this line was typed in, someone pressed some wrong keys!
X
X 5. Now move on to Lesson 3.2.
X
XNOTE: Remember that you should be learning by use, not memorization.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 3.3 *
X **************
X =====>>>>> THE CHANGE COMMAND <<<<<=====
X
X ** To change part or all of a word, type cw . **
X
X 1. Move the cursor to the first line below marked --->.
X
X 2. Place the cursor on the u in lubw.
X
X 3. Type cw and the correct word (in this case, type 'ine'.)
X
X 4. Press <ESC> and move to the next error (the first character to be changed.)
X
X 5. Repeat steps 3 and 4 until the first sentence is the same as the second.
X
X---> This lubw has a few wptfd that mrrf changing usf the change command.
X---> This line has a few words that need changing using the change command.
X
XNotice that cw not only replaces the word, but also places you in insert.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 3.4 *
X **************
X =====>>>>> MORE CHANGES USING c <<<<<=====
X
X ** The change command is used with the same objects as delete. **
X
X 1. The change command works in the same way as delete. The format is:
X
X [number] c object OR c [number] object
X
X 2. The objects are also the same, such as w (word), $ (end of line), etc.
X
X 3. Move to the first line below marked --->.
X
X 4. Move the cursor to the first error.
X
X 5. Type c$ to make the rest of the line like the second and press <ESC>.
X
X---> The end of this line needs some help to make it like the second.
X---> The end of this line needs to be corrected using the c$ command.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X ********************
X * LESSON 3 SUMMARY *
X ********************
X
X 1. To replace text that has already been deleted, type p . This Puts the
X deleted text AFTER the cursor (if a line was deleted it will go on the
X line below the cursor).
X
X 2. To replace the character under the cursor, type r and then the
X character which will replace the original.
X
X 3. The change command allows you to change the specified object from the
X cursor to the end of the object. eg. Type cw to change from the
X cursor to the end of the word, c$ to change to the end of a line.
X
X 4. The format for change is:
X
X [number] c object OR c [number] object
X
XNow go on to the next lesson.
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 4.1 *
X **************
X =====>>>>> LOCATION AND FILE STATUS <<<<<=====
X
X ** Type CTRL-g to show your location in the file and the file status.
X Type SHIFT-G to move to a line in the file. **
X
X Note: Read this entire lesson before executing any of the steps!!
X
X 1. Hold down the Ctrl key and press g . A status line will appear at the
X bottom of the page with the filename and the line you are on. Remember
X the line number for Step 3.
X
X 2. Press shift-G to move you to the bottom of the file.
X
X 3. Type in the number of the line you were on and then shift-G. This will
X return you to the line you were on when you first pressed Ctrl-g.
X (When you type in the numbers, they will NOT be displayed on the screen.)
X
X 4. If you feel confident to do this, execute steps 1 through 3.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 4.2 *
X **************
X =====>>>>> THE SEARCH COMMAND <<<<<=====
X
X ** Type / followed by a phrase to search for the phrase. **
X
X 1. In command mode type the / character. Notice that it and the cursor
X appear at the bottom of the screen as with the : command.
X
X 2. Now type 'errroor' <RETURN>. This is the word you want to search for.
X
X 3. To search for the same phrase again, simply type n .
X To search for the same phrase in the opposite direction, type Shift-N .
X
X 4. If you want to search for a phrase in the backwards direction, use the
X command ? instead of /.
X
X---> When the search reaches the end of the file it will continue at the start.
X
X "errroor" is not the way to spell error; errroor is an error.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 4.3 *
X **************
X =====>>>>> MATCHING PARENTHESES SEARCH <<<<<=====
X
X ** Type % to find a matching ),], or } . **
X
X 1. Place the cursor on any (, [, or { in the line below marked --->.
X
X 2. Now type the % character.
X
X 3. The cursor should be on the matching parenthesis or bracket.
X
X 4. Type % to move the cursor back to the first bracket (by matching).
X
X---> This ( is a test line with ('s, ['s ] and {'s } in it. ))
X
XNote: This is very useful in debugging a program with unmatched parentheses!
X
X
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 4.4 *
X **************
X =====>>>>> A WAY TO CHANGE ERRORS <<<<<=====
X
X ** Type :s/old/new/g to substitute 'new' for 'old'. **
X
X 1. Move the cursor to the line below marked --->.
X
X 2. Type :s/thee/the <RETURN> . Note that this command only changes the
X first occurrence on the line.
X
X 3. Now type :s/thee/the/g meaning substitute globally on the line.
X This changes all occurrences on the line.
X
X---> thee best time to see thee flowers is in thee spring.
X
X 4. To change every occurrence of a character string between two lines,
X type :#,#s/old/new/g where #,# are the numbers of the two lines.
X Type :%s/old/new/g to change every occurrence in the whole file.
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X ********************
X * LESSON 4 SUMMARY *
X ********************
X
X 1. Ctrl-g displays your location in the file and the file status.
X Shift-G moves to the end of the file. A line number followed
X by Shift-G moves to that line number.
X
X 2. Typing / followed by a phrase searches FORWARD for the phrase.
X Typing ? followed by a phrase searches BACKWARD for the phrase.
X After a search type n to find the next occurrence in the same direction
X or Shift-N to search in the opposite direction.
X
X 3. Typing % while the cursor is on a (,),[,],{, or } locates its
X matching pair.
X
X 4. To substitute new for the first old on a line type :s/old/new
X To substitute new for all 'old's on a line type :s/old/new/g
X To substitute phrases between two line #'s type :#,#s/old/new/g
X To substitute all occurrences in the file type :%s/old/new/g
X To ask for confirmation each time add 'c' :%s/old/new/gc
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 5.1 *
X **************
X =====>>>>> HOW TO EXECUTE AN AMIGA COMMAND <<<<<=====
X
X ** Type :! followed by an Amiga command to execute that command. **
X
X 1. Type the familiar command : to set the cursor at the bottom of the
X screen. This allows you to enter a command.
X
X 2. Now type the ! (exclamation point) character. This allows you to
X execute an Amiga shell command.
X
X 3. As an example type ls following the !. This will show you a listing
X of your directory, just as if you were at the % prompt.
X
X---> Note: It is possible to execute any shell command this way.
X
X
X
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 5.2 *
X **************
X =====>>>>> MORE ON WRITING FILES <<<<<=====
X
X ** To save the changes made to the file, type :w FILENAME. **
X
X 1. Type :!dir to get a listing of your directory.
X
X 2. Choose a filename that is not already in your area, such as TEST.
X
X 3. Now type: :w TEST (where TEST is the filename you chose.)
X
X 4. This saves the whole file (Vim Tutor) under the name TEST.
X To verify this, type :!dir again to see your directory
X
X---> Note that if you were to exit Vim and enter again with the filename TEST,
X the file would be an exact copy of the tutor when you saved it.
X
X 5. Now remove the file from your area by typing: :!delete TEST
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 5.3 *
X **************
X =====>>>>> A SELECTIVE WRITE COMMAND <<<<<=====
X
X ** To save part of the file, type :#,# w FILENAME **
X
X 1. Once again, type :!dir to obtain a listing of your directory and
X choose a suitable filename such as TEST.
X
X 2. Move the cursor to the top of this page and type Ctrl-g to find the
X number of that line. REMEMBER THIS NUMBER!
X
X 3. Now move to the bottom of the page and type Ctrl-g again. REMEMBER THIS
X LINE NUMBER ALSO!
X
X 4. To save ONLY a section to a file, type :#,# w TEST where #,# are
X the two numbers you remembered (top,bottom) and TEST is your filename.
X
X 5. Again, see that the file is there with :!dir but DO NOT remove it.
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 5.4 *
X **************
X =====>>>>> RETRIEVING AND MERGING FILES <<<<<=====
X
X ** To insert the contents of a file, type :r FILENAME **
X
X 1. Type :!dir to make sure your TEST filename is present from before.
X
X 2. Place the cursor at the top of this page.
X
XNOTE: After executing Step 3 you will see Lesson 5.3. Then move DOWN to
X this lesson again.
X
X 3. Now retrieve your TEST file using the command :r TEST where TEST is
X the name of the file.
X
XNOTE: The file you retrieve is placed starting where the cursor is located.
X
X 4. To verify that a file was retrieved, cursor back and notice that there
X are now two copies of Lesson 5.3, the original and the file version.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X ********************
X * LESSON 5 SUMMARY *
X ********************
X
X 1. :!command executes an Amiga system command.
X
X Some useful examples are:
X :!dir - shows a directory listing of your area.
X :!delete FILENAME - removes file FILENAME from your area.
X
X 2. :w FILENAME writes the current Vim file to disk with name FILENAME.
X
X 3. :#,# FILENAME saves the lines # through # in file FILENAME.
X
X 4. :r FILENAME retrieves disk file FILENAME and inserts it into the
X current file following the cursor position.


X
X
X
X
X

X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 6.1 *
X **************
X =====>>>>> THE OPEN COMMAND <<<<<=====
X
X ** Type o to open a line below the cursor and place you in insert mode. **
X
X 1. Move the cursor to the line below marked --->.
X
X 2. Type o (lowercase) to open up a line BELOW the cursor and place you in
X insert mode.
X
X 3. Now copy the line marked ---> and press <ESC> to exit insert mode.
X
X---> After typing o the cursor is placed on the open line in insert mode.
X
X 4. To open up a line ABOVE the cursor, simply type a capital O , rather
X than a lowercase o. Try this on the line below.
XOpen up a line above this by typing Shift-O while the cursor is on this line.
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 6.2 *
X **************
X =====>>>>> THE APPEND COMMAND <<<<<=====
X
X ** Type a to insert text AFTER the cursor. **
X
X 1. Move the cursor to the end of the first line below marked ---> by
X typing $ in Command mode.
X
X 2. Type an a (lowercase) to append text AFTER the character under the
X cursor. (Uppercase A appends to the end of the line.)
X
XNote: This avoids typing i , the last character, the text to insert, <ESC>,
X cursor-right, and finally, x , just to append to the end of a line!
X
X 3. Now complete the first line. Note also that append is exactly the same
X as insert mode, except for the location where text is inserted.
X
X---> This line will allow you to practice
X---> This line will allow you to practice appending text to the end of a line.
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 6.3 *
X **************
X =====>>>>> ANOTHER VERSION OF REPLACE <<<<<=====
X
X ** Type a capital R to replace more than one character. **
X
X 1. Move the cursor to the first line below marked --->.
X
X 2. Place the cursor at the beginning of the first word that is different
X from the second line marked ---> (the word 'last').
X
X 3. Now type R and replace the remainder of the text on the first line by
X typing over the old text to make the first line the same as the second.
X
X---> To make the first line the same as the last on this page use the keys.
X---> To make the first line the same as the second, type R and the new text.
X
X 4. Note that when you press <ESC> to exit, any unaltered text remains.
X
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X **************
X * Lesson 6.4 *
X **************
X =====>>>>> SET ENVIRONMENT VARIABLE <<<<<=====
X
X ** Change environment so a search or substitute ignores case **
X
X
X 1. Search for 'ignore' by entering:
X /ignore
X Repeat several times by hitting the n key
X
X 2. Set the 'ic' (Ignore case) variable by typing:
X :set ic
X
X 3. Now search for 'ignore' again by entering: n
X Repeat search several more times by hitting the n key
X
X
X
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X ********************
X * LESSON 6 SUMMARY *
X ********************
X
X 1. Typing o opens a line BELOW the cursor and places the cursor on the open
X line in insert mode.
X Typing a capital O opens the line ABOVE the line the cursor is on.
X
X 2. Type an a to insert text AFTER the character the cursor is on.
X Typing a capital A automatically appends text to the end of the line.
X
X 3. Typing a capital R enters replace mode until <ESC> is pressed to exit.
X
X 4. Typing ":set xxx" sets the environment variable "xxx"


X
X
X
X
X
X

X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X
X This concludes the Vim Tutor. It was intended to give a brief overview of
X the Vim editor, just enough to allow you to use the editor fairly easily.
X It is far from complete as Vim has many many more commands.
X
X For more information on Vim editor please refer to:
X
X doc/reference.doc - a complete description of Vim
X doc/index - a short summary of all commands
X doc/difference.doc - summary of differences between vi and Vim
X
X Or hit the HELP key!
X
X This tutorial was written by Michael C. Pierce and Robert K. Ware,
X Colorado School of Mines using ideas supplied by Charles Smith,
X Colorado State University.
X E-mail: bw...@mines.colorado.edu.
X
X Modified for Vim by Bram Moolenaar.
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
END_OF_FILE
if test 28799 -ne `wc -c <'vim/tutor/tutor'`; then
echo shar: \"'vim/tutor/tutor'\" unpacked with wrong size!
fi
# end of 'vim/tutor/tutor'
fi
echo shar: End of archive 14 \(of 23\).
cp /dev/null ark14isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:35:31 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 15
Archive-name: vim/part15
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 15 (of 23)."
# Contents: vim/src/normal.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:11 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/normal.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/normal.c'\"
else
echo shar: Extracting \"'vim/src/normal.c'\" \(29120 characters\)
sed "s/^X//" >'vim/src/normal.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * Contains the main routine for processing characters in command mode.
X * Communicates closely with the code in ops.c to handle the operators.


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X

X#undef EXTERN
X#undef INIT
X#define EXTERN
X#define INIT(x) x
X#include "ops.h"
X
X/*


X * Generally speaking, every command in normal() should either clear any

X * pending operator (with CLEAROP), or set the motion type variable.
X */
X
X#define CLEAROP (operator = NOP) /* clear any pending operator */
X#define CLEAROPBEEP clearopbeep() /* CLEAROP plus a beep() */
X#define CHECKCLEAROP if (checkclearop()) break;
X#define CHECKCLEAROPQ if (checkclearopq()) break;
X
X/*
X * If a count is given before the operator, it is saved in opnum.
X */
Xstatic linenr_t opnum = 0;
Xstatic linenr_t Prenum; /* The (optional) number before a command. */
Xstatic int substituting = FALSE; /* TRUE when in 'S' command */
Xint redo_Quote_busy = FALSE; /* TRUE when redo-ing a quote */
X
Xstatic void prep_redo __ARGS((long, int, int, int));
Xstatic int checkclearop __ARGS((void));
Xstatic int checkclearopq __ARGS((void));
Xstatic void clearopbeep __ARGS((void));
Xstatic void premsg __ARGS((int, int));
Xstatic void adjust_lnum __ARGS((void));
X
Xextern int restart_edit; /* this is in edit.c */
X
X/*
X * normal
X *
X * Execute a command in normal mode.
X *
X * This is basically a big switch with the cases arranged in rough categories
X * in the following order:
X *
X * 0. Macros (v, @)
X * 1. Screen positioning commands (^U, ^D, ^F, ^B, ^E, ^Y, z)
X * 2. Control commands (:, <help>, ^L, ^G, ^^, ZZ, *, ^], ^T)
X * 3. Cursor motions (G, H, M, L, l, K_RARROW, , h, K_LARROW, ^H, k, K_UARROW, ^P, +, CR, LF, j, K_DARROW, ^N, _, |, B, b, W, w, E, e, $, ^, 0)
X * 4. Searches (?, /, n, N, T, t, F, f, ,, ;, ], [, %, (, ), {, })
X * 5. Edits (., u, K_UNDO, ^R, U, r, J, p, P, ^A, ^S)
X * 6. Inserts (A, a, I, i, o, O, R)
X * 7. Operators (~, d, c, y, >, <, !, =)
X * 8. Abbreviations (x, X, D, C, s, S, Y, &)
X * 9. Marks (m, ', `, ^O, ^I)
X * 10. Buffer setting (")
X * 11. Quoting (q)
X * 12. Suspend (^Z)


X */
X
X void

Xnormal()


X{
X register u_char c;

X long n;
X int flag = FALSE;
X int type = 0; /* used in some operations to modify type */
X int dir = FORWARD; /* search direction */
X u_char nchar = NUL;
X int finish_op;
X linenr_t Prenum1;
X char searchbuff[CMDBUFFSIZE]; /* buffer for search string */
X FPOS *pos;
X register char *ptr;
X int command_busy = FALSE;
X
X static linenr_t redo_Quote_nlines;
X static int redo_Quote_type;
X static long redo_Quote_col;
X
X Prenum = 0;
X /*
X * If there is an operator pending, then the command we take this time
X * will terminate it. Finish_op tells us to finish the operation before
X * returning this time (unless the operation was cancelled).
X */
X finish_op = (operator != NOP);
X
X if (!finish_op && !yankbuffer)
X opnum = 0;
X
X if (vpeekc() == NUL || KeyTyped == TRUE)
X premsg(NUL, NUL);
X State = NORMAL_BUSY;


X c = vgetc();
X

X /* Pick up any leading digits and compute 'Prenum' */
X while ((c >= '1' && c <= '9') || (Prenum != 0 && (c == DEL || c == '0')))
X {
X if (c == DEL)
X Prenum /= 10;
X else
X Prenum = Prenum * 10 + (c - '0');
X if (Prenum < 0) /* got too large! */
X Prenum = 999999999;
X premsg(' ', NUL);
X c = vgetc();
X }
X
X /*
X * If we're in the middle of an operator (including after entering a yank
X * buffer with ") AND we had a count before the
X * operator, then that count overrides the current value of Prenum. What
X * this means effectively, is that commands like "3dw" get turned into
X * "d3w" which makes things fall into place pretty neatly.
X * If you give a count before AND after the operator, they are multiplied.
X */
X if (opnum != 0)
X {
X if (Prenum)
X Prenum *= opnum;
X else
X Prenum = opnum;
X opnum = 0;
X }
X
X Prenum1 = (Prenum == 0 ? 1 : Prenum); /* Prenum often defaults to 1 */
X premsg(c, NUL);
X
X /*
X * get an additional character if we need one
X */
X if (strchr("@zZtTfF[]rm'`\"", c) || (c == 'v' && Recording == FALSE))
X {
X State = NOMAPPING;
X nchar = vgetc(); /* no macro mapping for this char */
X premsg(c, nchar);
X }
X flushbuf(); /* flush the premsg() characters onto the screen so we can
X see them while the command is being executed */
X
X if (c != 'z') /* the 'z' command gets another character */
X {
X State = NORMAL;
X script_winsize_pp();
X }
X if (nchar == ESC)
X {
X CLEAROP;
X goto normal_end;
X }
X switch (c)
X {
X
X/*
X * 0: Macros
X */
X case 'v': /* (stop) recording into a named buffer */
X CHECKCLEAROP;
X if (!dorecord(nchar))
X CLEAROPBEEP;
X break;
X
X case '@': /* execute a named buffer */
X CHECKCLEAROP;
X while (Prenum1--)
X if (!doexecbuf(nchar))
X {
X CLEAROPBEEP;
X break;


X }
X break;
X
X/*

X * 1: Screen positioning commands
X */
X case Ctrl('D'):
X flag = TRUE;


X
X case Ctrl('U'):

X CHECKCLEAROP;
X if (Prenum)
X p_scroll = (Prenum > Rows - 1) ? Rows - 1 : Prenum;
X n = (p_scroll < Rows) ? p_scroll : Rows - 1;
X if (flag)
X {
X Topline += n;
X if (Topline > line_count)
X Topline = line_count;
X comp_Botline(); /* compute Botline */
X onedown(n);
X }
X else
X {
X if (n >= Curpos.lnum)
X n = Curpos.lnum - 1;
X Prenum1 = Curpos.lnum - n;
X scrolldown(n);
X if (Prenum1 < Curpos.lnum)
X Curpos.lnum = Prenum1;


X }
X beginline(TRUE);
X updateScreen(VALID);

X break;
X
X case Ctrl('B'):
X case K_SUARROW:
X dir = BACKWARD;
X
X case Ctrl('F'):
X case K_SDARROW:
X CHECKCLEAROP;
X onepage(dir, Prenum1);
X break;
X
X case Ctrl('E'):
X CHECKCLEAROP;
X scrollup(Prenum1);
X updateScreen(VALID);
X break;
X
X case Ctrl('Y'):
X CHECKCLEAROP;
X scrolldown(Prenum1);
X updateScreen(VALID);
X break;
X
X case 'z':
X CHECKCLEAROP;
X if (isdigit(nchar))
X {
X /*
X * we misuse some variables to be able to call premsg()
X */
X operator = c;
X opnum = Prenum;
X Prenum = nchar - '0';


X for (;;)
X {

X premsg(' ', NUL);
X nchar = vgetc();
X State = NORMAL;
X script_winsize_pp();
X if (nchar == DEL)
X Prenum /= 10;
X else if (isdigit(nchar))
X Prenum = Prenum * 10 + (nchar - '0');
X else if (nchar == CR)
X {
X set_winsize((int)Columns, (int)Prenum, TRUE);


X break;
X }
X else
X {

X CLEAROPBEEP;
X break;
X }
X }
X operator = NOP;
X break;
X }
X
X if (Prenum) /* line number given */
X {
X setpcmark();
X if (Prenum > line_count)


X Curpos.lnum = line_count;
X else

X Curpos.lnum = Prenum;
X }
X State = NORMAL;
X script_winsize_pp();
X switch (nchar)
X {
X case NL: /* put Curpos at top of screen */
X case CR:
X Topline = Curpos.lnum;
X updateScreen(VALID);
X break;
X
X case '.': /* put Curpos in middle of screen */
X n = (Rows + plines(Curpos.lnum)) / 2;
X goto dozcmd;
X
X case '-': /* put Curpos at bottom of screen */
X n = Rows - 1;


X /* FALLTHROUGH */
X

X dozcmd:
X {
X register linenr_t lp = Curpos.lnum;
X register long l = plines(lp);
X
X do
X {
X Topline = lp;
X if (--lp == 0)
X break;
X l += plines(lp);
X } while (l <= n);
X }
X updateScreen(VALID);


X break;
X
X default:

X CLEAROPBEEP;


X }
X break;
X
X/*

X * 2: Control commands
X */
X case ':':
X if (Quote.lnum)
X goto dooperator;
X CHECKCLEAROP;
X docmdline(NULL);
X break;
X
X case K_HELP:
X CHECKCLEAROP;
X help();
X break;
X
X case Ctrl('L'):
X CHECKCLEAROP;
X updateScreen(CLEAR);
X break;
X
X case Ctrl('G'):
X CHECKCLEAROP;
X fileinfo();
X break;
X
X case K_CCIRCM: /* shorthand command */
X CHECKCLEAROPQ;
X if (getaltfile((int)Prenum, (linenr_t)0, TRUE))
X emsg(e_noalt);
X break;
X
X case 'Z': /* write, if changed, and exit */
X CHECKCLEAROPQ;
X if (nchar != 'Z')
X {
X CLEAROPBEEP;
X break;
X }
X stuffReadbuff(":x\n");
X break;
X
X case Ctrl(']'): /* :ta to current identifier */
X CHECKCLEAROPQ;
X case '*': /* / to current identifier */
X case '#': /* ? to current identifier */
X case 'K': /* run program for current identifier */


X {
X register int col;
X

X ptr = nr2ptr(Curpos.lnum);
X col = Curpos.col;
X
X /*

X * skip to start of identifier.
X */
X while (ptr[col] != NUL && !isidchar(ptr[col]))
X ++col;
X
X /*
X * Back up to start of identifier. This doesn't match the
X * real vi but I like it a little better and it shouldn't bother
X * anyone.
X */
X while (col > 0 && isidchar(ptr[col - 1]))
X --col;
X
X if (!isidchar(ptr[col]))
X {
X CLEAROPBEEP;
X break;
X }
X
X if (Prenum)
X stuffnumReadbuff(Prenum);
X switch (c)
X {
X case '*':
X stuffReadbuff("/");
X break;
X case '#':
X stuffReadbuff("?");
X break;
X case 'K':
X stuffReadbuff(":! ");
X stuffReadbuff(p_kp);
X stuffReadbuff(" ");
X break;
X default:
X stuffReadbuff(":ta ");
X }
X
X /*
X * Now grab the chars in the identifier
X */
X while (isidchar(ptr[col]))
X {
X stuffReadbuff(mkstr(ptr[col]));
X ++col;
X }


X stuffReadbuff("\n");
X }

X break;
X
X case Ctrl('T'): /* backwards in tag stack */
X CHECKCLEAROPQ;
X dotag("", 2, (int)Prenum1);
X break;
X
X/*
X * Cursor motions
X */
X case 'G':
X mtype = MLINE;
X setpcmark();
X if (Prenum == 0 || Prenum > line_count)


X Curpos.lnum = line_count;
X else

X Curpos.lnum = Prenum;
X beginline(TRUE);
X break;
X
X case 'H':
X case 'M':
X if (c == 'M')
X n = Rows / 2;
X else
X n = Prenum;
X mtype = MLINE;
X Curpos.lnum = Topline;
X while (n && onedown((long)1))
X --n;
X beginline(TRUE);
X break;
X
X case 'L':
X mtype = MLINE;
X Curpos.lnum = Botline - 1;
X for (n = Prenum; n && oneup((long)1); n--)
X ;
X beginline(TRUE);
X break;
X
X case 'l':
X case K_RARROW:
X case ' ':
X mtype = MCHAR;
X mincl = FALSE;
X n = Prenum1;
X while (n--)
X {
X if (!oneright())
X {
X if (operator == NOP)
X beep();
X else
X {
X if (lineempty(Curpos.lnum))
X CLEAROPBEEP;
X else
X {
X mincl = TRUE;
X if (n)
X beep();
X }


X }
X break;
X }
X }

X set_want_col = TRUE;
X break;
X
X case 'h':
X case K_LARROW:
X case Ctrl('H'):
X case DEL:
X mtype = MCHAR;
X mincl = FALSE;
X n = Prenum1;
X while (n--)
X {
X if (!oneleft())
X {
X if (operator != DELETE && operator != CHANGE)
X beep();
X else if (Prenum1 == 1)
X CLEAROPBEEP;
X break;
X }
X }
X set_want_col = TRUE;
X break;
X
X case '-':
X flag = TRUE;


X /* FALLTHROUGH */
X

X case 'k':
X case K_UARROW:
X case Ctrl('P'):
X mtype = MLINE;
X if (!oneup(Prenum1))
X CLEAROPBEEP;
X else if (flag)
X beginline(TRUE);
X break;
X
X case '+':
X case CR:
X flag = TRUE;


X /* FALLTHROUGH */
X

X case 'j':
X case K_DARROW:
X case Ctrl('N'):
X case NL:
X mtype = MLINE;
X if (!onedown(Prenum1))
X CLEAROPBEEP;
X else if (flag)
X beginline(TRUE);


X break;
X
X /*

X * This is a strange motion command that helps make operators more
X * logical. It is actually implemented, but not documented in the
X * real 'vi'. This motion command actually refers to "the current
X * line". Commands like "dd" and "yy" are really an alternate form of
X * "d_" and "y_". It does accept a count, so "d3_" works to delete 3
X * lines.
X */
X case '_':
Xlineop:
X mtype = MLINE;
X if (!onedown((long)(Prenum1 - 1)))
X CLEAROPBEEP;
X else if (operator != YANK) /* 'Y' does not move cursor */
X beginline(TRUE);


X break;
X
X case '|':

X mtype = MCHAR;
X mincl = TRUE;
X beginline(FALSE);
X if (Prenum > 0)
X coladvance((colnr_t)(Prenum - 1));
X Curswant = Prenum - 1;


X break;
X
X /*

X * Word Motions
X */
X
X case 'B':
X type = 1;


X /* FALLTHROUGH */
X

X case 'b':
X case K_SLARROW:
X mtype = MCHAR;
X mincl = FALSE;
X set_want_col = TRUE;
X if (bck_word(Prenum1, type))
X CLEAROPBEEP;
X break;
X
X case 'E':
X type = 1;


X /* FALLTHROUGH */
X

X case 'e':
X mincl = TRUE;
X goto dowrdcmd;
X
X case 'W':
X type = 1;


X /* FALLTHROUGH */
X

X case 'w':
X case K_SRARROW:
X mincl = FALSE;
X flag = TRUE;
X /*
X * This is a little strange. To match what the real vi does, we
X * effectively map 'cw' to 'ce', and 'cW' to 'cE', provided that we are
X * not on a space or a TAB. This seems
X * impolite at first, but it's really more what we mean when we say
X * 'cw'.
X */
X if (operator == CHANGE && (n = gcharCurpos()) != ' ' && n != TAB &&
X n != NUL)
X {
X mincl = TRUE;
X flag = FALSE;
X }
X
Xdowrdcmd:
X mtype = MCHAR;
X set_want_col = TRUE;
X if (flag)
X n = fwd_word(Prenum1, type);
X else
X n = end_word(Prenum1, type, operator == CHANGE);
X if (n)
X {
X CLEAROPBEEP;


X break;
X }
X /*

X * if we do a 'dw' for the last word in a line, we only delete the rest
X * of the line, not joining the two lines.
X */
X if (operator == DELETE && Prenum1 == 1 && startop.lnum != Curpos.lnum)
X {
X Curpos = startop;
X while (oneright())
X ;
X mincl = TRUE;
X }
X break;
X
X case '$':
X mtype = MCHAR;
X mincl = TRUE;
X Curswant = 29999; /* so we stay at the end */
X if (!onedown((long)(Prenum1 - 1)))
X {
X CLEAROPBEEP;
X break;
X }
X if (Quote_block)
X updateScreen(NOT_VALID);
X break;
X
X case '^':
X flag = TRUE;


X /* FALLTHROUGH */
X

X case '0':
X mtype = MCHAR;
X mincl = FALSE;
X beginline(flag);
X break;
X
X/*
X * 4: Searches
X */
X case '?':
X case '/':
X if (!getcmdline(c, (u_char *)searchbuff))
X {
X CLEAROP;
X break;
X }
X mtype = MCHAR;
X mincl = FALSE;


X set_want_col = TRUE;
X

X n = dosearch(c == '/' ? FORWARD : BACKWARD, searchbuff, FALSE, Prenum1, TRUE);
X if (n == 0)
X CLEAROPBEEP;
X else if (n == 2)
X mtype = MLINE;
X break;
X
X case 'N':
X flag = 1;
X
X case 'n':
X mtype = MCHAR;
X mincl = FALSE;
X set_want_col = TRUE;
X if (!dosearch(0, NULL, flag, Prenum1, TRUE))
X CLEAROPBEEP;


X break;
X
X /*

X * Character searches


X */
X case 'T':

X dir = BACKWARD;


X /* FALLTHROUGH */
X

X case 't':
X type = 1;
X goto docsearch;
X
X case 'F':
X dir = BACKWARD;


X /* FALLTHROUGH */
X

X case 'f':
Xdocsearch:
X mtype = MCHAR;
X mincl = TRUE;
X set_want_col = TRUE;
X if (!searchc(nchar, dir, type, Prenum1))
X {
X CLEAROPBEEP;
X }
X break;
X
X case ',':
X flag = 1;


X /* FALLTHROUGH */
X

X case ';':
X dir = flag;
X goto docsearch; /* nchar == NUL, thus repeat previous search */
X
X /*
X * section or C function searches
X */
X
X case '[':
X dir = BACKWARD;


X /* FALLTHROUGH */
X

X case ']':
X mtype = MLINE;
X set_want_col = TRUE;
X flag = '{';
X if (nchar != c)
X {
X if (nchar == '[' || nchar == ']')
X flag = '}';
X else
X {
X CLEAROPBEEP;
X break;
X }
X }
X if (dir == FORWARD && operator != NOP) /* e.g. y]] searches for '}' */
X flag = '}';
X if (!findpar(dir, Prenum1, flag))
X {
X CLEAROPBEEP;
X }
X break;
X
X case '%':
X mincl = TRUE;
X if (Prenum) /* {cnt}% : goto {cnt} percentage in file */
X {
X if (Prenum > 100)
X CLEAROPBEEP;
X else
X {
X mtype = MLINE;
X setpcmark();
X Curpos.lnum = line_count * Prenum / 100;


X Curpos.col = 0;
X }
X }

X else /* % : go to matching paren */
X {
X mtype = MCHAR;
X if ((pos = showmatch()) == NULL)
X CLEAROPBEEP;
X else
X {
X setpcmark();
X Curpos = *pos;


X set_want_col = TRUE;
X }
X }

X break;
X
X case '(':
X dir = BACKWARD;


X /* FALLTHROUGH */
X

X case ')':
X mtype = MCHAR;
X if (c == ')')
X mincl = FALSE;
X else
X mincl = TRUE;


X set_want_col = TRUE;
X

X if (!findsent(dir, Prenum1))
X CLEAROPBEEP;


X break;
X
X case '{':

X dir = BACKWARD;


X /* FALLTHROUGH */
X

X case '}':
X mtype = MCHAR;
X mincl = FALSE;


X set_want_col = TRUE;
X

X if (!findpar(dir, Prenum1, NUL))
X CLEAROPBEEP;
X break;
X
X/*
X * 5: Edits
X */
X case '.':
X CHECKCLEAROPQ;
X if (!start_redo(Prenum))
X CLEAROPBEEP;
X break;
X
X case 'u':
X if (Quote.lnum)
X goto dooperator;
X case K_UNDO:
X CHECKCLEAROPQ;
X u_undo((int)Prenum1);
X set_want_col = TRUE;
X break;
X
X case Ctrl('R'):
X CHECKCLEAROPQ;
X u_redo((int)Prenum1);
X set_want_col = TRUE;
X break;
X
X case 'U':
X if (Quote.lnum)
X goto dooperator;
X CHECKCLEAROPQ;
X u_undoline();
X set_want_col = TRUE;


X break;
X
X case 'r':

X if (Quote.lnum)
X {
X c = 'c';
X goto dooperator;
X }
X CHECKCLEAROPQ;
X n = strlen(nr2ptr(Curpos.lnum)) - Curpos.col;
X if (n < Prenum1) /* not enough characters to replace */
X {
X CLEAROPBEEP;
X break;
X }
X
X if (nchar == Ctrl('V')) /* get another character */
X {
X c = Ctrl('V');
X State = NOMAPPING;
X nchar = vgetc(); /* no macro mapping for this char */


X State = NORMAL;
X }

X else
X c = NUL;
X prep_redo(Prenum1, 'r', c, nchar);
X stuffnumReadbuff(Prenum1);
X stuffReadbuff("R");


X if (c)
X stuffReadbuff(mkstr(c));

X stuffReadbuff(mkstr(nchar));
X stuffReadbuff("\033");
X break;
X
X case 'J':
X if (Quote.lnum) /* join the quoted lines */
X {
X if (Curpos.lnum > Quote.lnum)
X {
X Prenum = Curpos.lnum - Quote.lnum + 1;
X Curpos.lnum = Quote.lnum;
X }
X else
X Prenum = Quote.lnum - Curpos.lnum + 1;
X Quote.lnum = 0;
X }
X CHECKCLEAROP;
X if (Prenum <= 1)
X Prenum = 2; /* default for join is two lines! */
X if (Curpos.lnum + Prenum - 1 > line_count) /* beyond last line */
X {
X CLEAROPBEEP;
X break;
X }
X
X prep_redo(Prenum, 'J', NUL, NUL);
X dodojoin(Prenum, TRUE, TRUE);
X break;
X
X case 'P':
X dir = BACKWARD;


X /* FALLTHROUGH */
X

X case 'p':
X CHECKCLEAROPQ;
X prep_redo(Prenum, c, NUL, NUL);
X doput(dir, Prenum1);
X break;
X
X case Ctrl('A'): /* add to number */
X case Ctrl('S'): /* subtract from number */
X CHECKCLEAROPQ;
X if (doaddsub((int)c, Prenum1))
X prep_redo(Prenum1, c, NUL, NUL);
X break;
X
X/*
X * 6: Inserts
X */
X case 'A':
X set_want_col = TRUE;
X while (oneright())
X ;


X /* FALLTHROUGH */
X

X case 'a':
X CHECKCLEAROPQ;
X /* Works just like an 'i'nsert on the next character. */
X if (u_saveCurpos())
X {
X if (!lineempty(Curpos.lnum))
X incCurpos();
X startinsert(c, FALSE, Prenum1);
X command_busy = TRUE;
X }
X break;
X
X case 'I':
X beginline(TRUE);


X /* FALLTHROUGH */
X

X case 'i':
X CHECKCLEAROPQ;
X if (u_saveCurpos())
X {
X startinsert(c, FALSE, Prenum1);
X command_busy = TRUE;
X }
X break;
X
X case 'o':
X if (Quote.lnum) /* switch start and end of quote */
X {
X Prenum = Quote.lnum;
X Quote.lnum = Curpos.lnum;
X Curpos.lnum = Prenum;
X n = Quote.col;
X Quote.col = Curpos.col;
X Curpos.col = n;
X break;
X }
X CHECKCLEAROP;
X if (u_save(Curpos.lnum, (linenr_t)(Curpos.lnum + 1)) && Opencmd(FORWARD, TRUE))
X {
X startinsert('o', TRUE, Prenum1);
X command_busy = TRUE;
X }
X break;
X
X case 'O':
X CHECKCLEAROPQ;
X if (u_save((linenr_t)(Curpos.lnum - 1), Curpos.lnum) && Opencmd(BACKWARD, TRUE))
X {
X startinsert('O', TRUE, Prenum1);
X command_busy = TRUE;
X }
X break;
X
X case 'R':
X if (Quote.lnum)
X {
X c = 'c';
X Quote.col = QUOTELINE;
X goto dooperator;
X }
X CHECKCLEAROPQ;
X if (u_saveCurpos())
X {
X startinsert('R', FALSE, Prenum1);
X command_busy = TRUE;


X }
X break;
X
X/*

X * 7: Operators
X */
X case '~': /* swap case */
X /*
X * if tilde is not an operator and Quoting is off: swap case
X * of a single character
X */
X if (!p_to && !Quote.lnum)
X {
X CHECKCLEAROPQ;
X if (lineempty(Curpos.lnum))
X {
X CLEAROPBEEP;
X break;
X }
X prep_redo(Prenum, '~', NUL, NUL);
X
X if (!u_saveCurpos())
X break;
X
X for (; Prenum1 > 0; --Prenum1)
X {
X if (gcharCurpos() == NUL)
X break;
X swapchar(&Curpos);
X incCurpos();
X }


X
X set_want_col = TRUE;

X CHANGED;


X updateline();
X break;
X }

X /*FALLTHROUGH*/
X
X case 'd':
X case 'c':
X case 'y':
X case '>':
X case '<':
X case '!':
X case '=':
X case 'V':
Xdooperator:
X n = strchr(opchars, c) - opchars + 1;
X if (n == operator) /* double operator works on lines */
X goto lineop;
X CHECKCLEAROP;
X if (Prenum != 0)
X opnum = Prenum;
X startop = Curpos;
X operator = n;
X break;
X
X/*
X * 8: Abbreviations
X */
X
X /* when quoting the next commands are operators */
X case 'S':
X case 'Y':
X case 'D':
X case 'C':
X case 'x':
X case 'X':
X case 's':
X if (Quote.lnum)
X {
X static char trans[] = "ScYyDdCcxdXdsc";
X
X if (isupper(c)) /* uppercase means linewise */
X Quote.col = QUOTELINE;
X c = *(strchr(trans, c) + 1);
X goto dooperator;
X }
X
X case '&':
X CHECKCLEAROPQ;
X if (Prenum)
X stuffnumReadbuff(Prenum);
X
X if (c == 'S')
X {
X beginline((int)p_ai);
X substituting = TRUE;
X }
X else if (c == 'Y' && p_ye)
X c = 'Z';
X {
X static char *(ar[9]) = {"dl", "dh", "d$", "c$", "cl", "c$", "yy", "y$", ":s\r"};
X static char *str = "xXDCsSYZ&";
X
X stuffReadbuff(ar[strchr(str, c) - str]);


X }
X break;
X
X/*

X * 9: Marks
X */
X
X case 'm':
X CHECKCLEAROP;
X if (!setmark(nchar))
X CLEAROPBEEP;


X break;
X
X case '\'':

X flag = TRUE;


X /* FALLTHROUGH */
X

X case '`':
X pos = getmark(nchar, (operator == NOP));
X if (pos == (FPOS *)-1) /* jumped to other file */
X {
X if (flag)
X beginline(TRUE);
X break;
X }
X
X if (pos != NULL)
X setpcmark();
X
Xcursormark:
X if (pos == NULL)
X CLEAROPBEEP;
X else
X {
X Curpos = *pos;
X if (flag)
X beginline(TRUE);
X }
X mtype = flag ? MLINE : MCHAR;
X mincl = FALSE; /* ignored if not MCHAR */
X set_want_col = TRUE;
X break;
X
X case Ctrl('O'): /* goto older pcmark */
X Prenum1 = -Prenum1;
X /* FALLTHROUGH */
X
X case Ctrl('I'): /* goto newer pcmark */
X CHECKCLEAROPQ;
X pos = movemark((int)Prenum1);
X if (pos == (FPOS *)-1) /* jump to other file */


X {
X set_want_col = TRUE;

X break;
X }
X goto cursormark;
X
X/*
X * 10. Buffer setting
X */
X case '"':
X CHECKCLEAROP;
X if (isalnum(nchar) || nchar == '.')
X {
X yankbuffer = nchar;
X opnum = Prenum; /* remember count before '"' */
X }
X else
X CLEAROPBEEP;
X break;
X
X/*
X * 11. Quoting
X */
X case 'q':
X case 'Q':
X case Ctrl('Q'):
X CHECKCLEAROP;
X Quote_block = FALSE;
X if (Quote.lnum) /* stop quoting */
X {
X Quote.lnum = 0;
X updateScreen(NOT_VALID); /* delete the inversion */
X }
X else /* start quoting */


X {
X Quote = Curpos;

X if (c == 'Q') /* linewise */
X Quote.col = QUOTELINE;
X else if (c == Ctrl('Q')) /* blockwise */
X Quote_block = TRUE;
X updateline(); /* start the inversion */


X }
X break;
X
X/*

X * 12. Suspend
X */
X
X case Ctrl('Z'):
X CLEAROP;
X Quote.lnum = 0; /* stop quoting */
X stuffReadbuff(":st!\r"); /* no autowrite */
X break;
X
X/*
X * The end
X */
X case ESC:
X if (Quote.lnum)
X {
X Quote.lnum = 0; /* stop quoting */
X updateScreen(NOT_VALID);
X }
X
X default: /* not a known command */
X CLEAROPBEEP;
X break;
X
X } /* end of switch on command character */
X
X/*
X * if we didn't start or finish an operator, reset yankbuffer, unless we
X * need it later.
X */
X if (!finish_op && !operator && strchr("\"DCYSsXx", c) == NULL)
X yankbuffer = 0;
X
X /*
X * If an operation is pending, handle it...
X */
X if ((Quote.lnum || finish_op) && operator != NOP)
X {
X if (operator != YANK && !Quote.lnum) /* can't redo yank */
X {
X prep_redo(Prenum, opchars[operator - 1], c, nchar);
X if (c == '/' || c == '?') /* was a search */
X {
X AppendToRedobuff(searchbuff);
X AppendToRedobuff(NL_STR);
X }
X }
X
X if (redo_Quote_busy)


X {
X startop = Curpos;

X Curpos.lnum += redo_Quote_nlines - 1;
X switch (redo_Quote_type)
X {
X case 'Q': Quote.col = QUOTELINE;
X break;
X
X case Ctrl('Q'):
X Quote_block = TRUE;
X break;
X
X case 'q':
X if (redo_Quote_nlines <= 1)
X Curpos.col += redo_Quote_col;
X else
X Curpos.col = redo_Quote_col;
X break;
X }
X if (redo_Quote_col == 29999)
X {
X Curswant = 29999;
X coladvance(29999);
X }
X }
X else if (Quote.lnum)
X startop = Quote;
X
X /*
X * imitate the strange behaviour of vi:
X * When doing }, while standing on an indent, the indent is
X * included in the operated text.
X */
X if (c == '}' && !Quote.lnum)
X {
X n = 0;
X for (ptr = nr2ptr(startop.lnum); *ptr; ++ptr)
X {
X if (!isspace(*ptr))
X break;
X if (++n == startop.col)


X {
X startop.col = 0;

X break;
X }
X }
X }
X
X if (lt(startop, Curpos))


X {
X endop = Curpos;

X Curpos = startop;
X }
X else
X {
X endop = startop;
X startop = Curpos;
X }
X nlines = endop.lnum - startop.lnum + 1;
X
X if (Quote.lnum || redo_Quote_busy)
X {


X if (Quote_block) /* block mode */
X {

X startvcol = getvcol(&startop, 2);
X n = getvcol(&endop, 2);
X if (n < startvcol)
X startvcol = n;
X
X /* if '$' was used, get endvcol from longest line */
X if (Curswant == 29999)
X {
X Curpos.col = 29999;
X endvcol = 0;
X for (Curpos.lnum = startop.lnum; Curpos.lnum <= endop.lnum; ++Curpos.lnum)
X if ((n = getvcol(&Curpos, 3)) > endvcol)
X endvcol = n;
X Curpos = startop;
X }
X else if (redo_Quote_busy)
X endvcol = startvcol + redo_Quote_col;
X else
X {
X endvcol = getvcol(&startop, 3);
X n = getvcol(&endop, 3);
X if (n > endvcol)
X endvcol = n;
X }
X coladvance(startvcol);
X }
X
X /*
X * prepare to redo quoting: this is based on the size
X * of the quoted text
X */
X if (operator != YANK && operator != COLON) /* can't redo yank and : */
X {
X prep_redo(0L, 'q', opchars[operator - 1], NUL);
X if (Quote_block)
X redo_Quote_type = Ctrl('Q');
X else if (Quote.col == QUOTELINE)
X redo_Quote_type = 'Q';
X else
X redo_Quote_type = 'q';
X if (Curswant == 29999)
X redo_Quote_col = 29999;
X else if (Quote_block)
X redo_Quote_col = endvcol - startvcol;
X else if (nlines > 1)
X redo_Quote_col = endop.col;
X else
X redo_Quote_col = endop.col - startop.col;
X redo_Quote_nlines = nlines;
X }
X
X mincl = TRUE;
X if (Quote.col == QUOTELINE)
X mtype = MLINE;
X else
X mtype = MCHAR;
X
X redo_Quote_busy = FALSE;
X /*
X * Switch quoting off now, so screen updating does
X * not show inverted text when the screen is redrawn.
X * With YANK and sometimes with COLON and FILTER there is no screen
X * redraw, so it is done here to remove the inverted part.
X */
X Quote.lnum = 0;
X if (operator == YANK || operator == COLON || operator == FILTER)
X updateScreen(NOT_VALID);
X }
X
X set_want_col = 1;
X if (!mincl && !equal(startop, endop))
X oneless = 1;
X else
X oneless = 0;
X
X switch (operator)
X {
X case LSHIFT:
X case RSHIFT:
X adjust_lnum();
X doshift(operator);
X break;
X
X case DELETE:
X dodelete();
X break;
X
X case YANK:
X doyank(FALSE);
X break;
X
X case CHANGE:
X dochange();
X break;
X
X case FILTER:
X bangredo = TRUE; /* dobang() will put cmd in redo buffer */
X
X case INDENT:
X case COLON:
X adjust_lnum();
X sprintf(IObuff, ":%ld,%ld", (long)startop.lnum, (long)endop.lnum);
X stuffReadbuff(IObuff);
X if (operator != COLON)
X stuffReadbuff("!");
X if (operator == INDENT)
X {
X stuffReadbuff(p_ep);


X stuffReadbuff("\n");
X }

X /* docmdline() does the rest */
X break;
X
X case TILDE:
X case UPPER:
X case LOWER:
X dotilde();
X break;
X
X case FORMAT:
X adjust_lnum();
X doformat();


X break;
X
X default:

X CLEAROPBEEP;
X }
X operator = NOP;
X Quote_block = FALSE;
X yankbuffer = 0;
X }
X
Xnormal_end:
X premsg(-1, NUL);
X if (restart_edit && operator == NOP && Quote.lnum == 0 && !command_busy && stuff_empty() && yankbuffer == 0)
X startinsert(NUL, FALSE, 1L);


X}
X
X static void

Xprep_redo(num, cmd, c, nchar)
X long num;
X int cmd;
X int c;
X int nchar;
X{
X if (substituting) /* special case: 'S' command is done like 'c$' */
X {
X substituting = FALSE;
X cmd = 'S';
X c = NUL;
X nchar = NUL;
X }
X ResetBuffers();
X if (yankbuffer != 0) /* yank from specified buffer */
X {
X AppendToRedobuff("\"");
X AppendToRedobuff(mkstr(yankbuffer));
X }
X if (num)
X AppendNumberToRedobuff(num);
X AppendToRedobuff(mkstr(cmd));


X if (c != NUL)

X AppendToRedobuff(mkstr(c));
X if (nchar != NUL)
X AppendToRedobuff(mkstr(nchar));
X}
X
X/*
X * check for operator active


X */
X static int

Xcheckclearop()
X{
X if (operator == NOP)
X return (FALSE);
X clearopbeep();
X return (TRUE);
X}
X
X/*
X * check for operator or Quoting active


X */
X static int

Xcheckclearopq()
X{
X if (operator == NOP && Quote.lnum == 0)
X return (FALSE);
X clearopbeep();
X return (TRUE);


X}
X
X static void

Xclearopbeep()
X{
X CLEAROP;
X beep();
X}
X
X/*
X * display, on the last line of the window, the characters typed before
X * the last command character, plus 'c'


X */
X static void

Xpremsg(c1, c2)
X int c1, c2;
X{
X char c;
X
X if (!p_sc || !KeyTyped)
X return;
X
X outstr(T_CI); /* disable cursor */
X windgoto((int)Rows - 1, (int)Columns - 12);
X if (c1 == -1)
X outstrn(" ");
X else
X {
X if (opnum)
X outnum((long)opnum);
X if (yankbuffer)
X {
X outchar('"');
X outchar(yankbuffer);
X }
X if (operator == 'z')
X outchar('z');
X else if (operator)
X outchar(opchars[operator - 1]);
X if (Prenum)
X outnum((long)Prenum);
X if (c1)
X {
X c = c1;
X outtrans(&c, 1);
X }
X if (c2)
X {
X c = c2;
X outtrans(&c, 1);
X }
X }
X setcursor();
X outstr(T_CV); /* enable cursor */
X}
X
X/*
X * If we are going to do an linewise operator we have to adjust endop.lnum
X * if we end in column one while mtype is MCHAR and mincl is FALSE


X */
X static void

Xadjust_lnum()
X{
X if (mtype == MCHAR && mincl == FALSE &&
X endop.col == 0 && endop.lnum > startop.lnum)
X --endop.lnum;
X}
END_OF_FILE
if test 29120 -ne `wc -c <'vim/src/normal.c'`; then
echo shar: \"'vim/src/normal.c'\" unpacked with wrong size!
fi
# end of 'vim/src/normal.c'
fi
echo shar: End of archive 15 \(of 23\).
cp /dev/null ark15isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:35:57 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 16
Archive-name: vim/part16
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 16 (of 23)."
# Contents: vim/src/screen.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:12 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/screen.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/screen.c'\"
else
echo shar: Extracting \"'vim/src/screen.c'\" \(29501 characters\)
sed "s/^X//" >'vim/src/screen.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * screen.c: code for displaying on the screen


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X

Xchar *tgoto __PARMS((char *cm, int col, int line));
X

Xstatic u_char *Nextscreen = NULL; /* What's to be put on the screen. */
Xstatic int NumLineSizes = 0; /* # of active LineSizes */
Xstatic linenr_t *LineNumbers = NULL; /* Pointer to the line for LineSizes */
Xstatic u_char *LineSizes = NULL; /* Number of rows the lines occupy */
Xstatic u_char **LinePointers = NULL; /* array of pointers into Netscreen */
X
X/*
X * The following variable is set (in cursupdate) to the number of physical
X * lines taken by the line the cursor is on. We use this to avoid extra calls
X * to plines(). The optimized routine updateline()
X * makes sure that the size of the cursor line hasn't changed. If so, lines
X * below the cursor will move up or down and we need to call the routine
X * updateScreen() to examine the entire screen.
X */
Xstatic int Cline_size; /* size (in rows) of the cursor line */
Xstatic int Cline_row; /* starting row of the cursor line */
Xint redraw_msg = TRUE; /* TRUE when "insert mode" needs updating */
Xstatic FPOS oldCurpos = {0, 0}; /* last known end of quoted part */
Xstatic int oldCurswant = 0; /* last known value of Curswant */
Xstatic int canopt; /* TRUE when cursor goto can be optimized */
Xstatic int emptyrows = 0; /* number of '~' rows on screen */
X
Xstatic int screenline __ARGS((linenr_t, int, int));
Xstatic void screenchar __ARGS((u_char *, int, int));
Xstatic void screenfill __ARGS((int, int));
X
X/*
X * updateline() - like updateScreen() but only for cursor line
X *
X * This determines whether or not we need to call updateScreen() to examine
X * the entire screen for changes. This occurs if the size of the cursor line
X * (in rows) hasn't changed.
X */
X void
Xupdateline()
X{
X int row;
X int n;
X
X screenalloc(); /* allocate screen buffers if size changed */
X
X if (Nextscreen == NULL || RedrawingDisabled)
X return;
X
X screenchar(NULL, 0, 0); /* init cursor position of screenchar() */


X outstr(T_CI); /* disable cursor */
X

X row = screenline(Curpos.lnum, Cline_row, (int)Rows - 1);
X
X outstr(T_CV); /* enable cursor again */
X
X if (row == Rows) /* line too long for screen */
X updateScreen(VALID_TO_CURSCHAR);
X else
X {
X n = row - Cline_row;
X if (n != Cline_size) /* line changed size */
X {
X if (n < Cline_size) /* got smaller: delete lines */
X s_del(row, Cline_size - n, FALSE);
X else /* got bigger: insert lines */
X s_ins(Cline_row + Cline_size, n - Cline_size, FALSE);
X
X updateScreen(VALID_TO_CURSCHAR);
X }
X }
X}
X
X/*
X * updateScreen()
X *
X * Based on the current value of Topline, transfer a screenfull of stuff from
X * Filemem to Nextscreen, and update Botline.


X */
X
X void

XupdateScreen(type)
X int type;
X{
X register int row;
X register int endrow;
X linenr_t lnum;
X linenr_t lastline = 0; /* only valid if endrow != Rows -1 */
X int done; /* if TRUE, we hit the end of the file */
X int didline; /* if TRUE, we finished the last line */
X int srow = 0; /* starting row of the current line */
X int idx;
X int i;
X long j;
X static int postponed_not_valid = FALSE;
X register u_char *screenp;
X
X screenalloc(); /* allocate screen buffers if size changed */
X
X if (Nextscreen == NULL)
X return;
X
X if (type == CLEAR) /* first clear screen */
X {
X screenclear();
X type = NOT_VALID;
X }
X if (type == CURSUPD) /* update cursor and then redraw */
X {
X NumLineSizes = 0;
X cursupdate(); /* will call updateScreen(VALID) */
X return;
X }
X if (NumLineSizes == 0)
X type = NOT_VALID;
X
X if (RedrawingDisabled)
X {
X if (type == NOT_VALID)
X postponed_not_valid = TRUE; /* use NOT_VALID next time */
X return;
X }
X
X if (postponed_not_valid)
X {
X type = NOT_VALID;
X postponed_not_valid = FALSE;
X }
X
X/* return if there is nothing to do */
X if ((type == VALID && Topline == LineNumbers[0]) ||
X (type == INVERTED && oldCurpos.lnum == Curpos.lnum &&
X oldCurpos.col == Curpos.col))
X return;
X
X if (type == NOT_VALID)
X {
X redraw_msg = TRUE;
X NumLineSizes = 0;
X }
X
X idx = 0;
X row = 0;
X lnum = Topline;


X outstr(T_CI); /* disable cursor */
X

X /* The number of rows shown is Rows-1. */
X /* The default last row is the status/command line. */
X endrow = Rows - 1;
X
X if (type == VALID || type == VALID_TO_CURSCHAR)
X {
X /*
X * We handle two special cases:
X * 1: we are off the top of the screen by a few lines: scroll down
X * 2: Topline is below LineNumbers[0]: may scroll up
X */
X if (Topline < LineNumbers[0]) /* may scroll down */
X {
X j = LineNumbers[0] - Topline;
X if (j < Rows - 3) /* not too far off */
X {
X lastline = LineNumbers[0] - 1;
X i = plines_m(Topline, lastline);
X if (i < Rows - 3) /* less than a screen off */
X {
X /*
X * Try to insert the correct number of lines.
X * This may fail and the screen may have been cleared.
X */
X if (s_ins(0, i, FALSE) && NumLineSizes)
X {
X endrow = i;
X
X if ((NumLineSizes += j) > Rows - 1)
X NumLineSizes = Rows - 1;
X for (idx = NumLineSizes; idx - j >= 0; idx--)
X {
X LineNumbers[idx] = LineNumbers[idx - j];
X LineSizes[idx] = LineSizes[idx - j];
X }
X idx = 0;
X }
X }
X else /* far off: clearing the screen is faster */
X screenclear();
X }
X else /* far off: clearing the screen is faster */
X screenclear();
X }
X else /* may scroll up */
X {
X j = -1;
X for (i = 0; i < NumLineSizes; i++) /* try to find Topline in LineNumbers[] */
X {
X if (LineNumbers[i] == Topline)
X {
X j = i;
X break;
X }
X row += LineSizes[i];
X }
X if (j == -1) /* Topline is not in LineNumbers */
X {
X row = 0;
X screenclear(); /* far off: clearing the screen is faster */
X }
X else
X {
X /*
X * Try to delete the correct number of lines.
X * Topline is at LineNumbers[i].
X */
X if ((row == 0 || s_del(0, row, FALSE)) && NumLineSizes)
X {
X srow = row;
X row = 0;


X for (;;)
X {

X if (type == VALID_TO_CURSCHAR && lnum == Curpos.lnum)
X break;
X if (row + srow + LineSizes[j] >= Rows - 1)
X break;
X LineSizes[idx] = LineSizes[j];
X LineNumbers[idx] = lnum++;
X
X row += LineSizes[idx++];
X if (++j >= NumLineSizes)
X break;
X }
X NumLineSizes = idx;
X }
X else
X row = 0; /* update all lines */
X }
X }
X if (endrow == Rows - 1 && idx == 0) /* no scrolling */
X NumLineSizes = 0;
X }
X
X done = didline = FALSE;
X screenchar(NULL, 0, 0); /* init cursor position of screenchar() */
X
X if (Quote.lnum) /* check if we are updating the inverted part */
X {
X linenr_t from, to;
X
X /* find the line numbers that need to be updated */
X if (Curpos.lnum < oldCurpos.lnum)
X {
X from = Curpos.lnum;
X to = oldCurpos.lnum;
X }
X else
X {
X from = oldCurpos.lnum;
X to = Curpos.lnum;
X }
X /* if in block mode and changed column or Curswant: update all lines */
X if (Quote_block && (Curpos.col != oldCurpos.col || Curswant != oldCurswant))
X {
X if (from > Quote.lnum)
X from = Quote.lnum;
X if (to < Quote.lnum)
X to = Quote.lnum;
X }
X
X if (from < Topline)
X from = Topline;
X if (to >= Botline)
X to = Botline - 1;
X
X /* find the minimal part to be updated */
X if (type == INVERTED)
X {
X while (lnum < from) /* find start */
X {
X row += LineSizes[idx++];
X ++lnum;
X }
X srow = row;
X for (j = idx; j < NumLineSizes; ++j) /* find end */
X {
X if (LineNumbers[j] == to + 1)
X {
X endrow = srow;
X break;
X }
X srow += LineSizes[j];


X }
X oldCurpos = Curpos;

X oldCurswant = Curswant;
X }
X /* if we update the lines between from and to set oldCurpos */
X else if (lnum <= from && (endrow == Rows - 1 || lastline >= to))


X {
X oldCurpos = Curpos;

X oldCurswant = Curswant;
X }
X }
X
X /*
X * Update the screen rows from "row" to "endrow".
X * Start at line "lnum" which is at LineNumbers[idx].
X */


X for (;;)
X {

X if (lnum > line_count) /* hit the end of the file */
X {
X done = TRUE;
X break;
X }
X srow = row;
X row = screenline(lnum, srow, endrow);
X if (row > endrow) /* past end of screen */
X {
X LineSizes[idx] = plines(lnum); /* we may need the size of that */
X LineNumbers[idx++] = lnum; /* too long line later on */
X break;
X }
X
X LineSizes[idx] = row - srow;
X LineNumbers[idx++] = lnum;
X if (++lnum > line_count)
X {
X done = TRUE;
X break;
X }
X
X if (row == endrow)
X {
X didline = TRUE;
X break;
X }
X }
X if (idx > NumLineSizes)
X NumLineSizes = idx;
X
X /* Do we have to do off the top of the screen processing ? */
X if (endrow != Rows - 1)
X {
X row = 0;
X for (idx = 0; idx < NumLineSizes && row < (Rows - 1); idx++)
X row += LineSizes[idx];
X
X if (row < (Rows - 1))
X {
X done = TRUE;
X }
X else if (row > (Rows - 1)) /* Need to blank out the last line */
X {
X lnum = LineNumbers[idx - 1];
X srow = row - LineSizes[idx - 1];
X didline = FALSE;
X }
X else
X {
X lnum = LineNumbers[idx - 1] + 1;
X didline = TRUE;
X }
X }
X
X emptyrows = 0;
X /*
X * If we didn't hit the end of the file, and we didn't finish the last
X * line we were working on, then the line didn't fit.
X */
X if (!done && !didline)
X {
X if (lnum == Topline)
X {
X /*
X * Single line that does not fit!
X * Fill last line with '@' characters.
X */
X screenp = LinePointers[Rows - 2];
X for (i = 0; i < Columns; ++i)
X {
X if (*screenp != '@')
X {
X *screenp = '@';
X screenchar(screenp, (int)(Rows - 2), i);
X }
X ++screenp;
X }
X Botline = lnum + 1;
X }
X else
X {
X /*
X * Clear the rest of the screen and mark the unused lines.
X */
X screenfill(srow, '@');
X Botline = lnum;
X }
X }
X else
X {
X /* make sure the rest of the screen is blank */
X /* put '~'s on rows that aren't part of the file. */
X screenfill(row, '~');
X emptyrows = Rows - row - 1;
X
X if (done) /* we hit the end of the file */
X Botline = line_count + 1;
X else
X Botline = lnum;
X }
X
X if (redraw_msg)
X {
X showmode();
X redraw_msg = FALSE;
X }
X
X outstr(T_CV); /* enable cursor again */
X}
X
Xstatic int invert; /* shared by screenline() and screenchar() */
X
X/*
X * Move line "lnum" to the screen.
X * Start at row "startrow", stop when "endrow" is reached.
X * Return the number of last row the line occupies.


X */
X
X static int

Xscreenline(lnum, startrow, endrow)
X linenr_t lnum;
X int startrow;
X int endrow;
X{
X register u_char *screenp;
X register u_char c;
X register int col; /* visual column on screen */
X register int vcol; /* visual column for tabs */
X register int row;
X register u_char *ptr;
X char extra[16];
X char *p_extra;
X int n_extra;
X
X int fromcol, tocol; /* start/end of inverting */
X int temp;
X FPOS *top, *bot;
X
X row = startrow;
X col = 0;
X vcol = 0;
X invert = FALSE;
X fromcol = tocol = -10;
X ptr = (u_char *)nr2ptr(lnum);
X canopt = TRUE;
X if (Quote.lnum) /* quoting active */
X {
X if (ltoreq(Curpos, Quote)) /* Quote is after Curpos */
X {
X top = &Curpos;
X bot = &Quote;
X }
X else /* Quote is before Curpos */
X {
X top = &Quote;
X bot = &Curpos;


X }
X if (Quote_block) /* block mode */
X {

X if (lnum >= top->lnum && lnum <= bot->lnum)
X {
X fromcol = getvcol(top, 2);
X temp = getvcol(bot, 2);
X if (temp < fromcol)
X fromcol = temp;
X


X if (Curswant == 29999)

X tocol = 29999;
X else
X {
X tocol = getvcol(top, 3);
X temp = getvcol(bot, 3);
X if (temp > tocol)
X tocol = temp;
X ++tocol;
X }
X }
X }
X else /* non-block mode */
X {
X if (lnum > top->lnum && lnum <= bot->lnum)
X fromcol = 0;
X if (lnum == top->lnum)
X fromcol = getvcol(top, 2);
X if (lnum == bot->lnum)
X tocol = getvcol(bot, 3) + 1;
X
X if (Quote.col == QUOTELINE) /* linewise */
X {
X if (fromcol > 0)
X fromcol = 0;
X if (tocol > 0)
X tocol = QUOTELINE;
X }
X }
X /* if inverting in this line, can't optimize cursor positioning */
X if (fromcol >= 0 || tocol >= 0)
X canopt = FALSE;
X }
X screenp = LinePointers[row];
X if (p_nu)
X {
X sprintf(extra, "%7ld ", (long)lnum);
X p_extra = extra;
X n_extra = 8;
X vcol = -8; /* so vcol is 0 when line number has been printed */
X
X }
X else
X {
X p_extra = NULL;
X n_extra = 0;
X }


X for (;;)
X {

X if (vcol == fromcol) /* start inverting */
X {
X invert = TRUE;
X outstr(T_TI);
X }
X if (vcol == tocol) /* stop inverting */
X {
X invert = FALSE;
X outstr(T_TP);
X }
X
X /* Get the next character to put on the screen. */
X /*
X * The 'extra' array contains the extra stuff that is inserted to
X * represent special characters (tabs, and other non-printable stuff.
X * The order in the 'extra' array is reversed.
X */
X
X if (n_extra > 0)
X {
X c = (u_char)*p_extra++;
X n_extra--;
X }
X else
X {
X if ((c = *ptr++) < ' ' || (c > '~' && c < 0xa0))
X {
X /*
X * when getting a character from the file, we may have to turn it
X * into something else on the way to putting it into 'Nextscreen'.
X */
X if (c == TAB && !p_list)
X {
X p_extra = spaces;
X /* tab amount depends on current column */
X n_extra = (int)p_ts - vcol % (int)p_ts - 1;
X c = ' ';
X }
X else if (c == NUL && p_list)
X {
X extra[0] = NUL;
X p_extra = extra;
X n_extra = 1;
X c = '$';
X }
X else if (c != NUL)
X {
X p_extra = (char *)transchar(c);
X n_extra = charsize(c) - 1;
X c = (u_char)*p_extra++;
X }
X }
X }
X
X if (c == NUL)
X {
X if (invert)
X {
X if (vcol == 0) /* invert first char of empty line */
X {
X if (*screenp != (' ' ^ 0x80))
X {
X *screenp = (' ' ^ 0x80);
X screenchar(screenp, row, col);
X }
X ++screenp;
X ++col;
X }
X outstr(T_TP);
X invert = FALSE;
X }
X /*
X * blank out the rest of this row
X * could also use clear-to-end-of-line, but it is slower
X * on an Amiga
X */
X while (col < Columns)
X {
X if (*screenp != ' ')
X {
X *screenp = ' ';
X screenchar(screenp, row, col);
X }
X ++screenp;
X ++col;
X }
X row++;
X break;
X }
X if (col >= Columns)


X {
X col = 0;

X if (++row == endrow) /* line got too long for screen */
X {
X ++row;
X break;
X }
X screenp = LinePointers[row];
X }
X /* store the character in Nextscreen */
X if (!invert)
X {
X if (*screenp != c)
X {
X *screenp = c;
X screenchar(screenp, row, col);
X }
X }
X else
X {
X if (*screenp != (c ^ 0x80))
X {
X *screenp = c ^ 0x80;
X screenchar(screenp, row, col);
X }
X }
X ++screenp;
X col++;
X vcol++;
X }
X
X if (invert)
X {
X outstr(T_TP);
X invert = FALSE;
X }
X return (row);
X}
X
X/*
X * put character '*p' on the screen at position 'row' and 'col'


X */
X static void

Xscreenchar(p, row, col)
X u_char *p;


X int row;
X int col;
X{

X static int oldrow, oldcol; /* old cursor position */
X int c;
X
X if (p == NULL) /* initialize cursor position */
X {
X oldrow = oldcol = -1;
X return;
X }
X if (oldcol != col || oldrow != row)
X {
X /*
X * If we're on the same row (which happens a lot!), try to
X * avoid a windgoto().
X * If we are only a few characters off, output the
X * characters. That is faster than cursor positioning.
X * This can't be used when inverting (a part of) the line.
X */
X if (oldrow == row && oldcol < col)


X {
X register int i;
X

X i = col - oldcol;
X if (i <= 4 && canopt)
X {
X while (i)
X {
X c = *(p - i--);
X outchar(c);
X }
X }
X else if (T_CRI && *T_CRI) /* use tgoto interface! jw */
X outstr(tgoto(T_CRI, 0, i));
X else
X windgoto(row, col);
X
X oldcol = col;
X }
X else
X windgoto(oldrow = row, oldcol = col);
X }
X if (invert)
X outchar(*p ^ 0x80);
X else
X outchar(*p);
X oldcol++;
X}
X
X/*
X * Fill the screen at 'srow' with character 'c' followed by blanks.


X */
X static void

Xscreenfill(srow, c)
X int srow;
X int c;
X{
X register int row;
X register int col;
X register u_char *screenp;
X
X for (row = srow; row < (Rows - 1); ++row)
X {
X screenp = LinePointers[row];
X if (*screenp != c)
X {
X *screenp = c;
X screenchar(screenp, row, 0);
X }
X ++screenp;
X for (col = 1; col < Columns; ++col)
X {
X if (*screenp != ' ')
X {
X *screenp = ' ';
X screenchar(screenp, row, col);
X }
X ++screenp;
X }
X }
X}
X
X/*
X * compute Botline. Can be called after Topline or Rows changed.
X */
X void
Xcomp_Botline()
X{
X linenr_t lnum;
X int done = 0;
X
X for (lnum = Topline; lnum <= line_count; ++lnum)
X {
X if ((done += plines(lnum)) >= Rows)
X break;
X }
X Botline = lnum; /* Botline is the line that is just below the window */
X}
X
X/*
X * prt_line() - print the given line
X * returns the number of characters written.
X */
X int
Xprt_line(s)
X char *s;
X{
X register int si = 0;
X register char c;
X register int col = 0;
X
X char extra[16];
X int n_extra = 0;
X int n;
X


X for (;;)
X {

X if (n_extra > 0)
X c = extra[--n_extra];
X else {
X c = s[si++];
X if (c == TAB && !p_list)
X {
X strcpy(extra, " ");
X /* tab amount depends on current column */
X n_extra = (p_ts - 1) - col % p_ts;
X c = ' ';
X }
X else if (c == NUL && p_list)
X {
X extra[0] = NUL;
X n_extra = 1;
X c = '$';
X }
X else if (c != NUL && (n = charsize(c)) > 1)
X {
X char *p;
X
X n_extra = 0;
X p = transchar(c);
X /* copy 'ch-str'ing into 'extra' in reverse */
X while (n > 1)
X extra[n_extra++] = p[--n];
X c = p[0];
X }
X }
X
X if (c == NUL)
X break;
X
X outchar(c);
X col++;
X }
X return col;
X}
X
X void
Xscreenalloc()
X{
X static int old_Rows = 0;
X static int old_Columns = 0;
X register int i;
X
X /*
X * Allocation of the sceen buffers is done only when the size changes
X */
X if (Nextscreen != NULL && Rows == old_Rows && Columns == old_Columns)
X return;
X
X old_Rows = Rows;
X old_Columns = Columns;
X
X /*
X * If we're changing the size of the screen, free the old arrays
X */
X if (Nextscreen != NULL)
X free((char *)Nextscreen);
X if (LinePointers != NULL)
X free((char *)LinePointers);
X if (LineNumbers != NULL)
X free((char *) LineNumbers);
X if (LineSizes != NULL)
X free(LineSizes);
X
X Nextscreen = (u_char *)malloc((size_t) (Rows * Columns));
X LineNumbers = (linenr_t *) malloc((size_t) (Rows * sizeof(linenr_t)));
X LineSizes = (u_char *)malloc((size_t) Rows);
X LinePointers = (u_char **)malloc(sizeof(u_char *) * Rows);
X
X if (Nextscreen == NULL || LineNumbers == NULL || LineSizes == NULL ||
X LinePointers == NULL)
X {
X emsg(e_outofmem);
X if (Nextscreen != NULL)
X free((char *)Nextscreen);
X Nextscreen = NULL;
X }
X else
X {
X for (i = 0; i < Rows; ++i)
X LinePointers[i] = Nextscreen + i * Columns;
X }
X
X screenclear();
X}
X
X void
Xscreenclear()
X{
X register u_char *np;
X register u_char *end;
X
X if (starting || Nextscreen == NULL)
X return;
X
X outstr(T_ED); /* clear the display */
X
X np = Nextscreen;
X end = Nextscreen + Rows * Columns;
X
X /* blank out Nextscreen */
X while (np != end)
X *np++ = ' ';
X
X /* clear screen info */
X NumLineSizes = 0;
X}
X
X void
Xcursupdate()
X{
X linenr_t p;
X long nlines;
X int i;
X int temp;
X
X screenalloc(); /* allocate screen buffers if size changed */
X
X if (Nextscreen == NULL)
X return;
X
X if (Curpos.lnum > line_count)
X Curpos.lnum = line_count;
X if (bufempty()) /* special case - file is empty */
X {
X Topline = 1;
X Curpos.lnum = 1;
X Curpos.col = 0;
X for (i = 0; i < Rows; i++)
X LineSizes[i] = 0;
X if (NumLineSizes == 0) /* don't know about screen contents */
X updateScreen(NOT_VALID);
X NumLineSizes = 1;
X }
X else if (Curpos.lnum < Topline)
X {
X /*
X * If the cursor is above the top of the screen, scroll the screen to
X * put it at the top of the screen.
X * If we weren't very close to begin with, we scroll more, so that
X * the line is close to the middle.
X */
X temp = Rows / 3;
X if (Topline - Curpos.lnum >= temp)
X {
X p = Curpos.lnum;
X for (i = 0; i < temp && p > 1; i += plines(--p))
X ;
X Topline = p;
X }
X else if (p_sj > 1) /* scroll at least p_sj lines */
X {
X for (i = 0; i < p_sj && Topline > 1; i += plines(--Topline))
X ;
X
X }
X if (Topline > Curpos.lnum)


X Topline = Curpos.lnum;
X updateScreen(VALID);
X }

X else if (Curpos.lnum >= Botline)
X {
X nlines = Curpos.lnum - Botline + 1;
X /*
X * compute the number of lines at the top which have the same or more
X * rows than the rows of the lines below the bottom
X */
X if (nlines <= Rows)
X {
X /* get the number or rows to scroll minus the number of
X free '~' rows */
X temp = plines_m(Botline, Curpos.lnum) - emptyrows;


X if (temp <= 0)

X nlines = 0;
X else
X {
X /* scroll minimal number of lines */
X if (temp < p_sj)
X temp = p_sj;
X for (i = 0, p = Topline; i < temp && p < Botline; ++p)
X i += plines(p);
X nlines = p - Topline;
X }
X }
X
X /*
X * Scroll up if the cursor is off the bottom of the screen a bit.
X * Otherwise put it at 2/3 of the screen.
X */
X if (nlines > Rows / 3 && nlines > p_sj)
X {
X p = Curpos.lnum;
X temp = (2 * Rows) / 3;
X nlines = 0;
X i = 0;
X do /* this loop could win a contest ... */
X i += plines(p);
X while (i < temp && (nlines = 1) != 0 && --p != 0);
X Topline = p + nlines;
X }
X else
X scrollup(nlines);
X updateScreen(VALID);
X }
X else if (NumLineSizes == 0) /* don't know about screen contents */
X updateScreen(NOT_VALID);
X Cursrow = Curscol = Cursvcol = i = 0;
X for (p = Topline; p != Curpos.lnum; ++p)
X if (RedrawingDisabled) /* LineSizes[] invalid */
X Cursrow += plines(p);
X else
X Cursrow += LineSizes[i++];
X
X Cline_row = Cursrow;
X if (!RedrawingDisabled && i > NumLineSizes)
X /* Should only happen with a line that is too */
X /* long to fit on the last screen line. */
X Cline_size = 0;
X else
X {
X if (RedrawingDisabled) /* LineSizes[] invalid */
X Cline_size = plines(Curpos.lnum);
X else
X Cline_size = LineSizes[i];
X
X curs_columns(); /* compute Cursvcol and Curscol */
X }
X
X if (set_want_col)
X {
X Curswant = Cursvcol;
X set_want_col = FALSE;
X }
X showruler(0);
X}
X
X/*
X * compute Curscol and Cursvcol
X */
X void
Xcurs_columns()
X{
X Cursvcol = getvcol(&Curpos, 1);
X Curscol = Cursvcol;
X if (p_nu)
X Curscol += 8;
X
X Cursrow = Cline_row;
X while (Curscol >= Columns)
X {
X Curscol -= Columns;
X Cursrow++;
X }
X if (Cursrow > Rows - 2) /* Cursor past end of screen */
X Cursrow = Rows - 2; /* happens with line that does not fit on screen */
X}
X
X/*
X * get virtual column number of pos
X * type = 1: where the cursor is on this character
X * type = 2: on the first position of this character
X * type = 3: on the last position of this character
X */
X int
Xgetvcol(pos, type)
X FPOS *pos;
X int type;
X{
X int col;
X int vcol;
X u_char *ptr;
X int incr;
X u_char c;
X
X vcol = 0;
X ptr = (u_char *)nr2ptr(pos->lnum);
X for (col = pos->col; col >= 0; --col)
X {
X c = *ptr++;
X if (c == NUL) /* make sure we don't go past the end of the line */
X break;
X
X /* A tab gets expanded, depending on the current column */
X incr = chartabsize(c, vcol);
X
X if (col == 0) /* character at pos.col */
X {
X if (type == 3 || (type == 1 && c == TAB && State == NORMAL && !p_list))
X --incr;


X else
X break;
X }

X vcol += incr;
X }

X return vcol;
X}
X
X void
Xscrolldown(nlines)
X long nlines;
X{
X register long done = 0; /* total # of physical lines done */
X
X /* Scroll up 'nlines' lines. */
X while (nlines--)
X {
X if (Topline == 1)
X break;
X done += plines(--Topline);
X }
X /*
X * Compute the row number of the last row of the cursor line
X * and move it onto the screen.
X */
X Cursrow += done + plines(Curpos.lnum) - 1 - Cursvcol / Columns;
X while (Cursrow >= Rows - 1 && Curpos.lnum > 1)
X Cursrow -= plines(Curpos.lnum--);
X}
X
X void
Xscrollup(nlines)
X long nlines;
X{
X#ifdef NEVER
X register long done = 0; /* total # of physical lines done */
X
X /* Scroll down 'nlines' lines. */
X while (nlines--)
X {
X if (Topline == line_count)
X break;
X done += plines(Topline);
X if (Curpos.lnum == Topline)
X ++Curpos.lnum;
X ++Topline;
X }
X s_del(0, done, TRUE);
X#endif
X Topline += nlines;


X if (Topline > line_count)
X Topline = line_count;

X if (Curpos.lnum < Topline)


X Curpos.lnum = Topline;
X}

X
X/*
X * The rest of the routines in this file perform screen manipulations. The
X * given operation is performed physically on the screen. The corresponding
X * change is also made to the internal screen image. In this way, the editor
X * anticipates the effect of editing changes on the appearance of the screen.
X * That way, when we call screenupdate a complete redraw isn't usually
X * necessary. Another advantage is that we can keep adding code to anticipate
X * screen changes, and in the meantime, everything still works.
X */
X
X/*
X * s_ins(row, nlines, invalid) - insert 'nlines' lines at 'row'
X * if 'invalid' is TRUE the LineNumbers[] is invalidated.
X * Returns 0 if the lines are not inserted, 1 for success.
X */
X int
Xs_ins(row, nlines, invalid)
X int row;
X int nlines;
X int invalid;
X{
X int i;
X int j;
X u_char *temp;
X
X screenalloc(); /* allocate screen buffers if size changed */
X
X if (Nextscreen == NULL)
X return 0;
X
X if (invalid)
X NumLineSizes = 0;
X
X if (nlines > (Rows - 1 - row))
X nlines = Rows - 1 - row;
X
X if (RedrawingDisabled || nlines <= 0 ||
X ((T_CIL == NULL || *T_CIL == NUL) &&
X (T_IL == NULL || *T_IL == NUL) &&
X (T_SR == NULL || *T_SR == NUL || row != 0)))
X return 0;
X
X if (Rows - nlines < 5) /* only a few lines left: redraw is faster */
X {
X screenclear(); /* will set NumLineSizes to 0 */
X return 0;
X }
X
X /*
X * It "looks" better if we do all the inserts at once
X */
X if (T_CIL && *T_CIL)
X {
X windgoto(row, 0);
X if (nlines == 1 && T_IL && *T_IL)
X outstr(T_IL);
X else
X outstr(tgoto(T_CIL, 0, nlines));
X }
X else
X {
X for (i = 0; i < nlines; i++)
X {
X if (i == 0 || row != 0)
X windgoto(row, 0);
X if (T_IL && *T_IL)
X outstr(T_IL);
X else
X outstr(T_SR);
X }
X }
X windgoto((int)Rows - 1, 0); /* delete any garbage that may have */
X clear_line(); /* been shifted to the bottom line */
X redraw_msg = TRUE;
X
X /*
X * Now shift LinePointers nlines down to reflect the inserted lines.
X * Clear the inserted lines.
X */
X for (i = 0; i < nlines; ++i)
X {
X j = Rows - 2 - i;
X temp = LinePointers[j];
X while ((j -= nlines) >= row)
X LinePointers[j + nlines] = LinePointers[j];
X LinePointers[j + nlines] = temp;
X memset(temp, ' ', (size_t)Columns);
X }
X return 1;
X}
X
X/*
X * s_del(row, nlines, invalid) - delete 'nlines' lines at 'row'
X * If 'invalid' is TRUE LineNumbers[] is ivalidated.
X * Return 1 for success, 0 if the lines are not deleted.
X */
X int
Xs_del(row, nlines, invalid)
X int row;
X int nlines;
X int invalid;
X{
X int j;
X int i;
X u_char *temp;
X
X screenalloc(); /* allocate screen buffers if size changed */
X
X if (Nextscreen == NULL)
X return 0;
X
X if (invalid)
X NumLineSizes = 0;
X
X if (nlines > (Rows - 1 - row))
X nlines = Rows - 1 - row;
X
X if (RedrawingDisabled || nlines <= 0 ||
X ((T_DL == NULL || *T_DL == NUL) &&
X (T_CDL == NULL || *T_CDL == NUL) &&
X row != 0))
X return 0;
X
X if (Rows - nlines < 5) /* only a few lines left: redraw is faster */
X {
X screenclear(); /* will set NumLineSizes to 0 */


X return 0;
X }
X

X windgoto((int)Rows - 1, 0); /* delete any garbage that may be */
X clear_line(); /* on the bottom line */
X redraw_msg = TRUE;
X
X /* delete the lines */
X if (T_CDL && *T_CDL)
X {
X windgoto(row, 0);
X if (nlines == 1 && T_DL && *T_DL)
X outstr(T_DL);
X else
X outstr(tgoto(T_CDL, 0, nlines));
X }
X else
X {
X if (row == 0)
X {
X for (i = 0; i < nlines; i++)
X outchar('\n');
X }
X else
X {
X for (i = 0; i < nlines; i++)
X {
X windgoto(row, 0);
X outstr(T_DL); /* delete a line */
X }
X }
X }
X
X /*
X * Now shift LinePointers nlines up to reflect the deleted lines.
X * Clear the deleted lines.
X */
X for (i = 0; i < nlines; ++i)
X {
X j = row + i;
X temp = LinePointers[j];
X while ((j += nlines) < Rows - 1)
X LinePointers[j - nlines] = LinePointers[j];
X LinePointers[j - nlines] = temp;
X memset(temp, ' ', (size_t)Columns);


X }
X return 1;
X}
X

X void
Xshowmode()
X{
X if ((p_mo && (State == INSERT || State == REPLACE)) || Recording)
X {
X gotocmdline(TRUE, NUL);
X if (p_mo)
X {
X if (State == INSERT)
X outstrn("-- INSERT --");


X if (State == REPLACE)

X outstrn("-- REPLACE --");
X }
X if (Recording)
X outstrn("recording");
X }
X showruler(1);
X}
X
X/*
X * delete mode message
X */
X void
Xdelmode()
X{
X if (Recording)
X msg("recording");
X else
X msg("");
X}
X
X/*
X * if ruler option is set: show current cursor position
X * if always is FALSE, only print if position has changed
X */
X void
Xshowruler(always)
X int always;
X{
X static linenr_t oldlnum = 0;
X static colnr_t oldcol = 0;
X static int oldlen = 0;
X int newlen;
X char buffer[20];
X
X if (p_ru && (redraw_msg || always || Curpos.lnum != oldlnum || Cursvcol != oldcol))
X {
X windgoto((int)Rows - 1, (int)Columns - 22);
X /*
X * Some sprintfs return the lenght, some return a pointer.
X * To avoid portability problems we use strlen here.
X */
X sprintf(buffer, "%ld,%d", Curpos.lnum, Cursvcol + 1);
X newlen = strlen(buffer);
X outstrn(buffer);
X while (newlen < oldlen)
X {
X outchar(' ');
X --oldlen;
X }
X oldlen = newlen;
X oldlnum = Curpos.lnum;
X oldcol = Cursvcol;
X redraw_msg = FALSE;
X }
X}
X
X/*
X * Clear a line. The cursor must be at the first char of the line.
X */
X void
Xclear_line()


X{
X register int i;
X

X if (T_EL != NULL && *T_EL != NUL)
X outstr(T_EL);
X else
X for (i = 1; i < Columns; ++i)
X outchar(' ');
X}
X
END_OF_FILE
if test 29501 -ne `wc -c <'vim/src/screen.c'`; then
echo shar: \"'vim/src/screen.c'\" unpacked with wrong size!
fi
# end of 'vim/src/screen.c'
fi
echo shar: End of archive 16 \(of 23\).
cp /dev/null ark16isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:36:14 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 17
Archive-name: vim/part17
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 17 (of 23)."
# Contents: vim/src/amiga.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:12 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/amiga.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/amiga.c'\"
else
echo shar: Extracting \"'vim/src/amiga.c'\" \(29917 characters\)
sed "s/^X//" >'vim/src/amiga.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * amiga.c
X *
X * Amiga system-dependent routines.


X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X

X#include <fcntl.h>
X
X#undef TRUE /* will be redefined by exec/types.h */
X#undef FALSE
X
X#ifndef LATTICE
X# include <exec/types.h>
X# include <exec/exec.h>
X# include <libraries/dos.h>
X# include <libraries/dosextens.h>
X# include <intuition/intuition.h>
X#else
X# include <proto/dos.h>
X# include <libraries/dosextens.h>
X# include <proto/intuition.h>
X# include <proto/exec.h>
X#endif
X
X#ifndef NO_ARP
X#include <libraries/arpbase.h> /* for arp.library */
X#endif
X#include <dos/dostags.h> /* for 2.0 functions */
X#include <dos/dosasl.h>
X
X#if defined(LATTICE) && !defined(SASC) && !defined(NO_ARP)
X# include <libraries/arp_pragmas.h>
X#endif
X
X/*


X * At this point TRUE and FALSE are defined as 1L and 0L, but we want 1 and 0.
X */
X#undef TRUE

X#define TRUE (1)
X#undef FALSE
X#define FALSE (0)
X
X#ifndef AZTEC_C
Xstatic long dos_packet __ARGS((struct MsgPort *, long, long));
X#endif
Xstatic int lock2name __ARGS((BPTR lock, char *buf, long len));
Xstatic struct FileInfoBlock *get_fib __ARGS((char *));
X
Xstatic BPTR raw_in = (BPTR)NULL;
Xstatic BPTR raw_out = (BPTR)NULL;
Xstatic int close_win = FALSE; /* set if Vim opened the window */
X
Xstruct IntuitionBase *IntuitionBase = NULL;
X#ifndef NO_ARP
Xstruct ArpBase *ArpBase = NULL;
X#endif
X
Xstatic struct Window *wb_window;
Xstatic char *oldwindowtitle = NULL;
Xstatic int quickfix = FALSE;
X
X#ifndef NO_ARP
Xint dos2 = FALSE; /* Amiga DOS 2.0x or higher */
X#endif
Xint size_set = FALSE; /* set to TRUE if window size was set */
X
X void
Xwin_resize_on()
X{
X outstrn("\033[12{");
X}
X
X void
Xwin_resize_off()
X{
X outstrn("\033[12}");
X}
X
X/*


X * the number of calls to Write is reduced by using the buffer "outbuf"
X */
X#define BSIZE 2048
Xstatic u_char outbuf[BSIZE];

Xstatic int bpos = 0; /* number of chars in outbuf */
X
X/*
X * flushbuf(): flush the output buffer
X */
X void


Xflushbuf()
X{
X if (bpos != 0)

X {
X Write(raw_out, (char *)outbuf, (long)bpos);
X bpos = 0;
X }
X}
X
X/*
X * outchar(c): put a character into the output buffer.
X * Flush it if it becomes full.


X */
X void
Xoutchar(c)
X unsigned c;
X{

X outbuf[bpos] = c;
X ++bpos;
X if (bpos >= BSIZE)
X flushbuf();

X}
X
X/*


X * GetChars(): low level input funcion.
X * Get a characters from the keyboard.
X * If type == T_PEEK do not wait for characters.
X * If type == T_WAIT wait a short time for characters.
X * If type == T_BLOCK wait for characters.
X */
X int
XGetChars(buf, maxlen, type)
X char *buf;
X int maxlen;

X int type;
X{
X int len;
X long time = 1000000L; /* one second */


X
X switch (type)
X {
X case T_PEEK:

X time = 100L;
X case T_WAIT:
X if (WaitForChar(raw_in, time) == 0) /* no character available */
X return 0;


X break;
X
X case T_BLOCK:

X /*


X * If there is no character available within 2 seconds (default)
X * write the autoscript file to disk
X */

X if (WaitForChar(raw_in, p_ut * 1000L) == 0)
X updatescript(0);
X }
X
X for (;;) /* repeat until we got a character */
X {
X len = Read(raw_in, buf, (long)maxlen);


X if (len > 0)
X return len;
X }
X}
X
X void

Xsleep(n)
X int n;
X{
X#ifndef LATTICE /* SAS declares void Delay(UNLONG) */
X void Delay __ARGS((long));
X#endif
X
X if (n > 0)
X Delay((long)(50L * n));


X}
X
X void
Xvim_delay()
X{

X Delay(25L);
X}
X
X/*
X * We have no job control, fake it by starting a new shell.


X */
Xvoid
Xmch_suspend()
X{

X outstr("new shell started\n");
X stoptermcap();
X call_shell(NULL, 0);
X starttermcap();
X}

X
X#define DOS_LIBRARY ((UBYTE *) "dos.library")


X
X void
Xmch_windinit()
X{

X static char intlibname[] = "intuition.library";
X
X#ifdef AZTEC_C
X Enable_Abort = 0; /* disallow vim to be aborted */
X#endif


X Columns = 80;
X Rows = 24;

X
X /*
X * Set input and output channels, unless we have opened our own window
X */
X if (raw_in == (BPTR)NULL)
X {
X raw_in = Input();
X raw_out = Output();
X }
X
X flushbuf();
X
X wb_window = NULL;
X if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary((UBYTE *)intlibname, 0L)) == NULL)
X {
X fprintf(stderr, "cannot open %s!?\n", intlibname);
X mch_windexit(3);
X }
X mch_get_winsize();
X}
X
X#include <workbench/startup.h>


X
X/*
X * Check_win checks whether we have an interactive window.
X * If not, a new window is opened with the newcli command.
X * If we would open a window ourselves, the :sh and :! commands would not
X * work properly (Why? probably because we are then running in a background CLI).
X * This also is the best way to assure proper working in a next Workbench release.

X *


X * For the -e option (quickfix mode) we open our own window and disable :sh.

X * Otherwise the compiler would never know when editing is finished.


X */
X#define BUF2SIZE 320 /* lenght of buffer for argument with complete path */
X
X void

Xcheck_win(argc, argv)


X int argc;
X char **argv;
X{

X int i;
X BPTR nilfh, fh;
X char buf1[20];
X char buf2[BUF2SIZE];
X static char *(constrings[3]) = {"con:0/0/662/210/",
X "con:0/0/640/200/",
X "con:0/0/320/200/"};
X static char winerr[] = "VIM: Can't open window!\n";
X struct WBArg *argp;
X int ac;
X char *av;
X char *device = NULL;
X int exitval = 4;
X struct Library *DosBase;
X
X/*
X * check if we are running under DOS 2.0x or higher
X */
X if (DosBase = OpenLibrary(DOS_LIBRARY, 37L))
X {
X CloseLibrary(DosBase);
X#ifndef NO_ARP
X dos2 = TRUE;
X#endif
X }
X else /* without arp functions we NEED 2.0 */
X {
X#ifdef NO_ARP
X fprintf(stderr, "Need Amigados version 2.04 or later\n");
X exit(3);
X#else
X /* need arp functions for dos 1.x */
X if (!(ArpBase = (struct ArpBase *) OpenLibrary((UBYTE *)ArpName, ArpVersion)))
X {
X fprintf(stderr, "Need %s version %ld\n", ArpName, ArpVersion);
X exit(3);
X }
X#endif
X }
X
X/*
X * scan argv[] for the '-e' and '-d' arguments
X */
X for (i = 1; i < argc; ++i)
X if (argv[i][0] == '-')
X {
X switch (argv[i][1])
X {
X case 'e':
X quickfix = TRUE;
X break;
X
X case 'd':
X if (i < argc - 1)
X device = argv[i + 1];


X break;
X }
X }
X

X/*
X * If we were not started from workbench, do not have a '-d' argument and
X * we have been started with an interactive window, use that window.
X */
X if (argc != 0 && device == NULL &&
X IsInteractive(Input()) && IsInteractive(Output()))
X return;
X
X/*
X * If we are in quickfix mode, we open our own window. We can't use the
X * newcli trick below, because the compiler would not know when we are finished.
X */
X if (quickfix)
X {
X /*
X * Try to open a window. First try the specified device.
X * Then try a 24 line 80 column window.
X * If that fails, try two smaller ones.
X */
X for (i = -1; i < 3; ++i)
X {
X if (i >= 0)
X device = constrings[i];
X if (device && (raw_in = Open((UBYTE *)device, (long)MODE_NEWFILE)) != (BPTR)NULL)
X break;
X }
X if (raw_in == (BPTR)NULL) /* all three failed */
X {
X fprintf(stderr, winerr);
X goto exit;
X }
X raw_out = raw_in;
X close_win = TRUE;
X return;
X }
X
X if ((nilfh = Open((UBYTE *)"NIL:", (long)MODE_NEWFILE)) == (BPTR)NULL)
X {
X fprintf(stderr, "Cannot open NIL:\n");
X goto exit;
X }
X
X /*
X * make a unique name for the temp file (which we will not delete!)
X */
X sprintf(buf1, "t:nc%ld", buf1); /* nobody else is using our stack */
X if ((fh = Open((UBYTE *)buf1, (long)MODE_NEWFILE)) == (BPTR)NULL)
X {
X fprintf(stderr, "Cannot create %s\n", buf1);
X goto exit;
X }
X /*
X * Write the command into the file, put quotes around the arguments that
X * have a space in them.
X */
X if (argc == 0) /* run from workbench */
X ac = ((struct WBStartup *)argv)->sm_NumArgs;
X else
X ac = argc;
X for (i = 0; i < ac; ++i)
X {
X if (argc == 0)
X {
X *buf2 = NUL;
X argp = &(((struct WBStartup *)argv)->sm_ArgList[i]);
X if (argp->wa_Lock)
X lock2name(argp->wa_Lock, buf2, (long)(BUF2SIZE - 1));
X#ifndef NO_ARP
X if (dos2) /* use 2.0 function */
X#endif
X AddPart((UBYTE *)buf2, (UBYTE *)argp->wa_Name, (long)(BUF2SIZE - 1));
X#ifndef NO_ARP
X else /* use arp function */
X TackOn(buf2, argp->wa_Name);
X#endif
X av = buf2;
X }
X else
X av = argv[i];
X
X if (av[0] == '-' && av[1] == 'd') /* skip '-d' option */
X {
X ++i;
X continue;
X }
X if (strchr(av, ' '))
X Write(fh, "\"", 1L);
X Write(fh, av, (long)strlen(av));
X if (strchr(av, ' '))
X Write(fh, "\"", 1L);
X Write(fh, " ", 1L);
X }
X Write(fh, "\nendcli\n", 8L);
X Close(fh);
X
X/*
X * Try to open a new cli in a window. If '-d' argument was given try to open
X * the specified device. Then try a 24 line 80 column window.
X * If that fails, try two smaller ones.
X */
X for (i = -1; i < 3; ++i)
X {
X if (i >= 0)
X device = constrings[i];
X else if (device == NULL)
X continue;
X sprintf(buf2, "newcli <nil: >nil: %s from %s", device, buf1);
X#ifndef NO_ARP
X if (dos2)
X {
X#endif
X if (!SystemTags((UBYTE *)buf2, SYS_UserShell, TRUE, TAG_DONE))
X break;
X#ifndef NO_ARP
X }
X else
X {
X if (Execute((UBYTE *)buf2, nilfh, nilfh))
X break;
X }
X#endif
X }
X if (i == 3) /* all three failed */
X {
X DeleteFile((UBYTE *)buf1);
X fprintf(stderr, winerr);
X goto exit;
X }
X exitval = 0; /* The Execute succeeded: exit this program */
X
Xexit:
X#ifndef NO_ARP
X if (ArpBase)
X CloseLibrary((struct Library *) ArpBase);
X#endif
X exit(exitval);
X}
X
X/*


X * fname_case(): Set the case of the filename, if it already exists.
X * This will cause the filename to remain exactly the same.
X */
X void
Xfname_case(name)
X char *name;
X{

X register struct FileInfoBlock *fib;
X register size_t len;
X
X fib = get_fib(name);
X if (fib != NULL)
X {
X len = strlen(name);
X if (len == strlen(fib->fib_FileName)) /* safety check */
X memmove(name, fib->fib_FileName, len);
X free(fib);
X }
X}
X
X/*
X * Get the FileInfoBlock for file "fname"
X * The returned structure has to be free()d.
X * Returns NULL on error.
X */
X static struct FileInfoBlock *
Xget_fib(fname)
X char *fname;
X{
X register BPTR flock;
X register struct FileInfoBlock *fib;
X
X if (fname == NULL) /* safety check */
X return NULL;
X fib = (struct FileInfoBlock *)malloc(sizeof(struct FileInfoBlock));
X if (fib != NULL)
X {


X flock = Lock((UBYTE *)fname, (long)ACCESS_READ);

X if (flock == (BPTR)NULL || !Examine(flock, fib))
X {
X free(fib); /* in case of an error the memory is freed here */
X fib = NULL;
X }
X if (flock)
X UnLock(flock);
X }
X return fib;
X}
X
X/*


X * settitle(): set titlebar of our window

X */
Xstatic char *lasttitle = NULL;
X
X void
Xsettitle(str)


X char *str;
X{
X

X if (wb_window != NULL)
X {
X free(lasttitle);
X lasttitle = alloc((unsigned)(strlen(str) + 7));
X if (lasttitle != NULL)
X {
X sprintf(lasttitle, "VIM - %s", str);
X SetWindowTitles(wb_window, (UBYTE *)lasttitle, (UBYTE *)-1L);
X }
X }
X}
X
X void
Xresettitle()
X{
X if (wb_window != NULL && lasttitle != NULL)
X SetWindowTitles(wb_window, (UBYTE *)lasttitle, (UBYTE *)-1L);
X}
X
X/*


X * get name of current directory into buffer 'buf' of length 'len' bytes
X */

Xdirname(buf, len)
X char *buf;

X int len;
X{
X return FullName("", buf, len);
X}
X
X/*


X * get absolute filename into buffer 'buf' of length 'len' bytes
X */

XFullName(fname, buf, len)
X char *fname, *buf;

X int len;
X{
X BPTR l;
X int retval = 0;
X
X if (fname == NULL) /* always fail */
X return 0;
X
X if ((l = Lock((UBYTE *)fname, (long)ACCESS_READ)))/* lock the file */
X {
X retval = lock2name(l, buf, (long)len);
X UnLock(l);
X }
X if (retval == 0 || *buf == 0 || *buf == ':')
X strcpy(buf, fname); /* something failed; use the filename */
X return retval;
X}
X
X/*
X * Get the full filename from a lock. Use 2.0 function if possible, because
X * the arp function has more restrictions on the path length.


X */
X static int

Xlock2name(lock, buf, len)
X BPTR lock;
X char *buf;
X long len;
X{
X#ifndef NO_ARP
X if (dos2) /* use 2.0 function */
X#endif
X return (int)NameFromLock(lock, (UBYTE *)buf, len);
X#ifndef NO_ARP
X else /* use arp function */
X return (int)PathName(lock, buf, (long)(len/32));
X#endif
X}
X
X/*


X * get file permissions for 'name'
X */
X long
Xgetperm(name)
X char *name;
X{

X struct FileInfoBlock *fib;
X long retval = -1;
X
X fib = get_fib(name);
X if (fib != NULL)
X {
X retval = fib->fib_Protection;
X free(fib);
X }
X return retval;
X}
X
X/*


X * set file permission for 'name' to 'perm'
X */

Xsetperm(name, perm)
X char *name;

X long perm;
X{
X perm &= ~FIBF_ARCHIVE; /* reset archived bit */
X return (int)SetProtection((UBYTE *)name, (long)perm);
X}
X
X/*


X * check if "name" is a directory
X */

Xisdir(name)
X char *name;
X{

X struct FileInfoBlock *fib;
X int retval = -1;
X
X fib = get_fib(name);
X if (fib != NULL)
X {
X retval = (fib->fib_DirEntryType >= 0);
X free(fib);
X }
X return retval;
X}
X
X/*


X * Careful: mch_windexit() may be called before mch_windinit()!
X */

X void
Xmch_windexit(r)
X int r;
X{

X if (raw_in) /* put terminal in 'normal' mode */


X {
X settmode(0);
X stoptermcap();
X }

X if (raw_out)
X {
X if (term_console)
X {
X win_resize_off(); /* window resize events de-activated */
X if (size_set)
X outstr("\233t\233u"); /* reset window size (CSI t CSI u) */
X }
X flushbuf();
X }
X
X if (wb_window != NULL) /* disable window title */
X SetWindowTitles(wb_window, (UBYTE *)oldwindowtitle, (UBYTE *)-1L);


X stopscript(); /* remove autoscript file */

X#ifndef NO_ARP
X if (ArpBase)
X CloseLibrary((struct Library *) ArpBase);
X#endif
X if (close_win)
X Close(raw_in);
X if (r)
X printf("exiting with %d\n", r); /* somehow this makes :cq work!? */
X exit(r);
X}
X
X/*
X * This is a routine for setting a given stream to raw or cooked mode on the
X * Amiga . This is useful when you are using Lattice C to produce programs
X * that want to read single characters with the "getch()" or "fgetc" call.
X *
X * Written : 18-Jun-87 By Chuck McManis.
X */
X
X#define MP(xx) ((struct MsgPort *)((struct FileHandle *) (BADDR(xx)))->fh_Type)
X
X/*
X * Function mch_settmode() - Convert the specified file pointer to 'raw' or 'cooked'
X * mode. This only works on TTY's.
X *
X * Raw: keeps DOS from translating keys for you, also (BIG WIN) it means
X * getch() will return immediately rather than wait for a return. You
X * lose editing features though.
X *
X * Cooked: This function returns the designate file pointer to it's normal,
X * wait for a <CR> mode. This is exactly like raw() except that
X * it sends a 0 to the console to make it back into a CON: from a RAW:
X */
X void
Xmch_settmode(raw)
X int raw;
X{
X if (dos_packet(MP(raw_in), (long)ACTION_SCREEN_MODE, raw ? -1L : 0L) == 0)
X fprintf(stderr, "cannot change console mode ?!\n");
X}
X
X/*
X * Code for this routine came from the following :
X *
X * ConPackets.c - C. Scheppner, A. Finkel, P. Lindsay CBM
X * DOS packet example
X * Requires 1.2
X *
X * Found on Fish Disk 56.
X *
X * Heavely modified by mool.
X */
X
X#include <devices/conunit.h>
X
X/*
X * try to get the real window size
X * return non-zero for failure
X */
X int
Xmch_get_winsize()
X{
X struct ConUnit *conUnit;
X char id_a[sizeof(struct InfoData) + 3];
X struct InfoData *id;
X
X if (!term_console) /* not an amiga window */
X return 1;
X
X /* insure longword alignment */
X id = (struct InfoData *)(((long)id_a + 3L) & ~3L);
X
X /*
X * Should make console aware of real window size, not the one we set.
X * Unfortunately, under DOS 2.0x this redraws the window and it
X * is rarely needed, so we skip it now, unless we changed the size.
X */
X if (size_set)
X outstr("\233t\233u"); /* CSI t CSI u */
X flushbuf();
X
X if (dos_packet(MP(raw_out), (long)ACTION_DISK_INFO, ((ULONG) id) >> 2) == 0 ||
X (wb_window = (struct Window *)id->id_VolumeNode) == NULL)
X {
X /* it's not an amiga window, maybe aux device */
X /* terminal type should be set */
X term_console = FALSE;
X return 1;
X }
X if (oldwindowtitle == NULL)
X oldwindowtitle = (char *)wb_window->Title;
X if (id->id_InUse == (BPTR)NULL)
X {
X fprintf(stderr, "mch_get_winsize: not a console??\n");
X return (2);
X }
X conUnit = (struct ConUnit *) ((struct IOStdReq *) id->id_InUse)->io_Unit;
X
X /* get window size */
X Rows = conUnit->cu_YMax + 1;
X Columns = conUnit->cu_XMax + 1;
X if (Rows < 0 || Rows > 200) /* cannot be an amiga window */


X {
X Columns = 80;
X Rows = 24;

X term_console = FALSE;


X return 1;
X }
X

X check_winsize();
X script_winsize();
X


X return 0;
X}
X

X/*
X * try to set the real window size
X */
X void
Xmch_set_winsize()
X{
X if (term_console)
X {
X size_set = TRUE;
X outchar(CSI);
X outnum((long)Rows);
X outchar('t');
X outchar(CSI);
X outnum((long)Columns);
X outchar('u');


X flushbuf();
X }
X}
X

X#ifdef SETKEYMAP
X/*
X * load and activate a new keymap for our CLI - DOES NOT WORK -
X * The problem is that after the setting of the keymap the input blocks
X * But the new keymap works allright in another window.
X * Tried but no improvement:
X * - remembering the length, data and command fields in request->io_xxx
X * - settmode(0) first, settmode(1) afterwards
X * - putting the keymap directly in conunit structure
X */
X
X#include <devices/keymap.h>
X
X void
Xset_keymap(name)
X char *name;
X{
X char id_a[sizeof(struct InfoData) + 3];
X struct InfoData *id;
X static struct KeyMap *old;
X static BPTR segment = (BPTR)NULL;
X struct IOStdReq *request;
X int c;
X
X if (!term_console)
X return;
X
X /* insure longword alignment */
X id = (struct InfoData *)(((long)id_a + 3L) & ~3L);
X
X if (dos_packet(MP(raw_out), (long)ACTION_DISK_INFO, ((ULONG) id) >> 2) == 0)
X {
X emsg("dos_packet failed");
X return;
X }
X if (id->id_InUse == (BPTR)NULL)
X {
X emsg("not a console??");
X return;
X }
X request = (struct IOStdReq *) id->id_InUse;
X
X if (segment != (BPTR)NULL) /* restore old keymap */
X {
X request->io_Command = CD_SETKEYMAP;
X request->io_Length = sizeof(struct KeyMap);
X request->io_Data = (APTR)old;
X DoIO((struct IORequest *)request);
X if (request->io_Error)
X emsg("Cannot reset keymap");
X else /* no error, free the allocated memory */
X {
X UnLoadSeg(segment);
X FreeMem(old, sizeof(struct KeyMap));
X segment = (BPTR)NULL;
X }
X }
X if (name != NULL)
X {
X segment = LoadSeg(name);
X if (segment == (BPTR)NULL)
X {
X emsg("Cannot open keymap file");
X return;
X }
X old = (struct KeyMap *)AllocMem(sizeof(struct KeyMap), MEMF_PUBLIC);
X if (old == NULL)
X {
X emsg(e_outofmem);
X UnLoadSeg(segment);
X segment = (BPTR)NULL;
X }
X else
X {
X request->io_Command = CD_ASKKEYMAP;
X request->io_Length = sizeof(struct KeyMap);
X request->io_Data = (APTR)old;
X DoIO((struct IORequest *)request);
X if (request->io_Error)
X {
X emsg("Cannot get old keymap");
X UnLoadSeg(segment);
X segment = (BPTR)NULL;
X FreeMem(old, sizeof(struct KeyMap));
X }
X else
X {
X request->io_Command = CD_SETKEYMAP;
X request->io_Length = sizeof(struct KeyMap);
X request->io_Data = (APTR)((segment << 2) + 18);
X DoIO((struct IORequest *)request);
X if (request->io_Error)
X emsg("Cannot set keymap");
X
X /* test for blocking */
X request->io_Command = CMD_READ;
X request->io_Length = 1;
X request->io_Data = (APTR)&c;
X DoIO((struct IORequest *)request); /* BLOCK HERE! */
X if (request->io_Error)
X emsg("Cannot set keymap");
X }
X }
X }
X}
X#endif
X
X#ifndef AZTEC_C
X/*
X * Sendpacket.c
X *
X * An invaluable addition to your Amiga.lib file. This code sends a packet to
X * the given message port. This makes working around DOS lots easier.
X *
X * Note, I didn't write this, those wonderful folks at CBM did. I do suggest
X * however that you may wish to add it to Amiga.Lib, to do so, compile it and
X * say 'oml lib:amiga.lib -r sendpacket.o'
X */
X
X/* #include <proto/exec.h> */
X/* #include <proto/dos.h> */
X#include <exec/memory.h>
X
X/*
X * Function - dos_packet written by Phil Lindsay, Carolyn Scheppner, and Andy
X * Finkel. This function will send a packet of the given type to the Message
X * Port supplied.
X */
X
X static long
Xdos_packet(pid, action, arg)
X struct MsgPort *pid; /* process indentifier ... (handlers message port) */
X long action, /* packet type ... (what you want handler to do) */
X arg; /* single argument */
X{
X# ifndef NO_ARP
X struct MsgPort *replyport;
X struct StandardPacket *packet;
X long res1;
X


X if (dos2)
X# endif

X return DoPkt(pid, action, arg, 0L, 0L, 0L, 0L); /* use 2.0 function */
X# ifndef NO_ARP
X
X replyport = (struct MsgPort *) CreatePort(NULL, 0); /* use arp function */
X if (!replyport)
X return (0);
X
X /* Allocate space for a packet, make it public and clear it */
X packet = (struct StandardPacket *)
X AllocMem((long) sizeof(struct StandardPacket), MEMF_PUBLIC | MEMF_CLEAR);
X if (!packet) {
X DeletePort(replyport);
X return (0);
X }
X packet->sp_Msg.mn_Node.ln_Name = (char *) &(packet->sp_Pkt);
X packet->sp_Pkt.dp_Link = &(packet->sp_Msg);
X packet->sp_Pkt.dp_Port = replyport;
X packet->sp_Pkt.dp_Type = action;
X packet->sp_Pkt.dp_Arg1 = arg;
X
X PutMsg(pid, (struct Message *)packet); /* send packet */
X
X WaitPort(replyport);
X GetMsg(replyport);
X
X res1 = packet->sp_Pkt.dp_Res1;
X
X FreeMem(packet, (long) sizeof(struct StandardPacket));
X DeletePort(replyport);
X
X return (res1);


X# endif
X}
X#endif
X

X/*
X * call shell, return non-zero for failure
X */
X int
Xcall_shell(cmd, filter)
X char *cmd;


X int filter; /* if != 0: called by dofilter() */
X{

X BPTR mydir;
X int x;
X#ifndef LATTICE
X int use_execute;
X char *shellcmd = NULL;
X char *shellarg;
X#endif
X int retval = 0;
X
X if (close_win)
X {
X /* if Vim opened a window: Executing a shell may cause crashes */
X emsg("Cannot execute shell with -e option");


X return 1;
X }
X

X if (term_console)
X win_resize_off(); /* window resize events de-activated */


X flushbuf();
X
X settmode(0); /* set to cooked mode */

X mydir = Lock((UBYTE *)"", (long)ACCESS_READ); /* remember current directory */
X
X#ifdef LATTICE /* not tested very much */


X if (cmd == NULL)

X {
X#ifndef NO_ARP
X if (dos2)
X#endif
X x = SystemTags(p_sh, SYS_UserShell, TRUE, TAG_DONE);
X#ifndef NO_ARP
X else
X x = Execute(p_sh, raw_in, raw_out);


X#endif
X }
X else
X {

X#ifndef NO_ARP
X if (dos2)
X#endif
X x = SystemTags(cmd, SYS_UserShell, TRUE, TAG_DONE);
X#ifndef NO_ARP
X else
X x = Execute(cmd, 0L, raw_out);
X#endif
X }
X#ifdef NO_ARP
X if (x < 0)
X#else
X if ((dos2 && x < 0) || (!dos2 && !x))
X#endif


X {
X if (cmd == NULL)

X smsg("Cannot execute shell %s", p_sh);
X else
X smsg("Cannot execute %s", cmd);
X outchar('\n');
X retval = 1;
X }
X#ifdef NO_ARP
X else if (x)
X#else
X else if (!dos2 || x)
X#endif
X {
X if (x = IoErr())


X {
X smsg("%d returned", x);

X outchar('\n');
X retval = 1;
X }
X }
X#else
X if (p_st >= 4 || (p_st >= 2 && !filter))
X use_execute = 1;
X else
X use_execute = 0;
X if (!use_execute)
X {
X /*
X * separate shell name from argument
X */
X shellcmd = strsave(p_sh);
X if (shellcmd == NULL) /* out of memory, use Execute */
X use_execute = 1;
X else
X {
X shellarg = shellcmd;
X skiptospace(&shellarg);
X *shellarg = NUL;
X skipspace(&shellarg);
X }
X }
X if (cmd == NULL)
X {
X if (use_execute)
X {
X#ifndef NO_ARP
X if (dos2)
X#endif
X x = SystemTags((UBYTE *)p_sh, SYS_UserShell, TRUE, TAG_DONE);
X#ifndef NO_ARP
X else
X x = !Execute((UBYTE *)p_sh, raw_in, raw_out);
X#endif
X }
X else
X x = fexecl(shellcmd, shellcmd, shellarg, NULL);
X }
X else if (use_execute)
X {
X#ifndef NO_ARP
X if (dos2)
X#endif
X x = SystemTags((UBYTE *)cmd, SYS_UserShell, TRUE, TAG_DONE);
X#ifndef NO_ARP
X else
X x = !Execute((UBYTE *)cmd, 0L, raw_out);
X#endif
X }
X else if (p_st & 1)
X x = fexecl(shellcmd, shellcmd, shellarg, cmd, NULL);
X else
X x = fexecl(shellcmd, shellcmd, shellarg, "-c", cmd, NULL);
X#ifdef NO_ARP
X if (x < 0)
X#else
X if ((dos2 && x < 0) || (!dos2 && x))
X#endif
X {
X if (use_execute)
X smsg("Cannot execute %s", cmd == NULL ? p_sh : cmd);
X else
X smsg("Cannot execute shell %s", shellcmd);
X outchar('\n');
X retval = 1;
X }
X else
X {
X if (use_execute)
X {
X#ifdef NO_ARP
X if (x)
X#else
X if (!dos2 || x)
X#endif
X x = IoErr();
X }
X else
X x = wait();
X if (x)


X {
X smsg("%d returned", x);

X outchar('\n');
X retval = 1;
X }
X }
X free(shellcmd);
X#endif
X
X if (mydir = CurrentDir(mydir)) /* make sure we stay in the same directory */
X UnLock(mydir);


X settmode(1); /* set to raw mode */

X resettitle();
X if (term_console)
X win_resize_on(); /* window resize events activated */
X return retval;
X}
X
X/*


X * check for an "interrupt signal"

X * We only react to a CTRL-C, but also clear the other break signals to avoid trouble
X * with lattice-c programs.


X */
X void
Xbreakcheck()
X{

X if (SetSignal(0L, (long)(SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D|SIGBREAKF_CTRL_E|SIGBREAKF_CTRL_F)) & SIGBREAKF_CTRL_C)
X {
X got_int = TRUE;
X flush_buffers(); /* remove all typeahead and macro stuff */
X }
X}
X
X/* this routine causes manx to use this Chk_Abort() rather than it's own */
X/* otherwise it resets our ^C when doing any I/O (even when Enable_Abort */
X/* is zero). Since we want to check for our own ^C's */
X
X#ifdef _DCC
X#define Chk_Abort chkabort
X#endif
X
X long
XChk_Abort()
X{
X return(0L);


X}
X
X#ifdef WILD_CARDS
X/*

X * ExpandWildCard() - this code does wild-card pattern matching using the arp
X * routines. This is based on WildDemo2.c (found in arp1.1
X * distribution). That code's copyright follows :
X *-------------------------------------------------------------------------
X * WildDemo2.c - Search filesystem for patterns, and separate into directories
X * and files, sorting each separately using DA lists.
X *
X * -+=SDB=+-
X *
X * Copyright (c) 1987, Scott Ballantyne
X * Use and abuse as you please.


X *
X * num_pat is number of input patterns
X * pat is array of pointers to input patterns
X * num_file is pointer to number of matched file names

X * file is pointer to array of pointers to matched file names
X * if file_only is TRUE we match only files, no dirs
X * if list_notfound is TRUE we include not-found entries (probably locked)
X * return 0 for success, 1 for error (you may loose some memory)
X *-------------------------------------------------------------------------
X */
X
X/* #include <arpfunctions.h> */
Xextern void *malloc __ARGS((size_t)), *calloc __ARGS((size_t, size_t));
Xstatic int insfile __ARGS((char *));
Xstatic void freefiles __ARGS((void));
X
X#define ANCHOR_BUF_SIZE (512)
X#define ANCHOR_SIZE (sizeof(struct AnchorPath) + ANCHOR_BUF_SIZE)
X
X/*
X * we use this structure to built a list of file names
X */
Xstruct onefile
X{
X struct onefile *next;
X char name[1]; /* really longer */
X} *namelist = NULL;
X
X/*
X * insert one file into the list of file names
X * return -1 for failure
X * return 0 for success


X */
X static int

Xinsfile(name)
X char *name;
X{
X struct onefile *new;
X
X new = (struct onefile *)alloc((unsigned)(sizeof(struct onefile) + strlen(name)));


X if (new == NULL)

X return -1;
X strcpy(&(new->name[0]), name);
X new->next = namelist;
X namelist = new;


X return 0;
X}
X

X/*
X * free a whole list of file names


X */
X static void

Xfreefiles()
X{
X struct onefile *p;
X
X while (namelist)
X {
X p = namelist->next;
X free(namelist);
X namelist = p;
X }
X}
X


XExpandWildCards(num_pat, pat, num_file, file, files_only, list_notfound)
X int num_pat;
X char **pat;
X int *num_file;
X char ***file;
X int files_only;
X int list_notfound;

X{
X int i;
X struct AnchorPath *Anchor;
X int domatchend = FALSE;
X LONG Result;
X struct onefile *p;


X char *errmsg = NULL;

X char *starbuf, *sp, *dp;


X
X *num_file = 0;

X *file = (char **)"";
X

X /* Get our AnchorBase */
X Anchor = (struct AnchorPath *) calloc((size_t)1, (size_t)ANCHOR_SIZE);
X if (!Anchor)
X goto OUT_OF_MEMORY;
X Anchor->ap_StrLen = ANCHOR_BUF_SIZE; /* ap_Length not supported anymore */
X#ifdef APF_DODOT
X Anchor->ap_Flags = APF_DODOT | APF_DOWILD; /* allow '.' for current dir */
X#else
X Anchor->ap_Flags = APF_DoDot | APF_DoWild; /* allow '.' for current dir */
X#endif
X
X for (i = 0; i < num_pat; i++)
X {
X#ifndef NO_ARP
X if (dos2)
X {
X#endif
X /* hack to replace '*' by '#?' */
X starbuf = alloc((unsigned)(2 * strlen(pat[i]) + 1)); /* maximum required */
X if (starbuf == NULL)
X goto OUT_OF_MEMORY;
X for (sp = pat[i], dp = starbuf; *sp; ++sp)
X {
X if (*sp == '*')
X {
X *dp++ = '#';
X *dp++ = '?';
X }
X else
X *dp++ = *sp;
X }
X *dp = NUL;
X Result = MatchFirst((UBYTE *)starbuf, Anchor);
X free(starbuf);
X#ifndef NO_ARP
X }
X else
X Result = FindFirst(pat[i], Anchor);
X#endif
X domatchend = TRUE;
X while (Result == 0)
X {
X if (!files_only || Anchor->ap_Info.fib_DirEntryType < 0)
X {
X (*num_file)++;
X if (insfile(Anchor->ap_Buf))
X {
XOUT_OF_MEMORY:
X errmsg = "Out of memory";
X goto Return;
X }
X }
X#ifndef NO_ARP
X if (dos2)
X#endif
X Result = MatchNext(Anchor);
X#ifndef NO_ARP
X else
X Result = FindNext(Anchor);
X#endif
X }
X if (Result == ERROR_BUFFER_OVERFLOW)
X {
X errmsg = "ANCHOR_BUF_SIZE too small.";
X goto Return;
X }
X if (Result != ERROR_NO_MORE_ENTRIES)
X {
X if (list_notfound) /* put object with error in list */
X {
X (*num_file)++;
X if (insfile(pat[i]))
X goto OUT_OF_MEMORY;
X }
X else if (Result != ERROR_OBJECT_NOT_FOUND)
X {
X errmsg = "I/O ERROR";
X goto Return;
X }
X }
X MatchEnd(Anchor);
X domatchend = FALSE;
X }
X
X p = namelist;
X if (p)
X {
X *file = (char **) malloc(sizeof(char *) * (*num_file));


X if (*file == NULL)

X goto OUT_OF_MEMORY;
X for (i = *num_file - 1; p; p = p->next, --i)
X {
X (*file)[i] = (char *) malloc(strlen(p->name) + 1);
X if ((*file)[i] == NULL)
X goto OUT_OF_MEMORY;
X strcpy((*file)[i], p->name);
X }
X }
XReturn:
X if (domatchend)
X MatchEnd(Anchor);
X if (Anchor)
X free(Anchor);
X freefiles();
X if (errmsg)
X {
X emsg(errmsg);
X *num_file = 0;
X return 1;
X }
X return 0;
X}
X
Xvoid


XFreeWild(num, file)
X int num;
X char **file;
X{

X if (file == NULL || num == 0)
X return;
X while (num--)
X free(file[num]);


X free(file);
X}
X
X int
Xhas_wildcard(p)

X char *p;
X{


X for ( ; *p; ++p)

X if (strchr("*?[(~#", *p) != NULL)


X return 1;
X return 0;
X}

X#endif /* WILD_CARDS */
X
X/*
X * With 2.0 support for reading local environment variables


X */
X
X char *

Xvimgetenv(var)
X char *var;


X{
X int len;
X

X#ifndef NO_ARP
X if (!dos2)
X return getenv(var);
X#endif
X
X len = GetVar((UBYTE *)var, (UBYTE *)IObuff, (long)(IOSIZE - 1), (long)0);


X
X if (len == -1)

X return NULL;
X else
X return IObuff;
X}
END_OF_FILE
if test 29917 -ne `wc -c <'vim/src/amiga.c'`; then
echo shar: \"'vim/src/amiga.c'\" unpacked with wrong size!
fi
# end of 'vim/src/amiga.c'
fi
echo shar: End of archive 17 \(of 23\).
cp /dev/null ark17isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:36:39 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 18
Archive-name: vim/part18
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 18 (of 23)."
# Contents: vim/src/regexp.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:12 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/regexp.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/regexp.c'\"
else
echo shar: Extracting \"'vim/src/regexp.c'\" \(39338 characters\)
sed "s/^X//" >'vim/src/regexp.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *
X * This is NOT the original regular expression code as written by
X * Henry Spencer. This code has been modified specifically for use
X * with the VIM editor, and should not be used apart from compiling
X * VIM. If you want a good regular expression library, get the
X * original code. The copyright notice that follows is from the
X * original.
X *
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *
X *

X * regcomp and regexec -- regsub and regerror are elsewhere
X *


X * Copyright (c) 1986 by University of Toronto.
X * Written by Henry Spencer. Not derived from licensed software.
X *
X * Permission is granted to anyone to use this software for any
X * purpose on any computer system, and to redistribute it freely,
X * subject to the following restrictions:

X *


X * 1. The author is not responsible for the consequences of use of
X * this software, no matter how awful, even if they arise
X * from defects in it.
X *
X * 2. The origin of this software must not be misrepresented, either
X * by explicit claim or by omission.
X *
X * 3. Altered versions must be plainly marked as such, and must not
X * be misrepresented as being the original software.
X *

X * Beware that some of this code is subtly aware of the way operator
X * precedence is structured in regular expressions. Serious changes in
X * regular-expression syntax might require a total rethink.
X *
X * $Log: regexp.c,v $
X * Revision 1.2 88/04/28 08:09:45 tony


X * First modification of the regexp library. Added an external variable
X * 'reg_ic' which can be set to indicate that case should be ignored.
X * Added a new parameter to regexec() to indicate that the given string
X * comes from the beginning of a line and is thus eligible to match

X * 'beginning-of-line'.
X *


X * Revisions by Olaf 'Rhialto' Seibert, rhi...@cs.kun.nl:
X * Changes for vi: (the semantics of several things were rather different)
X * - Added lexical analyzer, because in vi magicness of characters
X * is rather difficult, and may change over time.
X * - Added support for \< \> \1-\9 and ~
X * - Left some magic stuff in, but only backslashed: \| \+
X * - * and \+ still work after \) even though they shouldn't.
X */

X#include "vim.h"
X#include "globals.h"
X#include "proto.h"

X#undef DEBUG


X
X#include <stdio.h>
X#include "regexp.h"
X#include "regmagic.h"

X
X/*
X * The "internal use only" fields in regexp.h are present to pass info from
X * compile to execute that permits the execute phase to run lots faster on
X * simple cases. They are:
X *
X * regstart char that must begin a match; '\0' if none obvious
X * reganch is the match anchored (at beginning-of-line only)?
X * regmust string (pointer into program) that match must include, or NULL
X * regmlen length of regmust string
X *
X * Regstart and reganch permit very fast decisions on suitable starting points
X * for a match, cutting down the work a lot. Regmust permits fast rejection
X * of lines that cannot possibly match. The regmust tests are costly enough
X * that regcomp() supplies a regmust only if the r.e. contains something
X * potentially expensive (at present, the only such thing detected is * or +
X * at the start of the r.e., which can involve a lot of backup). Regmlen is
X * supplied because the test in regexec() needs it and regcomp() is computing
X * it anyway.
X */
X
X/*
X * Structure for regexp "program". This is essentially a linear encoding
X * of a nondeterministic finite-state machine (aka syntax charts or
X * "railroad normal form" in parsing technology). Each node is an opcode
X * plus a "next" pointer, possibly plus an operand. "Next" pointers of
X * all nodes except BRANCH implement concatenation; a "next" pointer with
X * a BRANCH on both ends of it is connecting two alternatives. (Here we
X * have one of the subtle syntax dependencies: an individual BRANCH (as
X * opposed to a collection of them) is never concatenated with anything
X * because of operator precedence.) The operand of some types of node is
X * a literal string; for others, it is a node leading into a sub-FSM. In
X * particular, the operand of a BRANCH node is the first node of the branch.
X * (NB this is *not* a tree structure: the tail of the branch connects
X * to the thing following the set of BRANCHes.) The opcodes are:
X */
X
X/* definition number opnd? meaning */
X#define END 0 /* no End of program. */
X#define BOL 1 /* no Match "" at beginning of line. */
X#define EOL 2 /* no Match "" at end of line. */
X#define ANY 3 /* no Match any one character. */
X#define ANYOF 4 /* str Match any character in this string. */
X#define ANYBUT 5 /* str Match any character not in this
X * string. */
X#define BRANCH 6 /* node Match this alternative, or the
X * next... */
X#define BACK 7 /* no Match "", "next" ptr points backward. */
X#define EXACTLY 8 /* str Match this string. */
X#define NOTHING 9 /* no Match empty string. */
X#define STAR 10 /* node Match this (simple) thing 0 or more
X * times. */
X#define PLUS 11 /* node Match this (simple) thing 1 or more
X * times. */
X#define BOW 12 /* no Match "" after [^a-zA-Z0-9_] */
X#define EOW 13 /* no Match "" at [^a-zA-Z0-9_] */
X#define MOPEN 20 /* no Mark this point in input as start of
X * #n. */
X /* MOPEN+1 is number 1, etc. */
X#define MCLOSE 30 /* no Analogous to MOPEN. */
X#define BACKREF 40 /* node Match same string again \1-\9 */
X
X#define Magic(x) ((x)|('\\'<<8))
X
X/*
X * Opcode notes:
X *
X * BRANCH The set of branches constituting a single choice are hooked
X * together with their "next" pointers, since precedence prevents
X * anything being concatenated to any individual branch. The
X * "next" pointer of the last BRANCH in a choice points to the
X * thing following the whole choice. This is also where the
X * final "next" pointer of each individual branch points; each
X * branch starts with the operand node of a BRANCH node.
X *
X * BACK Normal "next" pointers all implicitly point forward; BACK
X * exists to make loop structures possible.
X *
X * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
X * BRANCH structures using BACK. Simple cases (one character
X * per match) are implemented with STAR and PLUS for speed
X * and to minimize recursive plunges.
X *
X * MOPEN,MCLOSE ...are numbered at compile time.
X */
X
X/*
X * A node is one char of opcode followed by two chars of "next" pointer.
X * "Next" pointers are stored as two 8-bit pieces, high order first. The
X * value is a positive offset from the opcode of the node containing it.
X * An operand, if any, simply follows the node. (Note that much of the
X * code generation knows about this implicit relationship.)
X *
X * Using two bytes for the "next" pointer is vast overkill for most things,
X * but allows patterns to get big without disasters.
X */
X#define OP(p) (*(p))
X#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
X#define OPERAND(p) ((p) + 3)
X
X/*
X * See regmagic.h for one further detail of program structure.
X */
X
X
X/*
X * Utility definitions.
X */


X#ifndef CHARBITS
X#define UCHARAT(p) ((int)*(unsigned char *)(p))
X#else
X#define UCHARAT(p) ((int)*(p)&CHARBITS)
X#endif
X

X#define FAIL(m) { emsg(m); return NULL; }
X
Xstatic int ismult __ARGS((int));
X
X static int
Xismult(c)
X int c;
X{
X return (c == Magic('*') || c == Magic('+') || c == Magic('?'));
X}
X
X/*
X * Flags to be passed up and down.
X */
X#define HASWIDTH 01 /* Known never to match null string. */
X#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
X#define SPSTART 04 /* Starts with * or +. */
X#define WORST 0 /* Worst case. */
X
X/*
X * The following supports the ability to ignore case in searches.
X */
X
X#include <ctype.h>
X
Xint reg_ic = 0; /* set by callers to ignore case */
X
X/*
X * mkup - convert to upper case IF we're doing caseless compares
X */
X#ifdef __STDC__
X#define mkup(c) (reg_ic ? toupper(c) : (c))
X#else
X#define mkup(c) ((reg_ic && islower(c)) ? toupper(c) : (c))
X#endif
X
X/*
X * The following allows empty REs, meaning "the same as the previous RE".
X * per the ed(1) manual.
X */
X/* #define EMPTY_RE */ /* this is done outside of regexp */
X#ifdef EMTY_RE
Xchar *reg_prev_re;
X#endif
X
X#define TILDE
X#ifdef TILDE
Xchar *reg_prev_sub;
X#endif
X
X/*
X * This if for vi's "magic" mode. If magic is false, only ^$\ are magic.
X */
X
Xint reg_magic = 1;
X
X/*
X * Global work variables for regcomp().
X */
X
Xstatic unsigned char *regparse; /* Input-scan pointer. */
Xstatic int regnpar; /* () count. */
Xstatic char regdummy;
Xstatic char *regcode; /* Code-emit pointer; &regdummy = don't. */
Xstatic long regsize; /* Code size. */
Xstatic char **regendp; /* Ditto for endp. */
X
X/*
X * META contains all characters that may be magic, except '^' and '$'.
X * This depends on the configuration options TILDE, BACKREF.
X * (could be done simpler for compilers that know string concatenation)
X */
X
X#ifdef TILDE
X# ifdef BACKREF
X static char META[] = ".[()|?+*<>~123456789";
X# else
X static char META[] = ".[()|?+*<>~";
X# endif
X#else
X# ifdef BACKREF
X static char META[] = ".[()|?+*<>123456789";
X# else
X static char META[] = ".[()|?+*<>";
X# endif
X#endif
X
X/*
X * Forward declarations for regcomp()'s friends.
X */
Xstatic void initchr __ARGS((unsigned char *));
Xstatic int getchr __ARGS((void));
Xstatic int peekchr __ARGS((void));
Xstatic int peekpeekchr __ARGS((void));
X#define PeekChr() curchr /* shortcut only when last action was peekchr() */
Xstatic int curchr;
Xstatic void skipchr __ARGS((void));
Xstatic void ungetchr __ARGS((void));
Xstatic char *reg __ARGS((int, int *));
Xstatic char *regbranch __ARGS((int *));
Xstatic char *regpiece __ARGS((int *));
Xstatic char *regatom __ARGS((int *));
Xstatic char *regnode __ARGS((int));
Xstatic char *regnext __ARGS((char *));
Xstatic void regc __ARGS((int));
Xstatic void unregc __ARGS((void));
Xstatic void reginsert __ARGS((int, char *));
Xstatic void regtail __ARGS((char *, char *));
Xstatic void regoptail __ARGS((char *, char *));
X
X#undef STRCSPN
X#ifdef STRCSPN
Xstatic int strcspn __ARGS((const char *, const char *));
X#endif
Xstatic int cstrncmp __ARGS((char *, char *, int));
X
X/*
X - regcomp - compile a regular expression into internal code
X *
X * We can't allocate space until we know how big the compiled form will be,
X * but we can't compile it (and thus know how big it is) until we've got a
X * place to put the code. So we cheat: we compile it twice, once with code
X * generation turned off and size counting turned on, and once "for real".
X * This also means that we don't allocate space until we are sure that the
X * thing really will compile successfully, and we never have to move the
X * code and thus invalidate pointers into it. (Note that it has to be in
X * one piece because free() must be able to free it all.)
X *
X * Beware that the optimization-preparation code in here knows about some
X * of the structure of the compiled regexp.


X */
X regexp *

Xregcomp(exp)
X char *exp;
X{
X register regexp *r;
X register char *scan;
X register char *longest;
X register int len;
X int flags;
X/* extern char *malloc();*/
X
X if (exp == NULL) {
X FAIL(e_null);
X }
X
X#ifdef EMPTY_RE /* this is done outside of regexp */
X if (*exp == '\0') {
X if (reg_prev_re) {
X exp = reg_prev_re;
X } else {
X FAIL(e_noprevre);
X }
X }
X#endif
X
X /* First pass: determine size, legality. */
X initchr((unsigned char *)exp);
X regnpar = 1;
X regsize = 0L;
X regcode = &regdummy;
X regendp = NULL;
X regc(MAGIC);
X if (reg(0, &flags) == NULL)
X return NULL;
X
X /* Small enough for pointer-storage convention? */
X if (regsize >= 32767L) /* Probably could be 65535L. */
X FAIL(e_toolong);
X
X /* Allocate space. */
X/* r = (regexp *) malloc((unsigned) (sizeof(regexp) + regsize));*/
X r = (regexp *) alloc((unsigned) (sizeof(regexp) + regsize));
X if (r == NULL)
X FAIL(e_outofmem);
X
X#ifdef EMPTY_RE /* this is done outside of regexp */
X if (exp != reg_prev_re) {
X free(reg_prev_re);
X if (reg_prev_re = alloc(strlen(exp) + 1))
X strcpy(reg_prev_re, exp);
X }
X#endif
X
X /* Second pass: emit code. */
X initchr((unsigned char *)exp);
X regnpar = 1;
X regcode = r->program;
X regendp = r->endp;
X regc(MAGIC);
X if (reg(0, &flags) == NULL) {
X free(r);
X return NULL;
X }
X
X /* Dig out information for optimizations. */
X r->regstart = '\0'; /* Worst-case defaults. */
X r->reganch = 0;
X r->regmust = NULL;
X r->regmlen = 0;
X scan = r->program + 1; /* First BRANCH. */
X if (OP(regnext(scan)) == END) { /* Only one top-level choice. */
X scan = OPERAND(scan);
X
X /* Starting-point info. */
X if (OP(scan) == EXACTLY)
X r->regstart = *OPERAND(scan);
X else if (OP(scan) == BOL)
X r->reganch++;
X
X /*
X * If there's something expensive in the r.e., find the longest
X * literal string that must appear and make it the regmust. Resolve
X * ties in favor of later strings, since the regstart check works
X * with the beginning of the r.e. and avoiding duplication
X * strengthens checking. Not a strong reason, but sufficient in the
X * absence of others.
X */
X if (flags & SPSTART) {
X longest = NULL;
X len = 0;
X for (; scan != NULL; scan = regnext(scan))
X if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= (size_t)len) {
X longest = OPERAND(scan);
X len = strlen(OPERAND(scan));
X }
X r->regmust = longest;
X r->regmlen = len;
X }
X }
X#ifdef DEBUG
X regdump(r);
X#endif


X return r;
X}
X
X/*

X - reg - regular expression, i.e. main body or parenthesized thing
X *
X * Caller must absorb opening parenthesis.
X *
X * Combining parenthesis handling with the base level of regular expression
X * is a trifle forced, but the need to tie the tails of the branches to what
X * follows makes it hard to avoid.


X */
X static char *

Xreg(paren, flagp)
X int paren; /* Parenthesized? */
X int *flagp;
X{
X register char *ret;
X register char *br;
X register char *ender;
X register int parno = 0;
X int flags;
X
X *flagp = HASWIDTH; /* Tentatively. */
X
X /* Make an MOPEN node, if parenthesized. */
X if (paren) {
X if (regnpar >= NSUBEXP)
X FAIL(e_toombra);
X parno = regnpar;
X regnpar++;
X ret = regnode((char)(MOPEN + parno));
X if (regendp)
X regendp[parno] = NULL; /* haven't seen the close paren yet */
X } else
X ret = NULL;
X
X /* Pick up the branches, linking them together. */
X br = regbranch(&flags);
X if (br == NULL)
X return NULL;
X if (ret != NULL)
X regtail(ret, br); /* MOPEN -> first. */
X else
X ret = br;
X if (!(flags & HASWIDTH))
X *flagp &= ~HASWIDTH;
X *flagp |= flags & SPSTART;
X while (peekchr() == Magic('|')) {
X skipchr();
X br = regbranch(&flags);
X if (br == NULL)
X return NULL;
X regtail(ret, br); /* BRANCH -> BRANCH. */
X if (!(flags & HASWIDTH))
X *flagp &= ~HASWIDTH;
X *flagp |= flags & SPSTART;
X }
X
X /* Make a closing node, and hook it on the end. */
X ender = regnode((char)((paren) ? MCLOSE + parno : END));
X regtail(ret, ender);
X
X /* Hook the tails of the branches to the closing node. */
X for (br = ret; br != NULL; br = regnext(br))
X regoptail(br, ender);
X
X /* Check for proper termination. */
X if (paren && getchr() != Magic(')')) {
X FAIL(e_toombra);
X } else if (!paren && peekchr() != '\0') {
X if (PeekChr() == Magic(')')) {
X FAIL(e_toomket);
X } else
X FAIL(e_trailing);/* "Can't happen". */
X /* NOTREACHED */
X }
X /*
X * Here we set the flag allowing back references to this set of
X * parentheses.
X */
X if (paren && regendp)
X regendp[parno] = ender; /* have seen the close paren */
X return ret;
X}
X
X/*
X - regbranch - one alternative of an | operator
X *
X * Implements the concatenation operator.


X */
X static char *

Xregbranch(flagp)
X int *flagp;
X{
X register char *ret;
X register char *chain;
X register char *latest;
X int flags;
X
X *flagp = WORST; /* Tentatively. */
X
X ret = regnode(BRANCH);
X chain = NULL;
X while (peekchr() != '\0' && PeekChr() != Magic('|') && PeekChr() != Magic(')')) {
X latest = regpiece(&flags);
X if (latest == NULL)
X return NULL;
X *flagp |= flags & HASWIDTH;
X if (chain == NULL) /* First piece. */
X *flagp |= flags & SPSTART;
X else
X regtail(chain, latest);
X chain = latest;
X }
X if (chain == NULL) /* Loop ran zero times. */
X (void) regnode(NOTHING);
X
X return ret;
X}
X
X/*
X - regpiece - something followed by possible [*+?]
X *
X * Note that the branching code sequences used for ? and the general cases
X * of * and + are somewhat optimized: they use the same NOTHING node as
X * both the endmarker for their branch list and the body of the last branch.
X * It might seem that this node could be dispensed with entirely, but the
X * endmarker role is not redundant.
X */
Xstatic char *
Xregpiece(flagp)
X int *flagp;
X{
X register char *ret;
X register int op;
X register char *next;
X int flags;
X
X ret = regatom(&flags);
X if (ret == NULL)
X return NULL;
X
X op = peekchr();
X if (!ismult(op)) {
X *flagp = flags;
X return ret;
X }
X if (!(flags & HASWIDTH) && op != Magic('?'))
X FAIL("*+ operand could be empty");
X *flagp = (op != Magic('+')) ? (WORST | SPSTART) : (WORST | HASWIDTH);
X
X if (op == Magic('*') && (flags & SIMPLE))
X reginsert(STAR, ret);
X else if (op == Magic('*')) {
X /* Emit x* as (x&|), where & means "self". */
X reginsert(BRANCH, ret); /* Either x */
X regoptail(ret, regnode(BACK)); /* and loop */
X regoptail(ret, ret); /* back */
X regtail(ret, regnode(BRANCH)); /* or */
X regtail(ret, regnode(NOTHING)); /* null. */
X } else if (op == Magic('+') && (flags & SIMPLE))
X reginsert(PLUS, ret);
X else if (op == Magic('+')) {
X /* Emit x+ as x(&|), where & means "self". */
X next = regnode(BRANCH); /* Either */
X regtail(ret, next);
X regtail(regnode(BACK), ret); /* loop back */
X regtail(next, regnode(BRANCH)); /* or */
X regtail(ret, regnode(NOTHING)); /* null. */
X } else if (op == Magic('?')) {
X /* Emit x? as (x|) */
X reginsert(BRANCH, ret); /* Either x */
X regtail(ret, regnode(BRANCH)); /* or */
X next = regnode(NOTHING);/* null. */
X regtail(ret, next);
X regoptail(ret, next);
X }
X skipchr();
X if (ismult(peekchr()))
X FAIL("Nested *?+");
X
X return ret;
X}
X
X/*
X - regatom - the lowest level
X *
X * Optimization: gobbles an entire sequence of ordinary characters so that
X * it can turn them into a single node, which is smaller to store and
X * faster to run. Backslashed characters are exceptions, each becoming a
X * separate node; the code is simpler that way and it's not worth fixing.
X */
Xstatic char *
Xregatom(flagp)
X int *flagp;
X{
X register char *ret;
X int flags;
X
X *flagp = WORST; /* Tentatively. */
X
X switch (getchr()) {
X case Magic('^'):
X ret = regnode(BOL);
X break;
X case Magic('$'):
X ret = regnode(EOL);
X break;
X case Magic('<'):
X ret = regnode(BOW);
X break;
X case Magic('>'):
X ret = regnode(EOW);
X break;
X case Magic('.'):
X ret = regnode(ANY);
X *flagp |= HASWIDTH | SIMPLE;
X break;
X case Magic('['):{
X /*
X * In a character class, different parsing rules apply.
X * Not even \ is special anymore, nothing is.
X */
X if (*regparse == '^') { /* Complement of range. */
X ret = regnode(ANYBUT);
X regparse++;
X } else
X ret = regnode(ANYOF);
X if (*regparse == ']' || *regparse == '-')
X regc(*regparse++);
X while (*regparse != '\0' && *regparse != ']') {
X if (*regparse == '-') {
X regparse++;
X if (*regparse == ']' || *regparse == '\0')
X regc('-');
X else {
X register int class;
X register int classend;
X
X class = UCHARAT(regparse - 2) + 1;
X classend = UCHARAT(regparse);
X if (class > classend + 1)
X FAIL(e_invrange);
X for (; class <= classend; class++)
X regc((char)class);
X regparse++;
X }
X } else if (*regparse == '\\' && regparse[1]) {
X regparse++;
X regc(*regparse++);
X } else
X regc(*regparse++);
X }
X regc('\0');
X if (*regparse != ']')
X FAIL(e_toomsbra);
X skipchr(); /* let's be friends with the lexer again */
X *flagp |= HASWIDTH | SIMPLE;
X }
X break;
X case Magic('('):
X ret = reg(1, &flags);
X if (ret == NULL)
X return NULL;
X *flagp |= flags & (HASWIDTH | SPSTART);


X break;
X case '\0':

X case Magic('|'):
X case Magic(')'):
X FAIL(e_internal); /* Supposed to be caught earlier. */
X /* break; Not Reached */
X case Magic('?'):
X case Magic('+'):
X case Magic('*'):
X FAIL("?+* follows nothing");
X /* break; Not Reached */
X#ifdef TILDE
X case Magic('~'): /* previous substitute pattern */
X if (reg_prev_sub) {


X register char *p;
X

X ret = regnode(EXACTLY);
X p = reg_prev_sub;
X while (*p) {
X regc(*p++);
X }
X regc('\0');
X if (p - reg_prev_sub) {
X *flagp |= HASWIDTH;
X if ((p - reg_prev_sub) == 1)
X *flagp |= SIMPLE;
X }
X } else
X FAIL(e_nopresub);
X break;
X#endif
X#ifdef BACKREF
X case Magic('1'):
X case Magic('2'):
X case Magic('3'):
X case Magic('4'):
X case Magic('5'):
X case Magic('6'):
X case Magic('7'):
X case Magic('8'):
X case Magic('9'): {
X int refnum;
X
X ungetchr();
X refnum = getchr() - Magic('0');
X /*
X * Check if the back reference is legal. We use the parentheses
X * pointers to mark encountered close parentheses, but this
X * is only available in the second pass. Checking opens is
X * always possible.
X * Should also check that we don't refer to something that
X * is repeated (+*?): what instance of the repetition should
X * we match? TODO.
X */
X if (refnum < regnpar &&
X (regendp == NULL || regendp[refnum] != NULL))
X ret = regnode(BACKREF + refnum);
X else
X FAIL("Illegal back reference");
X }
X break;
X#endif
X default:{
X register int len;
X int chr;
X
X ungetchr();
X len = 0;
X ret = regnode(EXACTLY);
X while ((chr = peekchr()) != '\0' && (chr < Magic(0))) {
X /*
X * We have to check for a following '*', '+' or '?'.
X * In those cases we must have a node with a single character
X * (added by mool)
X */
X if (len != 0 && peekpeekchr())
X break;
X regc(chr);
X skipchr();
X len++;
X }
X#ifdef DEBUG
X if (len == 0)
X FAIL("Unexpected magic character; check META.");
X#endif
X if (len > 1 && ismult(chr))
X unregc(); /* Back off of *+? operand */
X regc('\0');
X *flagp |= HASWIDTH;
X if (len == 1)
X *flagp |= SIMPLE;
X }
X break;
X }
X
X return ret;
X}
X
X/*
X - regnode - emit a node
X */
Xstatic char * /* Location. */
Xregnode(op)
X int op;
X{
X register char *ret;


X register char *ptr;
X

X ret = regcode;
X if (ret == &regdummy) {
X regsize += 3;
X return ret;
X }
X ptr = ret;
X *ptr++ = op;
X *ptr++ = '\0'; /* Null "next" pointer. */
X *ptr++ = '\0';
X regcode = ptr;
X
X return ret;
X}
X
X/*
X - regc - emit (if appropriate) a byte of code
X */
Xstatic void
Xregc(b)
X int b;
X{
X if (regcode != &regdummy)
X *(u_char *)regcode++ = b;
X else
X regsize++;
X}
X
X/*
X - unregc - take back (if appropriate) a byte of code
X */
Xstatic void
Xunregc()
X{
X if (regcode != &regdummy)
X regcode--;
X else
X regsize--;
X}
X
X/*
X - reginsert - insert an operator in front of already-emitted operand
X *
X * Means relocating the operand.
X */
Xstatic void
Xreginsert(op, opnd)
X int op;
X char *opnd;
X{
X register char *src;
X register char *dst;
X register char *place;
X
X if (regcode == &regdummy) {
X regsize += 3;
X return;
X }
X src = regcode;
X regcode += 3;
X dst = regcode;
X while (src > opnd)
X *--dst = *--src;
X
X place = opnd; /* Op node, where operand used to be. */
X *place++ = op;
X *place++ = '\0';
X *place = '\0';
X}
X
X/*
X - regtail - set the next-pointer at the end of a node chain
X */
Xstatic void
Xregtail(p, val)
X char *p;
X char *val;
X{
X register char *scan;
X register char *temp;
X register int offset;
X
X if (p == &regdummy)
X return;
X
X /* Find last node. */
X scan = p;
X for (;;) {
X temp = regnext(scan);
X if (temp == NULL)
X break;
X scan = temp;
X }
X
X if (OP(scan) == BACK)
X offset = scan - val;
X else
X offset = val - scan;
X *(scan + 1) = (char) ((offset >> 8) & 0377);
X *(scan + 2) = (char) (offset & 0377);
X}
X
X/*
X - regoptail - regtail on operand of first argument; nop if operandless
X */
Xstatic void
Xregoptail(p, val)
X char *p;
X char *val;
X{
X /* "Operandless" and "op != BRANCH" are synonymous in practice. */
X if (p == NULL || p == &regdummy || OP(p) != BRANCH)
X return;
X regtail(OPERAND(p), val);
X}
X
X/*
X - getchr() - get the next character from the pattern. We know about
X * magic and such, so therefore we need a lexical analyzer.
X */
X
X/* static int curchr; */
Xstatic int prevchr;
X
Xstatic void
Xinitchr(str)
Xunsigned char *str;
X{
X regparse = str;
X curchr = prevchr = -1;
X}
X
Xstatic int
Xpeekchr()
X{
X if (curchr < 0) {
X switch (curchr = regparse[0]) {
X case '.':
X case '*':
X /* case '+':*/
X /* case '?':*/
X case '[':
X case '~':
X if (reg_magic)
X curchr = Magic(curchr);


X break;
X case '^':

X /* ^ is only magic as the very first character */
X if (prevchr < 0)
X curchr = Magic('^');
X break;
X case '$':
X /* $ is only magic as the very last character */
X if (!regparse[1])
X curchr = Magic('$');
X break;
X case '\\':
X regparse++;
X if (regparse[0] == NUL)
X curchr = '\\'; /* trailing '\' */
X else if (strchr(META, regparse[0]))
X {
X /*
X * META contains everything that may be magic sometimes, except
X * ^ and $ ("\^" and "\$" are never magic).
X * We now fetch the next character and toggle its magicness.
X * Therefore, \ is so meta-magic that it is not in META.
X */
X curchr = -1;
X peekchr();
X curchr ^= Magic(0);
X }
X else
X {
X /*
X * Next character can never be (made) magic?
X * Then backslashing it won't do anything.
X */
X curchr = regparse[0];
X }


X break;
X }
X }
X

X return curchr;
X}
X
X/*
X * return 1 if the character returned by peekchr() is followed by a '*', '+' or '?'
X */
Xstatic int
Xpeekpeekchr()
X{
X if (regparse[1] == '\\')
X {
X if ((!reg_magic && regparse[2] == '*') || regparse[2] == '+' || regparse[2] == '?')
X return 1;
X }
X else if (reg_magic && regparse[1] == '*')
X return 1;
X return 0;
X}
X
Xstatic void
Xskipchr()
X{
X regparse++;
X prevchr = curchr;
X curchr = -1;
X}
X
Xstatic int
Xgetchr()
X{
X int chr;
X
X chr = peekchr();
X skipchr();
X
X return chr;
X}
X
Xstatic void
Xungetchr()
X{
X curchr = prevchr;
X /*
X * Backup regparse as well; not because we will use what it points at,
X * but because skipchr() will bump it again.
X */
X regparse--;
X}
X
X/*
X * regexec and friends
X */
X
X/*
X * Global work variables for regexec().
X */
Xstatic char *reginput; /* String-input pointer. */
Xstatic char *regbol; /* Beginning of input, for ^ check. */
Xstatic char **regstartp; /* Pointer to startp array. */
X/* static char **regendp; */ /* Ditto for endp. */
X
X/*
X * Forwards.
X */
Xstatic int regtry __ARGS((regexp *, char *));
Xstatic int regmatch __ARGS((char *));
Xstatic int regrepeat __ARGS((char *));
X
X#ifdef DEBUG
Xint regnarrate = 1;
Xvoid regdump __ARGS((regexp *));
Xstatic char *regprop __ARGS((char *));
X#endif
X
X/*
X - regexec - match a regexp against a string
X */
Xint
Xregexec(prog, string, at_bol)
X register regexp *prog;
X register char *string;
X int at_bol;


X{
X register char *s;
X

X /* Be paranoid... */
X if (prog == NULL || string == NULL) {
X emsg(e_null);
X return 0;
X }
X /* Check validity of program. */


X if (UCHARAT(prog->program) != MAGIC) {

X emsg(e_re_corr);
X return 0;
X }
X /* If there is a "must appear" string, look for it. */
X if (prog->regmust != NULL) {
X s = string;
X while ((s = cstrchr(s, prog->regmust[0])) != NULL) {
X if (cstrncmp(s, prog->regmust, prog->regmlen) == 0)
X break; /* Found it. */
X s++;
X }
X if (s == NULL) /* Not present. */
X return 0;
X }
X /* Mark beginning of line for ^ . */
X if (at_bol)
X regbol = string; /* is possible to match bol */
X else
X regbol = NULL; /* we aren't there, so don't match it */
X
X /* Simplest case: anchored match need be tried only once. */
X if (prog->reganch)
X return regtry(prog, string);
X
X /* Messy cases: unanchored match. */
X s = string;
X if (prog->regstart != '\0')
X /* We know what char it must start with. */
X while ((s = cstrchr(s, prog->regstart)) != NULL) {
X if (regtry(prog, s))
X return 1;
X s++;
X }
X else
X /* We don't -- general case. */
X do {
X if (regtry(prog, s))
X return 1;
X } while (*s++ != '\0');
X
X /* Failure. */


X return 0;
X}
X

X/*
X - regtry - try match at specific point
X */
Xstatic int /* 0 failure, 1 success */
Xregtry(prog, string)
X regexp *prog;
X char *string;


X{
X register int i;

X register char **sp;
X register char **ep;
X
X reginput = string;
X regstartp = prog->startp;
X regendp = prog->endp;
X
X sp = prog->startp;
X ep = prog->endp;
X for (i = NSUBEXP; i > 0; i--) {
X *sp++ = NULL;
X *ep++ = NULL;
X }
X if (regmatch(prog->program + 1)) {
X prog->startp[0] = string;
X prog->endp[0] = reginput;


X return 1;
X } else

X return 0;
X}
X
X/*

X - regmatch - main matching routine
X *
X * Conceptually the strategy is simple: check to see whether the current
X * node matches, call self recursively to see whether the rest matches,
X * and then act accordingly. In practice we make some effort to avoid
X * recursion, in particular by going through "ordinary" nodes (that don't
X * need to know whether the rest of the match failed) by a loop instead of
X * by recursion.
X */
Xstatic int /* 0 failure, 1 success */
Xregmatch(prog)
X char *prog;
X{
X register char *scan; /* Current node. */
X char *next; /* Next node. */
X
X scan = prog;
X#ifdef DEBUG
X if (scan != NULL && regnarrate)
X fprintf(stderr, "%s(\n", regprop(scan));
X#endif
X while (scan != NULL) {
X#ifdef DEBUG
X if (regnarrate) {
X fprintf(stderr, "%s...\n", regprop(scan));
X }
X#endif
X next = regnext(scan);
X switch (OP(scan)) {
X case BOL:
X if (reginput != regbol)


X return 0;
X break;

X case EOL:
X if (*reginput != '\0')


X return 0;
X break;

X case BOW: /* \<word; reginput points to w */
X#define isidchar(x) (isalnum(x) || ((x) == '_'))
X if (reginput != regbol && isidchar(reginput[-1]))
X return 0;
X if (!reginput[0] || !isidchar(reginput[0]))


X return 0;
X break;

X case EOW: /* word\>; reginput points after d */
X if (reginput == regbol || !isidchar(reginput[-1]))
X return 0;
X if (reginput[0] && isidchar(reginput[0]))


X return 0;
X break;

X case ANY:
X if (*reginput == '\0')
X return 0;
X reginput++;
X break;
X case EXACTLY:{
X register int len;
X register char *opnd;
X
X opnd = OPERAND(scan);
X /* Inline the first character, for speed. */
X if (mkup(*opnd) != mkup(*reginput))
X return 0;
X len = strlen(opnd);
X if (len > 1 && cstrncmp(opnd, reginput, len) != 0)
X return 0;
X reginput += len;
X }
X break;
X case ANYOF:
X if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
X return 0;
X reginput++;
X break;
X case ANYBUT:
X if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
X return 0;
X reginput++;
X break;
X case NOTHING:
X break;
X case BACK:
X break;
X case MOPEN + 1:
X case MOPEN + 2:
X case MOPEN + 3:
X case MOPEN + 4:
X case MOPEN + 5:
X case MOPEN + 6:
X case MOPEN + 7:
X case MOPEN + 8:
X case MOPEN + 9:{
X register int no;
X register char *save;
X
X no = OP(scan) - MOPEN;
X save = regstartp[no];
X regstartp[no] = reginput; /* Tentatively */
X#ifdef DEBUG
X printf("MOPEN %d pre @'%s' ('%s' )'%s'\n",
X no, save,
X regstartp[no]? regstartp[no] : "NULL",
X regendp[no]? regendp[no] : "NULL");
X#endif
X
X if (regmatch(next)) {
X#ifdef DEBUG
X printf("MOPEN %d post @'%s' ('%s' )'%s'\n",
X no, save,
X regstartp[no]? regstartp[no] : "NULL",
X regendp[no]? regendp[no] : "NULL");
X#endif
X return 1;
X }
X regstartp[no] = save; /* We were wrong... */
X return 0;
X }
X /* break; Not Reached */
X case MCLOSE + 1:
X case MCLOSE + 2:
X case MCLOSE + 3:
X case MCLOSE + 4:
X case MCLOSE + 5:
X case MCLOSE + 6:
X case MCLOSE + 7:
X case MCLOSE + 8:
X case MCLOSE + 9:{
X register int no;
X register char *save;
X
X no = OP(scan) - MCLOSE;
X save = regendp[no];
X regendp[no] = reginput; /* Tentatively */
X#ifdef DEBUG
X printf("MCLOSE %d pre @'%s' ('%s' )'%s'\n",
X no, save,
X regstartp[no]? regstartp[no] : "NULL",
X regendp[no]? regendp[no] : "NULL");
X#endif
X
X if (regmatch(next)) {
X#ifdef DEBUG
X printf("MCLOSE %d post @'%s' ('%s' )'%s'\n",
X no, save,
X regstartp[no]? regstartp[no] : "NULL",
X regendp[no]? regendp[no] : "NULL");
X#endif
X return 1;
X }
X regendp[no] = save; /* We were wrong... */
X return 0;
X }
X /* break; Not Reached */
X#ifdef BACKREF
X case BACKREF + 1:
X case BACKREF + 2:
X case BACKREF + 3:
X case BACKREF + 4:
X case BACKREF + 5:
X case BACKREF + 6:
X case BACKREF + 7:
X case BACKREF + 8:
X case BACKREF + 9:{
X register int no;
X int len;
X
X no = OP(scan) - BACKREF;
X if (regendp[no] != NULL) {
X len = regendp[no] - regstartp[no];
X if (cstrncmp(regstartp[no], reginput, len) != 0)
X return 0;
X reginput += len;
X } else {
X /*emsg("backref to 0-repeat");*/
X /*return 0;*/
X }
X }
X break;
X#endif
X case BRANCH:{
X register char *save;
X
X if (OP(next) != BRANCH) /* No choice. */
X next = OPERAND(scan); /* Avoid recursion. */
X else {
X do {
X save = reginput;
X if (regmatch(OPERAND(scan)))
X return 1;
X reginput = save;
X scan = regnext(scan);
X } while (scan != NULL && OP(scan) == BRANCH);
X return 0;
X /* NOTREACHED */
X }
X }
X break;
X case STAR:
X case PLUS:{
X register char nextch;
X register int no;
X register char *save;
X register int min;
X
X /*
X * Lookahead to avoid useless match attempts when we know
X * what character comes next.
X */
X nextch = '\0';
X if (OP(next) == EXACTLY)
X nextch = *OPERAND(next);
X min = (OP(scan) == STAR) ? 0 : 1;
X save = reginput;
X no = regrepeat(OPERAND(scan));
X while (no >= min) {
X /* If it could work, try it. */
X if (nextch == '\0' || *reginput == nextch)
X if (regmatch(next))
X return 1;
X /* Couldn't or didn't -- back up. */
X no--;
X reginput = save + no;


X }
X return 0;
X }

X /* break; Not Reached */
X case END:
X return 1; /* Success! */
X /* break; Not Reached */
X default:


X emsg(e_re_corr);
X return 0;

X /* break; Not Reached */
X }
X
X scan = next;
X }
X
X /*
X * We get here only if there's trouble -- normally "case END" is the
X * terminating point.
X */
X emsg(e_re_corr);


X return 0;
X}
X
X/*

X - regrepeat - repeatedly match something simple, report how many
X */
Xstatic int
Xregrepeat(p)
X char *p;
X{
X register int count = 0;
X register char *scan;
X register char *opnd;
X
X scan = reginput;
X opnd = OPERAND(p);
X switch (OP(p)) {
X case ANY:
X count = strlen(scan);
X scan += count;
X break;
X case EXACTLY:
X while (mkup(*opnd) == mkup(*scan)) {
X count++;
X scan++;
X }
X break;
X case ANYOF:
X while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
X count++;
X scan++;
X }
X break;
X case ANYBUT:
X while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
X count++;
X scan++;
X }
X break;
X default: /* Oh dear. Called inappropriately. */
X emsg(e_re_corr);
X count = 0; /* Best compromise. */
X break;
X }
X reginput = scan;
X
X return count;
X}
X
X/*
X - regnext - dig the "next" pointer out of a node
X */
Xstatic char *
Xregnext(p)


X register char *p;
X{

X register int offset;
X
X if (p == &regdummy)
X return NULL;
X
X offset = NEXT(p);
X if (offset == 0)
X return NULL;
X
X if (OP(p) == BACK)
X return p - offset;
X else
X return p + offset;
X}
X
X#ifdef DEBUG
X
X/*
X - regdump - dump a regexp onto stdout in vaguely comprehensible form
X */
Xvoid
Xregdump(r)
X regexp *r;


X{
X register char *s;

X register char op = EXACTLY; /* Arbitrary non-END op. */
X register char *next;
X /*extern char *strchr();*/
X
X
X s = r->program + 1;
X while (op != END) { /* While that wasn't END last time... */
X op = OP(s);
X printf("%2d%s", s - r->program, regprop(s)); /* Where, what. */
X next = regnext(s);
X if (next == NULL) /* Next ptr. */
X printf("(0)");
X else
X printf("(%d)", (s - r->program) + (next - s));
X s += 3;
X if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
X /* Literal string, where present. */
X while (*s != '\0') {
X putchar(*s);
X s++;
X }
X s++;
X }
X putchar('\n');
X }
X
X /* Header fields of interest. */
X if (r->regstart != '\0')
X printf("start `%c' ", r->regstart);
X if (r->reganch)
X printf("anchored ");
X if (r->regmust != NULL)
X printf("must have \"%s\"", r->regmust);
X printf("\n");
X}
X
X/*
X - regprop - printable representation of opcode
X */
Xstatic char *
Xregprop(op)
X char *op;
X{
X register char *p;
X static char buf[50];
X
X (void) strcpy(buf, ":");
X
X switch (OP(op)) {
X case BOL:
X p = "BOL";
X break;
X case EOL:
X p = "EOL";
X break;
X case ANY:
X p = "ANY";
X break;
X case ANYOF:
X p = "ANYOF";
X break;
X case ANYBUT:
X p = "ANYBUT";
X break;
X case BRANCH:
X p = "BRANCH";
X break;
X case EXACTLY:
X p = "EXACTLY";
X break;
X case NOTHING:
X p = "NOTHING";
X break;
X case BACK:
X p = "BACK";
X break;
X case END:
X p = "END";
X break;
X case MOPEN + 1:
X case MOPEN + 2:
X case MOPEN + 3:
X case MOPEN + 4:
X case MOPEN + 5:
X case MOPEN + 6:
X case MOPEN + 7:
X case MOPEN + 8:
X case MOPEN + 9:
X sprintf(buf + strlen(buf), "MOPEN%d", OP(op) - MOPEN);
X p = NULL;
X break;
X case MCLOSE + 1:
X case MCLOSE + 2:
X case MCLOSE + 3:
X case MCLOSE + 4:
X case MCLOSE + 5:
X case MCLOSE + 6:
X case MCLOSE + 7:
X case MCLOSE + 8:
X case MCLOSE + 9:
X sprintf(buf + strlen(buf), "MCLOSE%d", OP(op) - MCLOSE);
X p = NULL;
X break;
X case BACKREF + 1:
X case BACKREF + 2:
X case BACKREF + 3:
X case BACKREF + 4:
X case BACKREF + 5:
X case BACKREF + 6:
X case BACKREF + 7:
X case BACKREF + 8:
X case BACKREF + 9:
X sprintf(buf + strlen(buf), "BACKREF%d", OP(op) - BACKREF);
X p = NULL;
X break;
X case STAR:
X p = "STAR";
X break;
X case PLUS:
X p = "PLUS";
X break;
X default:
X sprintf(buf + strlen(buf), "corrupt %d", OP(op));
X p = NULL;
X break;
X }
X if (p != NULL)
X (void) strcat(buf, p);
X return buf;
X}
X#endif
X
X/*
X * The following is provided for those people who do not have strcspn() in
X * their C libraries. They should get off their butts and do something
X * about it; at least one public-domain implementation of those (highly
X * useful) string routines has been published on Usenet.
X */
X#ifdef STRCSPN
X/*
X * strcspn - find length of initial segment of s1 consisting entirely
X * of characters not from s2


X */
X
Xstatic int

Xstrcspn(s1, s2)
X const char *s1;
X const char *s2;
X{
X register char *scan1;
X register char *scan2;


X register int count;
X

X count = 0;
X for (scan1 = s1; *scan1 != '\0'; scan1++) {
X for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */
X if (*scan1 == *scan2++)
X return count;
X count++;
X }
X return count;
X}
X#endif
X
X/*
X * Compare two strings, ignore case if reg_ic set.
X * Return 0 if strings match, non-zero otherwise.


X */
X static int

Xcstrncmp(s1, s2, n)
X char *s1, *s2;
X int n;
X{
X if (!reg_ic)
X return strncmp(s1, s2, (size_t)n);
X
X#ifndef UNIX
X return strnicmp(s1, s2, (size_t)n);
X#else
X# ifdef STRNCASECMP
X return strncasecmp(s1, s2, (size_t)n);
X# else
X while (n && *s1 && *s2)
X {
X if (mkup(*s1) != mkup(*s2))
X return 1;
X s1++;
X s2++;
X n--;
X }
X if (n)


X return 1;
X return 0;

X# endif /* STRNCASECMP */


X#endif /* UNIX */
X}
X

X char *
Xcstrchr(s, c)
X char *s;
X int c;
X{
X char *p;
X
X c = mkup(c);
X
X for (p = s; *p; p++)
X {
X if (mkup(*p) == c)
X return p;
X }
X return NULL;
X}
END_OF_FILE
if test 39338 -ne `wc -c <'vim/src/regexp.c'`; then
echo shar: \"'vim/src/regexp.c'\" unpacked with wrong size!
fi
# end of 'vim/src/regexp.c'
fi
echo shar: End of archive 18 \(of 23\).
cp /dev/null ark18isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:37:57 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 19
Archive-name: vim/part19
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 19 (of 23)."
# Contents: vim/doc/reference.doc3
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:13 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/reference.doc3' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/reference.doc3'\"
else
echo shar: Extracting \"'vim/doc/reference.doc3'\" \(41128 characters\)
sed "s/^X//" >'vim/doc/reference.doc3' <<'END_OF_FILE'
X
X:![!]{cmd} [!][arg] Execute {cmd} with the shell. The optional bangs are
X replaced with the previously given command. The
X optional [arg] is appended. See also the 'shell' and
X 'shelltype' option.
X
X:ve[rsion] Print the version number of the editor.
X
XK Run a program to lookup the identifier under the
X cursor. The name of the program is given with the
X 'keywordprg' (kp) option. The identifier is formed
X of letters, numbers and the underscore. The
X identifier under or right of the cursor is used. The
X same can be done with the command
X ":!{program} {identifier}".
X {not in Vi}
X
X
X 15. Repeating commands
X
X15.1 Single repeats
X
X. Repeat last change with count replaced by [cnt].
X
XSimple changes can be repeated with the '.' command. Without a count, the
Xcount of the last change is used. If you enter a count, it will replace the
Xlast one. If the last change included a specification of a numbered
Xregister, the register number will be incremented. See the section on undo
Xand redo for an example how to use this.
X
X
X15.2 Multiple repeats
X
X:[range]g[lobal]/{pattern}/[cmd]
X Execute the Ex command [cmd] (default ":p") on the
X lines within [range] where {pattern} matches.
X
X:[range]g[lobal]!/{pattern}/[cmd]
X Execute the Ex command [cmd] (default ":p") on the
X lines within [range] where {pattern} does NOT match.
X
X:[range]v[global]/{pattern}/[cmd]
X Same as :g!.
X
XThe global commands work by first scanning through the [range] lines and
Xmarking each line where a match occurs. In a second scan the [cmd] is
Xexecuted for each marked line with its line number prepended. If a line is
Xchanged or deleted its mark disappears. The default for [range] is the whole
Xbuffer (1,$). Use "CTRL-C" to interrupt the command.
X
XTo repeat a non-Ex command, you will have to put the command in a file and
Xuse "source!". For example:
X :g/pat/so! scriptfile
XMake sure that the scriptfile ends with a whole command, otherwise Vim will
Xwait for you to type the rest of the command for each match. The screen will
Xnot have been updated, so you don't know what you are doing.
X
XThe undo/redo command will undo/redo the whole global command at once.
X
X
X15.3 Complex repeats
X
Xv<a-zA-Z> Record typed characters into named register <a-zA-Z>
X (uppercase to append).
X
Xv Stops recording. {Vi: no recording}
X
X@<a-z> Execute the contents of named register <a-z> [cnt]
X times.
X
X@@ Repeat the previous @<a-z> [cnt] times.
X
X:@<a-z> Execute the contents of named register <a-z> as an
X Ex command. {Vi: only in some versions}
X
X:@@ Repeat the previous :@<a-z>. {Vi: only in some
X versions}
X
X:so[urce] {file} Read Ex commands from {file}.
X
X:so[urce]! {file} Read VIM commands from {file}. {not in Vi}
X
XAll commands and command sequences can be repeated by putting them in a named
Xregister and then executing it. There are two ways to get the commands in the
Xregister:
X- Use the record command. You type the commands once, and while they are
X being executed they are stored in a register. Easy, because you can see
X what you are doing. If you make a mistake, 'put' the register into the
X file, edit the command sequence, and then delete it into the register
X again. You can continue recording by appending to the register (use an
X uppercase letter).
X- Delete or yank the command sequence into the register.
X
XOften used command sequences can be put under a function key with the ':map'
Xcommand.
X
XAn alternative is to put the commands in a file, and execute them with the
X':source!' command. Useful for long command sequences. Can be combined with
Xthe ':map' command to put complicated commands under a funcion key.
X
XThe ':source' command reads Ex commands from a file line by line. You will
Xhave to type any needed keyboard input. The ':source!' command reads from a
Xscript file character by character, interpreting each character as if you
Xtyped it.
X
XExample: When you give the ":!ls" command you are asked to "hit return to
Xcontinue". If you ':source' a file with the line "!ls" in it, you will have
Xto type the return yourself. But if you ':source!' a file with the line
X":!ls" in it, the next characters from that file are read until a <CR> is
Xfound. You will not have to type <CR> yourself, unless ":!ls" was the last
Xline in the file.
X
XIt is possible to put ':source[!]' commands in the script file, so you can
Xmake a top-down hierachy of script files. The ':source' command can be
Xnested as deep as the number of files that can be opened at one time (about
X15). The ':source!' command can be nested up to 15 levels deep.
X
XIn script files terminal-dependent key codes are represented by
Xterminal-independent single character codes:
X
X code hex meaning
X
X 128 0x80 up-arrow
X 129 0x81 down-arrow
X 130 0x82 left-arrow
X 131 0x83 right-arrow
X 132 0x84 shift up-arrow
X 133 0x85 shift down-arrow
X 134 0x86 shift left-arrow
X 135 0x87 shift right-arrow
X
X 136 0x88 function key 1
X 137 0x89 function key 2
X 138 0x8a function key 3
X 139 0x8b function key 4
X 140 0x8c function key 5
X 141 0x8d function key 6
X 142 0x8e function key 7
X 143 0x8f function key 8
X 144 0x90 function key 9
X 145 0x91 function key 10
X
X 146 0x92 shifted function key 1
X 147 0x93 shifted function key 2
X 148 0x94 shifted function key 3
X 149 0x95 shifted function key 4
X 150 0x96 shifted function key 5
X 151 0x97 shifted function key 6
X 152 0x98 shifted function key 7
X 153 0x99 shifted function key 8
X 154 0x9a shifted function key 9
X 155 0x9b shifted function key 10
X
X 156 0x9c help key
X 157 0x9d undo key
X 158 0x9e CTRL-@
X
X
X 16. Undo and redo
X
X<UNDO> or
Xu Undo [cnt] changes. {Vi: only one level}
X
X:u[ndo] Undo one change. {Vi: only one level}
X
XCTRL-R Redo [cnt] changes which were undone with 'u'. {Vi:
X redraw screen}
X
XU Undo all latest changes on one line. {Vi: while not
X moved off of it}
X
XThe last changes are remembered. You can go back in time with the 'u'
Xcommand. You can then go forward again with the 'CTRL-R' command. If you
Xmake a new change after the 'u' command, the 'CTRL-R' will not be possible
Xanymore. The number of changes that are remembered is set with the
X'undolevels' option. If it is zero, the old fashioned Vi undo is present:
Xone level of undo and undo undoes itself.
X
XThe 'U' command is treated by undo/redo just like any other command. Thus a
X'u' command undos a 'U' command and a 'CTRL-R' command redoes it again. When
Xmixing 'U', 'u' and 'CTRL-R' you will notice that the 'U' command will
Xrestore the situation of a line to before the previous 'U' command. This may
Xbe confusing. Try it out to get used to it.
X
XThe numbered registers can also be used for undoing deletes. Each time you
Xdelete text, it is put into register "1. The contents of register "1 is
Xshifted to "2, etc. The contents of register "9 is lost. You can now get
Xback the most recent deleted text with the put command: '"1P'. You can get
Xback the text of three deletes ago with '"3P'.
X
XIf you want to get back more than one part of deleted text, you can use a
Xspecial feature of the repeat command '.'. It will increase the number of the
Xregister used. So if you first do '"1P', the following '.' will result in a
X'"2P'. Repeating this will result in all numbered registers to be inserted.
X
XExample: If you deleted text with 'dd....' it can be restored with
X '"1P....'.
X
XIf you don't know in which register the deleted text is, you can use the
X:display command. An alternative is to try the first register with '"1P', and
Xif it is not what you want do 'u.'. This will result in the contents of the
Xfirst put to be removed, and a repeat of the put command for the second
Xregister. Repeat the 'u.' until you got what you want.
X
X
X 17. Key mapping
X
X:map {lhs} {rhs} Map the key sequence {lhs} to {rhs} in normal mode.
X
X:map! {lhs} {rhs} Map the key sequence {lhs} to {rhs} in insert and
X command line mode.
X
X:noremap {lhs} {rhs} Map the key sequence {lhs} to {rhs} in normal mode.
X Disallow remapping of {rhs}. {not in Vi}
X
X:noremap! {lhs} {rhs} Map the key sequence {lhs} to {rhs} in insert and
X command line mode. Disallow remapping of {rhs}. {not
X in Vi}
X
X:unm[ap] {lhs} Remove the mapping of {lhs} for normal mode.
X
X:unm[ap]! {lhs} Remove the mapping of {lhs} for insert and command
X line mode.
X
X:map List all key mappings for normal mode.
X
X:map! List all key mappings for insert and command line
X mode.
X
X:map {lhs} List the key mappings for the key sequences starting
X with {lhs} in normal mode.
X
X:map! {lhs} List the key mappings for the key sequences starting
X with {lhs} in insert and command line mode.
X
XThese commands are used to map a key or key sequence to a string of
Xcharacters. You can use this to put command sequences under function keys,
Xtranslate one key into another, etc. See the "Options" chapter below for how
Xto save and restore the current mapping.
X
XEverything from the first non-blank after {lhs} upto the end of the line (or
X<|>) is considered to be part of {rhs}. This allows the {rhs} to end with a
Xspace.
X
XTo include a space in {lhs} precede it with a CTRL-V (type two CTRL-Vs for
Xeach space). If you want a {rhs} that starts with a space, precede {rhs}
Xwith a single CTRL-V (You have to type CTRL-V two times). You can create an
Xempty {rhs} by typing nothing after the two CTRL-Vs.
X
XIt is not possible to put a comment after this command, because the <">
Xcharacter is considered to be part of the {rhs}. To put a <|> in {rhs}
Xescape it with a backslash or a CTRL-V (to get one CTRL-V you have to type
Xit twice).
X
XTo avoid mapping of the characters you type in insert or comand line mode,
Xtype a CTRL-V first.
X
XNote that the second character (argument) of the commands @zZtTfF[]rm'`"v is
Xnot mapped. This was probably done to be able to use all the named registers
Xand marks, even when the command with the same name has been mapped.
X
XSome examples (given as you type them; e.g. the "^V" is CTRL-V which you
Xtype, but will not show up on the screen):
X
X :map g /foo^V^Mcwbar^V^[ (replace next "foo" by "bar")
X :map! qq quadrillion questions
X
XVim will compare what you type with the start of a mapped sequence. If there
Xis an incomplete match, it will get more characters until there either is a
Xcomplete match or until there is no match at all. Example: If you map! "qq",
Xthe first <q> will not appear on the screen until you type another
Xcharacter. This is because Vim cannot know if the next character will be a
X<q> or not. If you set the 'timeout' option (which is the default) Vim will
Xonly wait for one second. After that it assumes that the "q" is to be
Xinterpreted as such. If type slowly, or your system is slow, reset the
X'timeout' option. Then you might want to set the 'ttimeout' option. See the
X"Options" chapter.
X
XIf you want to exchange the meaning of two keys you should use the :noremap
Xcommand. For example:
X :noremap k j
X :noremap j k
XThis will exchange the cursor up and down commands. With the normal :map
Xcommand, when the 'remap' option is set, mapping takes place until the text
Xis found not to be a part of a {lhs}. For example, if you use:
X :map x y
X :map y x
XVim will replace x by y, and then y by x, etc. When this has happened 1000
Xtimes, Vim will give an error message.
X
XSee the file "index" for keys that are not used and thus can be mapped
Xwithout loosing any builtin function.
X
X
X 18. Recovery after a crash.
X
XYou have spent several hours typing in that text that has to be finished
Xnext morning, and then disaster strikes: Your computer crashes.
X
X DON'T PANIC!
X
X
X18.1 The autoscript file
X
XVim keeps track of everything you type. Using the original file you started
Xfrom and the autoscript file you can recover (almost) all of your work.
X
XThe name of the autoscript file is the same as the file you are editing,
Xwith the extension ".vim". On MSDOS machines and when the 'shortname' option
Xis set, any '.' is replaced by '_'. If this file already exists (e.g. when
Xyou are recovering from a crash) a warning is given and another extention is
Xused, ".vil", ".vik", etc. An existing file will never be overwritten. The
Xfile is deleted as soon as the edited text is successfully written to disk.
X
XTechnical: The replacement of '.' by '_' is done to avoid problems with
X MSDOS compatible filesystems (e.g. crossdos, multidos). If Vim is
X able to detect that the file is on an MSDOS-like filesystem, a
X flag is set that has the same effect as the 'shortname' option.
X This flag is reset when you start editing another file.
X
X If the ".vim" filename already exists, the last character is
X decremented until there is no file with that name or ".via" is
X reached. In the last case, no autoscript file is created.
X
XBy setting the 'directory' option you can place the file in another
Xplace than where the edited file is. It is adviced to put the autoscript
Xfiles on a "scratch" partition. This reduces the risc of damaging the
Xpartition where the edited file is. You can also use a recoverable ram disk,
Xbut there is no 100% guarantee that this works. Putting it in RAM: makes no
Xsense, you will loose it in a crash. Put a command resembling the following
Xone in s:.exrc:
X :set dir=dh2:tmp/
XThis is also very handy when editing files on floppy.
X
XThe autoscript file is updated after typing 100 characters or when you have
Xnot typed anything for two seconds. This only happens if the buffer was
Xchanged, not when you only moved around. The reason why it is not kept up to
Xdate all the time is that this would slow down normal work too much. You can
Xchange the 100 character count with the 'updatecount' option. You can set
Xthe time with the 'updatetime' option. The time is given in milliseconds.
X
XIf the writing to the autoscript file is not wanted, it can be switched off
Xby setting the 'updatecount' option to 0. The same is done when starting Vim
Xwith the "-n" or "-v" option. Writing can be switched back on by setting the
X'updatecount' option to non-zero. If you have changed the buffer when
Xswitching on, the autoscript file will be incomplete and recovery will
Xprobably fail. To avoid this write out the buffer with ":w" before switching
Xon the autoscript file.
X
X
X18.2 Recovery
X
XIn most cases recovery is quite easy: start Vim on the same file you were
Xediting when the crash happened, with the "-r" option added. Vim will start
Xediting the file using the key strokes in the autoscript file. Be sure that
Xthe recovery was successful before overwriting the original file or deleting
Xthe autoscript file.
X
XExample: vim -r reference.doc
X
XImportant: The .exrc file must be the same as with the original edit session,
Xbecause some options have effect on the editing. Also the window size must be
Xexactly the same, because the cursor movement resulting from some commands
Xdepends on the window size (e.g. CTRL-F). To help you with that the window
Xresizing events are written into the script file with ":winsize" commands.
XThe result of this command is that Vim will resize the used part of the
Xwindow, but the window itself will remain the same size. The commands will
Xbe executed correctly, but the window contents may look disturbed. During
Xnormal editing you should not use the ":winsize" command. Use the window
Xresizing gadget in the lower right corner of the window. Do not resize the
Xwindow during recovery!
X
XIn some cases the "-r" option does not result in successful recovery. This
Xhappens when you executed a command that cannot be reproduced anymore. For
Xexample: Reading a file which does not exist anymore. In such a case the
Xsucceeding commands probably only make things worse. To solve this you will
Xhave to edit the autoscript file and remove the commands that cause errors.
XIf this becomes difficult try splitting up the autoscript file in small
Xpieces. {Vi: recovers in another way that has a larger change to succeed but
Xcauses more overhead}
X
XIf the autoscript file is not ending in ".vim" but in something else, you can
Xuse the script reading option "-s {filename}". This will have (almost) the
Xsame effect as the "-r" option. This is also handy when the script file is
Xin another directory than expected.
X
XYou can give the "-r" option in combination with the "-s scriptin" option.
XThe scriptin file will be read first, then the autoscript file for recovery.
X
XThe difference between using the "-r" option and the "-s" option is that with
Xthe "-r" option the name of the script file is made from the file name, and
Xthe last modification date is checked to see if the autoscript file is
Xnewer. This prevents the wrong autoscript file to be used for a recovery.
X
X
X 19. Options
X
XVi has a number of internal variables and switches which can be set to
Xachieve special effects. These options come in three forms, those that are
Xswitches, which toggle from off to on and back, those that require a numeric
Xvalue, and those that require an alphanumeric string value.
X
X
X19.1 Setting options
X
X:se[t] Show all modified options. {Vi: non-default options}
X
X:se[t] all Show all but terminal options.
X
X:se[t] termcap Show all terminal options.
X
X:se[t] {option} Set toggle option on, show value of string or number
X option.
X
X:se[t] no{option} Set toggle option off.
X
X:se[t] inv{option} Invert toggle option. {not in Vi}
X
X:se[t] {option}={value} Set string or number option to {value}.
X
X:se[t] {option}? Show value of {option}.
X
XThe arguments to ":set" may be repeated. For example:
X":set ai nosi sw=3 ts=3". If you make an error in one of the arguments an
Xerror message will be given and the text upto the next space will be
Xskipped. Thus following arguments will be processed.
X
XBesides changing options with the ":set" command, there are four
Xalternatives to set options automatically for one or more files. The first
Xand second ones are used for all files. The third is used to set options for
Xthe files in one directory. The last is used to set options for a single
Xfile. The first three are done when you start VIM, in the given order. The
Xlast is done whenever you start editing a new file.
X
X1. The environment variable VIMINIT is read for an Ex command. You can set
X VIMINIT to something like "set noai sw=3" to set options.
X2. Only if there is no VIMINIT environment variable, the file
X "s:.vimrc" is read for Ex commands. You can include set commands in this
X file. (see below for how to automatically create a file with set commands).
X3. If VIMINIT is not found and "s:.vimrc" does not exist, EXINIT is used,
X in the same way as VIMINIT.
X4. If VIMINIT is not found, "s:.vimrc" does not exist and EXINIT is not found,
X the file "s:.exrc" is read for Ex commands.
X5. The file ".vimrc" in the current directory is read for Ex commands. You
X can include set commands in this file. If this file is not found the file
X ".exrc" is tried.
X6. If you start editing a new file, a number of lines at the beginning and
X end of the file are checked for the string "vi:" or "ex:". The text after
X it is considered to be the arguments for a ":set" command, separated with
X colons. For example: "vi:noai:sw=3".
X How many lines are checked depends on the 'modelines' option.
X The string "vi:" or "ex:" must be preceded with a blank or begin at the
X start of a line. This minimizes the chance that a normal word like "lex:"
X is catched. Note that all of the rest of the line is used, thus a line
X like: "/* vi:ts=4: */" will give an error message for the trailing "*/".
X
X
X19.2 Saving settings
X
X:mkexrc [file] Write current key mappings and changed options to
X [file] (default ".exrc"), unless it already exists.
X {not in Vi}
X
X:mkexrc! [file] Always write current key mappings and changed
X options to [file] (default ".exrc"). {not in Vi}
X
X:mkvimrc[!] [file] Same as :mkexrc, but default is ".vimrc". {not in
X Vi}
X
XThese commands will write ":map" and ":set" commands to a file, in such a
Xway that when these commands are executed, the current key mappings and
Xoptions will be set again. A common method is to use a default ".exrc" file
Xby first reading one in with ":source s:.exrc.Cprogs", change the settings
Xand then save them in the current directory with ":mkexrc!".
X
X
X19.3 Options summary
X
XIn the list below all the options are mentioned with their full name and some
Xwith an abbreviation between brackets. Both forms may be used.
X
Xautoindent (ai) toggle (default off)
X Copy indent from current line when starting a new line (typing <CR>
X in insert mode or when using the 'o' or 'O' command). If you do not
X type anything on the new line except <BS> and then type <ESC> or
X <CR>, the indent is deleted again. When autoindent is set,
X formatting (with the 'V' command or when you reach 'textwidth' in
X insert mode) uses the indent of the first line.
X
Xautowrite (aw) toggle (default off)
X Write the contents of the file, if it has been modified, on each
X :next, :rewind, :previous, :stop, :tag, :!, CTRL-] and CTRL-^
X command.
X
Xbackspace (bs) number (default 0)
X Influences the working of <BS>, <DEL>, CTRL-W and CTRL-U in insert
X mode. If set to 0 Vi compatible backspacing is used. When 1 allow
X backspacing over newlines. When larger than 1 allow backspacing over
X the start of insert. In the last case CTRL-W and CTRL-U stop once at
X the start of insert. {not in Vi}
X
Xbackup (bk) toggle (default on)
X Make a backup before overwriting a file. Leave it around after the
X file has been succesfully written. If you do not want to keep the
X backup file, but you do want a backup while it is being written, use
X the 'writebackup' option. If you do not want a backup file at all
X reset both options. {not in Vi}
X
Xbackupdir (bdir) string (default "~/")
X For Unix systems only. Name of the directory where the backup file
X is put when it cannot be created in the same directory as the
X original file. {not in Vi}
X
Xcolumns number (default 80)
X Number of columns in the display. Normally this is set by the
X terminal initialization and does not have to be set by hand. {not in
X Vi}
X
Xcompatible (cp) toggle (default off)
X At the moment this option is set, several other options will be set
X or reset to make Vim vi-compatible. Switching this option off has no
X effect. {not in Vi}
X
X option new value effect
X
X backspace 0 normal backspace
X backup off no backup file
X digraph off no digraphs
X expandtab off tabs not expanded to spaces
X history 0 no commandline history
X insertmode off do not start in insert mode
X joinspaces on insert 2 spaces after period
X modelines 0 no modelines
X repdel on in replace mode del deletes a char
X ruler off no ruler
X scrolljump 0 no jump scroll
X shiftround off indent not rounded to shiftwidth
X showcommand off command characters not shown
X showmode off current mode not shown
X smartindent off no smart indentation
X textwidth 9999 maximum text width
X tildeop off tilde is not an operator
X ttimeout off no terminal timeout
X undolevels 0 no multilevel undo
X updatecount 0 no autoscript file
X writebackup off no backup file written
X yankendofline off do not Yank to end of line
X
Xdigraph (dg) toggle (default off)
X Enable the entering of digraphs in input mode with {char1} <BS>
X {char2}. Only works if Vim was compiled with digraphs enabled. {not
X in Vi}
X
Xdirectory (dir) string (default "")
X Directory for the autoscript file. Empty means in same directory as
X the edited file. The name must end in an ':' or '/'. {Vi: directory
X to put temp file in, defaults to "/tmp"}
X
Xequalprg (ep) string (default "indent")
X External program to use for '=' command. {not in Vi}
X
Xerrorbells (eb) toggle (default off)
X Ring the bell for error messages. Does not work on the Amiga, you
X always get a screen flash.
X
Xerrorfile (ef) string (default "AztecC.Err")
X Name of the error file for the QuickFix option (see 5.5). {not in
X Vi}
X
Xexpandtab (et) toggle (default off)
X In insert mode: Use the appropriate number of spaces to insert a
X <TAB>. {not in Vi}
X
Xgraphic (gr) toggle (default off, MSDOS: on)
X When off characters between '~' and 0xa0 are displayed as "~?",
X "~@", "~A", etc.. When on the characters are sent to the display
X directly. This will allow for graphic characters to be shown on some
X terminals (e.g. MSDOS console) and mess up the display on others
X (e.g. Amiga).
X
Xhelpfile (hf) string (default "vim:vim.hlp")
X Name of the help file. It may start with an environment variable.
X For example: "$VIM/doc/vim.hlp". {not in Vi}
X
Xhistory (hi) number (default 20)
X Number of command lines that are remembered. {not in Vi}
X
Xignorecase (ic) toggle (default off)
X Ignore case in search patterns.
X
Xinsertmode (im) toggle (default off)
X Start the edit of a file in insert mode. {not in Vi}
X
Xjoinspaces (js) toggle (default on)
X Insert two spaces after a period with a join command. {not in Vi}
X
Xkeywordprg (kp) string (default "ref")
X Program to use for the 'K' command. {not in Vi}
X
Xlines number (default 25)
X Number of lines in the display. Normally you don't need to set this.
X That is done automatically by the terminal initialization code.
X
Xlist toggle (default off)
X List mode: Show tabs as CTRL-I, show end of line with $. Useful to
X see the difference between tabs and spaces and for trailing blanks.
X
Xmagic toggle (default on)
X Changes the special characters that can be used in search patterns.
X See section "Pattern searches".
X
Xmodelines (ml) number (default 5)
X The number of lines that is checked for set commands. See 19.1. {not
X in Vi}
X
Xnumber (nu) toggle (default off)
X Print the line number in front of each line.
X
Xparagraphs (para) string (default "IPLPPPQPP LIpplpipbp")
X Specifies the nroff macros that separate paragraphs. These are pairs
X of two letters.
X
Xreadonly (ro) toggle (default off)
X If set, writes fail unless you use an !. Affects anything that writes
X to protect you from accidental overwriting a file. Default on when
X vim is started in view mode ("vim -v").
X
Xremap toggle (default on)
X Allows for :map command to work recursively. If you do not want this
X for a single entry, use the :noremap command.
X
Xrepdel (rd) toggle (default on)
X When on, <DEL>, <BS>, CTRL-W and CTRL-U in replace mode delete
X characters. When off, only the cursor is moved, and no characters
X are deleted. {not in Vi}
X
Xreport number (default 2)
X Threshold for reporting number of lines changed.
X
Xruler (ru) toggle (default off)
X Show the line number and column of the cursor in the status line,
X separated by a comma. {not in Vi}
X
Xscroll number (default 12)
X Number of lines to scroll with CTRL-U and CTRL-D commands.
X
Xscrolljump number (default 1)
X Minimal number of lines to scroll when the cursor gets off the
X screen (e.g. with 'j'). Not used for scroll commands (e.g. CTRL-E,
X CTRL-D). Useful if your terminal scrolls very slow. {not in Vi}
X
Xsections string (default "SHNHH HUnhsh")
X Specifies the nroff macros that separate sections. These are pairs of
X two letters.
X
Xshell (sh) string (default "sh", MSDOS: "command")
X Name of the shell to use for ! and :! commands. See also the
X 'shelltype' option. It is allowed to give an argument to the
X command, e.g. "csh -f". If you type this in the command line you
X will have to put a backslash in front of the space.
X
Xshelltype (st) number (default 0)
X On the Amiga this option influences the way how the commands work
X which use a shell.
X 0 and 1: always use the shell
X 2 and 3: use the shell only to filter lines
X 4 and 5: use shell only for ':sh' command
X When not using the shell, the command is executed directly.
X
X 0 and 2: use 'shell -c cmd' to start external commands
X 1 and 3: use 'shell cmd' to start external commands
X
Xshiftround (sr) toggle (default off)
X Round indent to multiple of shiftwidth. Applies to > and < commands
X and to CTRL-T and CTRL-D in insert mode. {not in Vi}
X
Xshiftwidth (sw) number (default 8)
X Number of spaces to use for (auto)indent.
X
Xshortname (sn) toggle (default off)
X Filenames can be 8 characters plus one extention of 3 characters.
X Multiple dots in file names are not allowed. When this option is on,
X dots in filenames are replaced by underscores when adding an
X extention (".bak" or ".vim"). This option is not available for
X MSDOS, because then it would always be on. This option is useful
X when editing files on an MSDOS compatible filesystem, e.g. messydos
X or crossdos. {not in Vi}
X
Xshowcmd (sc) toggle (default on)
X show command in status line. Set this option off if your terminal
X is slow. {not in Vi}
X
Xshowmatch (sm) toggle (default off)
X When a bracket is inserted, briefly jump to the matching one.
X
Xshowmode (mo) toggle (default on)
X If in insert or replace mode, put a message on the last line.
X
Xsmartindent (si) toggle (default off)
X Do smart autoindenting in insert mode for C programs. Insert or
X delete indents at appropriate places. {not in Vi}
X
Xsuffixes (su) string (default ".bak.o.h.info.vim")
X Files with these suffixes are ignored when multiple files match a
X wildcard.
X
Xtabstop (ts) number (default 8)
X Number of spaces that a <TAB> in the file counts for.
X
Xtaglength (tl) number (default 0)
X If non-zero, tags are significant upto this number of characters.
X
Xtags string (default "tags")
X Filenames for the tag command, separated by spaces. {Vi: default is
X "tags /usr/lib/tags"}
X
Xterm string (default "amiga")
X Name of the terminal. Used for choosing the terminal control
X characters.
X
Xterse toggle (default on)
X Ignored. {Vi: shorten the error messages}
X
Xtildeop (to) toggle (default off)
X The tilde command <~> behaves like an operator. {not in Vi}
X
Xtimeout toggle (default on)
Xttimeout toggle (default off)
X These two options together determine the behaviour when part of a
X mapped key sequence or keyboard code has been received:
X
X timeout ttimeout action
X off off no time out
X on on or off time out on :mappings and key codes
X off on time out on key codes
X
X If there is no time out, Vim will wait until either the complete
X mapping or key sequence has been received, or it is clear that there
X is no mapping or key sequence for the received characters. For
X example: if you have mapped "vl" and Vim has received "v", the next
X character is needed to see if the "v" is followed by an "l". With a
X time out Vim will wait for about 1 second for the next character to
X arrive. After that the already received characters are interpreted
X as single characters.
X On slow terminals or very busy systems time out may cause
X malfunctioning cursor keys. If both options are off, Vim waits
X forever after an entered <ESC> if there are key codes that start
X with <ESC>. You will have to type <ESC> twice. If you do not have
X problems with key codes, but would like to have :mapped key
X sequences not time out in 1 second, set the ttimeout option and
X reset the timeout option. {the ttimeout option is not in Vi}
X
Xtextwidth number (default 9999)
X Maximum width of text that is being inserted. A longer line will be
X broken after white space to get this width. {not in Vi}
X
Xundolevels (ul) number (default 100)
X Maximum number of changes that can be undone (set to 0 for Vi
X compatibility). {not in Vi}
X
Xupdatecount (uc) number (default 100)
X After this many characters typed the auto script file will be written
X to disk. When zero the auto script will not be written to at all (see
X chapter on recovery). {not in Vi}
X
Xupdatetime (ut) number (default 2000)
X If this many milliseconds nothing is typed the auto script file will
X be written to disk (see chapter on recovery). {not in Vi}
X
Xvisualbell (vb) toggle (default off)
X Use (sort of) visual bell for AUX device. {not in Vi}
X
Xwrapmargin (wm) number (default 0)
X Number of characters from the right window border where wrapping
X starts. In Vim this is implemented by setting textwidth to the window
X width minus the wrapmargin. {Vi: works differently and less useful}
X
Xwrapscan (ws) toggle (default on)
X Searches wrap around the end of the file.
X
Xwriteany (wa) toggle (default off)
X Do not check for allowance when writing files.
X
Xwritebackup (wb) toggle (default on)
X Make a backup before overwriting a file. The backup is removed after
X the file was succesfully written, unless the 'backup' option is also
X on. {not in Vi}
X
Xyankendofline (ye) toggle (default off)
X The Y command yanks from the cursor until the end of the line instead
X of whole lines. {not in Vi}
X
X
X 20. Terminal information
X
XVim uses information about the terminal you are using to fill the screen and
Xrecognize what keys you hit. If this information is not correct the screen
Xmay be messed up or keys may not be recognized. The actions which have to be
Xperformed on the screen are accomplished by outputting a string of
Xcharacters. Special keys produce a string of characters. These strings are
Xstored in the terminal options, see section 20.2.
X
X
X20.1 startup
X
XWhen Vim is started a default terminal type is assumed. For the Amiga this
Xis a standard CLI window, for MSDOS the pc terminal, for Unix an ansi
Xterminal. A few other terminal types are always available. Use the command
X"set term=xxx" to find out which ones are builtin.
X
XYou can give the terminal name with the '-T' command line option. If it is
Xnot given Vim will try to get the name from the TERM environment variable.
X
XOn Unix the termcap file is used. On Amiga and MSDOS this is only available
Xif Vim was compiled with TERMCAP defined. If the termcap code is included
XVim will try to get the strings for the terminal you are using from the
Xtermcap file.
X
XFor normal editing the terminal will be put into "raw" mode. The strings
Xdefined with "t_ts" and "t_ks" will be sent to the terminal. Normally this
Xputs the terminal in a state where the termcap codes are valid and activates
Xthe cursor and function keys. When Vim exits the terminal will be put back
Xinto the mode it was before Vim started. The strings defined with "t_te" and
X"t_ke" will be sent to the terminal. On the Amiga with commands that print
Xmultiple lines at the bottom of the screen or execute an external command
X(e.g. "!!", ":files") the terminal will be put into normal mode for a
Xmoment. This means that you can stop the output to the screen by hitting a
Xprinting key. Output resumes when you hit <BS>.
X
XSome termcap entries are wrong in the sense that after sending t_ks the
Xcursor keys send codes different from the codes defined in the termcap. To
Xavoid this you can set t_ks (and t_ke) to empty strings. This must be done
Xduring initialization (see 3.4), otherwise its too late.
X
XSome termcap entries assume that the highest bit is always reset. For
Xexample: The cursor-up entry for the amiga could be ":ku=\EA:". But the
XAmiga really sends "\233A". This works fine if the highest bit is reset,
Xe.g. when using an Amiga over a serial line. If the cursor keys don't work,
Xtry the entry ":ku=\233A:".
X
XSome termcap entries have the entry ":ku=\E[A:". But the Amiga really sends
X"\233A". On output "\E[" and "\233" are often equivalent, on input they
Xaren't. You will have to change the termcap entry, or change the key code
Xwith the :set command to fix this.
X
XMany cursor key codes start with an <ESC>. Vim must find out if this a
Xsingle hit of the <ESC> key or the start of a cursor key sequence. It waits
Xfor a next character to arrive. If it does not arrive within one second a
Xsingle <ESC> is assumed. On very slow systems this may fail, causing cursor
Xkeys not to work sometimes. If you discover this problem reset the 'timeout'
Xoption. Vim will wait for the next character to arrive after an <ESC>. If
Xyou want to enter a single <ESC> you must type it twice.
X
XOn the Amiga the regcognition of window resizing is activated only when the
Xterminal name is "amiga" or "builtin_amiga".
X
X
X20.2 terminal options
X
XIt is always possible to change individual strings by setting the
Xappropriate option. For example:
X
X :set t_el=^V^[[K (CTRL-V, ESC, [, K)
X
XThe options are listed below along with the used termcap code. Two of them
Xare required: Cursor positioning and clear screen. The others are used to
Xminimize the screen updating overhead.
X
XYou can view the current codes with the command
X
X :set termcap
X
X
X option termcap meaning
X
XOUTPUT CODES
X t_name (name) name of current terminal entry
X t_el ce clear to end of line
X t_il al add new blank line
X t_cil AL add number of blank lines
X t_dl dl delete line
X t_cdl DL delete number of lines
X t_ed cl clear screen (required!)
X t_ci ci highlight color
X t_cv cv normal color
X t_tp me normal mode
X t_ti mr reverse mode
X t_cm cm cursor motion (required!)
X t_sr sr scroll reverse (backward)
X t_cri RI cursor number of chars right
X t_vb vb visual bell
X t_ks ks put terminal in "keypad transmit" mode
X t_ke ke out of "keypad transmit" mode
X t_ts ti put terminal in "termcap" mode
X t_te te out of "termcap" mode
X
XKEY CODES
X t_ku ku arrow up
X t_kd kd arrow down
X t_kr kr arrow right
X t_kl kl arrow left
X t_sku (none) shift arrow up
X t_skd (none) shift arrow down
X t_skr %i shift arrow right
X t_skl #4 shift arrow left
X t_f1 k1 function key 1
X t_f2 k2 function key 2
X t_f3 k3 function key 3
X t_f4 k4 function key 4
X t_f5 k5 function key 5
X t_f6 k6 function key 6
X t_f7 k7 function key 7
X t_f8 k8 function key 8
X t_f9 k9 function key 9
X t_f10 k; function key 10
X t_sf1 F1 function key 11 or shifted function key 1
X t_sf2 F2 function key 12 or shifted function key 2
X t_sf3 F3 function key 13 or shifted function key 3
X t_sf4 F4 function key 14 or shifted function key 4
X t_sf5 F5 function key 15 or shifted function key 5
X t_sf6 F6 function key 16 or shifted function key 6
X t_sf7 F7 function key 17 or shifted function key 7
X t_sf8 F8 function key 18 or shifted function key 8
X t_sf9 F9 function key 19 or shifted function key 9
X t_sf10 FA function key 20 or shifted function key 10
X t_help %1 help key
X t_undo &8 undo key
X
X
X20.3 Window size
X
XIf you are running Vim on an Amiga and the terminal name is "amiga" or
X"builtin_amiga", the amiga-specific window resizing will be enabled. On Unix
Xsystems three methods are tried to get the window size:
X
X- the environment variables "LINES" and "COLUMNS"
X- an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
X- from the termcap entries "li" and "co"
X
XIf everything fails a default size of 24 lines and 80 columns is assumed. If
Xa window-resize signal is received the size will be set again. If the window
Xsize is wrong you can use the 'lines' and 'columns' options to set the
Xcorrect values.
X
X
X20.4 slow and fast terminals
X
XIf you have a fast terminal you may like to set the 'ruler' option. The
Xcursor position is shown in the status line.
X
XIf you have a slow terminal you may want to reset the 'showcommand' option.
XThe command characters will not be shown in the status line. If the terminal
Xscrolls very slow, set the 'scrolljump' to 5 or so. If the cursor is moved
Xoff the screen (e.g. with 'j') Vim will scroll 5 lines at a time.
X
XIf the characters from the terminal are arriving with more than 1 second
Xbetween them you might want to set the 'timeout' and/or 'ttimeout' option.
XSee the "Options" chapter.
X
X
X 21. Differences from Vi and Ex
X
XThis chapter only lists what has not been mentioned in previous chapters.
X
X21.1 Missing commands
X
XA large number of the "Ex" commands (the commands that start with a colon)
Xare included. However, there is no Ex mode.
X
XThese commands are in Vi, but not in Vim.
X
XQ {Vi: go to Ex mode}
X
X:a[ppend] {Vi: append text}
X:c[hange] {Vi: replace lines}
X:i[nsert] {Vi: insert text}
X:l[ist] {Vi: list lines}
X:nu[mber] {Vi: print specified lines with their line number}
X:o[pen] {Vi: start editing in open mode}
X:pres[erve] {Vi: emergency exit}
X:rec[over] {Vi: recover a file after a crash or :preserve}
X:una[bbreviate] {Vi: remove from abbreviation list}
X:vi[sual] {Vi: switch from Ex or open to visual mode}
X:z {Vi: print some lines}
X:~ {Vi: do a substitute on the previous regular
X expression}
X
X
X21.2 Missing options
X
XThese options are in the unix Vi, but not in VIM.
X
Xautoprint (ap) toggle (default on)
Xbeautify (bf) toggle (default off)
Xedcompatible toggle (default off)
Xhardtabs (ht) number (default 8)
X number of spaces that a <TAB> moves on the display
Xlisp toggle (default off)
Xmesg toggle (default on)
Xopen toggle (default on)
Xoptimize (op) toggle (default on)
Xprompt toggle (default on)
Xredraw toggle (default off)
Xslowopen (slow) toggle (default off)
Xwarn toggle (default on)
X warn when the file has changed before a ! command
Xwindow number (default 24)
Xw300 number (default 24)
Xw1200 number (default 24)
Xw9600 number (default 24)
X
X
X 22. Credits
X
XParts of this manual comes from several Vi manuals, written by:
X W.N. Joy
X Alan P.W. Hewett
X Mark Horton
X
XThe editor VIM is based on Stevie and includes (ideas from) other software,
Xworked on by:
X Tim Thompson Stevie
X Tony Andrews Stevie
X G. R. (Fred) Walter Stevie
X Henry Spencer regular expressions
X Steve Kirkendall Elvis
X Juergen Weigert Lattice version, AUX improvements, UNIX and
X MSDOS ports
X Olaf Seibert DICE version and regexp improvements
X Peter da Silva termlib
X
XI must thank all the people that sent me bug reports and suggestions.
XThey keep Vim alive!
Xvi:tw=76
END_OF_FILE
if test 41128 -ne `wc -c <'vim/doc/reference.doc3'`; then
echo shar: \"'vim/doc/reference.doc3'\" unpacked with wrong size!
fi
# end of 'vim/doc/reference.doc3'
fi
echo shar: End of archive 19 \(of 23\).
cp /dev/null ark19isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:38:16 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 20
Archive-name: vim/part20
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 20 (of 23)."
# Contents: vim/doc/reference.doc2
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:13 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/reference.doc2' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/reference.doc2'\"
else
echo shar: Extracting \"'vim/doc/reference.doc2'\" \(46054 characters\)
sed "s/^X//" >'vim/doc/reference.doc2' <<'END_OF_FILE'
X (inclusive).
X
X; Repeat latest f, t, F or T [cnt] times.
X
X, Repeat latest f, t, F or T in opposite direction
X [cnt] times.
X
XThese commands move the cursor to the specified column in the current line.
XThey stop at the first column and at the end of the line, except '$', which
Xmay move to one of the next lines.
X
X
X6.2 Up-down motions
X
Xk or
X<C_UP> or
XCTRL-P [cnt] lines upward (linewise).
X
Xj or
X<C_DOWN> or
XCTRL-J or
X<LF> or
XCTRL-N [cnt] lines downward (linewise).
X
X- <minus> [cnt] lines upward, on the first non-blank character
X (linewise).
X
X+ or
XCTRL-M or
X<CR> [cnt] lines downward, on the first non-blank
X character (linewise).
X
X_ <underscore> [cnt] - 1 lines downward, on the first non-blank
X character (linewise).
X
XG Goto line [cnt], default last line, on the first
X non-blank character (linewise).
X
X:[range] Set the cursor on the (last) specified line number
X (cannot be used with an operator).
X
X{cnt}% Go to {cnt} percentage in the file, column 1
X (linewise). To compute the new line number this
X formula is used: {cnt} * number-of-lines / 100. {not
X in Vi}
X
XThese commands move to the specified line. They stop when reaching the first
Xor the last line. The first two commands put the cursor in the same column
X(if possible) as it was after the last command that changed the column,
Xexcept after the '$' command, then the cursor will be put on the last
Xcharacter of the line.
X
X
X6.3 Word motions
X
X<SC_RIGHT> or
Xw [cnt] words forward (exclusive).
X
XW [cnt] WORDS forward (exclusive).
X
Xe Forward to the end of word [cnt] (inclusive).
X
XE Forward to the end of WORD [cnt] (inclusive).
X
X<SC_LEFT> or
Xb [cnt] words backward (exclusive).
X
XB [cnt] WORDS backward (exclusive).
X
XThese commands move over words or WORDS. A word consists of a sequence of
Xletters, digits and underscores, or a sequence of other non-blank
Xcharacters, separated with blank space. A WORD consists of a sequence of
Xnon-blank characters, separated with blank space. The end of a line is also
Xconsidered to be blank space. An empty line is also considered to be a word
Xand a WORD.
X
XSpecial case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
Xon a non-blank. This is because "cw" is interpreted as change-word, and a
Xword does not include the following blank space. {Vi: "cw" when on a blank
Xfollowed by other blanks changes only the first blank; this is probably a
Xbug, because "dw" deletes all the blanks}
X
X
X6.4 Text object motions
X
X( [cnt] sentences backward (exclusive).
X
X) [cnt] sentences forward (exclusive).
X
X{ [cnt] paragraphs backward (exclusive).
X
X} [cnt] paragraphs forward (exclusive).
X
X]] [cnt] sections forward, except when used after an
X operator, then [cnt] SECTIONS forward (linewise).
X
X][ [cnt] SECTIONS forward (linewise).
X
X[[ [cnt] sections backward (linewise).
X
X[] [cnt] SECTIONS backward (linewise).
X
XThese commands move over three kinds of text objects.
X
XA sentence is defined as ending at a '.', '!' or '?' followed by either the
Xend of a line, or by a space. {Vi: two spaces} Any number of closing ')',
X']', '"' and ''' characters my appear after the '.', '!' or '?' before the
Xspaces or end of line. A paragraph and section boundary is also a sentence
Xboundary.
X
XA paragraph begins after each empty line, and also at each of a set of
Xparagraph macros, specified by the pairs of characters in the 'paragraphs'
Xoption. The default is "IPLPPPQPP LIpplpipbp", which corresponds to the
Xmacros ".IP", ".LP", etc. (these are nroff macros, the dot must be in the
Xfirst column). A section boundary is also a paragraph boundary.
X
XA section begins after a form-feed in the first column, a '{' in the first
Xcolumn, and also at each of a set of section macros, specified by the pairs
Xof characters in the 'sections' option. The default is "SHNHH HUnhsh". A
XSECTION is the same as a section, except that a '}' replaces the '{'. This
Xis useful to find the end of C-language functions.
X
X
X6.5 Pattern searches
X
X/{pattern}[/] Search forward for the [cnt]'th occurrence of
X {pattern} (exclusive).
X
X/{pattern}/{offset} Search forward for the [cnt]'th occurrence of
X {pattern} and go {offset} lines up or down (see
X below). (linewise).
X
X/ Search forward for the [cnt]'th latest used pattern
X with latest used {offset}.
X
X//{offset} Search forward for the [cnt]'th latest used pattern
X with new {offset}. If {offset} is empty no offset is
X used.
X
X* Search forward for the [cnt]'th occurrence of the
X ident after or under the cursor (exclusive). {not in
X Vi}
X
X# Search backward for the [cnt]'th occurrence of the
X ident after or under the cursor (exclusive). {not in
X Vi}
X
X?{pattern}[?] Search backward for the [cnt]'th previous
X occurrence of {pattern} (exclusive).
X
X?{pattern}?{offset} Search backward for the [cnt]'th previous occurrence
X of {pattern} and go {offset} lines up or down (see
X below) (linewise).
X
X? Search backward for the [cnt]'th latest used pattern
X with latest used {offset}.
X
X??{offset} Search backward for the [cnt]'th latest used pattern
X with new {offset}. If {offset} is empty no offset is
X used.
X
Xn Repeat the latest '/' or '?' [cnt] times. {Vi: no
X count}
X
XN Repeat the latest '/' or '?' [cnt] times in opposite
X direction. {Vi: no count}
X
XCTRL-C Interrupt current (search) command.
X
XThese commands search for the specified pattern. With "/" and "?" an
Xadditional offset may be given. There are two types of offsets: line offsets
Xand character offsets. {the character offsets are not in Vi}
X
XThe offset gives the cursor positition relative to the found match:
X +[num] [num] lines downwards, in column 1
X -[num] [num] lines upwards, in column 1
X e[+num] [num] characters to the right of the end of the match
X e[-num] [num] characters to the left of the end of the match
X s[+num] [num] characters to the right of the start of the match
X s[-num] [num] characters to the left of the start of the match
X n not an offset: search without setting the current position
X of the cursor (used for the :tags command)
X
XIf [num] is omitted it is assumed to be zero.
X
XExamples:
X
Xpattern cursor position
X/test/+1 one line below "test", in column 1
X/test/e on the last t of "test"
X/test/s+2 on the "s" of "test"
X
XIf one of these commands is used after an operator, the characters between
Xthe cursor position before and after the search is affected. However, if a
Xline offset is given, the whole lines between the two cursor positions are
Xaffected.
X
XThe last used <pattern> and <offset> are remembered. They can be used to
Xrepeat the search, possibly in another direction or with another count. Note
Xthat only one <pattern> is remembered for all searches, including :s
X(substitute). Each time an empty <pattern> is given, the previously used
X<pattern> is used.
X
XIf the 'wrapscan' option is set (which is the default), searches wrap around
Xthe end of the buffer. If 'wrapscan' is not set, the backward search stops
Xat the beginning and the forward search stops at the end of the buffer. If
Xthe pattern was not found the error message "pattern not found" is given,
Xand the cursor will not be moved.
X
XPatterns may contain special characters, depending on the setting of the
X'magic' option. The '*' and '#' commands search for the identifier currently
Xunder the cursor. If there is no indentifier under the cursor, the first one
Xto the right is used. This identifier may only contain letters, digits and
Xunderscores. Note that if you type with ten fingers, the characters are easy
Xto remember: the '#' is under your left hand middle finger and the '*' is
Xunder your right hand middle finger.
X
XThe definition of a pattern:
X
X1. A pattern is one or more branches, separated by '\|'. It matches anything
X that matches one of the branches.
X
X2. A branch is one or more pieces, concatenated. It matches a match for the
X first, followed by a match for the second, etc.
X
X3. A piece is an atom, possibly followed by:
X magic nomagic
X * \* matches 0 or more of the preceding atom
X \+ \+ matches 1 or more of the preceding atom {not
X in Vi}
X \? \? matches 0 or 1 of the preceding atom {not in
X Vi}
X
X4. An atom can be:
X - One of these five:
X magic nomagic
X . \. matches any single character
X \< \< matches the beginning of a word
X \> \> matches the end of a word
X ^ ^ at beginning of pattern, matches start of
X line
X $ $ at end of pattern, matches end of line
X - A pattern enclosed by escaped parentheses (e.g. "\(^a\)").
X - A single character, with no special meaning, matches itself
X - A backslash followed by a single character, with no special meaning,
X matches the single character.
X - A range. This is a sequence of characters enclosed in '[]' with the
X 'magic' option, or enclosed in '\[]' with the 'nomagic' option. It
X normally matches any single character from the sequence. If the
X sequence begins with '^', it matches any single character NOT in the
X sequence. If two characters in the sequence are separated by '-', this
X is shorthand for the full list of ASCII characters between them (e.g.
X '[0-9]' matches any decimal digit). To include a literal ']' in the
X sequence, make it the first character (following a possible '^'). To
X include a literal '\-', make it the first or last character.
X
XIf the 'ignorecase' option is set, the case of letters is ignored.
X
X<NUL> characters in the file are stored as <LF> in memory. To match them use
X<LF>, which can be typed with CTRL_V CTRL_J. Note that the <NUL> character is
Xdisplayed as "^@".
X
XExamples:
X^beep( Probably the start of the C function "beep".
X
X[a-zA-Z]$ Any alphabetic character at the end of a line.
X
X\(^\|[^a-zA-Z0-9_]\)[a-zA-Z_]\+[a-zA-Z0-9_]*
X A C identifier (will stop in front of it).
X
X[.!?][])"']*\($\|[ ]\) A search pattern that finds the end of a sentence,
X with almost the same definition as the <)> command.
X
X
X
X6.6 Various motions
X
Xm<a-zA-Z> Set mark <a-zA-Z> at cursor position (does not move
X the cursor, this is not a motion command).
X
X:[range]mar[k] <a-zA-Z> Set mark <a-zA-Z> at last line number in [range],
X column 0. Default is cursor line.
X
X:[range]k<a-zA-Z> Same as :mark, but the space before the mark name can
X be omitted.
X
X'<a-z> To the first non-blank character on the line with
X mark <a-z> (linewise).
X
X'<A-Z> To the first non-blank character on the line with
X mark <A-Z> in the correct file (linewise when in
X same file, not a motion command when in other file).

X {not in Vi}
X

X`<a-z> To the mark <a-z> (exclusive).
X
X`<A-Z> To the mark <A-Z> in the correct file (exclusive
X when in same file, not a motion command when in
X other file). {not in Vi}
X
X:marks List the current marks (not a motion command). {not
X in Vi}
X
XA mark is not visible in any way. It is just a position in the file that is
Xremembered. Do not confuse marks with named registers, they are totally
Xunrelated.
X
XLowercase marks are only remembered as long as you stay in the current
Xfile. If you start editing another file, change a character in a line or
Xdelete a line that contains a mark, that mark is erased. Lowercase marks can
Xbe used in combination with operators. For example: "d't" deletes the lines
Xfrom the cursor position to mark a. Hint: Use mark <t> for Top, <b> for
XBottom, etc..
X
XUppercase marks include the file name. {Vi: no uppercase marks} You can use
Xthem to jump from file to file. You can only use an uppercase mark with
Xan operator if the mark is in the current file. As long as you stay in the
Xcurrent file the line number of the mark remains correct, even if you
Xinsert/delete lines. After changing files the line number may be wrong
X(keeping them correct would take too much time). To avoid this use a
X":marks" command before abandoning a file, this will update the line numbers
Xin the current file.
X
X
X'[ To the first non-blank character on the first line
X of the previously operated text or start of the last
X putted text. {not in Vi}
X
X`[ To the first character of the previously operated
X text or start of the last putted text. {not in Vi}
X
X'] To the first non-blank character on the last line of
X the previously operated text or end of the last
X putted text. {not in Vi}
X
X`] To the last character of the previously operated
X text or end of the last putted text. {not in Vi}
X
XAfter executing an operator the Cursor is put at the beginning of the text
Xthat was operated upon. After a put command ("p" or "P") the cursor is
Xsometimes placed at the first inserted line and somtimes on the last
Xinserted character. The four commands above put the cursor at either
Xend. Example: After yanking 10 lines you want to go to the last one of them:
X"10Y']". After inserting several lines with the "p" command you want to jump
Xto the lowest inserted line: "p']".
X
XNote: After deleting text, the start and end positions are the same, except
Xwhen using blockwise quoting. These commands do not work when no operator
Xor put command has been used yet in the current file. The position may be
Xincorrect after inserting text and ".p.
X
X
X'' To the first non-blank character of the line where
X the cursor was before the latest jump (linewise).
X
X`` To the position before latest jump (exclusive).
X
XA "jump" is one of the following commands: "'", "`", "G", "/", "?", "n",
X"N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag" and the commands that
Xstart editing a new file. If you make the cursor "jump" with one of these
Xcommands, the position of the cursor before the jump is remembered. You can
Xreturn to that position with the "''" and "``" command, unless the line
Xcontaining that position was changed or deleted.
X
XCTRL-O Go to [cnt] Older cursor position in jump list
X (not a motion command). {not in Vi}
X
XCTRL-I Go to [cnt] newer cursor position in jump list
X (not a motion command). {not in Vi}
X
X:jumps Print the jump list (not a motion command). {not in
X Vi}
X
XJumps are remembered in a jump list. With the CTRL-O and CTRL-I command you
Xcan go to cursor positions before older jumps, and back again. Thus you can
Xmove up and down the list.
X
XFor example, after three jump commands you have this jump list:
X
X jump line file
X 1 1 -current-
X 2 70 -current-
X 3 1154 -current-
X>
X
XYou are currently in line 1167. If you then use the CTRL-O command, the
Xcursor is put in line 1154. This results in:
X
X jump line file
X 1 1 -current-
X 2 70 -current-
X> 3 1154 -current-
X 4 1167 -current-
X
XThe pointer will be set at the last used jump position. The next CTRL-O
Xcommand will use the entry above it, the next CTRL-I command will use the
Xentry below it. If the pointer is below the last entry, this indicates that
Xyou did not use a CTRL-I or CTRL-O before. In this case the CTRL-O command
Xwill cause the cursor position to be added to the jump list, so you can get
Xback to the postition before the CTRL-O. In this case this is line 1167.
X
XWith more CTRL-O commands you will go to lines 70 and 1. If you use CTRL-I
Xyou can go back to 1154 and 1167 again.
X
XIf you use a jump command, the current line number is inserted at the end of
Xthe jump list. If you used CTRL-O or CTRL-I just before that, the same line
Xmay be in the list twice. This may be a bit strange. Just try it and look at
Xthe jump list with the :jumps command. Note that this behaviour is different
Xfrom the tag stack.
X
XAfter the CTRL-O command that got you into line 1154 you could give another
Xjump command (e.g. 'G'). The jump list would then become:
X
X jump line file
X 1 1 -current-
X 2 70 -current-
X 3 1154 -current-
X 4 1167 -current-
X 5 1154 -current-
X>
X
XAs long as you stay in the same file, the line numbers will be adjusted for
Xdeleted and inserted lines. If you go to another file the line numbers may
Xbe wrong (keeping them correct would take too much time). If you want to
Xavoid this use a :jumps command before changing files. This will update the
Xline numbers in the current file.
X
X% Find the next parenthesis or (curly/square) bracket
X on this line and go to its match (inclusive). No
X count is allowed.
X
XH To line [cnt] from top (Home) of screen (default:
X first line on the screen) on the first non-blank
X character (linewise).
X
XM To Middle line of screen, on the first non-blank
X character (linewise).
X
XL To line [cnt] from bottom of screen (default: Last
X line on the screen) on the first non-blank character
X (linewise).
X
X
X 7. Scrolling
X
XUpwards scrolling, window goes downwards:
X
XCTRL-E Window [cnt] lines downwards in the buffer ([cnt]
X lines Extra).
X
XCTRL-D Window [cnt] lines Downwards in the buffer (default:
X previous [cnt] or half a screen).
X
X<SC_DOWN> or
XCTRL-F Window [cnt] pages Forwards (downwards) in the
X buffer.
X
XDownwards scrolling, window goes upwards:
X
XCTRL-Y Window [cnt] lines upwards in the buffer.
X
XCTRL-U Window [cnt] lines Upwards in the buffer (default:
X previous [cnt] or half a screen).
X
X<SC_UP> or
XCTRL-B Window [cnt] pages Backwards (upwards) in the buffer.
X
Xz<CR> Redraw, line [cnt] at top of window (default cursor
X line).
X
Xz{height}<CR> Redraw, make window {height} lines tall (if the
X height is different from the number of lines for the
X current terminal, this may cause problems with
X screen updating).
X
Xz. Redraw, line [cnt] at center of window (default
X cursor line).
X
Xz- Redraw, line [cnt] at bottom of window (default
X cursor line).
X
XThese commands move the contents of the window. If the cursor position is
Xmoved off of the window, the cursor is moved onto the window. A page is the
Xnumber of lines in the window minus two. The mnemonics for these commands
Xmay be a bit confusing. Remember that the commands refer to moving the
Xwindow upwards or downwards in the buffer. But when the window moves upwards
Xin the buffer, the text in the window moves downwards on your screen.
X
X
X 8. Tags
X
X:ta[g][!] {ident} Jump to the definition of {ident}, using the
X information in the tags file. Put {ident} in the tag
X stack. See below for [!].
X
XCTRL-] ":ta" to the identifier under or after cursor. Put
X the identifier in the tag stack. {Vi: identifier
X after the cursor}
X
XCTRL-T Jump to [cnt] older entry in the tag stack (default
X 1). {not in Vi}
X
X:[count]po[p][!] Jump to [count] older entry in tag stack (default 1).
X See below for [!]. {not in Vi}
X
X:[count]ta[g][!] Jump to [count] newer entry in tag stack (default 1).
X See below for [!]. {not in Vi}
X
X:tags Show the contents of the tag stack. The active
X entry is marked with a '>'. {not in Vi}
X
XA tag is an identifier that appears in the "tags" file. It is a sort of label
Xthat can be jumped to. For example: In C programs each function name can be
Xused as a tag.
X
XWith the ":tag" command the cursor will be positioned on the tag. With the
XCTRL-] command, the identifier on which the cursor is standing is used as the
Xtag. If the cursor is not on an identifier, the first identifier rightwards
Xof the cursor is used.
X
XIf the tag is in the current file this will always work. Otherwise the
Xperformed actions depend on whether the current file was changed, whether a !
Xis added to the command and on the 'autowrite' option:
X
X tag in file autowrite
Xcurrent file changed ! option action
X-----------------------------------------------------------------------------
X yes x x x goto tag
X no no x x read other file, goto tag
X no yes yes x abondon current file, read other file, goto
X tag
X no yes no on write current file, read other file, goto
X tag
X no yes no off fail
X-----------------------------------------------------------------------------
X
X- If the tag is in the current file, the command will always work.
X- If the tag is in another file and the current file was not changed, the
X other file will be made the current file and read into the buffer.
X- If the tag is in another file, the current file was changed and a ! is
X added to the command, the changes to the current file are lost, the other
X file will be made the current file and read into the buffer.
X- If the tag is in another file, the current file was changed and the
X 'autowrite' option is set, the current file will be written, the other
X file will be made the current file and read into the buffer.
X- If the tag is in another file, the current file was changed and the
X 'autowrite' option is not set, the command will fail. If you want to save
X the changes, use the ":w" command and then use ":tag" without an argument.
X This works because the tag is put on the stack anyway. If you want loose
X the changes you can use the ":tag!" command.
X
XThe ":tag" command works very well for C programs. If you see a call to a
Xfunction and wonder what that function does, position the cursor inside of
Xthe function name and hit CTRL-]. This will bring you to the function
Xdefinition. An easy way back is with the CTRL-T command. Also read about the
Xtag stack below.
X
XA tags file can be created with the external command 'ctags'. It will
Xcontain a tag for each function. Some versions of 'ctags' will also make a
Xtag for each "#defined" macro.
X
XThe lines in the tags file should have this format:
X
X {tag}{separator}{filename}{separator}{command}
X
X{tag} the identifier
X{separator} a single <TAB> or space character
X{filename} the file that contains the definition of {tag}
X{command} the Ex command that positions the cursor on the tag (it can
X be any Ex command, but normally it is a search command like
X "/^main").
X
XThe 'tags' option is a list of file names separated by spaces. Each of these
Xfiles is searched for the tag. This can be used to use a different file than
Xthe default file "tags". It can also be used to access a common tags file.
XFor example:
X
X:set tags=tags\ s:commontags
X
XThe tag will first be searched for in the file "tags" in the current
Xdirectory. If it is not found there the file "s:commontags" will be searched
Xfor the tag. The backslash is required for the space to be included in the
Xstring option.
X
X
XThe tags that you use are remembered in the tag stack. You can print this
Xstack with the ":tags" command. The result looks like this:
X
X # TO tag FROM line in file
X 1 main 1 harddisk2:text/vim/test
X> 2 FuncA 58 -current-
X 3 FuncC 357 harddisk2:text/vim/src/amiga.c
X
XThis list shows the tags that you jumped to and the cursor position before that
Xjump. The older tags are at the top, the newer at the bottom.
X
XThe '>' points to the active entry. This is the tag that will be used by the
Xnext ":tag" command. The CTRL-T and ":pop" command will use the position
Xabove the active entry.
X
XThe line number and file name are remembered to be able to get back to where
Xyou were before the tag command. As long as you stay within one file the
Xline number will be correct, also when deleting/inserting lines. When you go
Xto another file the line number may not always be correct (keeping them
Xcorrect all the time would take too much time). To avoid this use the
X":tags" command before abondoning a file, which will update the line numbers
Xin the current file.
X
XYou can jump to previously used tags with several commands. Some examples:
X
X ":pop" or CTRL-T to position before previous tag
X {count}CTRL_T to position before {count} older tag
X ":tag" to newer tag
X ":0tag" to last used tag
X
XThe most obvious way to use this is while browsing through the call graph of
Xa program. Consider the following call graph:
X
X main ---> FuncA ---> FuncC
X ---> FuncB
X
X(Explanation: main calls FuncA and FuncB; FuncA calls FuncC).
XYou can get from main to FuncA by using CTRL-] on the call to FuncA. Then
Xyou can CTRL-] to get to FuncC. If you now want to go back to main you can
Xuse CTRL-T twice. Then you can CTRL-] to FuncB.
X
XIf you issue a ":ta {ident}" or CTRL-] command, this tag is inserted at the
Xbottom of the stack. If the stack was full (it can hold upto 20 entries), the
Xoldest entry is deleted and the older entries shift one position up (their
Xindex number is decremented by one). If the last used entry was not at the
Xbottom, the entries below the last used one are moved to the top. This means
Xthat an old branch in the call graph is not lost, but moved to another place
Xon the tag stack. The stack above would change to:
X
X # TO tag FROM line in file
X 1 FuncA 58 harddisk2:text/vim/src/main.c
X 2 FuncC 357 harddisk2:text/vim/src/amiga.c
X 3 main 1 harddisk2:text/vim/test
X 4 FuncB 59 harddisk2:text/vim/src/main.c
X>
X
XIn the call graph example: You can use this to go back from FuncB to FuncC
Xby hitting CTRL-T twice. This may be a bit strange. Use the :tags command to
Xfind out what will happen with CTRL-T commands.
X
X
X 9. Inserting text
X
Xa Append text after the cursor [cnt] times.
X
XA Append text at the end of the line [cnt] times.
X
Xi Insert text before the cursor [cnt] times.
X
XI Insert text before the first CHAR on the line [cnt]
X times.
X
Xo Begin a new line below the cursor and insert text,
X repeat [cnt] times. {Vi: blank [cnt] screen lines}
X
XO Begin a new line above the cursor and insert text,
X repeat [cnt] times. {Vi: blank [cnt] screen lines}
X
XThese commands are used to start inserting text. They can be undone and
Xrepeated. You can end insert mode with <ESC>. See the section "Insert and
Xreplace mode" for the other special characters in insert mode. The effect of
X[cnt] takes place after insert mode is exited.
X
X:r[ead] {name} Insert the file {name} below the cursor.
X
X:{range}r[ead] {name} Insert the file {name} below the specified line.
X
X:r[ead]!{cmd} Execute {cmd} and insert its standard output below
X the cursor.
X
XThese commands insert the contents of a file, or the output of a command,
Xinto the buffer. They can be undone. They cannot be repeated with the "."
Xcommand. They work on a line basis, insertion starts below the line in which
Xthe cursor is, or below the specified line. To insert text above the first
Xline use the command ":0r {name}".
X
X
X 10. Deleting text
X
X["x]x Delete [cnt] characters under and after the cursor
X [into register x] (not linewise).
X
X["x]X Delete [cnt] characters before the cursor [into
X register x] (not linewise).
X
X["x]d{motion} Delete text that is moved over [into register x].
X
X["x]dd Delete [cnt] lines [into register x] (linewise).
X
X["x]D Delete the characters under the cursor until the end
X of the line and [cnt]-1 more lines [into register
X x]; synonym for d$ (not linewise).
X
X{quote}["x]x or
X{quote}["x]d Delete the quoted text [into register x] (see the
X chapter on quoting). {not in Vi}
X
X{quote}["x]X or
X{quote}["x]D Delete the quoted lines [into register x] (see the
X chapter on quoting). {not in Vi}
X
X:[range]d[elete] [x] Delete [range] lines (default: current line) [into
X register x].


X
X:[range]d[elete] [x] {count}

X Delete {count} lines, starting with [range] (default:
X current line, see 4.4.3) [into register x].
X
XThese commands delete text. They can be repeated (except ":d") and undone.
XUse quoting to delete blocks of text. See "copying" for an explanation of
Xregisters.
X
X
XJ Join [cnt] lines, with a minimum of two lines.
X
X{quote}J Join the quoted lines, with a minimum of two lines.


X {not in Vi}
X

X:[range]j[oin][!] Join [range] lines. Same as 'J', except when [!] is
X given, then no spaces will be inserted or deleted.
X
X:[range]j[oin][!] {count}
X Join {count} lines, starting with [range] (default:
X current line, see 4.4.3). Same as 'J', except when
X [!] is given, then no spaces will be inserted or
X deleted.
X
XThese commands delete the newline between lines. This has the effect of
Xjoining them into one line. They can be repeated (except ":j") and undone.
X
XOne space is inserted in place of the <NL>, unless the line ended with a
Xspace, <TAB> or the next line started with a ')'. If the next line has
Xleading blank space it is deleted first. If the 'joinspaces' option is set,
Xtwo spaces are inserted after a period.
X
X
X 11. Changing text
X
XThe following commands can be used to change text, that is delete some text
Xand insert something else, with one command. They can all be undone. The
Xnon-Ex commands can be repeated with the "." command.
X
X
X11.1 Delete and insert
X
XR Enter replace mode: Each character you type replaces
X an existing character, starting with the character
X under the cursor. Repeat the entered text [cnt]-1
X times.
X
X["x]c{motion} Delete {motion} text [into register x] and start
X insert.
X
X["x]cc Delete [cnt] lines [into register x] and start insert
X (linewise).
X
X["x]C Delete from the cursor position to the end of the
X line and [cnt]-1 more lines [into register x], and
X start insert. Synonym for c$ (not linewise).
X
X["x]s Delete [cnt] characters [into register x] and start
X insert (s stands for Substitute). Synonym for "cl"
X (not linewise).
X
X["x]S Delete [cnt] lines [into register x] and start
X insert. Synonym for "^cc" with 'autoindent' option
X or "0cc" with 'noautoindent' option (not linewise).
X
X{quote}["x]c or
X{quote}["x]r or
X{quote}["x]s Delete the quoted text [into register x] and start
X insert (see the chapter on quoting). {not in Vi}
X
X{quote}["x]C or
X{quote}["x]R or
X{quote}["x]S Delete the quoted lines [into register x] and start
X insert (see the chapter on quoting). {not in Vi}
X
XYou can end insert and replace mode with <ESC>. See the section "Insert and
Xreplace mode" for the other special characters in these modes. The effect of
X[cnt] takes place after insert or replace mode is exited. {Vi: does not
Xdirectly delete the text, but puts a '$' at the last deleted character}
XSee "copying" for an explanation of registers.
X
XReplace mode is just like insert mode, except that for every character you
Xenter, one character is deleted. If the end of a line is reached, further
Xcharacters are appended (just like insert mode). In replace mode the
Xbackspace key only moves the cursor positition, no characters are deleted,
Xunless the 'repdel' option is set (see section "insert and replace mode").
X
XSpecial case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
Xon a non-blank. This is because "cw" is interpreted as change-word, and a
Xword does not include the following blank space. {Vi: "cw" when on a blank
Xfollowed by other blanks changes only the first blank; this is probably a
Xbug, because "dw" deletes all the blanks}
X
X
X11.2 Simple changes
X
Xr<char> Replace [cnt] characters by <char>.
X
X~ 'notildeop' option: switch case of [cnt] characters
X under the cursor and move the cursor [cnt]
X characters to the right. {Vi: no count}
X
X~{motion} 'tildeop' option: switch case of {motion} text. {Vi:
X tilde cannot be used as an operator}
X
X{quote}~ switch case of quoted text (see the chapter on
X quoting). {not in Vi}
X
X{quote}u Make quoted text uppercase (see the chapter on
X quoting). {not in Vi}
X
X{quote}U Make quoted text lowercase (see the chapter on
X quoting). {not in Vi}
X
XCTRL-A Add [cnt] to the number at or after the cursor. {not
X in Vi}
X
XCTRL-S Subtract [cnt] from the number at or after the
X cursor. {not in Vi}
X
XThe CTRL-A and CTRL-S commands work for (signed) decimal numbers and
Xunsigned octal and hexadecimal numbers. Numbers starting with '0x' or '0X'
Xare assumed to be hexadecimal. To decide whether the hexadecimal number
Xshould be printed uppercase or not, the case of the rightmost letter in the
Xnumber is considered. If there is no letter in the current number, the
Xpreviously detected case is used. Numbers starting with a '0' are considered
Xto be octal. Other numbers are decimal and may be preceded with a minus
Xsign. If the cursor is on a number, that one will be used. Otherwise the
Xnumber right of the cursor will be used.
X
XThe CTRL-A command is very useful in a macro. Example: How to make a
Xnumbered list.
X
X1. Make the first entry. The entry should start with a number.
X2. Start recording: "va".
X3. Yank the entry into a buffer: "Y".
X4. Put a copy of the entry below the first one: "p".
X5. Increment the number: CTRL-A.
X6. Stop recording: "v".
X7. Repeat all this with "<count>@a".
X
X
X<{motion} Shift the {motion} lines one shiftwidth leftwards.
X
X<< Shift [cnt] lines one shiftwidth leftwards.
X
X{quote}< Shift the quoted lines one shiftwidth leftwards (see
X the chapter on quoting). {not in Vi}
X
X>{motion} Shift {motion} lines one shiftwidth rightwards.
X
X>> Shift [cnt] lines one shiftwidth rightwards.
X
X{quote}> Shift the quoted lines one shiftwidth rightwards
X (see the chapter on quoting). {not in Vi}
X
X:[range]< Shift [range] lines left.
X
X:[range]< {count} Shift {count} lines left, starting with [range]
X (default current line, see 4.4.3).
X
X:[range]> Shift {count} [range] lines right.
X
X:[range]> {count} Shift {count} lines right, starting with [range]
X (default current line, see 4.4.3).
X
XThe ">" and "<" commands are handy for changing the indent within programs.
XThe size of the blank space which is inserted or deleted can be set with the
X'shiftwidth' option. Normally the 'shiftwidth' option is set to 8, but you
Xcan set it to e.g. 3 to make smaller indents. The shift leftwards stops when
Xthere is no indent. The shift right does not do anything with empty lines.
XIf the 'shiftround' option is set, the indent is rounded to a multiple of
X'shiftwidth'.
X
XV{motion} Format the lines that were moved over. The length of
X each line will be restricted to the width set with
X the 'textwidth' option. If you did not set the
X 'textwidth' option, all lines will be joined
X together. If the 'autoindent' option is set, use the
X indent of the first line. {not in Vi}
X
X
X11.3 Complex changes
X
X!{motion}{filter} Filter {motion} text through the external program
X {filter}.
X
X!!{filter} Filter [cnt] lines through the external program
X {filter}.
X
X{quote}!{filter} Filter the quoted lines through the external program
X {filter} (see the chapter on quoting). {not in Vi}
X
X:{range}![!]{filter} [!][arg]
X Filter {range} lines through the external program
X {filter}. The optional bangs are replaced with the
X latest given command. The optional [arg] is appended.
X
X={motion} Filter {motion} lines through the external program
X given with the 'equalprg' option (default:
X "indent"). {Vi: when 'lisp' option is set, autoindent
X {motion} lines}
X
X== Filter [cnt] lines through the external program given
X with the 'equalprg' option (default: indent). {not
X in Vi}
X
X{quote}= Filter the quoted lines through the external program
X given with the 'equalprg' option (default: indent)
X (see the chapter on quoting). {not in Vi}
X
XA filter is a program that accepts text at standard input, changes it in some
Xway, and sends it to standard output. The commands above can be used to send
Xsome text through a filter. An example of a filter is "sort", which sorts
Xlines alphabetically. The "indent" program is used to pretty indent C
Xprograms (you need a version of indent that works like a filter, not all
Xversions do that). The shell, given with the 'shell' option, is used to
Xexecute the command (See also the 'shelltype' option).
XThe filter commands can be redone with '.'.
X
X:[range]s[ubstitute]/{pattern}/{string}/[g][c] [count]
X For each line in [range] replace the first occurrence
X of {pattern} by {string}. With option [g] all
X occurrences in the line are replaced. With option
X [c] each replace has to be confirmed (<y> to
X replace, <q> to quit replacing, anything else to
X skip). With [count] that many lines are are
X searched, starting with the last line number in
X [range] (default current line, see 4.4.3).
X
X:[range]s[ubstitute] [g][c] [count]
X Repeat last :substitute with new options and possibly
X on other lines.
X
X:[range]&[/{pattern}/{string}/][g][c] [count]
X Same as for :substitute.
X
X& Synonym for ":s".
X
XIf the {pattern} for the substitute command is empty, the previously given
Xpattern is used (from any search, including '/' and ":g").
X
XFor the definition of a pattern see 6.5, "Pattern searches".
X
XSome characters in {string} have a special meaning:
X
Xmagic nomagic action
X & \& replaced by the whole matched pattern
X \& & replaced by &
X \0 replaced by the whole matched pattern
X \1 replaced by the matched pattern in the first pair of ()
X \2 replaced by the matched pattern in the second pair of ()
X .. ..
X \9 replaced by the matched pattern in the ninth pair of ()
X ~ \~ replaced by the {string} of the previous substitute
X \~ ~ replaced by ~
X \u next character made uppercase
X \U following characters made uppercase
X \l next character made uppercase
X \L following characters made uppercase
X \e end of /u, /U, /l and /L
X \E end of /u, /U, /l and /L
X
XExamples:
X:s/a\|b/xxx\0xxx/g modifies "a b" in "xxxaxxx xxxbxxx"
X:s/\([abc]\)\([efg]\)/\2\1/g modifies "af fa bg" in "fa fa gb"
X
XWhen using parentheses in combination with '|', like in \([ab]\)\|\([cd]\),
Xeither the first or second pattern in parentheses did not match, so either
X\1 or \2 is empty. Example:
X:s/\([ab]\)\|\([cd]\)/\1x/g modifies "a b c d" in "ax bx x x"
X
X
X 12. Copying and moving text
X
X"<a-zA-Z0-9.> Use register <a-zA-Z0-9.> for next delete, yank or put
X (uppercase to append) (<.> only works with put).
X
X:di[splay] Display the contents of numbered and named registers.
X {Vi: no such command}
X
X["x]y{motion} Yank {motion} text [into register x].
X
X["x]yy Yank [cnt] lines [into register x] (linewise).
X
X["x]Y With 'noyankendofline' option: yank [cnt] lines
X [into register x] (synonym for yy, linewise); with
X 'yankendofline' option: yank until end of line
X (synonym for y$, not linewise).
X
X{quote}["x]y Yank the quoted text [into register x] (see the
X chapter on quoting). {not in Vi}
X
X{quote}["x]Y Yank the quoted lines [into register x] (see the
X chapter on quoting). {not in Vi}
X
X:[range]y[ank] [x] Yank [range] lines [into register x].
X
X:[range]y[ank] [x] {count}
X Yank {count} lines, starting with last line number
X in [range] (default: current line, see 4.4.3), [into
X register x].
X
X["x]p Put the text [from register x] after the cursor [cnt]
X times. {Vi: no count}
X
X["x]P Put the text [from register x] before the cursor
X [cnt] times. {Vi: no count}
X
X:[line]pu[t] [x] Put the text [from register x] after [line] (default
X current line).
X
X:[line]pu[t]! [x] Put the text [from register x] before [line] (default
X current line).
X
XThese commands can be used to copy text from one place to another. This is
Xdone by first getting the text into a register with a yank, delete or change
Xcommand. The register can then be inserted with a put command. All registers
Xare kept when changing files. Thus you can also use this to move text from
Xone file to another (the CTRL-^ command is a quick way to toggle between two
Xfiles).
X
XThe put commands can be repeated (except for :put) and undone. If the
Xcommand that was used to get the text into the register was linewise, the
Xtext will be inserted below or above the line where the cursor is. Otherwise
Xthe text will be inserted before or after the cursor. With the ":put"
Xcommand the text will always be inserted in the next line. You can exchange
Xtwo characters with the command sequence "xp". You can exchange two lines
Xwith the command sequence "ddp". The "']" or "`]" command can be used after
Xthe put command to move the cursor to the end of the inserted text, "'[" or
X"`[" to move the cursor to the start.
X
XIf the command that was used to get the text into the register used
Xblockwise quoting, the block of text will be inserted before ('P') or after
X('p') the cursor column, in the current and next lines. Vim will make the
Xwhole block of text start in the same column. Thus the inserted text looks
Xthe same as when it was yanked or deleted. Some <TAB> characters may be
Xreplaced by spaces to make this happen. However, if the width of the block
Xis not a multiple of a <TAB> width and the text after the inserted block
Xcontains <TAB>s, that text may be misaligned.
X
XThere are three types of registers: 10 numbered registers, 26 named
Xregisters and one insert register.
X The numbered registers are filled with yank and delete commands.
XNumbered register "0" is filled with the last yank command, unless another
Xregister was specified with ["x]. Numbered register "1" is filled with the
Xtext that was deleted by each delete or change command, unless another
Xregister was specified. The contents of register "1" is put in "2", "2" in
X"3", and so forth. The contents of register "9" is lost. {Vi: numbered
Xregister contents is lost when changing files; register 0 does not exist}
X The named registers are only filled when you say so. They are named
X'a' to 'z' normally. If you use an uppercase letter, the same registers as
Xwith the lower case letter is used, but the text is appended to the previous
Xregister contents. With a lower case letter the previous contents is lost.
X The insert register "." contains the last inserted text. It can only
Xbe used with the commands 'p', 'P' and ':put'.
X
XIf you use a put command without specifying a register, the register that
Xwas last written to is used. If you are confused, use the ":dis" command to
Xfind out what will be put.
X
XThe next three commands always work on whole lines.


X
X:[range]co[py] {address}

X Copy the lines given by [range] to below the line
X given by {address}.
X
X:t Synonym for copy.


X
X:[range]m[ove] {address}

X Move the lines given by [range] to below the line
X given by {address}.
X
X
X 13. Quoting
X
XQuoting is a flexible and easy way to select a piece of text for an
Xoperator. It is the only way to select a block of text.
X
Xq start/stop quoting per character. {not in Vi}
X
XQ start/stop quoting linewise. {not in Vi}
X
XCTRL-Q start/stop quoting blockwise. {not in Vi}
X
Xo go to Other end of quoted text: The current cursor
X position becomes the start of the quoted text and
X the cursor is moved to the Other end of the quoted
X text. {not in Vi}
X
XTo apply an operator on a piece of text:
X 1. mark the start of the text with 'q', 'Q' or CTRL-Q
X The character under the cursor will be used as the start.
X 2. move to the end of the text
X The text from the start of the quoting up to and including
X the character under the cursor is highlighted.
X 3. hit an operator
X The highlighted characters will be operated upon.
X
XThe quoted text includes the character under the cursor. Vim tries to invert
Xthe cursor, but on some terminals the inverted cursor looks strange or
Xcannot been seen at all.
X
XWith 'q' the text before the start positition and after the end position will
Xnot be highlighted. However, All uppercase and non-alpha operators, except
X'~', will work on whole lines anyway. See the list of operators below.
X
XWith CTRL-Q (blockwise quoting) the quoted text will be a rectangle between
Xstart position and the cursor. However, some operators work on whole lines
Xanyway (see the list below). The change and substitute operators will delete
Xthe quoted text and then start insertion at the top left position.
X
XWhen the '$' command is used with blockwise quoting, the right end of the
Xquoted text will be determined by the longest quoted line. This stops when a
Xmotion command is used that does not move straight up or down.
X
XIf 'q', 'Q', CTRL-Q or ESC is typed while quoting, the quoting stops and no
Xtext is affected. If you hit CTRL-Z quoting stops and the editor is
Xsuspended or a new shell is started.
X
XFor moving the end of the block many commands can be used, but you cannot
Xuse Ex commands, commands that make changes or abandon the file. Commands
X(starting with) ".pPiIaAO&", CTRL_^, "ZZ", CTRL-], CTRL-T, CTRL-R, CTRL-I
Xand CTRL-O. If you try to use one of these commands a beep is given and
Xquoting continues.
X
XThe operators that can be used are:
X ~ switch case


X d delete
X c change
X y yank

X > shift right (1)
X < shift left (1)
X ! filter through external command (1)
X = filter through 'equalprg' option command (1)
X V format lines to 'textwidth' length (1)
X
XAdditionally the following commands can be used:
X : start ex command for quoted lines (1)
X r change
X s change
X C change (2)
X R change (2)
X S change (2)
X x delete
X D delete (2)
X X delete (2)
X Y yank (2)
X J join (1)


X u make uppercase
X U make lowercase
X

X(1): always whole lines
X(2): whole lines when not using CTRL-Q
X
XIf you want to give a buffer name using the '"' command, do this just before
Xtyping the operator character.
X
XWhen repeating a quoted operator, the operator will be applied to the same
Xamount of text as the last time:
X- Linewise quoting: The same number of lines.
X- Blockwise quoting: The same number of lines and columns.
X- Normal quoting within one line: The same number of characters.
X- Normal quoting with several lines: The same number of lines, in the last
X line the same number of characters as in the last line the last time.
XThe start of the text is the Cursor position. If the '$' command was used as
Xone of the last commands to extend the quoted text, the repeating will be
Xapplied upto the rightmost column of the longest line.
X
X
X 14. Various commands
X
XCTRL-L Clear and redraw the screen.
X
XCTRL-Z On Unix systems: Suspend Vim. On other systems:
X start a new shell (like ":sh").
X
X<HELP> or
X:h[elp] Show the help file page by page. The help file name
X can be set with the 'helpfile' option. {Vi: no help}
X
X<DEL> When entering a number: remove the last digit.
X
X:[range]p[rint] Print [range] lines (default current line).
X
X:[range]p[rint] {count}
X Print {count} lines, starting with [range] (default
X current line, see 4.4.3).
X
X:= Print the line number.
X
X:sh[ell] Escape to a shell (name from 'shell' option).
END_OF_FILE
if test 46054 -ne `wc -c <'vim/doc/reference.doc2'`; then
echo shar: \"'vim/doc/reference.doc2'\" unpacked with wrong size!
fi
# end of 'vim/doc/reference.doc2'
fi
echo shar: End of archive 20 \(of 23\).
cp /dev/null ark20isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:38:39 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 21
Archive-name: vim/part21
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 21 (of 23)."
# Contents: vim/src/cmdline.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:13 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/cmdline.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/cmdline.c'\"
else
echo shar: Extracting \"'vim/src/cmdline.c'\" \(46721 characters\)
sed "s/^X//" >'vim/src/cmdline.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mo...@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*

X * cmdline.c: functions for reading in the command line and executing it
X */
X


X#include "vim.h"
X#include "globals.h"
X#include "proto.h"

X#include "param.h"
X#include "cmdtab.h"
X#include "ops.h" /* included because we call functions in ops.c */
X#include "fcntl.h" /* for chdir() */
X
X#ifdef LATTICE
X# define mktemp(a) tmpnam(a)
X#endif
X
X/*
X * the history list of alternate files
X */
X#define NUMALTFILES 20
X
Xstatic char *altfiles[NUMALTFILES]; /* alternate files */
Xstatic linenr_t altlnum[NUMALTFILES]; /* line # in alternate file */
Xstatic linenr_t doecmdlnum = 0; /* line # in new file for doecmd() */
X
X/*
X * variables shared between getcmdline() and redrawcmdline()
X */
Xstatic int cmdlen; /* number of chars on command line */
Xstatic int cmdpos; /* current cursor position */
Xstatic int cmdslen; /* lenght of command line on screen */
Xstatic int cmdspos; /* cursor position on screen */
Xstatic int cmdredraw; /* max. number of lines of the command - 1 */
Xstatic int cmdfirstc; /* ':', '/' or '?' */
Xstatic u_char *cmdbuff; /* pointer to command line buffer */
X
X/*
X * The next two variables contain the bounds of any range given in a command.
X * They are set by docmdline().
X */
Xstatic linenr_t line1, line2;
Xstatic int forceit;
Xstatic int regname;
X
Xstatic void cmdchecklen __ARGS((void));
Xstatic void cursorcmd __ARGS((void));
Xstatic u_char *DoOneCmd __ARGS((u_char *));
Xstatic void dobang __ARGS((int, u_char *));
Xstatic int autowrite __ARGS((void));
Xstatic int dowrite __ARGS((u_char *, int));
Xstatic int doecmd __ARGS((char *));
Xstatic void doshell __ARGS((char *));
Xstatic void dofilter __ARGS((u_char *, int, int));
Xstatic int check_readonly __ARGS((void));
Xstatic int check_changed __ARGS((int));
Xstatic int check_fname __ARGS((void));
Xstatic int check_more __ARGS((void));
Xstatic void setaltfname __ARGS((char *, linenr_t, int));
X#ifdef WILD_CARDS
Xstatic char *ExpandOne __ARGS((u_char *, int, int));
Xstatic void showmatches __ARGS((char *, int));
Xstatic char *addstar __ARGS((char *, int));
X#endif
Xstatic linenr_t get_address __ARGS((u_char **));


X
Xextern char *mktemp __ARGS((char *));
X

Xextern int global_busy, global_wait; /* shared with csearch.c */
X
X/*
X * variable shared with quickfix.c
X */
Xextern int qf_index;
X
X/*
X * getcmdline() - accept a command line starting with ':', '!', '/', or '?'
X *
X * For searches the optional matching '?' or '/' is removed.
X */
X
X int
Xgetcmdline(firstc, buff)
X int firstc; /* either ':', '/', or '?' */
X u_char *buff; /* buffer for command string */
X{
X register u_char c;
X int nextc = 0;
X register int i;
X int retval;
X int hiscnt; /* current history line in use */
X static char **history = NULL; /* history table */
X static int hislen = 0; /* actual lengt of history table */
X int newlen; /* new length of history table */
X static int hisidx = -1; /* last entered entry */
X char **temp;
X int j;
X
X#ifdef WILD_CARDS
X int gotesc = FALSE; /* TRUE when last char typed was <ESC> */
X char *p1, *p2;
X int oldlen;
X int difflen;
X int findex;
X#endif
X
X
X
X/*
X * set some variables for redrawcmd()
X */
X cmdfirstc = firstc;
X cmdbuff = buff;
X cmdlen = cmdpos = 0;
X cmdslen = cmdspos = 1;
X cmdredraw = 0;
X State = CMDLINE;
X gotocmdline(TRUE, firstc);
X
X/*
X * if size of history table changed, reallocate it
X */
X newlen = p_hi;
X if (newlen != hislen) /* history length changed */
X {
X if (newlen)
X temp = (char **)alloc((int)(newlen * sizeof(char *)));
X else
X temp = NULL;
X if (newlen == 0 || temp != NULL)
X {
X if (newlen > hislen) /* array becomes bigger */
X {
X for (i = 0; i <= hisidx; ++i)
X temp[i] = history[i];
X j = i;
X for ( ; i <= newlen - (hislen - hisidx); ++i)
X temp[i] = NULL;
X for ( ; j < hislen; ++i, ++j)
X temp[i] = history[j];
X }
X else /* array becomes smaller */
X {
X j = hisidx;
X for (i = newlen - 1; ; --i)


X {
X if (i >= 0)

X temp[i] = history[j]; /* copy newest entries */
X else
X free(history[j]); /* remove older entries */
X if (--j < 0)
X j = hislen - 1;
X if (j == hisidx)
X break;
X }
X hisidx = newlen - 1;
X }
X free(history);
X history = temp;
X hislen = newlen;
X }
X }
X hiscnt = hislen; /* set hiscnt to impossible history value */
X
X /* collect the command string, handling '\b', @ and much more */
X for (;;)
X {
X cursorcmd(); /* set the cursor on the right spot */
X if (nextc) /* character remaining from CTRL-V */
X {


X c = nextc;
X nextc = 0;
X }

X else
X c = vgetc();
X
X#ifdef WILD_CARDS
X if (c != ESC && c != Ctrl('N') && c != Ctrl('P') && gotesc)
X {
X (void)ExpandOne(NULL, FALSE, -2); /* may free expanded file names */
X gotesc = FALSE;
X }
X#endif
X
X if (c == '\n' || c == '\r')
X {
X outchar('\r');
X flushbuf();
X break;
X }
X
X switch (c)
X {
X case BS:
X case DEL:
X /*
X * delete current character is the same as backspace on next
X * character, except at end of line
X */
X if (c == DEL && cmdpos != cmdlen)
X ++cmdpos;
X if (cmdpos > 0)
X {
X --cmdpos;
X --cmdlen;
X for (i = cmdpos; i < cmdlen; ++i)
X buff[i] = buff[i + 1];
X redrawcmd();
X }
X else if (cmdlen == 0)


X {
X retval = FALSE;

X msg("");
X goto returncmd; /* back to cmd mode */
X }
X continue;
X
X/* case '@': only in very old vi */


X case Ctrl('U'):

Xclearline:
X cmdpos = 0;
X cmdlen = 0;
X cmdslen = 1;
X cmdspos = 1;
X gotocmdline(TRUE, firstc);
X continue;
X
X case ESC:
X#ifndef WILD_CARDS
X retval = FALSE;
X msg("");
X goto returncmd; /* back to cmd mode */
X#else
X /*
X * hitting <ESC> twice means: abandon command line
X */
X if (gotesc)


X {
X retval = FALSE;

X msg("");
X goto returncmd; /* back to cmd mode */
X }
X gotesc = TRUE;
X findex = 0;
X
Xdoexpand:
X outstr("..."); /* show that we are busy */
X flushbuf();
X i = cmdslen;
X cmdslen = cmdpos + 4;
X cmdchecklen(); /* check if we caused a scrollup */
X cmdslen = i;
X
X for (i = cmdpos; i > 0 && buff[i - 1] != ' '; --i)
X ;
X oldlen = cmdpos - i;
X
X /* add a "*" to the file name and expand it */
X if ((p1 = addstar((char *)&buff[i], oldlen)) != NULL)
X {
X if ((p2 = ExpandOne((u_char *)p1, FALSE, findex)) != NULL)
X {
X if (cmdlen + (difflen = strlen(p2) - oldlen) > CMDBUFFSIZE - 4)
X emsg(e_toolong);
X else
X {
X strncpy((char *)&buff[cmdpos + difflen], (char *)&buff[cmdpos], (size_t)(cmdlen - cmdpos));
X strncpy((char *)&buff[i], p2, strlen(p2));
X cmdlen += difflen;
X cmdpos += difflen;
X }
X free(p2);
X }
X free(p1);
X }
X redrawcmd();
X continue;
X


X case Ctrl('D'):

X {
X for (i = cmdpos; i > 0 && buff[i - 1] != ' '; --i)
X ;
X showmatches((char *)&buff[i], cmdpos - i);
X
X redrawcmd();


X continue;
X }
X#endif
X

X case K_RARROW:
X case K_SRARROW:
X do
X {
X if (cmdpos >= cmdlen)
X break;
X cmdspos += charsize(buff[cmdpos]);
X ++cmdpos;
X }
X while (c == K_SRARROW && buff[cmdpos] != ' ');
X continue;
X
X case K_LARROW:
X case K_SLARROW:
X do
X {
X if (cmdpos <= 0)
X break;
X --cmdpos;
X cmdspos -= charsize(buff[cmdpos]);
X }
X while (c == K_SLARROW && buff[cmdpos - 1] != ' ');
X continue;
X
X case Ctrl('N'): /* next match */
X case Ctrl('P'): /* previous match */
X#ifdef WILD_CARDS
X if (gotesc)
X {
X findex = (c == Ctrl('P')) ? 2 : 1;
X goto doexpand;
X }
X#endif
X case K_UARROW:
X case K_DARROW:
X if (hislen == 0) /* no history */
X continue;
X
X i = hiscnt;
X if (c == K_UARROW || c == Ctrl('P'))
X {
X if (hiscnt == hislen)
X hiscnt = hisidx;
X else if (hiscnt == 0 && hisidx != hislen - 1)
X hiscnt = hislen - 1;
X else if (hiscnt != hisidx + 1)
X --hiscnt;
X }
X else
X {
X if (hiscnt == hisidx) /* on last entry, clear the line */
X {
X hiscnt = hislen;
X goto clearline;
X }
X if (hiscnt == hislen) /* not on a history line, nothing to do */
X continue;
X if (hiscnt == hislen - 1)
X hiscnt = 0;
X else
X ++hiscnt;
X }
X if (hiscnt < 0 || history[hiscnt] == NULL)
X hiscnt = i;
X else
X {
X strcpy((char *)buff, history[hiscnt]);
X cmdpos = cmdlen = strlen((char *)buff);
X redrawcmd();
X }
X continue;
X
X case Ctrl('V'):
X outchar('^');
X outtrans((char *)(buff + cmdpos), cmdlen - cmdpos);
X ++cmdslen;
X cmdchecklen();
X --cmdslen;
X cursorcmd();
X c = get_literal(&nextc); /* get next (two) character(s) */
X }
X
X /* we come here if we have entered a normal character */
X if (cmdlen < CMDBUFFSIZE - 2)
X {
X for (i = cmdlen++; i > cmdpos; --i)
X buff[i] = buff[i - 1];
X buff[cmdpos] = c;
X outtrans((char *)(buff + cmdpos), cmdlen - cmdpos);
X ++cmdpos;
X i = charsize(c);
X cmdslen += i;
X cmdspos += i;
X }
X cmdchecklen();
X }
X buff[cmdlen] = NUL;
X
X if (hislen != 0)
X {
X if (++hisidx == hislen)
X hisidx = 0;
X free(history[hisidx]);
X history[hisidx] = strsave((char *)buff);
X }
X retval = TRUE;
X
Xreturncmd:
X if (cmdredraw)
X updateScreen(CLEAR);


X State = NORMAL;
X script_winsize_pp();

X return retval;
X}
X
X/*
X * Check if the command line spans more than one screen line.
X * The maximum number of lines is remembered.


X */
X static void

Xcmdchecklen()
X{
X if (cmdslen / Columns > cmdredraw)
X cmdredraw = cmdslen / Columns;
X}
X
X/*
X * this fuction is called when the screen size changes
X */
X void
Xredrawcmdline()
X{
X cmdredraw = 0;
X redrawcmd();
X cursorcmd();
X}
X
X/*
X * Redraw what is currently on the command line.
X */
X void
Xredrawcmd()


X{
X register int i;
X

X windgoto((int)Rows - 1 - cmdredraw, 0);
X outchar(cmdfirstc);
X cmdslen = 1;
X cmdspos = 1;
X outtrans((char *)cmdbuff, cmdlen);
X for (i = 0; i < cmdlen; )
X {
X cmdslen += charsize(cmdbuff[i]);
X if (++i == cmdpos)
X cmdspos = cmdslen;
X }
X for (i = (cmdredraw + 1) * Columns - cmdslen; --i > 0; )
X outchar(' ');
X cmdchecklen();


X}
X
X static void

Xcursorcmd()
X{
X windgoto((int)Rows - 1 - cmdredraw + (cmdspos / (int)Columns), cmdspos % (int)Columns);
X}
X
X/*
X * docmdline(): execute an Ex command line
X *
X * 1. If no line given, get one.
X * 2. Split up in parts separated with '|'.
X *
X * This function may be called recursively!
X */
X void
Xdocmdline(cmdline)
X u_char *cmdline;
X{
X u_char buff[CMDBUFFSIZE]; /* command line */
X u_char *nextcomm;
X
X/*
X * 1. If no line given: get one.
X */
X if (cmdline == NULL)
X {
X if (!getcmdline(':', buff))
X return;
X }
X else
X {
X if (strlen((char *)cmdline) > (size_t)(CMDBUFFSIZE - 2))
X {
X emsg(e_toolong);
X return;
X }
X /* Make a copy of the command so we can mess with it. */
X strcpy((char *)buff, (char *)cmdline);
X }
X
X/*
X * 2. Loop for each '|' separated command.
X * DoOneCmd will set nextcommand to NULL if there is no trailing '|'.
X */
X for (;;)
X {
X nextcomm = DoOneCmd(buff);
X if (nextcomm == NULL)
X break;
X strcpy((char *)buff, (char *)nextcomm);
X }
X}
X
X/*
X * Execute one Ex command.
X *
X * 2. skip comment lines and leading space
X * 3. parse range
X * 4. parse command
X * 5. parse arguments
X * 6. switch on command name
X *
X * This function may be called recursively!
X */
X static u_char *
XDoOneCmd(buff)
X u_char *buff;
X{
X u_char cmdbuf[CMDBUFFSIZE]; /* for '%' and '#' expansion */
X u_char c;
X register u_char *p;
X char *q;
X u_char *cmd, *arg;
X int i;
X int cmdidx;
X int argt;
X register linenr_t lnum;
X long n;
X int addr_count; /* number of address specifications */
X FPOS pos;
X int append = FALSE; /* write with append */
X u_char *nextcomm;
X
X
X/*
X * 2. skip comment lines and leading space, colons or bars
X */
X for (cmd = buff; *cmd && strchr(" \t:|", *cmd) != NULL; cmd++)
X ;
X
X nextcomm = NULL; /* default: no next command */
X if (strchr("#\"", *cmd) != NULL) /* ignore comment and empty lines */
X goto doend;
X
X/*
X * 3. parse a range specifier of the form: addr [,addr] [;addr] ..
X *
X * where 'addr' is:
X *
X * % (entire file)
X * $ [+-NUM]
X * 'x [+-NUM] (where x denotes a currently defined mark)
X * . [+-NUM]
X * [+-NUM]..
X * NUM
X *
X * The cmd pointer is updated to point to the first character following the
X * range spec. If an initial address is found, but no second, the upper bound
X * is equal to the lower.
X */
X
X addr_count = 0;
X --cmd;
X do {
X ++cmd; /* skip ',' or ';' */
X line1 = line2;
X line2 = Curpos.lnum; /* default is current line number */
X skipspace((char **)&cmd);
X lnum = get_address(&cmd);
X if (lnum == INVLNUM)
X {
X if (*cmd == '%') /* '%' - all lines */
X {
X ++cmd;
X line1 = 1;
X line2 = line_count;
X ++addr_count;
X }
X } else
X line2 = lnum;
X addr_count++;
X
X if (*cmd == ';')
X {
X if (line2 == 0)
X Curpos.lnum = 1;
X else
X Curpos.lnum = line2;
X }
X } while (*cmd == ',' || *cmd == ';');
X
X /* One address given: set start and end lines */
X if (addr_count == 1) {
X line1 = line2;
X /* ... but only implicit: really no address given */
X if (lnum == INVLNUM) {
X addr_count = 0;
X }
X }
X
X if (line1 > line2 || line2 > line_count)
X {
X emsg(e_invrange);
X goto doend;
X }
X
X/*
X * 4. parse command
X */
X
X skipspace((char **)&cmd);
X
X /*
X * If we got a line, but no command, then go to the line.
X */
X if (*cmd == NUL || *cmd == '"' || (*cmd == '|' && (nextcomm = cmd) != NULL))
X {
X if (addr_count != 0)
X {
X if (line2 == 0)
X Curpos.lnum = 1;
X else
X Curpos.lnum = line2;
X Curpos.col = 0;
X cursupdate();
X }
X goto doend;
X }
X
X /*
X * isolate the command and search for it in the command table
X */
X p = cmd;
X if (*cmd != 'k')
X while (isalpha(*p))
X ++p;
X if (p == cmd && strchr("@!=><&k", *p) != NULL) /* non-alpha or 'k' command */
X ++p;
X i = p - cmd;
X
X for (cmdidx = 0; cmdidx < CMD_SIZE; ++cmdidx)
X if (strncmp(cmdnames[cmdidx].cmd_name, (char *)cmd, (size_t)i) == 0)
X break;
X
X if (i == 0 || cmdidx == CMD_SIZE)
X {
X emsg(e_invcmd);
X goto doend;
X }
X
X if (*p == '!') /* forced commands */
X {
X ++p;
X forceit = TRUE;
X }
X else
X forceit = FALSE;
X
X/*
X * 5. parse arguments
X */
X argt = cmdnames[cmdidx].cmd_argt;
X
X if (!(argt & RANGE) && addr_count)
X {
X emsg(e_norange);
X goto doend;
X }
X
X if (!(argt & ZEROR)) /* zero in range not allowed */
X {
X if (line1 == 0)
X line1 = 1;
X if (line2 == 0)
X line2 = 1;
X }
X
X arg = p; /* remember start of argument */
X skipspace((char **)&arg);
X
X if ((argt & NEEDARG) && *arg == NUL)
X {
X emsg(e_argreq);
X goto doend;
X }
X
X /*
X * check for '|' to separate commands and '"' to start comments
X */
X if (argt & TRLBAR)
X {
X while (*p)
X {
X if (*p == Ctrl('V'))
X {
X if (argt & USECTRLV) /* skip the CTRL-V and next char */
X ++p;
X else /* remove CTRL-V and skip next char */
X strcpy((char *)p, (char *)p + 1);
X }
X else if ((*p == '"' && !(argt & NOTRLCOM)) || *p == '|')
X { /* remove the backslash or ^V */
X if (*(p - 1) == '\\')
X {
X strcpy((char *)p - 1, (char *)p);
X --p;
X }
X else
X {


X if (*p == '|')

X nextcomm = p + 1;
X *p = NUL;
X break;
X }
X }
X ++p;
X }
X }
X
X if ((argt & DFLALL) && addr_count == 0)
X {
X line1 = 1;
X line2 = line_count;
X }
X
X regname = 0;
X /* accept numbered register only when no count allowed (:put) */
X if ((argt & REGSTR) && (isalpha(*arg) || *arg == '.' || (!(argt & COUNT) && isdigit(*arg))))
X {
X regname = *arg;
X ++arg;
X skipspace((char **)&arg);
X }
X
X if ((argt & COUNT) && isdigit(*arg))
X {
X i = getdigits((char **)&arg);
X skipspace((char **)&arg);


X if (i <= 0)

X {
X emsg(e_zerocount);
X goto doend;
X }
X line1 = line2;
X line2 += i - 1;
X }
X
X if (!(argt & EXTRA) && strchr("|\"#", *arg) == NULL) /* no arguments allowed */
X {
X emsg(e_trailing);
X goto doend;
X }
X
X if (cmdidx == CMD_write && *arg == '>' && *(arg + 1) == '>') /* append */
X {
X arg += 2;
X skipspace((char **)&arg);
X append = TRUE;
X }
X
X /*
X * change '%' to Filename, '#' to altfile
X */
X if (argt & XFILE)
X {
X for (p = arg; *p; ++p)
X {
X c = *p;
X if (c != '%' && c != '#') /* nothing to expand */
X continue;
X if (*(p - 1) == '\\') /* remove escaped char */
X {
X strcpy((char *)p - 1, (char *)p);
X --p;
X continue;
X }
X
X n = 1; /* length of what we expand */
X if (c == '%')
X {
X if (check_fname())
X goto doend;
X q = Filename;
X }
X else
X {
X q = (char *)p + 1;
X i = getdigits(&q);
X n = q - (char *)p;
X
X if (i >= NUMALTFILES || altfiles[i] == NULL)
X {
X emsg(e_noalt);
X goto doend;
X }
X doecmdlnum = altlnum[i];
X q = altfiles[i];
X }
X i = strlen((char *)arg) + strlen(q) + 3;
X if (nextcomm)
X i += strlen((char *)nextcomm);
X if (i > CMDBUFFSIZE)
X {
X emsg(e_toolong);
X goto doend;
X }
X /*
X * we built the new argument in cmdbuf[], then copy it back to buff[]
X */
X *p = NUL;
X strcpy((char *)cmdbuf, (char *)arg);
X strcat((char *)cmdbuf, q);
X i = strlen((char *)cmdbuf);
X strcat((char *)cmdbuf, (char *)p+n);
X p = buff + i - 1;
X if (nextcomm)
X {
X i = strlen((char *)cmdbuf) + 1;
X strcpy((char *)cmdbuf + i, (char *)nextcomm);
X nextcomm = buff + i;
X }
X strcpy((char *)buff, (char *)cmdbuf);
X arg = buff;
X }
X#ifdef WILD_CARDS
X if (argt & NOSPC) /* one file argument: expand wildcards */
X {
X if (has_wildcard((char *)arg))
X {
X if ((p = (u_char *)ExpandOne(arg, TRUE, -1)) == NULL)
X goto doend;
X if (strlen((char *)p) + arg - buff < CMDBUFFSIZE - 2)
X strcpy((char *)arg, (char *)p);
X else
X emsg(e_toolong);
X free(p);


X }
X }
X#endif
X }
X

X/*
X * 6. switch on command name
X */
X switch (cmdidx)
X {
X case CMD_quit:
X exiting = TRUE;
X settmode(0); /* allows typeahead */
X if (check_changed(FALSE) || check_more())
X {
X exiting = FALSE;
X settmode(1);
X break;
X }
X getout(0);
X
X case CMD_stop:
X if (!forceit && Changed)
X autowrite();
X gotocmdline(TRUE, NUL);
X flushbuf();
X mch_suspend(); /* call machine specific function */
X updateScreen(CLEAR);
X break;
X
X case CMD_xit:
X case CMD_wq:
X exiting = TRUE;
X settmode(0); /* allows typeahead */
X if (((cmdidx == CMD_wq || Changed) &&
X (check_readonly() || !dowrite(arg, FALSE))) ||
X check_more())
X {
X exiting = FALSE;
X settmode(1);
X break;
X }
X getout(0);
X
X case CMD_args:
X gotocmdline(TRUE, NUL);
X for (i = 0; i < numfiles; ++i)
X {
X if (i == curfile)
X outchar('[');
X outstrn(files[i]);
X if (i == curfile)
X outchar(']');
X outchar(' ');
X }
X outchar('\n');
X wait_return(TRUE);
X break;
X
X case CMD_wnext:
X n = line2;
X line1 = 1;
X line2 = line_count;
X dowrite(arg, FALSE);
X line2 = n;
X arg = (u_char *)""; /* no file list */
X /*FALLTHROUGH*/
X
X case CMD_next:
X if (check_changed(TRUE))
X break;
X if (*arg != NUL) /* redefine file list */
X {
X if (doarglist((char *)arg))
X break;
X i = 0;
X }
X else
X {
X if (addr_count == 0)
X i = curfile + 1;
X else
X i = curfile + line2;
X }
X
Xdonextfile: if (i < 0 || i >= numfiles)
X {
X emsg(e_nomore);
X break;
X }
X if (check_changed(TRUE))
X break;
X curfile = i;
X doecmd(files[curfile]);
X break;
X
X case CMD_previous:
X case CMD_Next:
X if (addr_count == 0)
X i = curfile - 1;
X else
X i = curfile - line2;
X goto donextfile;
X
X case CMD_rewind:
X i = 0;
X goto donextfile;
X
X case CMD_write:
X if (*arg == '!') /* input lines to shell command */
X dofilter(arg + 1, TRUE, FALSE);
X else
X dowrite(arg, append);
X break;
X
X case CMD_edit:
X case CMD_ex:
X case CMD_visual:
X doecmd((char *)arg);
X break;
X
X case CMD_file:


X if (*arg == NUL)

X fileinfo();
X else
X {
X setfname((char *)arg);
X filemess(Filename, "");
X maketitle();
X }
X break;
X
X case CMD_files:
X#ifdef AMIGA
X settmode(0); /* set cooked mode, so output can be halted */
X#endif
X for (i = 0; i < NUMALTFILES; ++i)
X {
X if (altfiles[i])
X {
X sprintf(IObuff, "%2d \"%s\" line %ld\n", i, altfiles[i], (long)altlnum[i]);


X outstrn(IObuff);
X }
X flushbuf();

X }
X#ifdef AMIGA
X settmode(1);
X#endif
X wait_return(TRUE);

X break;
X
X case CMD_read:
X if (forceit || (*arg == '!' && ++arg))
X {
X dofilter(arg, FALSE, TRUE); /* :r!cmd */
X break;
X }
X if (!u_save(line2, (linenr_t)(line2 + 1)))
X break;
X if (readfile((char *)arg, line2, FALSE))
X {
X emsg(e_notopen);
X break;
X }
X updateScreen(NOT_VALID);
X CHANGED;
X break;
X
X case CMD_cd:
X case CMD_chdir:
X if (*arg == NUL)
X {
X if (dirname(IObuff, IOSIZE))
X msg(IObuff);
X else
X emsg(e_unknown);
X }
X else
X {
X if (chdir((char *)arg))
X emsg(e_failed);
X }
X break;
X
X case CMD_equal:
X smsg("line %ld", (long)line2);
X break;
X
X case CMD_list:
X i = p_list;
X p_list = 1;
X case CMD_number:
X case CMD_print:
X#ifdef AMIGA
X settmode(0); /* set cooked mode, so output can be halted */
X#endif
X gotocmdline(TRUE, NUL); /* clear command line */
X n = 0;
X for (;;)
X {
X if (p_nu || cmdidx == CMD_number)
X {
X sprintf(IObuff, "%7ld ", (long)line1);
X outstrn(IObuff);
X }
X n += prt_line(nr2ptr(line1));
X if (++line1 > line2)
X break;
X outchar('\n');
X flushbuf();
X n = Columns;


X }
X#ifdef AMIGA
X settmode(1);
X#endif
X

X if (cmdidx == CMD_list)
X p_list = i;
X
X if (n >= Columns - (p_ru ? 22 : p_sc ? 12 : 0))
X {
X outchar('\n');
X if (global_busy)
X global_wait = 1;
X else
X wait_return(TRUE);
X }
X break;
X
X case CMD_shell:
X doshell(NULL);
X break;
X
X case CMD_tag:
X dotag((char *)arg, 0, addr_count ? (int)line2 : 1);
X break;
X
X case CMD_pop:
X dotag("", 1, addr_count ? (int)line2 : 1);
X break;
X
X case CMD_tags:
X dotags();
X break;
X
X case CMD_marks:
X domarks();
X break;
X
X case CMD_jumps:
X dojumps();
X break;
X
X case CMD_digraph:
X#ifdef DIGRAPHS
X if (*arg)
X putdigraph((char *)arg);
X else
X listdigraphs();
X#else
X emsg("No digraphs in this version");
X#endif /* DIGRAPHS */
X break;
X
X case CMD_set:
X doset((char *)arg);
X break;
X
X case CMD_map:
X case CMD_noremap:
X /*
X * If we are sourcing .exrc or .vimrc in current directory we
X * print the mappings for security reasons.


X */
X if (secure)
X {
X secure = 2;

X outtrans((char *)cmd, -1);


X outchar('\n');
X }

X case CMD_unmap:
X switch (domap((*cmd == 'n') ? 2 : (*cmd == 'u'), (char *)arg,
X forceit ? INSERT : NORMAL))
X {
X case 1: emsg(e_invarg);
X break;
X case 2: emsg(e_nomap);
X break;
X case 3: emsg(e_ambmap);
X break;
X }
X break;
X
X case CMD_display:
X dodis(); /* display buffer contents */
X break;
X
X case CMD_help:
X help();
X break;
X
X case CMD_version:
X msg(longVersion);
X break;
X
X case CMD_winsize:
X line1 = getdigits((char **)&arg);
X skipspace((char **)&arg);
X line2 = getdigits((char **)&arg);
X set_winsize((int)line1, (int)line2, TRUE);
X break;
X
X case CMD_delete:
X case CMD_yank:
X case CMD_rshift:
X case CMD_lshift:
X yankbuffer = regname;
X startop.lnum = line1;
X endop.lnum = line2;
X nlines = line2 - line1 + 1;
X mtype = MLINE;
X Curpos.lnum = line1;
X switch (cmdidx)
X {
X case CMD_delete:
X dodelete();
X break;
X case CMD_yank:
X doyank(FALSE);
X break;
X case CMD_rshift:
X doshift(RSHIFT);
X break;
X case CMD_lshift:
X doshift(LSHIFT);
X break;
X }
X break;
X
X case CMD_put:
X yankbuffer = regname;
X Curpos.lnum = line2;
X doput(forceit ? BACKWARD : FORWARD, -1L);
X break;
X
X case CMD_t:
X case CMD_copy: /* copy: first yank, then put */
X case CMD_move: /* move: first delete, then put */
X n = get_address(&arg);
X if (n == INVLNUM)
X {
X emsg(e_invaddr);
X break;
X }
X
X if (cmdidx == CMD_move)
X {
X if (n >= line1)
X {
X --n;
X Curpos.lnum = n - (line2 - line1) + 1;
X }
X else
X Curpos.lnum = n + 1;
X while (line1 <= line2)
X {
X /* this undo is not efficient, but it works */
X u_save(line1 - 1, line1 + 1);
X q = delsline(line1, FALSE);
X u_save(n, n + 1);
X appendline(n, q);
X if (n < line1)
X {
X ++n;
X ++line1;
X }
X else
X --line2;
X }
X }
X else
X {
X u_save(n, n + 1);
X Curpos.lnum = n + 1;
X lnum = line2 - line1 + 1;
X while (line1 <= line2)
X {
X appendline(n, save_line(nr2ptr(line1)));
X ++n;
X ++line1;
X if (n < line1)
X {
X ++line1;
X ++line2;
X }
X }
X msgmore((long)lnum);
X }
X u_clearline();
X Curpos.col = 0;
X updateScreen(NOT_VALID);
X break;
X
X case CMD_and:
X case CMD_substitute:
X dosub(line1, line2, (char *)arg, &nextcomm);
X break;
X
X case CMD_join:
X Curpos.lnum = line1;
X if (line1 == line2)
X {
X if (line2 == line_count)


X {
X beep();
X break;
X }

X ++line2;
X }
X dodojoin(line2 - line1 + 1, !forceit, TRUE);
X break;
X
X case CMD_global:
X if (forceit)
X *cmd = 'v';
X case CMD_vglobal:
X doglob(*cmd, line1, line2, (char *)arg);
X break;
X
X case CMD_at: /* :[addr]@r */
X Curpos.lnum = line2;
X if (!doexecbuf(*arg)) /* put the register in mapbuf */
X beep();
X else
X docmdline(NULL); /* execute from the mapbuf */
X break;
X
X case CMD_bang:
X dobang(addr_count, arg);
X break;
X
X case CMD_undo:
X u_undo(1);
X break;
X
X case CMD_source:
X if (forceit) /* :so! read vi commands */
X openscript((char *)arg);
X else if (dosource((char *)arg)) /* :so read ex commands */
X emsg(e_notopen);
X break;
X
X case CMD_mkvimrc:


X if (*arg == NUL)

X arg = (u_char *)VIMRC_FILE;
X /*FALLTHROUGH*/
X
X case CMD_mkexrc:
X {
X FILE *fd;
X


X if (*arg == NUL)

X arg = (u_char *)EXRC_FILE;
X if (!forceit && (fd = fopen((char *)arg, "r")) != NULL)
X {
X fclose(fd);
X emsg(e_exists);
X break;
X }
X
X if ((fd = fopen((char *)arg, "w")) == NULL)
X {
X emsg(e_notcreate);
X break;
X }
X if (makemap(fd) || makeset(fd))
X emsg(e_write);
X fclose(fd);
X break;
X }
X
X case CMD_cc:
X qf_jump(atoi((char *)arg));
X break;
X
X case CMD_cf:


X if (*arg == NUL)

X arg = (u_char *)p_ef;
X if (!qf_init((char *)arg))
X qf_jump(0);
X break;
X
X case CMD_cl:
X qf_list();
X break;
X
X case CMD_cn:
X qf_jump(qf_index + 1);
X break;
X
X case CMD_cp:
X qf_jump(qf_index - 1);
X break;
X
X case CMD_cq:
X getout(1); /* this does not always work. why? */
X
X case CMD_mark:
X case CMD_k:
X pos = Curpos; /* save Curpos */
X Curpos.lnum = line2;
X Curpos.col = 0;
X setmark(*arg); /* set mark */
X Curpos = pos; /* restore Curpos */
X break;
X
X#ifdef SETKEYMAP
X case CMD_setkeymap:
X set_keymap(arg);
X break;
X#endif
X
X default:
X emsg(e_invcmd);
X }
X
X
Xdoend:
X return nextcomm;
X}
X
X/*
X * handle the :! command.
X * We replace the extra bangs by the previously entered command and remember
X * the command.


X */
X static void

Xdobang(addr_count, arg)
X int addr_count;
X u_char *arg;
X{
X static char *prevcmd = NULL; /* the previous command */
X char *t;
X char *trailarg;
X int len;
X
X /*
X * Disallow shell commands from .exrc and .vimrc in current directory for


X * security reasons.
X */
X if (secure)
X {
X secure = 2;
X emsg(e_curdir);

X return;
X }
X len = strlen((char *)arg) + 1;
X
X if (Changed)
X autowrite();
X /*
X * try to find an embedded bang, like in :!<cmd> ! [args]
X * (:!! is indicated by the 'forceit' variable)
X */
X trailarg = (char *)arg;
X skiptospace(&trailarg);
X skipspace(&trailarg);
X if (*trailarg == '!')
X *trailarg++ = NUL;
X else
X trailarg = NULL;
X
X if (forceit || trailarg != NULL) /* use the previous command */
X {
X if (prevcmd == NULL)
X {
X emsg(e_noprev);
X return;
X }
X len += strlen(prevcmd) * (trailarg != NULL && forceit ? 2 : 1);
X }
X
X if (len > CMDBUFFSIZE)
X {
X emsg(e_toolong);
X return;
X }
X if ((t = alloc(len)) == NULL)
X return;
X *t = NUL;
X if (forceit)
X strcpy(t, prevcmd);
X strcat(t, (char *)arg);
X if (trailarg != NULL)
X {
X strcat(t, prevcmd);
X strcat(t, trailarg);
X }
X free(prevcmd);
X prevcmd = t;
X
X if (bangredo) /* put cmd in redo buffer for ! command */
X {
X AppendToRedobuff(prevcmd);
X AppendToRedobuff("\n");
X bangredo = FALSE;
X }
X if (addr_count == 0)
X {
X smsg(":!%s", prevcmd);
X doshell(prevcmd); /* :! */
X }
X else
X {
X smsg(":%ld,%ld!%s", (long)line1, (long)line2, prevcmd);
X dofilter((u_char *)prevcmd, TRUE, TRUE); /* :range! */
X }
X}
X
X static int
Xautowrite()
X{
X if (!p_aw || check_readonly() || check_fname())
X return FALSE;
X return (writeit(Filename, (linenr_t)1, line_count, 0, 0));


X}
X
X static int

Xdowrite(arg, append)
X u_char *arg;
X int append;
X{
X FILE *f;
X int other;
X
X /*
X * if we have a new file name put it in the list of alternate file names
X */
X other = otherfile((char *)arg);
X if (*arg != NUL && other)
X setaltfname(strsave((char *)arg), (linenr_t)1, TRUE);
X
X /*
X * writing to the current file is not allowed in readonly mode
X */
X if ((*arg == NUL || !other) && check_readonly())
X return FALSE;
X
X /*
X * write to current file
X */
X if (*arg == NUL)
X {
X if (check_fname())
X return FALSE;
X return (writeit(Filename, line1, line2, append, forceit));
X }
X
X /*
X * write to other file; overwriting only allowed with '!'
X */
X if (!forceit && !append && !p_wa && (f = fopen((char *)arg, "r")) != NULL)
X { /* don't overwrite existing file */
X fclose(f);
X emsg(e_exists);
X return 0;
X }
X return (writeit((char *)arg, line1, line2, append, forceit));


X}
X
X static int

Xdoecmd(arg)
X char *arg;
X{
X int setalt;


X char *command = NULL;

X int redraw_save;
X linenr_t newlnum;
X
X newlnum = doecmdlnum;
X doecmdlnum = 0; /* reset it for next time */
X
X if (*arg == '+')
X {
X ++arg;
X if (isspace(*arg))


X command = "$";
X else

X {
X command = arg;
X while (*arg && !isspace(*arg))
X ++arg;
X }
X if (*arg)
X *arg++ = NUL;
X
X skipspace(&arg);
X }
X
X#ifdef AMIGA
X fname_case(arg); /* set correct case for filename */
X#endif
X setalt = (*arg != NUL && otherfile(arg));
X if (check_changed(FALSE))
X {
X if (setalt)
X setaltfname(strsave(arg), (linenr_t)1, TRUE);
X return FALSE;
X }
X if (setalt)
X {
X setaltfname(Filename, Curpos.lnum, FALSE);
X Filename = NULL;
X setfname(arg);
X }
X else if (newlnum == 0)
X newlnum = Curpos.lnum;
X maketitle();
X if (check_fname())
X return FALSE;
X
X /* clear mem and read file */
X freeall();
X filealloc();


X UNCHANGED;
X startscript(); /* re-start auto script file */

X startop.lnum = 0; /* clear '[ and '] marks */
X endop.lnum = 0;
X
X redraw_save = RedrawingDisabled;
X RedrawingDisabled = TRUE; /* don't redraw until the cursor is in
X * the right line */
X readfile(Filename, (linenr_t)0, TRUE);
X if (newlnum && command == NULL)
X {
X if (newlnum != INVLNUM)
X Curpos.lnum = newlnum;
X else
X Curpos.lnum = line_count;
X Curpos.col = 0;
X }


X if (command)
X docmdline((u_char *)command);

X RedrawingDisabled = redraw_save; /* cursupdate() will redraw the screen */
X if (p_im)
X stuffReadbuff("i"); /* start editing in insert mode */
X return TRUE;


X}
X
X static void

Xdoshell(cmd)
X char *cmd;
X{
X /*
X * Disallow shell commands from .exrc and .vimrc in current directory for


X * security reasons.
X */
X if (secure)
X {
X secure = 2;
X emsg(e_curdir);

X return;
X }
X gotocmdline(FALSE, '\n');
X
X stoptermcap();
X call_shell(cmd, 0);
X
X if (global_busy)
X global_wait = 1;
X else
X#ifdef AMIGA
X wait_return(!term_console);
X#else
X wait_return(TRUE);
X#endif
X starttermcap();
X
X /* in an Amiga window redrawing is caused by asking the window size */
X#ifdef AMIGA
X if (term_console)
X outstr("\033[0 q"); /* get window size */
X#endif /* AMIGA */
X}
X
X/*
X * dofilter: filter lines through a command given by the user
X *
X * We use temp files and the call_shell() routine here. This would normally
X * be done using pipes on a UNIX machine, but this is more portable to
X * the machines we usually run on. The call_shell() routine needs to be able
X * to deal with redirection somehow, and should handle things like looking
X * at the PATH env. variable, and adding reasonable extensions to the
X * command name given by the user. All reasonable versions of call_shell()
X * do this.
X * We use input redirection if do_in is TRUE.
X * We use output redirection if do_out is TRUE.


X */
X static void

Xdofilter(buff, do_in, do_out)
X u_char *buff;
X int do_in, do_out;
X{
X#ifdef LATTICE
X char itmp[L_tmpnam]; /* use tmpnam() */
X char otmp[L_tmpnam];
X#else
X char itmp[TMPNAMELEN];
X char otmp[TMPNAMELEN];
X#endif
X linenr_t linecount;
X char *p;
X
X /*
X * Disallow shell commands from .exrc and .vimrc in current directory for


X * security reasons.
X */
X if (secure)
X {
X secure = 2;
X emsg(e_curdir);

X return;
X }
X if (*buff == NUL) /* no filter command */
X return;
X linecount = line2 - line1 + 1;
X Curpos.lnum = line1;
X Curpos.col = 0;
X cursupdate();
X gotocmdline(FALSE, NUL);
X
X /*
X * 1. Form temp file names
X * 2. Write the lines to a temp file
X * 3. Run the filter command on the temp file
X * 4. Read the output of the command into the buffer
X * 5. Delete the original lines to be filtered
X * 6. Remove the temp files
X */
X
X#ifndef LATTICE
X /* for lattice we use tmpnam(), which will make its own name */
X strcpy(itmp, TMPNAME1);
X strcpy(otmp, TMPNAME2);
X#endif
X
X if ((do_in && *mktemp(itmp) == NUL) || (do_out && *mktemp(otmp) == NUL))
X {
X emsg(e_notmp);
X return;
X }
X
X outchar('\n'); /* ! command not overwritten by next mesages */
X if (do_in && !writeit(itmp, line1, line2, FALSE, 0))
X {
X outchar ('\n');
X emsg(e_notcreate);
X updateScreen(CLEAR); /* screen has been shifted up one line */
X return;
X }
X if (!do_out)


X outchar('\n');
X

X strcpy(IObuff, (char *)buff);
X if (do_in)
X {
X /*
X * If there is a pipe, we have to put the '<' in front of it
X */
X p = strchr(IObuff, '|');
X if (p)
X *p = NUL;
X strcat(IObuff, " < ");
X strcat(IObuff, itmp);
X p = strchr((char *)buff, '|');
X if (p)
X strcat(IObuff, p);
X }
X if (do_out)
X {
X strcat(IObuff, " > ");
X strcat(IObuff, otmp);
X }
X
X if (call_shell(IObuff, 1))
X {
X linecount = 0;
X goto error;
X }
X
X if (do_out)
X {
X if (!u_save((linenr_t)(line1 - 1), (linenr_t)(line2 + 1)))
X {
X linecount = 0;
X goto error;
X }
X if (readfile(otmp, line2, FALSE))
X {
X outchar ('\n');
X emsg(e_notread);
X linecount = 0;
X goto error;
X }
X
X if (do_in)
X {
X Curpos.lnum = line1;
X dellines(linecount, TRUE);


X }
X }
X else
X {

Xerror:
X if (global_busy)
X global_wait = 1;
X else
X wait_return(FALSE);
X }
X updateScreen(CLEAR);
X
X if (linecount > p_report)
X {
X if (!do_in && do_out)
X msgmore(linecount);
X else
X smsg("%ld lines filtered", (long)linecount);
X }
X remove(itmp);
X remove(otmp);
X return;
X}
X
X/*
X * Redefine the argument list to 'str'.
X * Return TRUE for failure.
X */
X int
Xdoarglist(str)
X char *str;
X{
X int new_numfiles = 0;
X char **new_files = NULL;
X#ifdef WILD_CARDS
X int exp_numfiles;
X char **exp_files;
X#endif
X char **t;
X char *p;
X int inquote;
X int i;
X
X while (*str)
X {
X /*
X * create a new entry in new_files[]
X */
X t = (char **)alloc((unsigned)(sizeof(char *) * (new_numfiles + 1)));
X if (t != NULL)
X for (i = new_numfiles; --i >= 0; )
X t[i] = new_files[i];
X free(new_files);
X if (t == NULL)
X return TRUE;
X new_files = t;
X new_files[new_numfiles++] = str;
X
X /*
X * isolate one argument, taking quotes
X */
X inquote = FALSE;
X for (p = str; *str; ++str)
X {
X if (*str == '\\' && *(str + 1) != NUL)
X *p++ = *++str;
X else
X {
X if (!inquote && isspace(*str))
X break;
X if (*str == '"')
X inquote ^= TRUE;
X else
X *p++ = *str;
X }
X }
X skipspace(&str);


X *p = NUL;
X }

X
X#ifdef WILD_CARDS
X if (ExpandWildCards(new_numfiles, new_files, &exp_numfiles, &exp_files, FALSE, TRUE) != 0)
X return TRUE;
X else if (exp_numfiles == 0)
X {
X emsg(e_nomatch);
X return TRUE;
X }
X FreeWild(numfiles, files);
X files = exp_files;
X numfiles = exp_numfiles;
X
X#else
X files = new_files;
X numfiles = new_numfiles;
X#endif


X
X return FALSE;
X}
X

Xextern int redraw_msg; /* this is in screen.c */
X
X void
Xgotocmdline(clr, firstc)
X int clr;
X int firstc;


X{
X windgoto((int)Rows - 1, 0);

X if (clr)
X {
X clear_line(); /* clear the bottom line */
X windgoto((int)Rows - 1, 0);


X redraw_msg = TRUE;
X }

X if (firstc)
X outchar(firstc);
X}
X
X static int
Xcheck_readonly()
X{
X if (!forceit && p_ro)
X {
X emsg(e_readonly);
X return TRUE;
X }


X return FALSE;
X}
X

X static int
Xcheck_changed(checkaw)
X int checkaw;
X{
X if (!forceit && Changed && (!checkaw || !autowrite()))
X {
X if (exiting)
X settmode(1); /* set raw again for typeahead */
X emsg(e_nowrtmsg);
X return TRUE;
X }


X return FALSE;
X}
X

X static int
Xcheck_fname()
X{


X if (Filename == NULL)

X {
X emsg(e_noname);
X return TRUE;
X }


X return FALSE;
X}
X

X static int
Xcheck_more()
X{
X if (!forceit && curfile + 1 < numfiles)
X {
X if (exiting)
X settmode(1); /* set raw again for typeahead */
X emsg(e_more);
X return TRUE;
X }
X return FALSE;
X}
X
X/*
X * try to abandon current file and edit "fname"
X * return 1 for "normal" error, 2 for "not written" error, 0 for success
X * -1 for succesfully opening another file
X */
X int
Xgetfile(fname, setpm)
X char *fname;
X int setpm;
X{
X int other;
X
X FullName(fname, IObuff, IOSIZE);


X if (Filename == NULL)

X other = TRUE;
X else
X other = fnamecmp(IObuff, Filename);
X if (other && !forceit && Changed && !autowrite())
X {
X emsg(e_nowrtmsg);
X return 2; /* file has been changed */
X }
X if (setpm)
X setpcmark();
X if (!other)
X return 0; /* it's in the same file */
X if (doecmd(fname))
X return -1; /* opened another file */
X return 1; /* error encountered */
X}
X
X/*
X * return TRUE if alternate file n is the same as the current file
X */
X int
Xsamealtfile(n)
X int n;
X{
X if (n < NUMALTFILES && altfiles[n] != NULL && Filename != NULL &&
X fnamecmp(altfiles[n], Filename) == 0)


X return TRUE;
X return FALSE;

X}
X
X/*
X * get alternate file n
X * set linenr to lnum or altlnum if lnum == 0
X * if (setpm) setpcmark
X * return 1 for failure, 0 for success
X */
X int
Xgetaltfile(n, lnum, setpm)
X int n;
X linenr_t lnum;
X int setpm;
X{
X if (n < 0 || n >= NUMALTFILES || altfiles[n] == NULL)
X return 1;
X if (lnum == 0)
X lnum = altlnum[n]; /* altlnum may be changed by getfile() */
X RedrawingDisabled = TRUE;
X if (getfile(altfiles[n], setpm) <= 0)
X {
X RedrawingDisabled = FALSE;
X if (lnum == 0 || lnum > line_count) /* check for valid lnum */
X Curpos.lnum = 1;
X else
X Curpos.lnum = lnum;


X
X Curpos.col = 0;

X return 0;
X }
X RedrawingDisabled = FALSE;


X return 1;
X}
X

X/*
X * get name of "n"th alternate file


X */
X char *

Xgetaltfname(n)
X int n;
X{
X if (n >= NUMALTFILES)
X return NULL;
X return altfiles[n];
X}
X
X/*
X * put name "arg" in the list of alternate files.
X * "arg" must have been allocated
X * "lnum" is the default line number when jumping to the file
X * "newfile" must be TRUE when "arg" != current file


X */
X static void

Xsetaltfname(arg, lnum, newfile)
X char *arg;
X linenr_t lnum;
X int newfile;


X{
X int i;
X

X free(altfiles[NUMALTFILES - 1]);
X for (i = NUMALTFILES - 1; i > 0; --i)
X {
X altfiles[i] = altfiles[i - 1];
X altlnum[i] = altlnum[i - 1];
X }
X incrmarks(); /* increment file number for all jumpmarks */
X incrtags(); /* increment file number for all tags */
X if (newfile)
X {
X decrmarks(); /* decrement file number for jumpmarks in current file */
X decrtags(); /* decrement file number for tags in current file */
X }
X
X altfiles[0] = arg;
X altlnum[0] = lnum;


X}
X
X#ifdef WILD_CARDS
X/*

X * Do wildcard expansion on the string 'str'.
X * Return a pointer to alloced memory containing the new string.
X * Return NULL for failure.
X *
X * mode = -2: only release file names
X * mode = -1: normal expansion, do not keep file names
X * mode = 0: normal expansion, keep file names
X * mode = 1: use next match in multiple match
X * mode = 2: use previous match in multiple match


X */
X static char *

XExpandOne(str, list_notfound, mode)
X u_char *str;
X int list_notfound;
X int mode;
X{
X char *ss = NULL;
X static char **cmd_files = NULL; /* list of input files */
X static int cmd_numfiles = -1; /* number of input files */
X static int findex;
X int i, found = 0;
X char *filesuf, *setsuf, *nextsetsuf;
X int filesuflen, setsuflen;
X
X/*
X * first handle the case of using an old match
X */
X if (mode >= 1)
X {
X if (cmd_numfiles > 0)
X {
X if (mode == 1)
X ++findex;
X else /* mode == 2 */
X --findex;
X if (findex < 0)
X findex = 0;
X if (findex > cmd_numfiles - 1)
X findex = cmd_numfiles - 1;
X return strsave(cmd_files[findex]);
X }
X else


X return NULL;
X }
X

X/* free old names */
X if (cmd_numfiles != -1)
X FreeWild(cmd_numfiles, cmd_files);
X cmd_numfiles = -1;
X findex = -1;
X
X if (mode == -2) /* only release file name */
X return NULL;
X
X if (ExpandWildCards(1, (char **)&str, &cmd_numfiles, &cmd_files, FALSE, list_notfound) != 0)
X /* error: do nothing */;
X else if (cmd_numfiles == 0)
X emsg(e_nomatch);
X else
X {
X if (cmd_numfiles > 1) /* more than one match; check suffixes */
X {
X found = -2;
X for (i = 0; i < cmd_numfiles; ++i)
X {
X if ((filesuf = strrchr(cmd_files[i], '.')) != NULL)
X {
X filesuflen = strlen(filesuf);
X for (setsuf = p_su; *setsuf; setsuf = nextsetsuf)
X {
X if ((nextsetsuf = strchr(setsuf + 1, '.')) == NULL)
X nextsetsuf = setsuf + strlen(setsuf);
X setsuflen = nextsetsuf - setsuf;
X if (filesuflen == setsuflen &&
X strncmp(setsuf, filesuf, (size_t)setsuflen) == 0)
X break;
X }
X if (*setsuf) /* suffix matched: ignore file */
X continue;
X }
X if (found >= 0)
X {
X found = -2;
X break;
X }
X found = i;
X }
X }
X if (found < 0)
X emsg(e_toomany);
X else
X ss = strsave(cmd_files[found]);
X }
X
X if (found != -2 || mode == -1)
X {
X FreeWild(cmd_numfiles, cmd_files);
X cmd_numfiles = -1;
X }
X return ss;
X}
X
X/*
X * show all filenames that match the string "file" with length "len"


X */
X static void

Xshowmatches(file, len)
X char *file;
X int len;
X{
X char *file_str;
X int num_files;
X char **files_found;
X int i, j, k;
X int maxlen;
X int lines;
X int columns;
X
X file_str = addstar(file, len); /* add star to file name */
X if (file_str != NULL)
X {
X outchar('\n');
X flushbuf();
X
X /* find all files that match the description */
X ExpandWildCards(1, &file_str, &num_files, &files_found, FALSE, FALSE);
X
X /* find the maximum length of the file names */
X maxlen = 0;
X for (i = 0; i < num_files; ++i)
X {
X j = strlen(files_found[i]);
X if (j > maxlen)
X maxlen = j;
X }
X
X /* compute the number of columns and lines for the listing */
X maxlen += 2; /* two spaces between file names */
X columns = (Columns + 2) / maxlen;
X if (columns < 1)
X columns = 1;
X lines = (num_files + columns - 1) / columns;
X
X /* list the files line by line */
X#ifdef AMIGA
X settmode(0); /* allow output to be halted */
X#endif
X for (i = 0; i < lines; ++i)
X {
X for (k = i; k < num_files; k += lines)
X {
X if (k > i)
X for (j = maxlen - strlen(files_found[k - lines]); --j >= 0; )
X outchar(' ');
X j = isdir(files_found[k]); /* highlight directories */
X if (j)
X {
X#ifdef AMIGA
X if (term_console)
X outstr("\033[33m"); /* use highlight color */
X else
X#endif /* AMIGA */
X outstr(T_TI);
X }
X outstrn(files_found[k]);
X if (j)
X {
X#ifdef AMIGA
X if (term_console)
X outstr("\033[0m"); /* use normal color */
X else
X#endif /* AMIGA */
X outstr(T_TP);
X }
X }
X outchar('\n');
X flushbuf();
X }
X free(file_str);
X FreeWild(num_files, files_found);


X#ifdef AMIGA
X settmode(1);
X#endif
X

X wait_return(TRUE);
X }
X}
X
X/*
X * copy the file name into allocated memory and add a '*' at the end


X */
X static char *

Xaddstar(fname, len)
X char *fname;
X int len;
X{
X char *retval;
X#ifdef MSDOS
X int i;
X#endif
X
X retval = alloc(len + 4);


X if (retval != NULL)
X {

X strncpy(retval, fname, (size_t)len);
X#ifdef MSDOS
X /*
X * if there is no dot in the file name, add "*.*" instead of "*".
X */
X for (i = len - 1; i >= 0; --i)
X if (retval[i] == '.' || retval[i] == '\\' || retval[i] == ':')
X break;
X if (retval[i] != '.')
X {
X retval[len++] = '*';
X retval[len++] = '.';
X }
X#endif
X retval[len] = '*';
X retval[len + 1] = 0;


X }
X return retval;
X}

X#endif /* WILD_CARDS */
X
X/*
X * dosource: read the file "fname" and execute its lines as EX commands
X *
X * This function may be called recursively!
X */
X int
Xdosource(fname)
X register char *fname;
X{
X register FILE *fp;


X register int len;
X

X expand_env(fname, IObuff, IOSIZE); /* use IObuff for expanded name */
X if ((fp = fopen(IObuff, READBIN)) == NULL)
X return 1;
X
X while (fgets(IObuff, IOSIZE, fp) != NULL && !got_int)
X {
X len = strlen(IObuff) - 1;
X if (len >= 0 && IObuff[len] == '\n') /* remove trailing newline */
X {
X#ifdef MSDOS
X if (len > 0 && IObuff[len - 1] == '\r') /* trailing CR-LF */
X --len;
X#endif
X IObuff[len] = NUL;
X }
X docmdline((u_char *)IObuff);
X breakcheck();
X }
X fclose(fp);
X if (got_int)
X emsg(e_interr);
X return 0;
X}
X
X/*
X * get single EX address
X */
X static linenr_t
Xget_address(ptr)
X u_char **ptr;
X{
X linenr_t curpos_lnum = Curpos.lnum;
X int c;
X int i;
X long n;
X u_char *cmd;
X FPOS pos;
X FPOS *fp;
X linenr_t lnum;
X
X cmd = *ptr;
X skipspace((char **)&cmd);
X lnum = INVLNUM;
X do
X {
X switch (*cmd)
X {
X case '.': /* '.' - Cursor position */
X ++cmd;
X lnum = curpos_lnum;
X break;
X
X case '$': /* '$' - last line */
X ++cmd;
X lnum = line_count;
X break;
X
X case '\'': /* ''' - mark */
X if (*++cmd == NUL || (fp = getmark(*cmd++, FALSE)) == NULL)
X {
X emsg(e_umark);
X goto error;
X }
X lnum = fp->lnum;
X break;
X
X case '/':
X case '?': /* '/' or '?' - search */
X c = *cmd++;
X pos = Curpos; /* save Curpos */
X Curpos.col = -1; /* searchit() will increment the col */
X if (c == '/')
X ++Curpos.lnum;
X searchcmdlen = 0;
X if (dosearch(c == '/' ? FORWARD : BACKWARD, (char *)cmd, FALSE, (long)1, FALSE))
X lnum = Curpos.lnum;
X Curpos = pos;
X
X cmd += searchcmdlen; /* adjust command string pointer */
X break;
X
X default:
X if (isdigit(*cmd)) /* absolute line number */
X lnum = getdigits((char **)&cmd);
X }
X
X while (*cmd == '-' || *cmd == '+')
X {
X if (lnum == INVLNUM)
X lnum = curpos_lnum;
X i = *cmd++;
X if (!isdigit(*cmd)) /* '+' is '+1', but '+0' is not '+1' */
X n = 1;
X else
X n = getdigits((char **)&cmd);
X if (i == '-')
X lnum -= n;
X else
X lnum += n;
X }
X
X curpos_lnum = lnum;
X } while (*cmd == '/' || *cmd == '?');
X
Xerror:
X *ptr = cmd;
X return lnum;
X}
END_OF_FILE
if test 46721 -ne `wc -c <'vim/src/cmdline.c'`; then
echo shar: \"'vim/src/cmdline.c'\" unpacked with wrong size!
fi
# end of 'vim/src/cmdline.c'
fi
echo shar: End of archive 21 \(of 23\).
cp /dev/null ark21isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:39:00 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 22
Archive-name: vim/part22
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 22 (of 23)."
# Contents: vim/doc/reference.doc1
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:14 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/reference.doc1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/reference.doc1'\"
else
echo shar: Extracting \"'vim/doc/reference.doc1'\" \(48721 characters\)
sed "s/^X//" >'vim/doc/reference.doc1' <<'END_OF_FILE'
X
X
X
X VIM reference manual
X
X By Bram Moolenaar
X
X version 1.27
X
X
X 1. Introduction
X 2. Notation
X 3. Starting VIM
X 4. Modes
X 5. Editing files
X 6. Cursor motions
X 7. Scrolling
X 8. Tags
X 9. Inserting text
X10. Deleting text
X11. Changing text
X12. Copying and moving text
X13. Quoting
X14. Various commands
X15. Repeating commands
X16. Undo and redo
X17. Key mapping
X18. Recovery after a crash
X19. Options
X20. Terminal information
X21. Differences from Vi and Ex
X22. Credits
X
X
X 1. Introduction
X
XVIM stands for Vi Imitation. VIM is a text editor which includes almost all
Xthe commands from the Unix program "Vi". It is very useful for editing
Xprograms and other ASCII text. All commands are given with the keyboard.
XThere is no mouse support and there are no menus. This gives the advantage
Xthat you can keep your fingers on the keyboard and your eyes on the screen.
X
XThroughout this manual the differences between Vi and Vim are mentioned in
Xcurly braces. Read the file "difference.doc" for a summary of the
Xdifferences.
X
XThis manual refers to VIM on the Commodore Amiga computer. On other
Xcomputers and on terminals there may be small differences. For MSDOS this
Xis documented in msdos.doc. For UNIX this is in unix.doc.
X
XThis manual is a reference for all the VIM commands and options. A basic
Xknowledge of "Vi" is assumed. A summary of this manual can be found in the
Xfile vim.hlp. It can be accessed from within VIM with the <HELP> key (in
XMSDOS <F1>) and with the command ":help". The 'helpfile' option can be
Xset to the name of the help file, so you can put it in any place you like.
X
X
X 2. Notation
X
X[] Characters in square brackets are optional.
X
X[cnt] An optional number that may precede the command to multiply
X or iterate the command. If no number is given a count of one
X is used, unless otherwise noted. Note that in this manual
X the [cnt] is not mentioned in the description of the
X command, but only in the explanation. This was done to make
X the commands more easy to lookup. If the "sc" option is on,
X the (partially) entered count is shown at the bottom of the
X window. You can use <DEL> to erase the last digit.
X
X["x] An optional named register designation where text can be
X stored. The x is a single character between <a> and <z> or
X <A> and <Z> and in some cases (with the put command) between
X <0> and <9> or <.>. The uppercase and lower case letter
X designate the same register, but the lower case letter is
X used to overwrite the previous register contents, while the
X uppercase letter is used to append to the previous register
X contents. Without the ""x" the deleted text is put into the
X unnamed register.
X
X{} Curly braces denote parts of the command which must appear,
X but can take a number of different values. The differences
X between VIM and Vi are also given in curly braces (this will
X be clear from the context).
X
X{motion} A command that moves the cursor. They are listed in chapter
X 6. This is used after an "operator" command to move over the
X text that is to be operated upon. If the motion includes a
X count and the operator also had a count, the two counts are
X multiplied. For example: "2d3w" deletes six words.
X
X{quote} A piece of text that is started with the 'q' or 'Q' command
X and ended by the cursor position. This is used before an
X "operator" to highlight the text that is to be operated
X upon. See the chapter on quoting.
X
X<character> A special character from the table below or a single ASCII
X character.
X
X<char1-char2> A single character from the range <char1> to <char2>. For
X example: <a-z> is a lower case letter. Multiple ranges may be
X concatenated. For example: <a-zA-Z0-9> is any alphanumeric
X character.
X
XCTRL-<char> <char> typed as a control character, that is, typing <char>
X while holding the CTRL key down. The case of <char> does not
X matter, thus CTRL-A and CTRL-a are equivalent.
X
X
Xnotation meaning equivalent hex value
X-----------------------------------------------------------------------
X<NUL> zero CTRL_@ 0x00 (or 0x9e)
X<BELL> bell CTRL-G 0x07
X<BS> backspace CTRL-H 0x08
X<TAB> tab CTRL-I 0x09
X<LF> linefeed CTRL-J 0x0a
X<NL> newline CTRL-J 0x0a (same as linefeed)
X<FF> formfeed CTRL-L 0x0c
X<CR> carriage return CTRL-M 0x0d
X<ESC> escape CTRL-[ 0x1b
X<SPACE> space 0x20
X<DEL> delete 0x7f
X<C_UP> cursor-up 0x80
X<C_DOWN> cursor-down 0x81
X<C_LEFT> cursor-left 0x82
X<C_RIGHT> cursor-right 0x83
X<SC_UP> shift-cursor-up 0x84
X<SC_DOWN> shift-cursor-down 0x85
X<SC_LEFT> shift-cursor-left 0x86
X<SC_RIGHT> shift-cursor-right 0x87
X<F1> - <F10> function keys 1 to 10 0x88 - 0x91
X<SF1> - <SF10> shift-function keys 1 to 10 0x92 - 0x9b
X<HELP> help key 0x9c
X<UNDO> undo key 0x9d
X-----------------------------------------------------------------------
X
X
X 3. Starting VIM
X
X3.1 Command line
X
XMost often VIM is started to edit a single file with the command
X
X vim file
X
XMore generally VIM is started with:
X
X vim [options] [filelist]
X


XIf the filelist is missing, the editor will start with an empty buffer.

XOtherwise exactly one out of the following six may be used to choose one or


Xmore files to be edited.
X

Xfile .. A list of file names. The first one will be the current file
X and read into the buffer. The cursor will be positioned on
X the first line of the buffer.
X
X+[num] file .. Same as the above, but the cursor will be positioned on line
X "num". If "num" is missing, the cursor will be positioned on
X the last line.
X
X+/{pat} file .. Same as the above, but the cursor will be positioned on the
X first line containing "pat" in the current file (see the
X section "pattern searches" for the available search
X patterns).
X
X+{command} file ..
X-c {command} file ..
X Same as the above, but "command" will be executed after the
X file has been read. "command" is interpreted as an Ex
X command. If the "command" contains spaces it must be
X enclosed in double quotes (this depends on the shell that is
X used). Example: Vim "+set si" main.c
X
X-t {tag} A tag. "tag" is looked up in the tags file, the associated
X file becomes the current file and the associated command is
X executed. Mostly this is used for C programs. In that case
X "tag" should be a function name. The effect is that the file
X containing that function becomes the current file and the
X cursor is positioned on the start of the function (see the
X section "tag searches").
X
X-e QuickFix mode. The error file "AztecC.Err" is read and the
X first error is displayed. See the section "using the
X QuickFix option".
X


XThe options, if present, must precede the filelist. The options may be given
Xin any order.
X

X-r Recovery mode. The autoscript file is read to recover a
X crashed editing session. It has almost the same effect as
X "-s file.vim". See the chapter "Recovery after a crash".
X
X-v View mode. The 'readonly' option will be set and no
X autoscript file will be written (see -n below). You can
X still edit the buffer, but will be prevented from
X accidentally overwriting a file. If you forgot that you are
X in view mode and did make some changes, you can overwrite
X a file by adding an exclamation mark to the Ex command, as in
X ":w!". The 'readonly' option can be reset with ":set noro"
X (see the options chapter). It is suggested to make an alias:
X "alias view vim -v".
X
X-n No autoscript file will be written. Recovery after a crash
X will be impossible. Handy if you want to edit a file on a
X very slow medium (e.g. floppy). Can also be done with ":set
X uc=0". You can switch it on again by setting the 'uc' option
X to some value, e.g. ":set uc=100" (only do this if the
X buffer was not changed yet).
X
X-T {terminal} Set the terminal type to "terminal". This influences the
X codes that Vim will send to your terminal. This is normally
X not needed, because Vim will be able to find out what type
X of terminal you are using (See chapter 20).
X
X-d {device} The "device" is opened to be used for editing. Normally you
X would use this to set the window position and size:
X "-d con:x/y/width/height", e.g. "-d con:30/10/600/150". But
X you can also use it to start editing on another device, e.g.
X AUX:. This only works on the Amiga.
X
X-s {scriptin} The script file "scriptin" is read. The characters in the
X file are interpreted as if you had typed them. The same can
X be done with the command ":source! {scriptin}". If the end
X of the file is reached before the editor exits, further
X characters are read from the keyboard. See also the section
X "complex repeats".
X
X-w {scriptout} All the characters that you type are recorded in the file


X "scriptout", until you exit VIM. This is useful if you want

X to create a script file to be used with "vim -s" or
X ":source!". See also the section "complex repeats".
X
XExample for using a script file to change a name in several files:
X Create a file "subs.vi" containing substitute commands and a :wq
X command:
X
X :%s/Jones/Smith/g
X :%s/Allen/Peter/g
X :wq
X
X Execute VIM on all files you want to change:
X
X foreach i ( *.let ) vim -s subs.vi $i
X
X
X3.2 Workbench (Amiga only)
X
XVim can be started from the workbench by clicking on its icon twice. It will
Xthen start with an empty buffer.
X
XVim can be started to edit one or more files by using a "Project" icon. The
X"Default Tool" of the icon must be the full pathname of the Vim executable.
XThe name of the ".info" file must be the same as the name of the text file.
XBy clicking on this icon twice, Vim will be started with the filename as
Xcurrent filename, which will be read into the buffer (if it exists). You can
Xedit multiple files by pressing the shift key while clicking on icons, and
Xclicking twice on the last one. The "Default Tool" for all these icons must
Xbe the same.
X
XIt is not possible to give arguments to Vim, other than filenames, from the
Xworkbench.
X
X
X3.3 Vim window
X
XVIM will run in the CLI window where it was started. If VIM was started with
Xthe "run" or "runback" command, or if VIM was started from the workbench, it
Xwill open a window of its own.
X
XTechnical detail:
X To open the new window a little trick is used. As soon as VIM
X recognizes that it does not run in a normal CLI window, it will
X create a script file in t:. This script file contains the same
X command as how VIM was started, and an "endcli" command. This script
X file is then executed with a "newcli" command (the "c:run" and
X "c:newcli" commands are required for this to work). The script file
X will hang around until reboot, or until you delete it. This method
X is required to get the ":sh" and ":!" commands to work correctly.
X But when Vim was started with the -e option (quickfix mode), this
X method is not used. The reason for this is that when a compiler
X starts Vim with the -e option it will wait for a return code. With
X the script trick the compiler cannot get the return code. As a
X consequence the ":sh" and ":!" commands are not available when the
X -e option is used.
X
XVIM will automatically recognize the window size and react to window
Xresizing. Under Amiga DOS 1.3 it is advised to use the fastfonts program
X"FF" to speed up display redrawing.
X
X
X3.4 Initialization
X
XWhen VIM starts running it does initializations in this order:
X
X1. Four places are searched for initializations. The first that exists is
X used, the others are ignored.
X 1. The environment variable VIMINIT
X 2. The file "s:.vimrc" (for Unix: "$HOME/.vimrc")
X 3. The environment variable EXINIT
X 4. The file "s:.exrc" (for Unix: "$HOME/.exrc")
X
X2. The current directory is searched for two files. The first that exists
X is used, the other is ignored.
X 1. The file ".vimrc"
X 2. The file ".exrc"
X
X If an environment variable is used, it is executed as a single Ex
X command line. Multiple commands must be separated with '|'. If a file is
X used, each line is executed as an Ex command line.
X
X3. The environment variable SHELL, if it exists, is used to set the
X 'shell' option.
X
X4. The environment variable TERM, if it exists, is used to set the 'term'
X option.
X
XThe first can be used to set your default settings and mappings for all edit
Xsessions. The second one for sessions in a certain directory. See the
Xsection "Saving settings" for how to create a file with commands to recreate
Xthe current settings.
X
XIf the VIMINIT environment variable or ".vimrc" exist the EXINIT and ".exrc"
Xare skipped. This can be used to initialize Vim without interfering with
Xanother version of Vi.
X
XOn the Amiga two types of environment variables exist. The ones set with the
XDOS 1.3 (or later) setenv command are recognized. See the AmigaDos 1.3
Xmanual. The environment variables set with the old Manx Set command (before
Xversion 5.0) are not recognized.
X
XWhile reading the ".vimrc" and the ".exrc" file some commands are disabled
Xfor security reasons. Otherwise it would be possible to create a .exrc that
Xcontains nasty commands, which another user may automatically execute when
Xhe starts Vim it that directory. The disabled commands are the ones that
Xstart a shell and the ones that write to a file. The ":map" commands are
Xechoed, so you can see which keys are being mapped. (On unix systems this
Xonly happens if you are not the owner of the ".vimrc" or ".exrc" file.)
X
X
X3.5 Suspending
X
XCTRL-Z Suspend the editor. Same as ":stop!".
X
X:st[op][!] Suspend the editor. If the "!" is not given,
X the buffer was changed, autowrite is set and
X a filename is known, the buffer will be
X written.
X
XOn BSD-UNIX systems it is possible to suspend Vim with CTRL-Z. This is only
Xpossible in command mode (see next chapter). Vim will restart if you make it
Xthe foreground job again. On other systems CTRL-Z will start a new shell.
XThis is the same as the ":sh" command. Vim will restart if you exit from the
Xshell.
X
X
X 4. Modes
X
X4.1 Introduction
X
XVIM has four basic modes:
X
Xcommand mode In command mode you can enter all the editor
X commands. If you start the editor you are in this
X mode (unless you have set the 'insertmode' option,
X see below).
X
Xinsert mode In insert mode the text you type is inserted into the
X buffer. If the 'showmode' option is set (which is
X default), the string "-- INSERT --" is shown at the
X bottom of the window.
X
Xreplace mode Replace mode is a special case of insert mode. You
X can do the same things as in insert mode, but for
X each character you enter (except some special
X characters) one character of the existing text is
X deleted. If the 'showmode' option is set (which is
X default), the string "-- REPLACE --" is shown at the
X bottom of the window.
X
Xcommand line mode In command line mode you can enter one line of text
X at the bottom of the window. This is for the Ex
X commands, the pattern search commands and the filter
X command.
X
XMore explanation on the insert, replace and command line mode is further on
Xin this chapter.
X
X
X4.2 Switching from mode to mode
X
XIf for any reason you do not know in which mode you are, you can always get
Xback to command mode by typing <ESC> twice. You will know you are back in
Xcommand mode when you see the screen flash or hear the bell after you type
X<ESC>.
X
X- go from command mode to insert mode by giving one of the commands
X "iIaAoOcCsS".
X- go from command mode to replace mode with the "R" command (not the "r"
X command!).
X- go from command mode to command line mode with the one of the commands
X ":/?!".
X
X- go from insert or replace mode to command mode with <ESC> (twice in some
X rare cases).
X- go from command line mode to command mode with <CR> (which causes the
X entered command to be executed), by deleting the complete line (e.g. with
X CTRL-U) and giving a final <BS>, or by hitting <ESC> twice. In the last
X case the first <ESC> will also be used to start filename completion, but
X you can ignore that.
X
XIf the 'insertmode' option is set, editing a file will start in insert mode.
X
X
X4.3 Insert and replace mode
X
XIn insert and replace mode the following characters have a special meaning,
Xother characters are inserted directly. To insert one of these special
Xcharacters into the buffer, precede it with CTRL-V. To insert a <NUL>
Xcharacter use CTRL-V CTRL-J (the <NUL> is actually stored as a <LF> in
Xmemory, but replaced with a <NUL> when written to a file). To insert a
XCTRL-C use "CTRL-V003".
X
Xchar action
X-----------------------------------------------------------------------
XCTRL-@ Insert previously inserted text and stop insert. {Vi: only
X when typed as first char, only upto 128 chars}
XCTRL-A Insert previously inserted text. {not in Vi}
XCTRL-B <0-9a-z>
X Insert the contents of a numbered or named register (see
X chapter on copying and moving text). 'B' stands for buffer,
X which is called register in this document. {not in Vi}
XCTRL-D Delete one shiftwidth of indent at the start of the current
X line. See also 'shiftround' option. {Vi: only after
X auto-indent; also accepts preceding <^> and <0>}
XCTRL-E Insert the character which is below the cursor. {not in Vi}
XCTRL-H <BS> Delete the character before the cursor (see below). {Vi:

X does not delete autoindents}

XCTRL-J <LF> Begin new line.
XCTRL-K {char1} {char2}
X Enter digraph (see below). {not in Vi}
XCTRL-M <CR> Begin new line.
XCTRL-O See below. {not in Vi}
XCTRL-R Insert the character which is above the cursor. {not in Vi}
XCTRL-T Insert one shiftwidth of indent at the start of the current
X line. See also 'shiftround' option. {Vi: only when in
X autoindent}
XCTRL-U Delete all entered characters in the current line (see
X below).
XCTRL-V Insert next non-digit literally. Up to three digits form the
X decimal value of a single byte. All this without mapping.
X {Vi: no decimal byte entry}
XCTRL-W Delete the word before the cursor (see below). See the
X section "word motions" for the definition of a word.
XCTRL-[ <ESC> End insert or replace mode, back to command mode.
X<DEL> Same as CTRL-H <BS>
X-----------------------------------------------------------------------
X
XThe effect of the <BS>, <DEL>, CTRL-W and CTRL-U depends on the 'backspace'
Xoption:
X
Xbackspace action
X option
X 0 delete stops in column 1 and start position of insert
X 1 delete stops at start position of insert
X 2 delete always, CTRL-W and CTRL-U stop once at start position of
X insert
X
XIf the 'backspace' option is non-zero and the cursor is in column 1 when one
Xof the three keys is used, the current line is joined with the previous
Xline. This effectively deletes the newline in front of the cursor. {Vi: does
Xnot cross lines, does not delete past start position of insert}
X
XWith CTRL-V followed by one, two or three digits you can enter the decimal
Xvalue of a byte, except 10. Normally CTRL-V is followed by three digits. The
Xformed byte is inserted as soon as you type the third digit. If you type
Xonly one or two digits and then a non-digit, the decimal value of those one
Xor two digits form the byte. After that the non-digit is dealt with in the
Xnormal way.
X
XIf you enter a value of 10, it will be interpreted as a 0. The 10 is a <LF>,
Xwhich is used internally to represent the NUL character. When writing the
Xbuffer to a file the <LF> character is translated into <NUL>. The <LF>
Xcharacter is written at the end of each line. Thus if you want to insert a
X<LF> character in a file you will have to make a line break.
X
X
Xspecial keys
X
XThe following keys are special. They stop the current insert, do something
Xand then restart insertion. This means you can do something without getting
Xout of insert mode. This is very handy if you prefer to use the insert mode
Xall the time, just like editors that don't have a separate command mode. You
Xmay also want to set the 'backspace' option to 2 and set the 'insertmode'
Xoption. You can map often used commands to function keys by preceding them
Xwith a CTRL-O.
X
XThe changes (inserted or deleted characters) before and after these keys can
Xbe undone separately. Only the last change can be redone and always behaves
Xlike an 'i' command.
X
Xchar action
X-----------------------------------------------------------------------


X<C_UP> cursor one line up
X<C_DOWN> cursor one line down
X<C_LEFT> cursor one character left
X<C_RIGHT> cursor one character right

X<SC_UP> move window one page up
X<SC_DOWN> move window one page down
X<SC_LEFT> cursor one word back (like 'b' command)
X<SC_RIGHT> cursor one word forward (like 'w' command)
XCTRL-O execute one command and return to insert mode
X-----------------------------------------------------------------------
X
XThe CTRL-O command has one side effect: If the cursor was beyond the end of
Xthe line it will be put on the last character in the line.
X
X
X'textwidth' option
X
XThe 'textwidth' option can be used to automatically break a line before it
Xis getting too long. Set the 'textwidth' option to the maximum line length.
XIf you then type more characters (not being spaces or tabs), the last word
Xwill be put on a new line (unless it is the only word on the line). {Vi has
Xthe 'wrapmargin' option, but it does not do what you want}.
X
XIf you want to format a block of text you can use the 'V' operator. Type 'V'
Xand a movement command to move the cursor to the end of the block. In many
Xcases the command "V}" will do what you want (format until the next empty
Xline). Or you can use quoting: hit 'q', move to the end of the block and hit
X'V'.
X
X
X'expandtab' option
X
XIf the 'expandtab' option is set, spaces will be used to fill the amount of
Xwhitespace of the tab. If you want to enter a real <TAB> use CTRL-V. The
X'expandtab' option is normally off.
X
X
Xdigraphs
X
X:dig[raph] show currently defined digraphs. {not in Vi}
X


X:dig[raph] {char1}{char2} {number} ...

X Add digraph {char1}{char2} to the list. {number} is
X the decimal representation of the entered character.
X
XDigraphs are used to enter characters that normally cannot be entered by
Xan ordinary keyboard. These are mostly accented characters which have the
Xeighth bit set. The digraphs are more easy to remember than the decimal
Xnumber that can be entered with CTRL-V (see above).
X
XVim must have been compiled with the 'digraphs' option enabled. If not, the
X":digraph" command will display an error message.
X
XThere are two methods to enter digraphs:
X CTRL-K {char1} {char2} or
X {char1} <BS> {char2}
XThe first is always available. The second only when the 'digraph' option is
Xset.
X
XOnce you have entered the digraph the character is treated like a normal
Xcharacter, taking up only one character in the file and on the screen.
XExample:
X <|> <BS> <|> will enter the double <|> character (166)
X <a> <BS> <^> will enter an 'a' with a hat (226)
X CTRL-K <-> <-> will enter a minus sign (173)
X
XThe default digraphs are listed in the file digraph.doc. They are meant for
Xthe Amiga character set, which is some international standard. With another
Xcharacter set they may be illogical.
X
XIf you accidently typed an <a> that should be an <e>, you will type <a> <BS>
X<e>. But that is a digraph, so you will not get wat you want. To avoid this,
Xuse <DEL> instead of <BS>.
X
X
Xreplace mode
X
XIn replace mode one character in the line is deleted for every character you
Xtype. If there are no characters to delete (at the end of the line), the
Xtyped character is appended (as in insert mode). Thus the number of
Xcharacters in a line stays the same until you get to the end of the line.
X
XBe careful with <TAB> characters. If you type a normal printing character in
Xits place, the number of characters is still the same, but the number of
Xcolumns will become smaller.
X
XThe 'repdel' option influences what happens if you delete characters in
Xreplace mode (with <BS>, <DEL>, CTRL-W or CTRL-U). If 'repdel' is on (the
Xdefault) the characters are really deleted. For example: If you made a
Xtyping error and hit <BS> to correct it, the number of characters in the
Xline will be one less. This is sometimes illogical, because replace mode was
Xmade to keep the number of characters the same. If you reset 'repdel', the
Xcharacters are not deleted but only the cursor is moved, so you can then
Xcorrect your typing error.
X
X
X4.4 Command line mode
X
XCommand line mode is used to enter Ex commands, search patterns and <!>
Xcommands.
X
X
X4.4.1 Command line editing
X
XNormal characters are inserted in front of the cursor position. You can move
Xaround in the command line with the left and right cursor keys. {Vi: can
Xonly alter the last character in the line}
X
XThe command lines that you enter are remembered in a history table. You can
Xrecall them with the up and down cursor keys. Use the 'history' option to
Xset the number of lines that are remembered (default 20).
X
XCTRL-V Insert next non-digit literally. Up to three digits form the
X decimal value of a single byte. All this without mapping.
X This works the same way as in insert mode (see above). {Vi:
X type the CTRL-V twice to get one}


X<C_LEFT> cursor left
X<C_RIGHT> cursor right
X<SC_LEFT> cursor one word left
X<SC_RIGHT> cursor one word right
X

X<BS> delete the character in front of the cursor
X<DEL> delete the character under the cursor (at end of line:
X character in front of the cursor)
XCTRL-U remove all characters
X
X<C_UP> recall older command line from history
X<C_DOWN> recall more recent command line from history
X
XCTRL-D list filenames that match the pattern in front of the cursor
X<ESC> do filename completion on the pattern in front of the cursor
XCTRL-N after <ESC> with multiple matches: go to next match;
X otherwise: recall more recent command line from history
XCTRL-P after <ESC> with multiple matches: go to previous match;
X otherwise: recall older command line from history
X
XIn the pattern for CTRL-D and <ESC> standard Amiga wildcards are accepted,
Xplus the <*> and <?> characters.
X
XFor filename completion you can use the 'suffixes' option to set a priority
Xbetween files with almost the same name. If there are multiple matches,
Xthose files with a file extension that is in the 'suffixes' option are
Xignored. The default is ".bak.o.h.info.vim", which means that files with the
Xextensions ".bak", ".o", ".h", ".info" and ".vim" are sometimes ignored. It
Xis impossible to ignore suffixes with two dots. Examples:
X
Xpattern: files: match:
Xtest* test.c test.h test.o test.c
Xtest* test.h test.o test.h and test.o
Xtest* test.i test.h test.c test.i and test.c
X
X
X4.4.2 Ex command lines
X
XThe Ex commands have a few specialities:
X
X<"> or <#> at the start of a line causes the whole line to be ignored. <">
Xafter a command causes the rest of the line to be ignored. This can be used
Xto add comments.
X
X<|> can be used to separate commands, so you can give multiple commands in
Xone line. The commands ":global", ":vglobal" and ":!" see the <|> as their
Xargument, and can therefore not be followed by another command.
X
XWhen the character <%> or <#> is used where a filename is expected, they are
Xexpanded to the current and alternate filename (see the chapter "editing
Xfiles").
X
XEmbedded and trailing spaces in filenames are allowed if one filename is
Xexpected as argument (":next {file..}" uses the space to separate filenames).
X
XWhen you want to use the special characters <"> or <|> in a command, or want
Xto use <%> or <#> in a filename, precede them with a backslash. The backslash
Xis not required in a range and in the ":substitute" command.
X
X
X4.4.3 Ex command line ranges
X
XSome Ex commands accept a line range in front of them. This is noted as
X[range]. It consists of one or more line specifiers, separated with ',' or
X';'. When separated with ';' the cursor position will be set to that line
Xbefore interpreting the next line specifier. The default line specifier for
Xmost commands is the cursor position, but the commands ":write" and
X":global" have the whole file (1,$) as default. If more line specifiers are
Xgiven than required for the command, the first one(s) will be ignored.
X
XLine numbers may be specified with:
X {number} an absolute line number


X . the current line
X $ the last line in the file
X % equal to 1,$ (the entire file)

X 't position of mark t (lower case)
X /{pattern}[/] the next line where {pattern} matches
X ?{pattern}[?] the previous line where {pattern} matches


X
XEach may be followed (several times) by '+' or '-' and an optional number.

XThis number is added or subtracted from the preceding line number. If the
Xnumber is omitted, 1 is used.
X
XThe '/' and '?' may be preceded with another address. The search starts from
Xthere. The '/' and '?' after {pattern} are required to separate the pattern
Xfrom anything that follows.
X
XThe {number} must be between 0 and the number of lines in the file. A 0 is
Xinterpreted as a 1, except with the commands tag, pop and read.
X


XExamples:
X .+3 three lines below the cursor

X /that/+1 the line below the next line containing "that"


X .,$ from current line until end of file

X 0/that the first line that containing "that"
X
XSome commands allow for a count after the command. This count is used as the
Xnumber of lines to be used, starting with the line given in the last line
Xspecifier (the default is the cursor line).
X
XExamples:
X :s/x/X/g 5 substitute <x> by <X> in the current line and four
X following lines
X :23d 4 delete lines 23, 24, 25 and 26
X
X
X4.5 The window contents
X
XIn command and insert/replace mode the screen window will show the current
Xcontents of the buffer: What You See Is What You Get. {Vi: when changing
Xtext a <$> is placed on the last changed character; The window is not always
Xupdated on slow terminals} Lines longer than the window width will wrap. The
Xbottom lines in the window may start with one of these two characters:
X
X<@> The next line is too long to fit in the window.
X<~> Below the last line in the buffer.
X
XIf the bottom line is completely filled with <@>, the line that is at the
Xtop of the window is too long to fit in the window. If the cursor is on this
Xline you can't see what you are doing, because this part of the line is not
Xshown. However, the part of the line before the <@>s can be edited normally.
X{Vi: gives an "internal error" on lines that do not fit in the window}
X
XAll normal ASCII characters are displayed directly on the screen. The <TAB>
Xis replaced by the number of spaces that it represents. Other non-printing
Xcharacters are replaced by "^<char>", where <char> is the non-printing
Xcharacter with 64 added. Thus character 7 (bell) will be shown as "^G".
XCharacters between 127 and 160 are replaced by "~<char>", where <char> is
Xthe character with 64 subtracted. These characters occupy more than one
Xposition on the screen. The cursor can only be positioned on the first one.
X
XIf you set the 'number' option, all lines will be preceded with their
Xnumber.
X
XIf you set the 'list' option, <TAB> characters will not be shown as several
Xspaces, but as "^I". A <$> will be placed at the end of the line, so you can
Xfind trailing blanks.
X
XIn command line mode only the command line itself is shown correctly. The
Xdisplay of the buffer contents is updated as soon as you go back to command
Xmode.
X
XSome commands hand over the window to external commands (e.g. ":shell" and
X"="). After these commands are finished the window may be clobbered with
Xoutput from the external command, so it needs to be redrawn. This is also
Xthe case if something is displayed on the status line that is longer than
Xthe width of the window. If you are expected to have a look at the screen
Xbefore it is redrawn, you get this message:
X
X Press RETURN or enter command to continue
X
XAfter you type a key the screen will be redrawn and Vim continues. If you
Xtype <CR>, <SP> or <NL> nothing else happens. If you type any other key, it
Xwill be interpreted as (the start of) a new command. {Vi: only <:> commands
Xare interpreted}
X
XThe last line of the window is used for status and other messages. The
Xstatus messages will only be used if an option is on:
X
Xstatus message option default
Xcurrent mode 'showmode' on
Xcommand characters 'showcmd' on
Xcursor position 'ruler' off
X
XThe current mode is "-- INSERT --" or "-- REPLACE --". The command
Xcharacters are those that you typed but were not used yet. {Vi: does not show the characters you
Xtyped or the cursor position}
X
XIf you have a slow terminal you can switch off the status messages to speed
Xup editing:
X :set nosc noru nosm
X
XIf there is an error, an error message will be shown for at least one second
X(in reverse video). {Vi: error messages may be overwritten with other
Xmessages before you have a chance to read them}
X
XSome commands show how many lines were affected. Above which threshold this
Xhappens can be controlled with the 'report' option (default 2).
X
XOn the Amiga VIM will run in a CLI window. The name VIM and the full name of
Xthe current filename will be shown in the title bar. When the window is
Xresized, VIM will automatically redraw the window. You may make the window as
Xsmall as you like, but if it gets too small not a single line will fit in it.
XMake it at least 40 characters wide to be able to read most messages on the
Xlast line.
X
X
X 5. Editing files
X
X5.1 Introduction
X
XEditing a file with VIM means:
X
X1. reading the file into the internal buffer
X2. changing the buffer with editor commands
X3. writing the buffer into a file
X
XAs long as you don't write the buffer, the original file remains unchanged.
XIf you start editing a file (read a file into the buffer), the file name is
Xremembered as the "current filename".
X
XIf there already was a current filename, then that one becomes the alternate
Xfile name. Up to 20 older alternate filenames are remembered in a list. When
Xyou enter a filename, for editing (e.g. with ":e filename") or writing (e.g.
Xwith (:w filename"), the filenames shift one down in this list. You can use
Xthis list to remember which files you edited and to quickly switch from one
Xfile to another with the CTRL-^ command (e.g. to copy text). {Vi: only one
Xalternate filename}
X
XIn Ex commands (the ones that start with a colon) you can refer to the
Xcurrent filename with <%> and refer to the alternate filename with <#> or
X"#0". The older alternate filenames are "#1", "#2", ..., "#20".
X
XCTRL-G or
X:f[ile] Prints the current filename and the cursor position.
X
X:f[ile] {name} Sets the current filename to {name}.
X
X:files Lists the alternate filenames.
X
XWhen writing the buffer, the default is to use the current filename. Thus
Xwhen you give the "ZZ" or ":wq" command, the original file will be
Xoverwritten. If you do not want this, the buffer can be written into another
Xfile by giving a filename argument to the ":write" command. For example:
X
X vim testfile
X [change the buffer with editor commands]
X :w newfile
X :q
X
XThis will create a file "newfile", that is a modified copy of "testfile".
XThe file "testfile" will remain unchanged. Anyway, if the 'backup' option is
Xset, VIM renames the original file before it will be overwritten. You can
Xuse this file if you discover that you need the original file. The name of
Xthe backup file is the same as the original file with ".bak" appended. Any
X'.' is replaced by '_' on MSDOS machines, when Vim has detected that an
XMSDOS-like filesystem is being used (e.g. messydos or crossdos) and when the
X'shortname' option is set.
X
XTechnical: On the Amiga you can use 30 characters for a file name. But on an
X MSDOS-compatible filesystem only 8 plus 3 characters are
X available. Vim tries to detect the type of filesystem when it is
X creating the .vim file. If an MSDOS-like filesystem is suspected,
X a flag is set that has the same effect as setting the 'shortname'
X option. This flag will be reset as soon as you start editing a
X new file. The flag will be used when making the filename for the
X ".vim" and ".bak" files for the current file. But when you are
X editing a file in a normal filesystem and write to an MSDOS-like
X filesystem the flag will not have been set. In that case the
X creation of the ".bak" file may fail and you will get an error
X message. Use the 'shortname' option.
X
XVIM remembers whether you have changed the buffer. You are protected from
Xloosing the changes you made. If you try to quit without writing, or want to
Xstart editing another file, this will be refused. In order to overrule this
Xprotection add a <!> to the command. The changes will then be lost. For
Xexample: ":q" will not work if the buffer was changed, but ":q!" will. To see
Xwhether the buffer was changed use the "CTRL-G" command. The message includes
Xthe string "[Modified]" if the buffer has been changed.
X
X
X5.2 Editing a file
X
X:e [+pat] Edit the current file, unless changes have been made.
X
X:e! [+pat] Edit the current file always. Discard any changes to
X the buffer.
X
X:e[dit] [+pat] {file} Edit {file}, unless changes have been made.
X
X:e[dit]! [+pat] {file} Edit {file} always. Discard any changes to the
X buffer.
X
X:ex [+pat] [file] Same as :edit.
X
X:vi[sual] [+pat] [file] Same as :edit. {Vi: go from Ex to visual mode}
X
XCTRL-^ Edit [cnt]th (default 0) alternate file (equivalent
X to ":e #[cnt]"). If the 'autowrite' option is set
X and the buffer was changed, write it. This is a
X quick way to toggle between two (or more) files.
X
X:cd Print the current directory name. {Vi: go to home
X directory}
X
X:cd {path} Change the current directory to {path}.
X
X:chd[ir] [path] Same as :cd.
X
XThese commands are used to start editing a single file. This means that the
Xfile is read into the buffer and the current filename is set. You may use the
X":cd" command to get to another directory, so you will not have to type that
Xdirectory name in front of the filenames.
X
XYou can use the ":e!" command if you messed up the buffer and want to start
Xall over again. The ":e" command is only useful if you have changed the
Xcurrent filename.
X
XThe [+pat] can be used to position the cursor in the newly opened file:
X + Start at the last line.
X +{num} Start at line {num}.
X +/{pat} Start at first line containing {pat}. {pat} must not
X contain any spaces.
X +{command} Execute {command} after opening the new file.
X {command} is an Ex command. It must not contain
X spaces.
X
X
X5.3 The file list
X
XIf you give more than one filename when starting VIM, this list is remembered
Xas the file list. You can use this list with the following commands:
X
X:ar[gs] Print the file list, with the current file in "[]".
X
X:[count]n[ext] Edit [count] next file, unless changes have been
X made and the 'autowrite' option is off {Vi: no
X count}.
X
X:[count]n[ext]! Edit [count] next file, discard any changes to the
X buffer {Vi: no count}.
X
X:n[ext] [+pat] {filelist}
X Define {filelist} as the new list of files and edit
X the first one, unless changes have been made and the
X 'autowrite' option is off.
X
X:n[ext]! [+pat] {filelist}
X Define {filelist} as the new list of files and edit
X the first one. Discard any changes to the buffer.
X
X:[count]N[ext] Edit [count] previous file in file list, unless
X changes have been made and the 'autowrite' option is
X off {Vi: no count}.
X
X:[count]N[ext]! Edit [count] previous file in file list. Discard any
X changes to the buffer {Vi: no count}.
X
X:[count]pre[vious] Same as :Next {Vi: no count}.
X
X:rew[ind] Start editing the first file in the file list, unless
X changes have been made and the 'autowrite' option is
X off.
X
X:rew[ind]! Start editing the first file in the file list.
X Discard any changes to the buffer.
X
X:[count]wn[ext] Write current file and start editing the [count]
X next file. {not in Vi}
X
X:[count]wn[ext] {file} Write current file to {file} and start editing the
X [count] next file, unless {file} already exists and
X the 'writeany' option is off.

X {not in Vi}
X

X:[count]wn[ext]! {file} Write current file to {file} and start editing the
X [count] next file. {not in Vi}
X
XThe [count] in the commands above defaults to one.
X
XThe wildcards in the file list are expanded and the filenames are sorted.
XThus you can use the command "vim *.c" to edit all the C files. From within
XVIM the command ":n *.c" does the same.
X
XYou are protected from leaving VIM if you are not editing the last file in
Xthe file list. This prevents you from forgetting that you were editing one
Xout of several files. You can exit anyway, and save any changes, with the
X":wq!" command. To loose any changes use the ":q!" command.
X
X
X5.4 Writing and quitting
X
X:[range]w[rite][!] Write the specified lines to the current file.
X
X:[range]w[rite] {file} Write the specified lines to {file}, unless it
X already exists and the 'writeany' option is off.
X
X:[range]w[rite]! {file} Write the specified lines to {file}. Overwrite an
X existing file.
X
X:[range]w[rite][!] >> Append the specified lines to the current file.
X
X:[range]w[rite][!] >> {file}
X Append the specified lines to {file}.
X
X:[range]w[rite] !{cmd} Execute {cmd} with [range] lines as standard input
X (note the space in front of the <!>).
X
XThe default [range] for the ":w" command is the whole buffer (1,$).
X
X
X:q[uit] Quit, unless changes have been made or not editing
X the last file in the file list.
X
X:q[uit]! Quit always, without writing.
X
X:cq Quit always, without writing, and return an error
X code. Used for Manx's QuickFix option (see 5.5).
X
X:wq Write the current file. Exit if not editing the
X last file in the file list.
X
X:wq! Write the current file and exit.
X
X:wq {file} Write to {file}. Exit if not editing the last
X file in the file list.
X
X:wq! {file} Write to {file} and exit.
X
X:x[it][!] [file] Like ":wq", but write only when changes have been
X made.
X
XZZ Store current file, if modified, and exit (same as
X ":x").
X
XIf you write to an existing file (but do not append) while the 'backup' or
X'writebackup' option is on, a backup of the original file is made. On Unix
Xsystems the file is copied, on other systems the file is renamed. After the
Xfile has been successfully written and when the 'writebackup' option is on
Xand the 'backup' option is off, the backup file is deleted.
X
X'backup' 'writebackup' action
X off off no backup made
X off on backup made, deleted afterwards
X on off backup made, not deleted
X on on backup made, not deleted
X
XOn Unix systems:
XWhen you write to an existing file, that file is truncated and then filled
Xwith the new text. This means that protection bits, owner and symbolic links
Xare unmodified. The backup file however, is a new file, owned by the user
Xwho edited the file. If it is not possible to create the backup file in the
Xsame directory as the original file, the directory given with the
X'backupdir' option is used (default: home directory).
X
XIf the creation of a backup file fails, the write is not done. If you want
Xto write anyway add a <!> to the command.
X
X
X5.5 Using the QuickFix option
X
XManx's Aztec C compiler on the Amiga has a speciality to speedup the
Xedit-compile-edit cycle. This is called the QuickFix option. VIM includes
Xsupport for this handy feature which is almost identical to Manx's editor
X"Z". What you should do is:
X
X- Set the CCEDIT environment variable with the command
X mset "CCEDIT=vim -e"
X
X- Compile with the -qf option. If the compiler finds any errors, Vim is
Xstarted and the cursor is positioned on the first error. The error message
Xwill be displayed on the last line. You can go to other errors with the
Xcommands mentioned below. You can fix the errors and write the file(s).
X
X- If you exit Vim normally the compiler will re-compile the same file. If you
Xexit with the :cq command, the compiler will terminate. Do this if you cannot
Xfix the error, or if another file needs to be compiled first.
X
XThe following commands can be used if you are in QuickFix mode:
X
X:cc [nr] Display error [nr]. If [nr] is omitted, the same
X error is displayed again.
X
X:cn Display the next error in the list.
X
X:cp Display the previous error in the list.
X
X:cq Quit Vim with an error code, so that the compiler
X will not compile the same file again.
X
X:cf Read the error file. This is done automatically when
X Vim is started with the -e option.
X
X:cl List all errors.
X
XThe name of the file can be set with the 'errorfile' option. The default is
X"AztecC.Err". The format of the file is:
X
X filename>linenumber:columnnumber:errortype:errornumber:errormessage
X
X filename name of the file in which the error was detected
X linenumber line number where the error was detected
X columnnumber column number where the error was detected
X errortype type of the error, normally a single 'E'
X errornumber number of the error
X errormessage description of the error
X
XIf you have a different compiler you could write a program that translates
Xthe error messages into this format. Even better, it could start the
Xcompiler (with make), interpret the output and, when there are any errors,
Xstart Vim and recompile.
X
XThere are some restrictions to the Quickfix option. The compiler only writes
Xthe first 25 errors to the errorfile (Manx's documentation does not say how
Xto get more). If you want to find the others, you will have to fix a few
Xerrors and exit the editor. After recompiling, upto 25 remaining errors
Xwill be found.
X
XIf Vim was started from the compiler the :sh and :! commands will not work,
Xbecause Vim is then running in the same process as the compiler and these
Xtwo commands may guru the machine then.
X
XIf you insert or delete lines, mostly the correct error location is still
Xfound because hidden marks are used (Manx's Z editor does not do this).
XSometimes, when the mark has been deleted for some reason, the message "line
Xchanged" is shown to warn you that the error location may not be correct. If
Xyou edit another file the marks are lost and the error locations may not be
Xcorrect anymore.
X
X
X 6. Cursor motions
X
XThese commands move the cursor position. If the new position is off of the
Xscreen, the screen is scrolled to show the cursor (see also 'scrolljump'
Xoption).
X
XThe motion commands can be used after other commands, called operators, to
Xhave the command operate on the text that was moved over. That is the text
Xbetween the cursor position before and after the motion. If the motion
Xincludes a count and the operator also had a count, the two counts are
Xmultiplied. For example: "2d3w" deletes six words.
X The operator either affects whole lines, or the characters between
Xthe cursor positions. Generally, motions that move between lines affect
Xlines, and motions that move within a line affect characters. However, there
Xare some exceptions.
X The motion is either inclusive or exclusive. When inclusive, the
Xstart and end positions of the motion are included in the operation. When
Xexclusive, the last character towards the end of the buffer is not included.
XLinewise motions are always inclusive.
X Which motions are linewise, inclusive or exclusive is mentioned
Xbelow.
X
XInstead of first giving the operator and then a motion you can use quoting:
Xmark the start of the text with <q>, move the cursor to the end of the text
Xthat is to be affected and then hit the operator. The text between the start
Xand the cursor position is highlighted, so you can see what text will be
Xoperated upon. This allows much more freedom, but requires more key strokes
Xand has limited redo functionality. See the chapter on quoting.
X
XIf you want to know where you are in the file use the "CTRL-G" command. If
Xyou set the 'ruler' option, the cursor position is continuously shown in the
Xstatus line (which slows down Vim a little).
X
XNOTE: Experienced users prefer the hjkl keys because they are always right
Xunder their fingers. Beginners often prefer the arrow keys, since they do not
Xrequire memorization of which hjkl key is which. The mnemonic value of hjkl
Xis clear from looking at the keyboard. Think of j as an arrow pointing
Xdownwards.
X
X6.1 Left-right motions
X
Xh or
X<C_LEFT> or
XCTRL-H or
X<BS> [cnt] characters to the left (exclusive).
X
Xl or
X<C_RIGHT> or
X<SPACE> [cnt] characters to the right (exclusive).
X
X0 To the first character of the line (exclusive).
X
X^ To the first non-blank character of the line
X (exclusive).
X
X$ To the end of line [cnt] from the cursor (inclusive).
X
X| To column [cnt] (inclusive).
X
Xf<char> To [cnt]'th occurrence of <char> to the right. The
X cursor is placed on <char> (inclusive).
X
XF<char> To the [cnt]'th occurrence of <char> to the left. The
X cursor is placed on <char> (inclusive).
X
Xt<char> Till before [cnt]'th occurrence of <char> to the
X right. The cursor is placed on the character left of
X <char> (inclusive).
X
XT<char> Till after [cnt]'th occurrence of <char> to the left.
X The cursor is placed on the character right of <char>
END_OF_FILE
if test 48721 -ne `wc -c <'vim/doc/reference.doc1'`; then
echo shar: \"'vim/doc/reference.doc1'\" unpacked with wrong size!
fi
# end of 'vim/doc/reference.doc1'
fi
echo shar: End of archive 22 \(of 23\).
cp /dev/null ark22isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:39:20 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 23
Archive-name: vim/part23
Environment: UNIX, AMIGA, MS-DOS

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:

# "End of archive 23 (of 23)."
# Contents: vim/src/arpbase.h
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:14 1993


PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/src/arpbase.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/arpbase.h'\"
else
echo shar: Extracting \"'vim/src/arpbase.h'\" \(49786 characters\)
sed "s/^X//" >'vim/src/arpbase.h' <<'END_OF_FILE'
X#ifndef LIBRARIES_ARPBASE_H
X#define LIBRARIES_ARPBASE_H 1
X
X/*
X ************************************************************************
X * *
X * 5/3/89 ARPbase.h by MKSoft from ARPbase.i by SDB *
X * *
X ************************************************************************
X * *
X * AmigaDOS Resource Project -- Library Include File *
X * for Lattice C 5.x or Manx C 5.x *
X * *
X ************************************************************************
X * *
X * Copyright (c) 1987/1988/1989 by Scott Ballantyne *
X * *
X * The arp.library, and related code and files may be freely used *
X * by supporters of ARP. Modules in the arp.library may not be *
X * extracted for use in independent code, but you are welcome to *
X * provide the arp.library with your work and call on it freely. *
X * *
X * You are equally welcome to add new functions, improve the ones *
X * within, or suggest additions. *
X * *
X * BCPL programs are not welcome to call on the arp.library. *
X * The welcome mat is out to all others. *
X * *
X ************************************************************************
X * *
X * N O T E ! You MUST! have IoErr() defined as LONG to use LastTracker *
X * If your compiler has other defines for this, you may wish *
X * to remove the prototype for IoErr() from this file. *
X * *
X ************************************************************************
X */
X
X/*
X ************************************************************************
X * First we need to include the Amiga Standard Include files... *
X ************************************************************************
X */
X#ifndef EXEC_TYPES_H
X#include <exec/types.h>
X#endif /* EXEC_TYPES_H */
X
X#ifndef EXEC_LISTS_H
X#include <exec/lists.h>
X#endif /* EXEC_LISTS_H */
X
X#ifndef EXEC_ALERTS_H
X#include <exec/alerts.h>
X#endif /* EXEC_ALERTS_H */
X
X#ifndef EXEC_LIBRARIES_H
X#include <exec/libraries.h>
X#endif /* EXEC_LIBRARIES_H */
X
X#ifndef EXEC_SEMAPHORES_H
X#include <exec/semaphores.h>
X#endif /* EXEC_SEMAPHORES_H */
X
X#ifndef LIBRARIES_DOS_H
X#include <libraries/dosextens.h>
X#endif /* LIBRARIES_DOS_H */
X
X/*
X ************************************************************************
X * Check for MANX/Lattice and define the differences... *
X ************************************************************************
X * At the moment MANX 3.6 does not have prototypes or the *
X * wonderful #pragma statements of Lattice 5.0... *
X * And, no __stdargs in MANX either... *
X ************************************************************************
X */
X#ifdef AZTEC_C
X
X /* Do we have an old 3.6a compiler? -olsen */
X
X#ifndef __VERSION
X#define __VERSION 360
X#endif /* __VERSION */
X
X /* If this is an old compiler, don't confuse it with
X * ANSI prototypes and pragmas. -olsen
X */
X
X#if __VERSION < 500
X#define NO_PRAGMAS 1
X#define NO_PROTOTYPES 1
X#endif /* __VERSION */
X
X#define C_Args
X
X#endif /* AZTEC_C */
X
X#ifdef LATTICE
X
X#define C_Args __stdargs
X
X#endif /* LATTICE */
X
X/*
X ************************************************************************
X * Standard definitions for arp library information *
X ************************************************************************
X */
X#define ArpName "arp.library" /* Name of library... */
X#define ArpVersion 39L /* Current version... */
X
X/*
X ************************************************************************
X * The current ARP library node... *
X ************************************************************************
X */
Xstruct ArpBase {
X struct Library LibNode; /* Standard library node */
X APTR DosRootNode; /* Copy of dl_Root */
X UBYTE Flags; /* See bitdefs below */
X UBYTE ESCChar; /* Character to be used for escaping */
X LONG ArpReserved1; /* ArpLib's use only!! */
X struct Library *EnvBase; /* Dummy library for MANX compatibility*/
X struct Library *DosBase; /* Cached DosBase */
X struct Library *GfxBase; /* Cached GfxBase */
X struct Library *IntuiBase; /* Cached IntuitionBase */
X struct MinList ResLists; /* Resource trackers */
X struct ResidentProgramNode *ResidentPrgList;/* Resident Programs. */
X struct SignalSemaphore ResPrgProtection;/* protection for above */
X BPTR SegList; /* Pointer to loaded libcode (a BPTR). */
X };
X
X/*
X ************************************************************************
X * The following is here *ONLY* for information and for *
X * compatibility with MANX. DO NOT use in new code! *
X ************************************************************************
X */
X#ifdef ARP_PRIVATE
Xstruct EnvBase {
X struct Library LibNode; /* Standard library node for linkage */
X BYTE *EnvSpace; /* Access only when Forbidden! */
X ULONG EnvSize; /* Total allocated mem for EnvSpace */
X struct ArpBase *ArpBase; /* Added in V32 for Resource Tracking */
X };
X#endif /* ARP_PRIVATE */
X
X/*
X ************************************************************************
X * These are used in release 33.4 but not by the library code. *
X * Instead, individual programs check for these flags. *
X ************************************************************************
X */
X#define ARPB_WILD_WORLD 0L ; Mixed BCPL/Normal wildcards.
X#define ARPB_WILD_BCPL 1L ; Pure BCPL wildcards.
X
X#define ARPF_WILD_WORLD (1L << ARPB_WILD_WORLD)
X#define ARPF_WILD_BCPL (1L << ARPB_WILD_BCPL)
X
X/*
X ************************************************************************
X * The alert object is what you use if you really must return an alert *
X * to the user. You would normally OR this with another alert number *
X * from the alerts.h file. Generally, should be NON deadend alerts. *
X * *
X * For example, if you can't open ArpLibrary: *
X * Alert( (AG_OpenLib|AO_ArpLib), 0L); *
X ************************************************************************
X */
X#define AO_ArpLib 0x00008036L /* Alert object */
X
X/*
X ************************************************************************
X * Alerts that arp.library may return... *
X ************************************************************************
X */
X#define AN_ArpLib 0x03600000L /* Alert number */
X#define AN_ArpNoMem 0x03610000L /* No more memory */
X#define AN_ArpInputMem 0x03610002L /* No memory for input buffer */
X#define AN_ArpNoMakeEnv 0x83610003L /* No memory to make EnvLib */
X
X#define AN_ArpNoDOS 0x83630001L /* Can't open dos.library */
X#define AN_ArpNoGfx 0x83630002L /* Can't open graphics.library */
X#define AN_ArpNoIntuit 0x83630003L /* Can't open intuition */
X#define AN_BadPackBlues 0x83640000L /* Bad packet returned to SendPacket() */
X#define AN_Zombie 0x83600003L /* Zombie roaming around system */
X
X#define AN_ArpScattered 0x83600002L /* Scatter loading not allowed for arp */
X
X
X/*
X ************************************************************************
X * Return codes you can get from calling ARP Assign()... *
X ************************************************************************
X */
X#define ASSIGN_OK 0L /* Everything is cool and groovey */
X#define ASSIGN_NODEV 1L /* "Physical" is not valid for assignment */
X#define ASSIGN_FATAL 2L /* Something really icky happened */
X#define ASSIGN_CANCEL 3L /* Tried to cancel something but it won't cancel */
X
X/*
X ************************************************************************
X * Size of buffer you need if you are going to call ReadLine() *
X ************************************************************************
X */
X#define MaxInputBuf 256L
X
X/*
X ************************************************************************
X * The ARP file requester data structure... *
X ************************************************************************
X */
X
X /* This whole part has to be skipped if libraries/asl.h is
X * pulled in before arpbase.h is included (which is the recommended
X * sequence). -olsen
X */
X
X#ifndef LIBRARIES_ASL_H
X#define LIBRARIES_ASL_H 1 /* mool: don't use libraries/asl.h */
X
X /* You know req.library? -olsen */
X
X#ifndef REQLIBRARY_H
X
Xstruct FileRequester {
X BYTE *fr_Hail; /* Hailing text */
X BYTE *fr_File; /* Filename array (FCHARS + 1) */
X BYTE *fr_Dir; /* Directory array (DSIZE + 1) */
X struct Window *fr_Window; /* Window requesting or NULL */
X UBYTE fr_FuncFlags; /* Set bitdef's below */
X UBYTE fr_Flags2; /* New flags... */
X VOID (*fr_Function)(); /* Your function, see bitdef's */
X WORD fr_LeftEdge; /* To be used later... */
X WORD fr_TopEdge;
X };
X
X#endif /* REQLIBRARY_H */
X
X/*
X ************************************************************************
X * The following are the defines for fr_FuncFlags. These bits tell *
X * FileRequest() what your fr_UserFunc is expecting, and what *
X * FileRequest() should call it for. *
X * *
X * You are called like so: *
X * fr_Function(Mask, Object) *
X * ULONG Mask; *
X * CPTR *Object; *
X * *
X * The Mask is a copy of the flag value that caused FileRequest() to *
X * call your function. You can use this to determine what action you *
X * need to perform, and exactly what Object is, so you know what to do *
X * and what to return. *
X ************************************************************************
X */
X#define FRB_DoWildFunc 7L /* Call me with a FIB and a name, ZERO return accepts. */
X#define FRB_DoMsgFunc 6L /* You get all IDCMP messages not for FileRequest() */
X#define FRB_DoColor 5L /* Set this bit for that new and different look */
X#define FRB_NewIDCMP 4L /* Force a new IDCMP (only if fr_Window != NULL) */
X#define FRB_NewWindFunc 3L /* You get to modify the newwindow structure. */
X#define FRB_AddGadFunc 2L /* You get to add gadgets. */
X#define FRB_GEventFunc 1L /* Function to call if one of your gadgets is selected. */
X#define FRB_ListFunc 0L /* Not implemented yet. */
X
X#define FRF_DoWildFunc (1L << FRB_DoWildFunc)
X#define FRF_DoMsgFunc (1L << FRB_DoMsgFunc)
X#define FRF_DoColor (1L << FRB_DoColor)
X#define FRF_NewIDCMP (1L << FRB_NewIDCMP)
X#define FRF_NewWindFunc (1L << FRB_NewWindFunc)
X#define FRF_AddGadFunc (1L << FRB_AddGadFunc)
X#define FRF_GEventFunc (1L << FRB_GEventFunc)
X#define FRF_ListFunc (1L << FRB_ListFunc)
X
X/*
X ************************************************************************
X * The FR2B_ bits are for fr_Flags2 in the file requester structure *
X ************************************************************************
X */
X#define FR2B_LongPath 0L /* Specify the fr_Dir buffer is 256 bytes long */
X
X#define FR2F_LongPath (1L << FR2B_LongPath)
X
X/*
X ************************************************************************
X * The sizes of the different buffers... *
X ************************************************************************
X */
X#define FCHARS 32L /* Filename size */
X#define DSIZE 33L /* Directory name size if not FR2B_LongPath */
X
X#define LONG_DSIZE 254L /* If FR2B_LongPath is set, use LONG_DSIZE */
X#define LONG_FSIZE 126L /* For compatibility with ARPbase.i */
X
X#define FR_FIRST_GADGET 0x7680L /* User gadgetID's must be less than this value */
X
X#endif /* LIBRARIES_ASL_H */
X
X#ifndef DOS_DOSASL_H /* mool: either this or dos/dosasl.h */
X#define DOS_DOSASL_H
X/*
X ************************************************************************
X * Structure expected by FindFirst()/FindNext() *
X * *
X * You need to allocate this structure and initialize it as follows: *
X * *
X * Set ap_BreakBits to the signal bits (CDEF) that you want to take a *
X * break on, or NULL, if you don't want to convenience the user. *
X * *
X * if you want to have the FULL PATH NAME of the files you found, *
X * allocate a buffer at the END of this structure, and put the size of *
X * it into ap_StrLen. If you don't want the full path name, make sure *
X * you set ap_StrLen to zero. In this case, the name of the file, and *
X * stats are available in the ap_Info, as per usual. *
X * *
X * Then call FindFirst() and then afterwards, FindNext() with this *
X * structure. You should check the return value each time (see below) *
X * and take the appropriate action, ultimately calling *
X * FreeAnchorChain() when there are no more files and you are done. *
X * You can tell when you are done by checking for the normal AmigaDOS *
X * return code ERROR_NO_MORE_ENTRIES. *
X * *
X * You will also have to check the DirEntryType variable in the ap_Info *
X * structure to determine what exactly you have received. *
X ************************************************************************
X */
Xstruct AnchorPath {
X struct AChain *ap_Base; /* Pointer to first anchor */
X struct AChain *ap_Last; /* Pointer to last anchor */
X LONG ap_BreakBits; /* Bits to break on */
X LONG ap_FoundBreak; /* Bits we broke on. Also returns ERROR_BREAK */
X BYTE ap_Flags; /* New use for the extra word... */
X BYTE ap_Reserved; /* To fill it out... */
X WORD ap_StrLen; /* This is what used to be ap_Length */
X struct FileInfoBlock ap_Info;
X BYTE ap_Buf[1]; /* Allocate a buffer here, if desired */
X };
X
X#define ap_Length ap_StrLen
X
X/*
X ************************************************************************
X * Bit definitions for the new ap_Flags... *
X ************************************************************************
X */
X#define APB_DoWild 0L /* User option ALL */
X#define APB_ItsWild 1L /* Set by FindFirst, used by FindNext */
X#define APB_DoDir 2L /* Bit is SET if a DIR node should be entered */
X /* Application can RESET this bit to AVOID */
X /* entering a dir. */
X#define APB_DidDir 3L /* Bit is set for an "expired" dir node */
X#define APB_NoMemErr 4L /* Set if there was not enough memory */
X#define APB_DoDot 5L /* If set, '.' (DOT) will convert to CurrentDir */
X
X#define APF_DoWild (1L << APB_DoWild)
X#define APF_ItsWild (1L << APB_ItsWild)
X#define APF_DoDir (1L << APB_DoDir)
X#define APF_DidDir (1L << APB_DidDir)
X#define APF_NoMemErr (1L << APB_NoMemErr)
X#define APF_DoDot (1L << APB_DoDot)
X
X/*
X ************************************************************************
X * Structure used by the pattern matching functions, no need to obtain, *
X * diddle or allocate this yourself. *
X * *
X * Note: If you did, you will now break as it has changed... *
X ************************************************************************
X */
X#ifdef ARP_PRIVATE
Xstruct AChain {
X struct AChain *an_Child;
X struct AChain *an_Parent;
X struct FileLock *an_Lock;
X struct FileInfoBlock *an_Info;
X BYTE an_Flags;
X char an_String[1]; /* Just as is .i file */
X }; /* ??? Don't use this! */
X#endif /* ARP_PRIVATE */
X
X#define DDB_PatternBit 0L
X#define DDB_ExaminedBit 1L
X#define DDB_Completed 2L
X#define DDB_AllBit 3L
X
X#define DDF_PatternBit (1L << DDB_PatternBit)
X#define DDF_ExaminedBit (1L << DDB_ExaminedBit)
X#define DDF_Completed (1L << DDB_Completed)
X#define DDF_AllBit (1L << DDB_AllBit)
X
X/*
X ************************************************************************
X * This structure takes a pointer, and returns FALSE if wildcard was *
X * not found by FindFirst() *
X ************************************************************************
X */
X#define IsWild( ptr ) ( *((LONG *)(ptr)) )
X
X/*
X ************************************************************************
X * Constants used by wildcard routines *
X * *
X * These are the pre-parsed tokens referred to by pattern match. It *
X * is not necessary for you to do anything about these, FindFirst() *
X * FindNext() handle all these for you. *
X ************************************************************************
X */
X#define P_ANY 0x80L /* Token for '*' | '#?' */
X#define P_SINGLE 0x81L /* Token for '?' */
X
X/*
X ************************************************************************
X * No need to muck with these as they may change... *
X ************************************************************************
X */
X#ifdef ARP_PRIVATE
X#define P_ORSTART 0x82L /* Token for '(' */
X#define P_ORNEXT 0x83L /* Token for '|' */
X#define P_OREND 0x84L /* Token for ')' */
X#define P_NOT 0x85L /* Token for '~' */
X#define P_NOTCLASS 0x87L /* Token for '^' */
X#define P_CLASS 0x88L /* Token for '[]' */
X#define P_REPBEG 0x89L /* Token for '[' */
X#define P_REPEND 0x8AL /* Token for ']' */
X#endif /* ARP_PRIVATE */
X
X#define ERROR_BUFFER_OVERFLOW 303L /* User or internal buffer overflow */
X#define ERROR_BREAK 304L /* A break character was received */
X#define ERROR_NOT_EXECUTABLE 305L /* A file has E bit cleared */
X /* dos/dosasl.h uses a good lot of the symbols and structures
X * defined here (AnchorPatch, AChain, ERROR_BREAK and the
X * like), so let's don't include it again.
X */
X
X/* #define DOS_DOSASL_H 1 */
X#endif /* added by mool */
X
X/*
X ************************************************************************
X * Structure used by AddDANode(), AddDADevs(), FreeDAList(). *
X * *
X * This structure is used to create lists of names, which normally *
X * are devices, assigns, volumes, files, or directories. *
X ************************************************************************
X */
Xstruct DirectoryEntry {
X struct DirectoryEntry *de_Next; /* Next in list */
X BYTE de_Type; /* DLX_mumble */
X BYTE de_Flags; /* For future expansion, DO NOT USE! */
X BYTE de_Name[1]; /* The name of the thing found */
X };
X
X/*
X ************************************************************************
X * Defines you use to get a list of the devices you want to look at. *
X * For example, to get a list of all directories and volumes, do: *
X * *
X * AddDADevs( mydalist, (DLF_DIRS | DLF_VOLUMES) ) *
X * *
X * After this, you can examine the de_type field of the elements added *
X * to your list (if any) to discover specifics about the objects added. *
X * *
X * Note that if you want only devices which are also disks, you must *
X * (DLF_DEVICES | DLF_DISKONLY). *
X ************************************************************************
X */
X#define DLB_DEVICES 0L /* Return devices */
X#define DLB_DISKONLY 1L /* Modifier for above: Return disk devices only */
X#define DLB_VOLUMES 2L /* Return volumes only */
X#define DLB_DIRS 3L /* Return assigned devices only */
X
X#define DLF_DEVICES (1L << DLB_DEVICES)
X#define DLF_DISKONLY (1L << DLB_DISKONLY)
X#define DLF_VOLUMES (1L << DLB_VOLUMES)
X#define DLF_DIRS (1L << DLB_DIRS)
X
X/*
X ************************************************************************
X * Legal de_Type values, check for these after a call to AddDADevs(), *
X * or use on your own as the ID values in AddDANode(). *
X ************************************************************************
X */
X#define DLX_FILE 0L /* AddDADevs() can't determine this */
X#define DLX_DIR 8L /* AddDADevs() can't determine this */
X#define DLX_DEVICE 16L /* It's a resident device */
X
X#define DLX_VOLUME 24L /* Device is a volume */
X#define DLX_UNMOUNTED 32L /* Device is not resident */
X
X#define DLX_ASSIGN 40L /* Device is a logical assignment */
X
X/*
X ************************************************************************
X * This macro is to check for an error return from the Atol() *
X * routine. If Errno is ERRBADINT, then there was an error... *
X * This was done to try to remain as close to source compatible *
X * as possible with the older (rel 1.1) ARPbase.h *
X ************************************************************************
X */
X#define ERRBADINT 1L
X#define Errno (IoErr() ? ERRBADINT : 0)
X
X/*
X ************************************************************************
X * Resource Tracking stuff... *
X ************************************************************************
X * *
X * There are a few things in arp.library that are only directly *
X * acessable from assembler. The glue routines provided by us for *
X * all 'C' compilers use the following conventions to make these *
X * available to C programs. The glue for other language's should use *
X * as similar a mechanism as possible, so that no matter what language *
X * or compiler we speak, when talk about arp, we will know what the *
X * other guy is saying. *
X * *
X * Here are the cases: *
X * *
X * Tracker calls... *
X * These calls return the Tracker pointer as a secondary *
X * result in the register A1. For C, there is no clean *
X * way to return more than one result so the tracker *
X * pointer is returned in IoErr(). For ease of use, *
X * there is a define that typecasts IoErr() to the correct *
X * pointer type. This is called LastTracker and should *
X * be source compatible with the earlier method of storing *
X * the secondary result. *
X * *
X * GetTracker() - *
X * Syntax is a bit different for C than the assembly call *
X * The C syntax is GetTracker(ID). The binding routines *
X * will store the ID into the tracker on return. Also, *
X * in an effort to remain consistant, the tracker will *
X * also be stored in LastTracker. *
X * *
X * In cases where you have allocated a tracker before you have obtained *
X * a resource (usually the most efficient method), and the resource has *
X * not been obtained, you will need to clear the tracker id. The macro *
X * CLEAR_ID() has been provided for that purpose. It expects a pointer *
X * to a DefaultTracker sort of struct. *
X ************************************************************************
X */
X#define CLEAR_ID(t) ((SHORT *) t)[-1]=NULL
X
X/*
X ************************************************************************
X * You MUST prototype IoErr() to prevent the possible error in defining *
X * IoErr() and thus causing LastTracker to give you trash... *
X * *
X * N O T E ! You MUST! have IoErr() defined as LONG to use LastTracker *
X * If your compiler has other defines for this, you may wish *
X * to remove the prototype for IoErr(). *
X ************************************************************************
X */
X#define LastTracker ((struct DefaultTracker *)IoErr())
X
X/*
X ************************************************************************
X * The rl_FirstItem list (ResList) is a list of TrackedResource (below) *
X * It is very important that nothing in this list depend on the task *
X * existing at resource freeing time (i.e., RemTask(0L) type stuff, *
X * DeletePort() and the rest). *
X * *
X * The tracking functions return a struct Tracker *Tracker to you, this *
X * is a pointer to whatever follows the tr_ID variable. *
X * The default case is reflected below, and you get it if you call *
X * GetTracker() ( see DefaultTracker below). *
X * *
X * NOTE: The two user variables mentioned in an earlier version don't *
X * exist, and never did. Sorry about that (SDB). *
X * *
X * However, you can still use ArpAlloc() to allocate your own tracking *
X * nodes and they can be any size or shape you like, as long as the *
X * base structure is preserved. They will be freed automagically just *
X * like the default trackers. *
X ************************************************************************
X */
Xstruct TrackedResource {
X struct MinNode tr_Node; /* Double linked pointer */
X BYTE tr_Flags; /* Don't touch */
X BYTE tr_Lock; /* Don't touch, for Get/FreeAccess() */
X SHORT tr_ID; /* Item's ID */
X
X/*
X ************************************************************************
X * The struct DefaultTracker *Tracker portion of the structure. *
X * The stuff below this point can conceivably vary, depending *
X * on user needs, etc. This reflects the default. *
X ************************************************************************
X */
X union {
X CPTR tr_Resource; /* Whatever */
X LONG tg_Verify; /* For use during TRAK_GENERIC */
X } tr_Object; /* The thing being tracked */
X union {
X VOID (*tg_Function)();/* Function to call for TRAK_GENERIC */
X struct Window *tr_Window2; /* For TRAK_WINDOW */
X } tr_Extra; /* Only needed sometimes */
X };
X
X#define tg_Value tg_Verify /* Ancient compatibility only! Do NOT use in new CODE!!! */
X
X/*
X ************************************************************************
X * You get a pointer to a struct of the following type when you call *
X * GetTracker(). You can change this, and use ArpAlloc() instead of *
X * GetTracker() to do tracking. Of course, you have to take a wee bit *
X * more responsibility if you do, as well as if you use TRAK_GENERIC *
X * stuff. *
X * *
X * TRAK_GENERIC folks need to set up a task function to be called when *
X * an item is freed. Some care is required to set this up properly. *
X * *
X * Some special cases are indicated by the unions below, for *
X * TRAK_WINDOW, if you have more than one window opened, and don't *
X * want the IDCMP closed particularly, you need to set a ptr to the *
X * other window in dt_Window2. See CloseWindowSafely() for more info. *
X * If only one window, set this to NULL. *
X ************************************************************************
X */
Xstruct DefaultTracker {
X union {
X CPTR dt_Resource; /* Whatever */
X LONG tg_Verify; /* For use during TRAK_GENERIC */
X } dt_Object; /* The object being tracked */
X union {
X VOID (*tg_Function)();/* Function to call for TRAK_GENERIC */
X struct Window *dt_Window2; /* For TRAK_WINDOW */
X } dt_Extra;
X };
X
X/*
X ************************************************************************
X * Items the tracker knows what to do about *
X ************************************************************************
X */
X#define TRAK_AAMEM 0L /* Default (ArpAlloc) element */
X#define TRAK_LOCK 1L /* File lock */
X#define TRAK_FILE 2L /* Opened file */
X#define TRAK_WINDOW 3L /* Window -- see docs */
X#define TRAK_SCREEN 4L /* Screen */
X#define TRAK_LIBRARY 5L /* Opened library */
X#define TRAK_DAMEM 6L /* Pointer to DosAllocMem block */
X#define TRAK_MEMNODE 7L /* AllocEntry() node */
X#define TRAK_SEGLIST 8L /* Program segment */
X#define TRAK_RESLIST 9L /* ARP (nested) ResList */
X#define TRAK_MEM 10L /* Memory ptr/length */
X#define TRAK_GENERIC 11L /* Generic Element, your choice */
X#define TRAK_DALIST 12L /* DAlist ( aka file request ) */
X#define TRAK_ANCHOR 13L /* Anchor chain (pattern matching) */
X#define TRAK_FREQ 14L /* FileRequest struct */
X#define TRAK_FONT 15L /* GfxBase CloseFont() */
X#define TRAK_MAX 15L /* Poof, anything higher is tossed */
X
X#define TRB_UNLINK 7L /* Free node bit */
X#define TRB_RELOC 6L /* This may be relocated (not used yet) */
X#define TRB_MOVED 5L /* Item moved */
X
X#define TRF_UNLINK (1L << TRB_UNLINK)
X#define TRF_RELOC (1L << TRB_RELOC)
X#define TRF_MOVED (1L << TRB_MOVED)
X
X/*
X ************************************************************************
X * Note: ResList MUST be a DosAllocMem'ed list!, this is done for *
X * you when you call CreateTaskResList(), typically, you won't need *
X * to access/allocate this structure. *
X ************************************************************************
X */
Xstruct ResList {
X struct MinNode rl_Node; /* Used by arplib to link reslists */
X struct Task *rl_TaskID; /* Owner of this list */
X struct MinList rl_FirstItem; /* List of Tracked Resources */
X struct ResList *rl_Link; /* SyncRun's use - hide list here */
X };
X
X/*
X ************************************************************************
X * Returns from CompareLock() *
X ************************************************************************
X */
X#define LCK_EQUAL 0L /* The two locks refer to the same object */
X#define LCK_VOLUME 1L /* Locks are on the same volume */
X#define LCK_DIFVOL1 2L /* Locks are on different volumes */
X#define LCK_DIFVOL2 3L /* Locks are on different volumes */
X
X/*
X ************************************************************************
X * ASyncRun() stuff... *
X ************************************************************************
X * Message sent back on your request by an exiting process. *
X * You request this by putting the address of your message in *
X * pcb_LastGasp, and initializing the ReplyPort variable of your *
X * ZombieMsg to the port you wish the message posted to. *
X ************************************************************************
X */
Xstruct ZombieMsg {
X struct Message zm_ExecMessage;
X ULONG zm_TaskNum; /* Task ID */
X LONG zm_ReturnCode; /* Process's return code */
X ULONG zm_Result2; /* System return code */
X struct DateStamp zm_ExitTime; /* Date stamp at time of exit */
X ULONG zm_UserInfo; /* For whatever you wish */
X };
X
X/*
X ************************************************************************
X * Structure required by ASyncRun() -- see docs for more info. *
X ************************************************************************
X */
Xstruct ProcessControlBlock {
X ULONG pcb_StackSize; /* Stacksize for new process */
X BYTE pcb_Pri; /* Priority of new task */
X UBYTE pcb_Control; /* Control bits, see defines below */
X APTR pcb_TrapCode; /* Optional Trap Code */
X BPTR pcb_Input;
X BPTR pcb_Output; /* Optional stdin, stdout */
X union {
X BPTR pcb_SplatFile; /* File to use for Open("*") */
X BYTE *pcb_ConName; /* CON: filename */
X } pcb_Console;
X CPTR pcb_LoadedCode; /* If not null, will not load/unload code */
X struct ZombieMsg *pcb_LastGasp; /* ReplyMsg() to be filled in by exit */
X struct MsgPort *pcb_WBProcess; /* Valid only when PRB_NOCLI */
X };
X
X/*
X ************************************************************************
X * Formerly needed to pass NULLCMD to a child. No longer needed. *
X * It is being kept here for compatibility only... *
X ************************************************************************
X */
X#define NOCMD "\n"
X
X/*
X ************************************************************************
X * The following control bits determine what ASyncRun() does on *
X * Abnormal Exits and on background process termination. *
X ************************************************************************
X */
X#define PRB_SAVEIO 0L /* Don't free/check file handles on exit */
X#define PRB_CLOSESPLAT 1L /* Close Splat file, must request explicitly */
X#define PRB_NOCLI 2L /* Don't create a CLI process */
X/* PRB_INTERACTIVE 3L This is now obsolete... */
X#define PRB_CODE 4L /* Dangerous yet enticing */
X#define PRB_STDIO 5L /* Do the stdio thing, splat = CON:Filename */
X
X#define PRF_SAVEIO (1L << PRB_SAVEIO)
X#define PRF_CLOSESPLAT (1L << PRB_CLOSESPLAT)
X#define PRF_NOCLI (1L << PRB_NOCLI)
X#define PRF_CODE (1L << PRB_CODE)
X#define PRF_STDIO (1L << PRB_STDIO)
X
X/*
X ************************************************************************
X * Error returns from SyncRun() and ASyncRun() *
X ************************************************************************
X */
X#define PR_NOFILE -1L /* Could not LoadSeg() the file */
X#define PR_NOMEM -2L /* No memory for something */
X/* PR_NOCLI -3L This is now obsolete */
X#define PR_NOSLOT -4L /* No room in TaskArray */
X#define PR_NOINPUT -5L /* Could not open input file */
X#define PR_NOOUTPUT -6L /* Could not get output file */
X/* PR_NOLOCK -7L This is now obsolete */
X/* PR_ARGERR -8L This is now obsolete */
X/* PR_NOBCPL -9L This is now obsolete */
X/* PR_BADLIB -10L This is now obsolete */
X#define PR_NOSTDIO -11L /* Couldn't get stdio handles */
X
X/*
X ************************************************************************
X * Added V35 of arp.library *
X ************************************************************************
X */
X#define PR_WANTSMESSAGE -12L /* Child wants you to report IoErr() to user */
X /* for SyncRun() only... */
X#define PR_NOSHELLPROC -13L /* Can't create a shell/cli process */
X#define PR_NOEXEC -14L /* 'E' bit is clear */
X#define PR_SCRIPT -15L /* S and E are set, IoErr() contains directory */
X
X/*
X ************************************************************************
X * Version 35 ASyncRun() allows you to create an independent *
X * interactive or background Shell/CLI. You need this variant of the *
X * pcb structure to do it, and you also have new values for nsh_Control,*
X * see below. *
X * *
X * Syntax for Interactive shell is: *
X * *
X * rc=ASyncRun("Optional Window Name","Optional From File",&NewShell); *
X * *
X * Syntax for a background shell is: *
X * *
X * rc=ASyncRun("Command line",0L,&NewShell); *
X * *
X * Same syntax for an Execute style call, but you have to be on drugs *
X * if you want to do that. *
X ************************************************************************
X */
Xstruct NewShell {
X ULONG nsh_StackSize; /* stacksize shell will use for children */
X BYTE nsh_Pri; /* ignored by interactive shells */
X UBYTE nsh_Control; /* bits/values: see above */
X CPTR nsh_LogMsg; /* Optional login message, if null, use default */
X BPTR nsh_Input; /* ignored by interactive shells, but */
X BPTR nsh_Output; /* used by background and execute options. */
X LONG nsh_RESERVED[5];
X };
X
X/*
X ************************************************************************
X * Bit Values for nsh_Control, you should use them as shown below, or *
X * just use the actual values indicated. *
X ************************************************************************
X */
X#define PRB_CLI 0L /* Do a CLI, not a shell */
X#define PRB_BACKGROUND 1L /* Background shell */
X#define PRB_EXECUTE 2L /* Do as EXECUTE... */
X#define PRB_INTERACTIVE 3L /* Run an interactive shell */
X#define PRB_FB 7L /* Alt function bit... */
X
X#define PRF_CLI (1L << PRB_CLI)
X#define PRF_BACKGOUND (1L << PRB_BACKGROUND)
X#define PRF_EXECUTE (1L << PRB_EXECUTE)
X#define PRF_INTERACTIVE (1L << PRB_INTERACTIVE)
X#define PRF_FB (1L << PRB_FB)
X
X/*
X ************************************************************************
X * Common values for sh_Control which allow you to do usefull *
X * and somewhat "standard" things... *
X ************************************************************************
X */
X#define INTERACTIVE_SHELL (PRF_FB|PRF_INTERACTIVE) /* Gimme a newshell! */
X#define INTERACTIVE_CLI (PRF_FB|PRF_INTERACTIVE|PRF_CLI) /* Gimme that ol newcli! */
X#define BACKGROUND_SHELL (PRF_FB|PRF_BACKGROUND) /* gimme a background shell */
X#define EXECUTE_ME (PRF_FB|PRF_BACKGROUND|PRF_EXECUTE) /* aptly named, doncha think? */
X
X/*
X ************************************************************************
X * Additional IoErr() returns added by ARP... *
X ************************************************************************
X */
X#define ERROR_NOT_CLI 400L /* Program/function neeeds to be cli */
X
X/*
X ************************************************************************
X * Resident Program Support *
X ************************************************************************
X * This is the kind of node allocated for you when you AddResidentPrg() *
X * a code segment. They are stored as a single linked list with the *
X * root in ArpBase. If you absolutely *must* wander through this list *
X * instead of using the supplied functions, then you must first obtain *
X * the semaphore which protects this list, and then release it *
X * afterwards. Do not use Forbid() and Permit() to gain exclusive *
X * access! Note that the supplied functions handle this locking *
X * protocol for you. *
X ************************************************************************
X */
Xstruct ResidentProgramNode {
X struct ResidentProgramNode *rpn_Next; /* next or NULL */
X LONG rpn_Usage; /* Number of current users */
X UWORD rpn_AccessCnt; /* Total times used... */
X ULONG rpn_CheckSum; /* Checksum of code */
X BPTR rpn_Segment; /* Actual segment */
X UWORD rpn_Flags; /* See definitions below... */
X BYTE rpn_Name[1]; /* Allocated as needed */
X };
X
X/*
X ************************************************************************
X * Bit definitions for rpn_Flags.... *
X ************************************************************************
X */
X#define RPNB_NOCHECK 0L /* Set in rpn_Flags for no checksumming... */
X#define RPNB_CACHE 1L /* Private usage in v1.3... */
X
X#define RPNF_NOCHECK (1L << RPNB_NOCHECK)
X#define RPNF_CACHE (1L << RPNB_CACHE)
X
X/*
X ************************************************************************
X * If your program starts with this structure, ASyncRun() and SyncRun() *
X * will override a users stack request with the value in rpt_StackSize. *
X * Furthermore, if you are actually attached to the resident list, a *
X * memory block of size rpt_DataSize will be allocated for you, and *
X * a pointer to this data passed to you in register A4. You may use *
X * this block to clone the data segment of programs, thus resulting in *
X * one copy of text, but multiple copies of data/bss for each process *
X * invocation. If you are resident, your program will start at *
X * rpt_Instruction, otherwise, it will be launched from the initial *
X * branch. *
X ************************************************************************
X */
Xstruct ResidentProgramTag {
X BPTR rpt_NextSeg; /* Provided by DOS at LoadSeg time */
X/*
X ************************************************************************
X * The initial branch destination and rpt_Instruction do not have to be *
X * the same. This allows different actions to be taken if you are *
X * diskloaded or resident. DataSize memory will be allocated only if *
X * you are resident, but StackSize will override all user stack *
X * requests. *
X ************************************************************************
X */
X UWORD rpt_BRA; /* Short branch to executable */
X UWORD rpt_Magic; /* Resident majik value */
X ULONG rpt_StackSize; /* min stack for this process */
X ULONG rpt_DataSize; /* Data size to allocate if resident */
X /* rpt_Instruction; Start here if resident */
X };
X
X/*
X ************************************************************************
X * The form of the ARP allocated node in your tasks memlist when *
X * launched as a resident program. Note that the data portion of the *
X * node will only exist if you have specified a nonzero value for *
X * rpt_DataSize. Note also that this structure is READ ONLY, modify *
X * values in this at your own risk. The stack stuff is for tracking, *
X * if you need actual addresses or stack size, check the normal places *
X * for it in your process/task struct. *
X ************************************************************************
X */
Xstruct ProcessMemory {
X struct Node pm_Node;
X UWORD pm_Num; /* This is 1 if no data, two if data */
X CPTR pm_Stack;
X ULONG pm_StackSize;
X CPTR pm_Data; /* Only here if pm_Num == 2 */
X ULONG pm_DataSize;
X };
X
X/*
X ************************************************************************
X * To find the above on your memlist, search for the following name. *
X * We guarantee this will be the only arp.library allocated node on *
X * your memlist with this name. *
X * i.e. FindName(task->tcb_MemEntry, PMEM_NAME); *
X ************************************************************************
X */
X#define PMEM_NAME "ARP_MEM"
X
X#define RESIDENT_MAGIC 0x4AFC /* same as RTC_MATCHWORD (trapf) */
X
X/*
X ************************************************************************
X * Date String/Data structures *
X ************************************************************************
X */
X#ifndef DOS_DATETIME_H /* added by mool */
X#define DOS_DATETIME_H
X
Xstruct DateTime {
X struct DateStamp dat_Stamp; /* DOS Datestamp */
X UBYTE dat_Format; /* controls appearance ot dat_StrDate */
X UBYTE dat_Flags; /* See BITDEF's below */
X BYTE *dat_StrDay; /* day of the week string */
X BYTE *dat_StrDate; /* date string */
X BYTE *dat_StrTime; /* time string */
X };
X
X/*
X ************************************************************************
X * Size of buffer you need for each DateTime strings: *
X ************************************************************************
X */
X#define LEN_DATSTRING 10L
X
X/*
X ************************************************************************
X * For dat_Flags *
X ************************************************************************
X */
X#define DTB_SUBST 0L /* Substitute "Today" "Tomorrow" where appropriate */
X#define DTB_FUTURE 1L /* Day of the week is in future */
X
X#define DTF_SUBST (1L << DTB_SUBST)
X#define DTF_FUTURE (1L << DTB_FUTURE)
X
X/*
X ************************************************************************
X * For dat_Format *
X ************************************************************************
X */
X#define FORMAT_DOS 0L /* dd-mmm-yy AmigaDOS's own, unique style */
X#define FORMAT_INT 1L /* yy-mm-dd International format */
X#define FORMAT_USA 2L /* mm-dd-yy The good'ol'USA. */
X#define FORMAT_CDN 3L /* dd-mm-yy Our brothers and sisters to the north */
X#define FORMAT_MAX FORMAT_CDN /* Larger than this? Defaults to AmigaDOS */
X
X /* dos/datetime.h uses the same structures and defines, so
X * keep the compiler from pulling it in. -olsen
X */
X
X/* #define DOS_DATETIME_H 1 */
X#endif
X
X/*
X ************************************************************************
X * Define NO_PROTOTYPES if your compiler does not handle them... *
X ************************************************************************
X */
X#if defined(NO_PROTOTYPES) || defined(__NO_PROTOS)
X#define ARGs(x) ()
X#else
X#define ARGs(x) x
X
X /* Added ArpVPrintf, ArpVFPrintf and ArpVSPrintf, so will have to
X * include the compiler specific stdarg header file. -olsen
X */
X
X#include <stdarg.h>
X
X#endif /* NO_PROTOTYPES */
X
X/*
X ************************************************************************
X * Note that C_Args is a #define that, in LATTICE does __stdargs *
X ************************************************************************
X */
X
X/*
X ************************************************************************
X * This prototype is here to prevent the possible error in defining *
X * IoErr() as LONG and thus causing LastTracker to give you trash... *
X * *
X * N O T E ! You MUST! have IoErr() defined as LONG to use LastTracker *
X * If your compiler has other defines for this, you may wish *
X * to move the prototype for IoErr() into the DO_ARP_COPIES *
X ************************************************************************
X */
X LONG IoErr ARGs( (VOID) );
X
X/*
X ************************************************************************
X * These duplicate the calls in dos.library *
X * Only include if you can use arp.library without dos.library *
X ************************************************************************
X */
X#ifdef DO_ARP_COPIES
X BPTR Open ARGs( (char *, LONG) );
X VOID Close ARGs( (BPTR) );
X LONG Read ARGs( (BPTR, char *, LONG) );
X LONG Write ARGs( (BPTR, char *, LONG) );
X BPTR Input ARGs( (VOID) );
X BPTR Output ARGs( (VOID) );
X LONG Seek ARGs( (BPTR, LONG, LONG) );
X LONG DeleteFile ARGs( (char *) );
X LONG Rename ARGs( (char *, char *) );
X BPTR Lock ARGs( (char *, LONG) );
X VOID UnLock ARGs( (BPTR) );
X BPTR DupLock ARGs( (BPTR) );
X LONG Examine ARGs( (BPTR, struct FileInfoBlock *) );
X LONG ExNext ARGs( (BPTR, struct FileInfoBlock *) );
X LONG Info ARGs( (BPTR, struct InfoData *) );
X BPTR CreateDir ARGs( (char *) );
X BPTR CurrentDir ARGs( (BPTR) );
Xstruct MsgPort *CreateProc ARGs( (char *, LONG, BPTR, LONG) );
X VOID Exit ARGs( (LONG) );
X BPTR LoadSeg ARGs( (char *) );
X VOID UnLoadSeg ARGs( (BPTR) );
Xstruct MsgPort *DeviceProc ARGs( (char *) );
X LONG SetComment ARGs( (char *, char *) );
X LONG SetProtection ARGs( (char *, LONG) );
X LONG *DateStamp ARGs( (LONG *) );
X VOID Delay ARGs( (LONG) );
X LONG WaitForChar ARGs( (BPTR, LONG) );
X BPTR ParentDir ARGs( (BPTR) );
X LONG IsInteractive ARGs( (BPTR) );
X LONG Execute ARGs( (char *, BPTR, BPTR) );
X#endif /* DO_ARP_COPIES */
X
X/*
X ************************************************************************
X * Now for the stuff that only exists in arp.library... *
X ************************************************************************
X */
X /* LONG C_Args Printf ARGs( (char *,...) ); */
X /* LONG C_Args FPrintf ARGs( (BPTR, char *,...) ); */
X LONG C_Args Printf ARGs( (UBYTE *, long, ...) );
X LONG C_Args FPrintf ARGs( (BPTR, UBYTE *, long, ...) );
X LONG Puts ARGs( (char *) );
X LONG ReadLine ARGs( (char *) );
X LONG GADS ARGs( (char *, LONG, char *, char **, char *) );
X LONG Atol ARGs( (char *) );
X ULONG EscapeString ARGs( (char *) );
X LONG CheckAbort ARGs( (VOID(*)) );
X LONG CheckBreak ARGs( (LONG, VOID(*)) );
X BYTE *Getenv ARGs( (char *, char *, LONG) );
X BOOL Setenv ARGs( (char *, char *) );
X BYTE *FileRequest ARGs( (struct FileRequester *) );
X VOID CloseWindowSafely ARGs( (struct Window *, LONG) );
X/* struct MsgPort *CreatePort ARGs( (const char *, LONG) ); */
Xstruct MsgPort *CreatePort ARGs( (UBYTE *, LONG) );
X VOID DeletePort ARGs( (struct MsgPort *) );
X LONG SendPacket ARGs( (LONG, LONG *, struct MsgPort *) );
X VOID InitStdPacket ARGs( (LONG, LONG *, struct DosPacket *, struct MsgPort *) );
X ULONG PathName ARGs( (BPTR, char *,LONG) );
X ULONG Assign ARGs( (char *, char *) );
X VOID *DosAllocMem ARGs( (LONG) );
X VOID DosFreeMem ARGs( (VOID *) );
X ULONG BtoCStr ARGs( (char *, BSTR, LONG) );
X ULONG CtoBStr ARGs( (char *, BSTR, LONG) );
Xstruct DeviceList *GetDevInfo ARGs( (struct DeviceList *) );
X BOOL FreeTaskResList ARGs( (VOID) );
X VOID ArpExit ARGs( (LONG,LONG) );
X VOID C_Args *ArpAlloc ARGs( (LONG) );
X VOID C_Args *ArpAllocMem ARGs( (LONG, LONG) );
X BPTR C_Args ArpOpen ARGs( (char *, LONG) );
X BPTR C_Args ArpDupLock ARGs( (BPTR) );
X BPTR C_Args ArpLock ARGs( (char *, LONG) );
X VOID C_Args *RListAlloc ARGs( (struct ResList *, LONG) );
Xstruct Process *FindCLI ARGs( (LONG) );
X BOOL QSort ARGs( (VOID *, LONG, LONG, int(*)) );
X BOOL PatternMatch ARGs( (char *,char *) );
X LONG FindFirst ARGs( (char *, struct AnchorPath *) );
X LONG FindNext ARGs( (struct AnchorPath *) );
X VOID FreeAnchorChain ARGs( (struct AnchorPath *) );
X ULONG CompareLock ARGs( (BPTR, BPTR) );
Xstruct ResList *FindTaskResList ARGs( (VOID) );
Xstruct ResList *CreateTaskResList ARGs( (VOID) );
X VOID FreeResList ARGs( (struct ResList *) );
X VOID FreeTrackedItem ARGs( (struct DefaultTracker *) );
Xstruct DefaultTracker C_Args *GetTracker ARGs( (LONG) );
X VOID *GetAccess ARGs( (struct DefaultTracker *) );
X VOID FreeAccess ARGs( (struct DefaultTracker *) );
X VOID FreeDAList ARGs( (struct DirectoryEntry *) );
Xstruct DirectoryEntry *AddDANode ARGs( (char *, struct DirectoryEntry **, LONG, LONG) );
X ULONG AddDADevs ARGs( (struct DirectoryEntry **, LONG) );
X LONG Strcmp ARGs( (char *, char *) );
X LONG Strncmp ARGs( (char *, char *, LONG) );
X BYTE Toupper ARGs( (BYTE) );
X LONG SyncRun ARGs( (char *, char *, BPTR, BPTR) );
X
X/*
X ************************************************************************
X * Added V32 of arp.library *
X ************************************************************************
X */
X LONG ASyncRun ARGs( (char *, char *, struct ProcessControlBlock *) );
X LONG SpawnShell ARGs( (char *, char *, struct NewShell *) );
X BPTR LoadPrg ARGs( (char *) );
X BOOL PreParse ARGs( (char *, char *) );


X
X/*
X ************************************************************************
X * Added V33 of arp.library *
X ************************************************************************
X */

X BOOL StamptoStr ARGs( (struct DateTime *) );
X BOOL StrtoStamp ARGs( (struct DateTime *) );
Xstruct ResidentProgramNode *ObtainResidentPrg ARGs( (char *) );
Xstruct ResidentProgramNode *AddResidentPrg ARGs( (BPTR, char *) );
X LONG RemResidentPrg ARGs( (char *) );
X VOID UnLoadPrg ARGs( (BPTR) );
X LONG LMult ARGs( (LONG, LONG) );
X LONG LDiv ARGs( (LONG, LONG) );
X LONG LMod ARGs( (LONG, LONG) );
X ULONG CheckSumPrg ARGs( (struct ResidentProgramNode *) );
X VOID TackOn ARGs( (char *, char *) );
X BYTE *BaseName ARGs( (char *) );
Xstruct ResidentProgramNode *ReleaseResidentPrg ARGs( (BPTR) );


X
X/*
X ************************************************************************
X * Added V36 of arp.library *
X ************************************************************************
X */

X LONG C_Args SPrintf ARGs( (char *, char *,...) );
X LONG GetKeywordIndex ARGs( (char *, char *) );
Xstruct Library C_Args *ArpOpenLibrary ARGs( (char *, LONG) );
Xstruct FileRequester C_Args *ArpAllocFreq ARGs( (VOID) );
X
X /* This one's a cutie which is supported via bypassing the
X * ??Printf glue routines. -olsen
X */
X
X LONG ArpVPrintf ARGs( (char *, va_list) );
X LONG ArpVFPrintf ARGs( (BPTR, char *, va_list) );
X LONG ArpVSPrintf ARGs( (char *, char *, va_list) );
X
X/*
X ************************************************************************
X * Check if we should do the pragmas... *


X ************************************************************************
X */
X

X#if !defined(NO_PRAGMAS) && !defined(__NO_PRAGMAS)
X#ifndef PROTO_ARP_H
X#include <proto/arp.h>
X#endif /* PROTO_ARP_H */
X#endif /* NO_PRAGMAS */
X
X#endif /* LIBRARIES_ARPBASE_H */
END_OF_FILE
if test 49786 -ne `wc -c <'vim/src/arpbase.h'`; then
echo shar: \"'vim/src/arpbase.h'\" unpacked with wrong size!
fi
# end of 'vim/src/arpbase.h'
fi
echo shar: End of archive 23 \(of 23\).
cp /dev/null ark23isdone

Bram Moolenaar

unread,
Apr 24, 1993, 9:44:19 PM4/24/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 24
Archive-name: vim/part24
Environment: UNIX, AMIGA, MS-DOS

[ Moderator error - There are only 23 parts to vim. One of the received ]
[ parts ( author numbered 24) was author instructions to the moderator. ]

Vim - Vi IMitation. A clone of the UNIX text editor Vi. Very useful for
editing programs and other plain ASCII text. Full Vi compatibility (except Q
command) and includes most Ex commands.

===============================================================================

0 new messages