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

v41i050: vim - Vi IMitation editor, v2.0, Part00/25

47 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 20, 1993, 10:41:36 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 50
Archive-name: vim/part00
Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

Vim - Vi IMproved. A clone of the UNIX text editor Vi. Very useful for
editing programs and other plain ASCII text. Full Vi compatibility (except Q
command, you don't need it). 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, line wrapping can be switched off,
file name stack, can be adjusted to understand error messages from any
compiler, shows current file name in window title, on-line help, etc.

Version 2.0, update to 1.27. Most important changes:
- 'wrap' option to switch line wrapping on/off
- filename completion is more like other programs and adjustable
- automatic detection of CR/LF line separator
- '-b' command line option to make editing binary files more easy
- added abbreviation
- :make command for quickly jumping to errors
- MSDOS version uses bios calls for screen output, ansi.sys not needed
- many small changes to make Vim more vi-compatible

Portability: Vim is currently running on Unix, MSdos and Amiga. Vim should
run on any UNIX system, although small modification may be required. It has
been tested on Sun, Ultrix, linux, hpux and many others. For MSDOS it can be
compiled with Turbo C and Borland C++.

Distribution:
comp.binaries.ibm.pc: vim_dos.zip: MSDOS binary and documentation

comp.binaries.amiga: vim_bin.lha: Amiga binary and documentation

comp.sources.misc: shell archive with sources and documentation

The documentation is almost the same for all systems. For MSDOS CR-LF is used
for line separator. For Amiga .info files are included. For the shell archive
some files are uuencoded because of unprintable characters.

Note that some files are uuencoded. I had to do this because there are
non-printable characters in these files that may be mangled by news. The
files are readable ASCII otherwise. To unpack the files completely unshar
the entire distribution and then run the file execute.me. This will uudecode
the files as appropriate.

Vim is charityware. Read uganda.txt for details.

===============================================================================
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 595473 | whatever will be accepted.
exit 0 # Just in case...

Bram Moolenaar

unread,
Dec 20, 1993, 10:42:11 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 51
Archive-name: vim/part01

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim vim/.exrc vim/README 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_ma.uue vim/macros/hanoi/poster
# vim/macros/keyword.uue 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/poster vim/src
# vim/src/addcr.c vim/src/ascii.h vim/src/debug.h vim/src/macros.h
# vim/src/mark.h vim/src/mkcmdtab.c vim/src/ops.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/sun_stdlib.h vim/src/term_fix.uue
# vim/src/vim.prj vim/src/vimresp vim/tutor vim/tutor/Readme
# vim/tutor/poster
# Wrapped by mool@oce-rd2 on Wed Dec 15 09: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'\" \(30 characters\)
sed "s/^X//" >'vim/.exrc' <<'END_OF_FILE'
Xset ai bs=2 shell=csh nojs ru
END_OF_FILE
if test 30 -ne `wc -c <'vim/.exrc'`; then
echo shar: \"'vim/.exrc'\" unpacked with wrong size!
fi
chmod +x 'vim/.exrc'
# end of 'vim/.exrc'
fi
if test -f 'vim/README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/README'\"
else
echo shar: Extracting \"'vim/README'\" \(1629 characters\)
sed "s/^X//" >'vim/README' <<'END_OF_FILE'
XREADME for version 2.0 of Vim: Vi IMproved.
X
XVim is an almost compatible version of the UNIX editor vi. Only the 'Q'
Xcommand is missing (you don't need it). Many new features have been added:
Xmulti level undo, command line history, filename completion, block operations,
Xetc. 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. Additionally function keys can be defined
Xby the user.
X
XVim currently runs under Amiga DOS, MSDOS and many UNIX versions. Porting to
Xother systems should 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 amiga.doc - remarks for Amiga
X unix.doc - remarks for unix
X msdos.doc - remarks for MSDOS
X
XVim is Charityware. You can copy it as much as you like. Please read
Xuganda.txt for details.
X
X
XThe makefile offers some compilation options. If you do not use digraphs, you
Xcan save some memory by recompiling without the DIGRAPHS option. The Amiga
Xand MS-DOS versions are compiled for a limited number of supported terminals.
XIf you want to use Vim with other terminals you can recompile with the
XTERMCAP option. See the makefiles for further options.
X
XPlease send comments, bug reports and suggestions to:
X
X Bram Moolenaar UUCP E-mail: mo...@oce.nl
X Clematisstraat 30 FAX: +31-77-595473
X 5925 BE Venlo
X The Netherlands
END_OF_FILE
if test 1629 -ne `wc -c <'vim/README'`; then
echo shar: \"'vim/README'\" unpacked with wrong size!
fi
chmod +x 'vim/README'
# end of 'vim/README'
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'\" \(1226 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/lib/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 cases the terminal may have a problem with CTRL-S (subtract
Xcommand). To get around this you can map another key to CTRL-S, and remap
XCTRL-S to nothing. You could use CTRL-W:
X :noremap! ^W ^V019
X :noremap! ^V019 ^V^V
X :noremap ^W ^V019
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
XBecause terminal updating under UNIX is often slow (e.g. serial line
Xterminal, shell window in suntools), the 'showcommand' and 'ruler' options
Xare default off.
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 1226 -ne `wc -c <'vim/doc/unix.doc'`; then
echo shar: \"'vim/doc/unix.doc'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/unix.doc'
# 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
chmod +x 'vim/doc/vim132.uue'
# 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'\" \(840 characters\)
sed "s/^X//" >'vim/execute.me' <<'END_OF_FILE'
X# Script to unpack the source distribution of Vim
X#
X# Execute this script in the 'vim' directory.
X# It is not very smart, no error checking at all.
X#
X# What it does:
X# - a few files with special characters in them will be uudecoded
X# - the three parts of reference.doc are concatenated
X#
Xcd macros
Xuudecode center.uue
Xrm center.uue
Xcd maze
Xuudecode maze_mac.uue
Xrm maze_mac.uue
Xcd ../hanoi
Xuudecode hanoi_ma.uue
Xrm hanoi_ma.uue
Xcd ../../src
Xuudecode digrap_c.uue
Xuudecode tccon_tc.uue
Xuudecode term_fix.uue
Xrm digrap_c.uue tccon_tc.uue term_fix.uue
Xcd ../doc
Xuudecode vim_hlp.uue
Xuudecode digr_doc.uue
Xuudecode vim_man.uue
Xuudecode vim132.uue
Xrm vim_hlp.uue digr_doc.uue vim_man.uue vim132.uue
Xcat reference.do1 reference.do2 reference.do3 reference.do4 >reference.doc
Xrm reference.do1 reference.do2 reference.do3 reference.do4
Xcd ..
END_OF_FILE
if test 840 -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
chmod +x 'vim/macros/center.uue'
# 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
chmod +x 'vim/macros/hanoi/click.me'
# end of 'vim/macros/hanoi/click.me'
fi
if test -f 'vim/macros/hanoi/hanoi_ma.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/hanoi/hanoi_ma.uue'\"
else
echo shar: Extracting \"'vim/macros/hanoi/hanoi_ma.uue'\" \(1577 characters\)
sed "s/^X//" >'vim/macros/hanoi/hanoi_ma.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_ma.uue'`; then
echo shar: \"'vim/macros/hanoi/hanoi_ma.uue'\" unpacked with wrong size!
fi
chmod +x 'vim/macros/hanoi/hanoi_ma.uue'
# end of 'vim/macros/hanoi/hanoi_ma.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
chmod +x 'vim/macros/hanoi/poster'
# end of 'vim/macros/hanoi/poster'
fi
if test -f 'vim/macros/keyword.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/macros/keyword.uue'\"
else
echo shar: Extracting \"'vim/macros/keyword.uue'\" \(767 characters\)
sed "s/^X//" >'vim/macros/keyword.uue' <<'END_OF_FILE'
X
Xbegin 644 keyword
XM(B!3;VUE(&AA;F1Y(&ME>7=O<F0M8V]M<&QE=&EO;B!M86-R;W,N"B(@5&AE6
XM('=O<F0@:6X@9G)O;G0@;V8@=&AE(&-U<G-O<B!I<R!T86ME;B!A<R!A('-E,
XM87)C:"!S=')I;F<L('1H92!P<F5V:6]U<PHB('!A<G1I86QL>2!M871C:&ENA
XM9R!W;W)D(&ES(&9O=6YD('=H:6-H('1H96X@<F5P;&%C97,@=&AE('=O<F0@)
XM:6X@9G)O;G0*(B!O9B!T:&4@8W5R<V]R+B!4:&4@;6%C<F]S('=O<FL@:6X@N
XM:6YS97)T(&UO9&4N"B(*(B!>2R!S96%R8VAE<R!B86-K=V%R9"!F;W(@=&AE^
XM(&9I<G-T(&UA=&-H"B(@7DX@<V5A<F-H97,@8F%C:W=A<F0@9F]R('1H92!N0
XM97AT(&UA=&-H("AA9G1E<B!>2RD*(B!>4"!S96%R8VAE<R!F;W)W87)D(&9O\
XM<B!T:&4@<')E=FEO=7,@;6%T8V@@*&%F=&5R(%Y+*0HB"B(@5&AA;FMS('1O-
XM($1A=F4@0V%U9VAE>2X*(@HZ;6%P(2`+(!86%@T;8FUM:3]</!M@;2)N>68-8
XM0&YM;B)N>7=@;6-F#0)N"CIM87`A(`X@+AM@;FYM;B)N>7=@;6-F+@)N"CIM2
X987`A(!`@+AM@;DYM;B)N>7=@;6-F+@)N"AM@[
X``
Xend
Xsize 520
END_OF_FILE
if test 767 -ne `wc -c <'vim/macros/keyword.uue'`; then
echo shar: \"'vim/macros/keyword.uue'\" unpacked with wrong size!
fi
chmod +x 'vim/macros/keyword.uue'
# end of 'vim/macros/keyword.uue'
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
chmod +x 'vim/macros/maze/README'
# 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
chmod +x 'vim/macros/maze/makefile'
# 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
chmod +x 'vim/macros/maze/maze.c'
# 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'\" \(626 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_mac<RETURN>" to load the macros
X
X type "g" to start
X
Xto interrupt type "<CTRL-C>"
X to quit type ":q!<RETURN>"
X
END_OF_FILE
if test 626 -ne `wc -c <'vim/macros/maze/maze_5.78'`; then
echo shar: \"'vim/macros/maze/maze_5.78'\" unpacked with wrong size!
fi
chmod +x 'vim/macros/maze/maze_5.78'
# 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
chmod +x 'vim/macros/maze/maze_ansi.c'
# 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
chmod +x 'vim/macros/maze/poster'
# 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'\" \(407 characters\)
sed "s/^X//" >'vim/macros/readme' <<'END_OF_FILE'
XThe macros in the maze and hanoi directories can be used to test Vim for
Xvi compatibility. They have been written for vi to show its unlimited
Xpossibilities.
X
XHANOI are macros that solve the tower of hanoi problem.
XMAZE are macros that solve a maze (amazing!).
X
XThey are unmodified.
X
X
XThe other files contain some handy macros:
X
Xcenter: center current line in 80-character line
Xkeyword: keyword completion
END_OF_FILE
if test 407 -ne `wc -c <'vim/macros/readme'`; then
echo shar: \"'vim/macros/readme'\" unpacked with wrong size!
fi
chmod +x 'vim/macros/readme'
# end of 'vim/macros/readme'
fi
if test -f 'vim/poster' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/poster'\"
else
echo shar: Extracting \"'vim/poster'\" \(1584 characters\)
sed "s/^X//" >'vim/poster' <<'END_OF_FILE'
XVim - Vi IMproved. A clone of the UNIX text editor Vi. Very useful for
Xediting programs and other plain ASCII text. Full Vi compatibility (except Q
Xcommand, you don't need it). Includes most Ex commands.
X
XExtra features above Vi: Multilevel undo, command line history, improved
Xcommand line editing, command typeahead display, command to display yank
Xbuffers, possibility to edit binary files, line wrapping can be switched off,
Xfile name stack, can be adjusted to understand error messages from any
Xcompiler, shows current file name in window title, on-line help, etc.
X
XVersion 2.0, update to 1.27. Most important changes:
X- 'wrap' option to switch line wrapping on/off
X- filename completion is more like other programs and adjustable
X- automatic detection of CR/LF line separator
X- '-b' command line option to make editing binary files more easy
X- added abbreviation
X- :make command for quickly jumping to errors
X- MSDOS version uses bios calls for screen output, ansi.sys not needed
X- many small changes to make Vim more vi-compatible
X
XPortability: Runs on MSDOS, Amiga and several UNIX versions.
X
XDistribution:
Xcomp.binaries.ibm.pc: vim_dos.zip: MSDOS binary and documentation
X
Xcomp.binaries.amiga: vim_bin.lha: Amiga binary and documentation
X
Xcomp.sources.misc: shell archive with sources and documentation
X
XThe documentation is almost the same for all systems. For MSDOS CR-LF is used
Xfor line separator. For Amiga .info files are included. For the shell archive
Xsome files are uuencoded because of unprintable characters.
X
XVim is charityware. Read uganda.txt for details.
END_OF_FILE
if test 1584 -ne `wc -c <'vim/poster'`; then
echo shar: \"'vim/poster'\" unpacked with wrong size!
fi
chmod +x 'vim/poster'
# end of 'vim/poster'
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
chmod +x 'vim/src/addcr.c'
# 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'\" \(794 characters\)
sed "s/^X//" >'vim/src/ascii.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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#define Meta(x) ((x) | 0x80)
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 794 -ne `wc -c <'vim/src/ascii.h'`; then
echo shar: \"'vim/src/ascii.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/ascii.h'
# 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
chmod +x 'vim/src/debug.h'
# end of 'vim/src/debug.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'\" \(1376 characters\)
sed "s/^X//" >'vim/src/macros.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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))
X
X/*
X * On some systems toupper()/tolower() only work on lower/uppercase characters
X */
X#if defined(sequent) || defined(DOMAIN) || !defined(__STDC__)
X# define TO_UPPER(c) (islower(c) ? toupper(c) : (c))
X# define TO_LOWER(c) (isupper(c) ? tolower(c) : (c))
X#else
X# define TO_UPPER toupper
X# define TO_LOWER tolower
X#endif
END_OF_FILE
if test 1376 -ne `wc -c <'vim/src/macros.h'`; then
echo shar: \"'vim/src/macros.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/macros.h'
# 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'\" \(545 characters\)
sed "s/^X//" >'vim/src/mark.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 545 -ne `wc -c <'vim/src/mark.h'`; then
echo shar: \"'vim/src/mark.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/mark.h'
# end of 'vim/src/mark.h'
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'\" \(2065 characters\)
sed "s/^X//" >'vim/src/mkcmdtab.c' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 "vim.h"
X
X#if defined(UTS4)
X int
X#else
X void
X#endif
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 2065 -ne `wc -c <'vim/src/mkcmdtab.c'`; then
echo shar: \"'vim/src/mkcmdtab.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/mkcmdtab.c'
# end of 'vim/src/mkcmdtab.c'
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'\" \(1955 characters\)
sed "s/^X//" >'vim/src/ops.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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<>!~=Q: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 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 */
XEXTERN int no_op; /* startop and endop the same */
END_OF_FILE
if test 1955 -ne `wc -c <'vim/src/ops.h'`; then
echo shar: \"'vim/src/ops.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/ops.h'
# end of 'vim/src/ops.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
chmod +x 'vim/src/proto.h'
# 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'\" \(261 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));
END_OF_FILE
if test 261 -ne `wc -c <'vim/src/proto/alloc.pro'`; then
echo shar: \"'vim/src/proto/alloc.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/alloc.pro'
# 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'\" \(1207 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 mch_write __PARMS((char *p, int len));
Xint GetChars __PARMS((char *buf, int maxlen, int time));
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, int cooked));
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 1207 -ne `wc -c <'vim/src/proto/amiga.pro'`; then
echo shar: \"'vim/src/proto/amiga.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/amiga.pro'
# 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'\" \(1043 characters\)
sed "s/^X//" >'vim/src/proto/buffers.pro' <<'END_OF_FILE'
X/* buffers.c */
Xunsigned char *get_recorded __PARMS((void));
Xunsigned char *get_inserted __PARMS((void));
Xint stuff_empty __PARMS((void));
Xvoid flush_buffers __PARMS((int typeahead));
Xvoid ResetRedobuff __PARMS((void));
Xvoid AppendToRedobuff __PARMS((char *s));
Xvoid AppendCharToRedobuff __PARMS((int c));
Xvoid AppendNumberToRedobuff __PARMS((long n));
Xvoid stuffReadbuff __PARMS((char *s));
Xvoid stuffcharReadbuff __PARMS((int c));
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_typestr __PARMS((char *str, int noremap));
Xvoid del_typestr __PARMS((int len));
Xunsigned char vgetc __PARMS((void));
Xunsigned char vpeekc __PARMS((void));
Xint domap __PARMS((int maptype, char *keys, int mode));
Xint check_abbr __PARMS((int c, char *ptr, int col, int mincol));
Xint makemap __PARMS((struct __stdio *fd));
Xint putescstr __PARMS((struct __stdio *fd, char *str, int set));
END_OF_FILE
if test 1043 -ne `wc -c <'vim/src/proto/buffers.pro'`; then
echo shar: \"'vim/src/proto/buffers.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/buffers.pro'
# 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
chmod +x 'vim/src/proto/charset.pro'
# 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'\" \(607 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));
Xvoid gotocmdline __PARMS((int clr, int firstc));
Xvoid gotocmdend __PARMS((void));
Xint check_fname __PARMS((void));
Xint getfile __PARMS((char *fname, char *sfname, int setpm));
Xint samealtfile __PARMS((int n));
Xint getaltfile __PARMS((int n, long lnum, int setpm));
Xchar *getaltfname __PARMS((int n));
Xchar *ExpandOne __PARMS((unsigned char *str, int list_notfound, int mode));
Xint dosource __PARMS((char *fname));
END_OF_FILE
if test 607 -ne `wc -c <'vim/src/proto/cmdline.pro'`; then
echo shar: \"'vim/src/proto/cmdline.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/cmdline.pro'
# 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
chmod +x 'vim/src/proto/csearch.pro'
# 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'\" \(169 characters\)
sed "s/^X//" >'vim/src/proto/digraph.pro' <<'END_OF_FILE'
X/* digraph.c */
Xint dodigraph __PARMS((int c));
Xint getdigraph __PARMS((int char1, int char2));
Xvoid putdigraph __PARMS((char *str));
Xvoid listdigraphs __PARMS((void));
END_OF_FILE
if test 169 -ne `wc -c <'vim/src/proto/digraph.pro'`; then
echo shar: \"'vim/src/proto/digraph.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/digraph.pro'
# 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
chmod +x 'vim/src/proto/edit.pro'
# 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'\" \(244 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, char *sfname, long from, int newfile));
Xint writeit __PARMS((char *fname, char *sfname, long start, long end, int append, int forceit, int whole));
END_OF_FILE
if test 244 -ne `wc -c <'vim/src/proto/fileio.pro'`; then
echo shar: \"'vim/src/proto/fileio.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/fileio.pro'
# 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
chmod +x 'vim/src/proto/help.pro'
# 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
chmod +x 'vim/src/proto/linefunc.pro'
# 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
chmod +x 'vim/src/proto/main.pro'
# 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
chmod +x 'vim/src/proto/mark.pro'
# 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'\" \(250 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 emsg2 __PARMS((char *s, char *a1));
Xvoid wait_return __PARMS((int redraw));
Xvoid start_msg __PARMS((void));
Xvoid end_msg __PARMS((void));
Xvoid check_msg __PARMS((void));
END_OF_FILE
if test 250 -ne `wc -c <'vim/src/proto/message.pro'`; then
echo shar: \"'vim/src/proto/message.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/message.pro'
# 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'\" \(1208 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, int delspaces));
Xint plines __PARMS((long p));
Xint plines_m __PARMS((long first, long last));
Xvoid fileinfo __PARMS((int fullname));
Xvoid setfname __PARMS((char *s, char *ss));
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 doscreen, int undo));
Xint gchar __PARMS((struct fpos *pos));
Xint gcharCurpos __PARMS((void));
Xvoid pcharCurpos __PARMS((int c));
Xint inindent __PARMS((void));
Xvoid skipspace __PARMS((char **pp));
Xvoid skiptospace __PARMS((char **pp));
Xvoid skiptodigit __PARMS((char **pp));
Xlong getdigits __PARMS((char **pp));
Xchar *plural __PARMS((long n));
Xvoid set_Changed __PARMS((void));
Xvoid change_warning __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));
Xchar *gettail __PARMS((char *fname));
Xint ispathsep __PARMS((int c));
END_OF_FILE
if test 1208 -ne `wc -c <'vim/src/proto/misccmds.pro'`; then
echo shar: \"'vim/src/proto/misccmds.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/misccmds.pro'
# 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
chmod +x 'vim/src/proto/normal.pro'
# 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'\" \(757 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, int round));
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 insert_space, int redraw));
Xint dojoin __PARMS((int insert_space, int redraw));
Xvoid doformat __PARMS((void));
Xvoid startinsert __PARMS((int initstr, int startln, long count));
Xint doaddsub __PARMS((int c, long Prenum1));
Xint startinmargin __PARMS((void));
END_OF_FILE
if test 757 -ne `wc -c <'vim/src/proto/ops.pro'`; then
echo shar: \"'vim/src/proto/ops.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/ops.pro'
# 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'\" \(229 characters\)
sed "s/^X//" >'vim/src/proto/param.pro' <<'END_OF_FILE'
X/* param.c */
Xvoid set_init __PARMS((void));
Xint doset __PARMS((char *arg));
Xvoid paramchanged __PARMS((char *arg));
Xint makeset __PARMS((struct __stdio *fd));
Xvoid clear_termparam __PARMS((void));
Xvoid comp_col __PARMS((void));
END_OF_FILE
if test 229 -ne `wc -c <'vim/src/proto/param.pro'`; then
echo shar: \"'vim/src/proto/param.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/param.pro'
# 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'\" \(202 characters\)
sed "s/^X//" >'vim/src/proto/quickfix.pro' <<'END_OF_FILE'
X/* quickfix.c */
Xint qf_init __PARMS((void));
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 202 -ne `wc -c <'vim/src/proto/quickfix.pro'`; then
echo shar: \"'vim/src/proto/quickfix.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/quickfix.pro'
# 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
chmod +x 'vim/src/proto/regexp.pro'
# 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'\" \(156 characters\)
sed "s/^X//" >'vim/src/proto/regsub.pro' <<'END_OF_FILE'
X/* regsub.c */
Xchar *regtilde __PARMS((char *source, int magic));
Xint regsub __PARMS((struct regexp *prog, char *source, char *dest, int copy, int magic));
END_OF_FILE
if test 156 -ne `wc -c <'vim/src/proto/regsub.pro'`; then
echo shar: \"'vim/src/proto/regsub.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/regsub.pro'
# 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'\" \(634 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 screenclear __PARMS((void));
Xvoid cursupdate __PARMS((void));
Xvoid curs_columns __PARMS((int scroll));
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 634 -ne `wc -c <'vim/src/proto/screen.pro'`; then
echo shar: \"'vim/src/proto/screen.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/screen.pro'
# 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'\" \(352 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));
Xvoid scriptfullpath __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 352 -ne `wc -c <'vim/src/proto/script.pro'`; then
echo shar: \"'vim/src/proto/script.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/script.pro'
# 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'\" \(727 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 dirc, 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, int eol));
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 727 -ne `wc -c <'vim/src/proto/search.pro'`; then
echo shar: \"'vim/src/proto/search.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/search.pro'
# 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'\" \(739 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));
Xchar *Curpos2ptr __PARMS((void));
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 739 -ne `wc -c <'vim/src/proto/storage.pro'`; then
echo shar: \"'vim/src/proto/storage.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/storage.pro'
# 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
chmod +x 'vim/src/proto/tag.pro'
# 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'\" \(849 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 flushbuf __PARMS((void));
Xvoid outchar __PARMS((unsigned int c));
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((char *buf, int maxlen, int time));
Xint check_termcode __PARMS((char *buf));
Xvoid outnum __PARMS((long n));
Xint outnuml __PARMS((long n));
Xvoid check_winsize __PARMS((void));
Xvoid set_winsize __PARMS((int width, int height, int mustset));
Xvoid set_winheight __PARMS((int height));
Xvoid settmode __PARMS((int raw));
Xvoid starttermcap __PARMS((void));
Xvoid stoptermcap __PARMS((void));
Xvoid cursor_on __PARMS((void));
Xvoid cursor_off __PARMS((void));
END_OF_FILE
if test 849 -ne `wc -c <'vim/src/proto/term.pro'`; then
echo shar: \"'vim/src/proto/term.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/term.pro'
# 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
chmod +x 'vim/src/proto/termlib.pro'
# 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'\" \(444 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));
Xint u_inssub __PARMS((long lnum));
Xint u_savedel __PARMS((long lnum, long nlines));
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 444 -ne `wc -c <'vim/src/proto/undo.pro'`; then
echo shar: \"'vim/src/proto/undo.pro'\" unpacked with wrong size!
fi
chmod +x 'vim/src/proto/undo.pro'
# 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
chmod +x 'vim/src/ptx_stdlib.h'
# 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
chmod +x 'vim/src/regexp.h'
# 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
chmod +x 'vim/src/regmagic.h'
# end of 'vim/src/regmagic.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
chmod +x 'vim/src/sun_stdlib.h'
# end of 'vim/src/sun_stdlib.h'
fi
if test -f 'vim/src/term_fix.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/term_fix.uue'\"
else
echo shar: Extracting \"'vim/src/term_fix.uue'\" \(89 characters\)
sed "s/^X//" >'vim/src/term_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/term_fix.uue'`; then
echo shar: \"'vim/src/term_fix.uue'\" unpacked with wrong size!
fi
chmod +x 'vim/src/term_fix.uue'
# end of 'vim/src/term_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'\" \(254 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 254 -ne `wc -c <'vim/src/vim.prj'`; then
echo shar: \"'vim/src/vim.prj'\" unpacked with wrong size!
fi
chmod +x 'vim/src/vim.prj'
# 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'\" \(320 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 320 -ne `wc -c <'vim/src/vimresp'`; then
echo shar: \"'vim/src/vimresp'\" unpacked with wrong size!
fi
chmod +x 'vim/src/vimresp'
# end of 'vim/src/vimresp'
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
chmod +x 'vim/tutor/Readme'
# 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
chmod +x 'vim/tutor/poster'
# end of 'vim/tutor/poster'
fi
echo shar: End of archive 1 \(of 25\).
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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

Bram Moolenaar

unread,
Dec 20, 1993, 10:44:31 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 55
Archive-name: vim/part05

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/csearch.c vim/src/digrap_c.uue vim/src/main.c
# vim/src/mark.c vim/src/quickfix.c
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:04 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'\" \(11434 characters\)
sed "s/^X//" >'vim/src/csearch.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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
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 static int do_all = FALSE; /* do multiple substitutions per line */
X static int do_ask = FALSE; /* ask for confirmation */
X char *pat, *sub = NULL;
X static char *old_sub = NULL;
X int delimiter;
X int sublen;
X int got_quit = FALSE;
X int got_match = FALSE;
X int temp;
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 if (!p_ed)
X {
X do_all = FALSE;
X do_ask = FALSE;
X }
X while (*cmd)
X {
X if (*cmd == 'g')
X do_all = !do_all;
X else if (*cmd == 'c')
X do_ask = !do_ask;
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 /*
X * ~ in the substitute pattern is replaced by the old pattern.
X * We do it here once to avoid it to be replaced over and over again.
X */
X sub = regtilde(sub, (int)p_magic);
X
X for (lnum = lp; lnum <= up && !(got_int || got_quit); ++lnum)
X {
X ptr = nr2ptr(lnum);
X if (regexec(prog, ptr, TRUE)) /* a match on this line */
X {
X char *new_end, *new_start = NULL;
X char *old_match, *old_copy;
X char *prev_old_match = NULL;
X char *p1, *p2;
X int did_sub = FALSE;
X int match, lastone;
X
X if (!got_match)
X {
X setpcmark();
X got_match = TRUE;
X }
X
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 old_copy = old_match = ptr;
X for (;;) /* loop until nothing more to replace */
X {
X Curpos.col = (int)(prog->startp[0] - ptr);
X /*
X * 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 (old_match == prev_old_match && old_match == prog->endp[0])
X {
X ++old_match;
X goto skip2;
X }
X while (do_ask) /* loop until 'y', 'n' or 'q' typed */
X {
X temp = RedrawingDisabled;
X RedrawingDisabled = FALSE;
X updateScreen(CURSUPD);
X smsg("replace by %s (y/n/q)? ", sub);
X setcursor();
X RedrawingDisabled = temp;
X if ((i = vgetc()) == 'q' || i == ESC || i == Ctrl('C'))
X {
X got_quit = TRUE;
X break;
X }
X else if (i == 'n')
X goto skip;
X else if (i == 'y')
X break;
X }
X if (got_quit)
X break;
X
X /* get length of substitution part */
X sublen = regsub(prog, sub, ptr, 0, (int)p_magic);
X if (new_start == NULL)
X {
X /*
X * Get some space for a temporary buffer to do the substitution
X * into.
X */
X if ((new_start = alloc((unsigned)(strlen(ptr) + sublen + 5))) == NULL)
X goto outofmem;
X *new_start = NUL;
X }
X else
X {
X /*
X * extend the temporary buffer to do the substitution into.
X */
X if ((p1 = alloc((unsigned)(strlen(new_start) + strlen(old_copy) + sublen + 1))) == NULL)
X goto outofmem;
X strcpy(p1, new_start);
X free(new_start);
X new_start = p1;
X }
X
X for (new_end = new_start; *new_end; new_end++)
X ;
X /*
X * copy up to the part that matched
X */
X while (old_copy < prog->startp[0])
X *new_end++ = *old_copy++;
X
X regsub(prog, sub, new_end, 1, (int)p_magic);
X nsubs++;
X did_sub = TRUE;
X
X /*
X * Now the trick is to replace CTRL-Ms with a real line break.
X * This would make it impossible to insert CTRL-Ms in the text.
X * That is the way vi works. In Vim the line break can be
X * avoided by preceding the CTRL-M with a CTRL-V. Now you can't
X * precede a line break with a CTRL-V, big deal.
X */
X while ((p1 = strchr(new_end, CR)) != NULL)
X {
X if (p1 == new_end || p1[-1] != Ctrl('V'))
X {
X if (u_inssub(lnum)) /* prepare for undo */
X {
X *p1 = NUL; /* truncate up to the CR */
X if ((p2 = save_line(new_start)) != NULL)
X {
X appendline(lnum - 1, p2);
X ++lnum;
X ++up; /* number of lines increases */
X }
X strcpy(new_start, p1 + 1); /* copy the rest */
X new_end = new_start;
X }
X }
X else /* remove CTRL-V */
X {
X strcpy(p1 - 1, p1);
X new_end = p1;
X }
X }
X
X old_copy = prog->endp[0]; /* remember next character to be copied */
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 old_match = prog->endp[0];
X prev_old_match = old_match;
Xskip2:
X match = -1;
X lastone = (*old_match == NUL || got_int || got_quit || !do_all);
X if (lastone || do_ask || (match = regexec(prog, old_match, (int)FALSE)) == 0)
X {
X if (new_start)
X {
X /*
X * copy the rest of the line, that didn't match
X */
X strcat(new_start, old_copy);
X i = old_match - ptr;
X
X if ((ptr = save_line(new_start)) != NULL && u_savesub(lnum))
X replaceline(lnum, ptr);
X
X free(new_start); /* free the temp buffer */
X new_start = NULL;
X old_match = ptr + i;
X old_copy = ptr;
X }
X if (match == -1 && !lastone)
X match = regexec(prog, old_match, (int)FALSE);
X if (match <= 0) /* quit loop if there is no more match */
X break;
X }
X /* breakcheck is slow, don't call it too often */
X if ((nsubs & 15) == 0)
X breakcheck();
X
X }
X if (did_sub)
X ++nlines;
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) /* interrupted */
X msg(e_interr);
X else if (got_match) /* did find something but nothing substituted */
X msg("");
X else /* nothing found */
X msg(e_nomatch);
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; /* get the delimiter */
X if (delim)
X ++cmd; /* skip delimiter if there is one */
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(e_nomatch);
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 global_busy = 0;
X if (global_wait) /* wait for return */
X wait_return(FALSE);
X screenclear();
X updateScreen(CURSUPD);
X msgmore(line_count - old_lcount);
X }
X
X clearmarked(); /* clear rest of the marks */
X free((char *) prog);
X}
END_OF_FILE
if test 11434 -ne `wc -c <'vim/src/csearch.c'`; then
echo shar: \"'vim/src/csearch.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/csearch.c'
# end of 'vim/src/csearch.c'
fi
if test -f 'vim/src/digrap_c.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/digrap_c.uue'\"
else
echo shar: Extracting \"'vim/src/digrap_c.uue'\" \(11106 characters\)
sed "s/^X//" >'vim/src/digrap_c.uue' <<'END_OF_FILE'
X
Xbegin 644 digraph.c
XM+RH@=FDZ=',]-#IS=STT"B`J"B`J(%9)32`M(%9I($E-<')O=F5D"B`J"B`J-
XM($-O9&4@0V]N=')I8G5T:6]N<R!">3H)0G)A;2!-;V]L96YA87()"0EM;V]L>
XM0&]C92YN;`H@*@D)"0D)"0E4:6T@5&AO;7!S;VX)"0ET=VET8V@A=&IT"B`JI
XM"0D)"0D)"51O;GD@06YD<F5W<PD)"6]N96-O;2%W;&1R9&<A=&]N>2`*("H)&
XM"0D)"0D)1RX@4BX@*$9R960I(%=A;'1E<@D)=V%T;6%T:"%W871C9VPA9W)WH
XM86QT97(@"B`J+PH*(VEF9&5F($1)1U)!4$A3"B\J"B`J(&1I9W)A<&@N8SH@#
XM8V]D92!F;W(@9&EG<F%P:',*("HO"@HC:6YC;'5D92`B=FEM+F@B"B-I;F-LK
XM=61E(")G;&]B86QS+F@B"B-I;F-L=61E(")P<F]T;RYH(@HC:6YC;'5D92`BN
XM<&%R86TN:"(*"G-T871I8R!V;VED('!R:6YT9&EG<F%P:"!?7T%21U,H*'5?2
XM8VAA<B`J*2D["@IU7V-H87()*"ID:6=R87!H;F5W*5LS73L)"0DO*B!P;VEN8
XM=&5R('1O(&%D9&5D(&1I9W)A<&AS("HO"FEN=`D)9&EG<F%P:&-O=6YT(#T@W
XM,#L)"0DO*B!N=6UB97(@;V8@861D960@9&EG<F%P:',@*B\*"B-I9F1E9B!-<
XM4T1/4PIU7V-H87()9&EG<F%P:&1E9F%U;'1;75LS72`](`D)+RH@<W1A;F1AH
XM<F0@35-$3U,@9&EG<F%P:',@*B\*"2`@('M[)T,G+"`G+"<L(#$R.'TL"2\J9
XM((`@*B\*"0E[)W4G+"`G(B<L(#$R.7TL"2\J(($@*B\*"0E[)V4G+"`G7"<GC
XM+"`Q,S!]+`DO*B""("HO"@D)>R=A)RP@)UXG+"`Q,S%]+`DO*B"#("HO"@D)H
XM>R=A)RP@)R(G+"`Q,S)]+`DO*B"$("HO"@D)>R=A)RP@)V`G+"`Q,S-]+`DOT
XM*B"%("HO"@D)>R=A)RP@)T`G+"`Q,S1]+`DO*B"&("HO"@D)>R=C)RP@)RPG$
XM+"`Q,S5]+`DO*B!^1R`H4T%3($,@8V%N)W0@:&%N9&QE('1H92!R96%L(&-HP
XM87(I("HO"@D)>R=E)RP@)UXG+"`Q,S9]+`DO*B!^2"`H4T%3($,@8V%N)W0@M
XM:&%N9&QE('1H92!R96%L(&-H87(I("HO"@D)>R=E)RP@)R(G+"`Q,S=]+`DO_
XM*B")("HO"@D)>R=E)RP@)V`G+"`Q,SA]+`DO*B"*("HO"@D)>R=I)RP@)R(GP
XM+"`Q,SE]+`DO*B"+("HO"@D)>R=I)RP@)UXG+"`Q-#!]+`DO*B",("HO"@D)+
XM>R=I)RP@)V`G+"`Q-#%]+`DO*B"-("HO"@D)>R=!)RP@)R(G+"`Q-#)]+`DOE
XM*B".("HO"@D)>R=!)RP@)T`G+"`Q-#-]+`DO*B"/("HO"@D)>R=%)RP@)UPG(
XM)RP@,30T?2P)+RH@D"`J+PH)"7LG82<L("=E)RP@,30U?2P)+RH@D2`J+PH)S
XM"7LG02<L("=%)RP@,30V?2P)+RH@DB`J+PH)"7LG;R<L("=>)RP@,30W?2P)U
XM+RH@DR`J+PH)"7LG;R<L("<B)RP@,30X?2P)+RH@E"`J+PH)"7LG;R<L("=@=
XM)RP@,30Y?2P)+RH@E2`J+PH)"7LG=2<L("=>)RP@,34P?2P)+RH@EB`J+PH)+
XM"7LG=2<L("=@)RP@,34Q?2P)+RH@ER`J+PH)"7LG>2<L("<B)RP@,34R?2P)/
XM+RH@F"`J+PH)"7LG3R<L("<B)RP@,34S?2P)+RH@F2`J+PH)"7LG52<L("<BK
XM)RP@,34T?2P)+RH@FB`J+PH)("`@('LG8R<L("=\)RP@,34U?2P)+RH@FR`J7
XM+PH)("`@('LG)"<L("<D)RP@,34V?2P)+RH@G"`J+PH)("`@('LG62<L("<MJ
XM)RP@,34W?2P)+RH@?ET@*%-!4R!#(&-A;B=T(&AA;F1L92!T:&4@<F5A;"!C)
XM:&%R*2`J+PH)("`@('LG4"<L("=T)RP@,34X?2P)+RH@GB`J+PH)("`@('LGX
XM9B<L("=F)RP@,34Y?2P)+RH@GR`J+PH)"7LG82<L("=<)R<L(#$V,'TL"2\J,
XM(*`@*B\*"0E[)VDG+"`G7"<G+"`Q-C%]+`DO*B"A("HO"@D)>R=O)RP@)UPG7
XM)RP@,38R?2P)+RH@HB`J+PH)"7LG=2<L("=<)R<L(#$V,WTL"2\J('AX("A3E
XM05,@0R!C86XG="!H86YD;&4@=&AE(')E86P@8VAA<BD@*B\*"0E[)VXG+"`G[
XM?B<L(#$V-'TL"2\J(*0@*B\*"0E[)TXG+"`G?B<L(#$V-7TL"2\J(*4@*B\*:
XM"0E[)V$G+"`G82<L(#$V-GTL"2\J(*8@*B\*"0E[)V\G+"`G;R<L(#$V-WTL:
XM"2\J(*<@*B\*"0E[)WXG+"`G/R<L(#$V.'TL"2\J(*@@*B\*"0E[)RTG+"`G:
XM82<L(#$V.7TL"2\J(*D@*B\*"0E[)V$G+"`G+2<L(#$W,'TL"2\J(*H@*B\**
XM"0E[)S$G+"`G,B<L(#$W,7TL"2\J(*L@*B\*"0E[)S$G+"`G-"<L(#$W,GTL_
XM"2\J(*P@*B\*"0E[)WXG+"`G(2<L(#$W,WTL"2\J(*T@*B\*"0E[)SPG+"`G1
XM/"<L(#$W-'TL"2\J(*X@*B\*"0E[)SXG+"`G/B<L(#$W-7TL"2\J(*\@*B\*>
XM"@D)>R=S)RP@)W,G+"`R,C5]+`DO*B#A("HO"@D)>R=J)RP@)W4G+"`R,S!]+
XM+`DO*B#F("HO"@D)>R=O)RP@)R\G+"`R,S=]+`DO*B#M("HO"@D)>R<K)RP@_
XM)RTG+"`R-#%]+`DO*B#Q("HO"@D)>R<^)RP@)STG+"`R-#)]+`DO*B#R("HOG
XM"@D)>R<\)RP@)STG+"`R-#-]+`DO*B#S("HO"@D)>R<Z)RP@)RTG+"`R-#9]_
XM+`DO*B#V("HO"@D)>R=^)RP@)WXG+"`R-#=]+`DO*B#W("HO"@D)>R=^)RP@+
XM)V\G+"`R-#A]+`DO*B#X("HO"@D)>R<R)RP@)S(G+"`R-3-]+`DO*B#]("HOM
XM"@D)>TY53"P@3E5,+"!.54Q]"@D)?3L*"B-E;'-E"2\J($U31$]3("HO"@IUW
XM7V-H87()9&EG<F%P:&1E9F%U;'1;75LS72`](`D)+RH@<W1A;F1A<F0@25-/1
XM(&1I9W)A<&AS("HO"@D@("![>R=^)RP@)R$G+"`Q-C%]+`DO*B"A("HO"@D@W
XM("`@>R=C)RP@)WPG+"`Q-C)]+`DO*B"B("HO"@D@("`@>R<D)RP@)R0G+"`Q(
XM-C-]+`DO*B"C("HO"@D@("`@>R=O)RP@)W@G+"`Q-C1]+`DO*B"D("HO"@D@O
XM("`@>R=9)RP@)RTG+"`Q-C5]+`DO*B"E("HO"@D@("`@>R=\)RP@)WPG+"`QE
XM-C9]+`DO*B"F("HO"@D@("`@>R=P)RP@)V$G+"`Q-C=]+`DO*B"G("HO"@D@E
XM("`@>R<B)RP@)R(G+"`Q-CA]+`DO*B"H("HO"@D@("`@>R=C)RP@)T\G+"`QC
XM-CE]+`DO*B"I("HO"@D)>R=A)RP@)RTG+"`Q-S!]+`DO*B"J("HO"@D)>R<\U
XM)RP@)SPG+"`Q-S%]+`DO*B"K("HO"@D)>R<M)RP@)RPG+"`Q-S)]+`DO*B"L&
XM("HO"@D)>R<M)RP@)RTG+"`Q-S-]+`DO*B"M("HO"@D)>R=R)RP@)T\G+"`Q'
XM-S1]+`DO*B"N("HO"@D)>R<M)RP@)STG+"`Q-S5]+`DO*B"O("HO"@D)>R=^>
XM)RP@)V\G+"`Q-S9]+`DO*B"P("HO"@D)>R<K)RP@)RTG+"`Q-S=]+`DO*B"Q,
XM("HO"@D)>R<R)RP@)S(G+"`Q-SA]+`DO*B"R("HO"@D)>R<S)RP@)S,G+"`Q`
XM-SE]+`DO*B"S("HO"@D)>R=<)R<L("=<)R<L(#$X,'TL"2\J(+0@*B\*"0E[@
XM)VHG+"`G=2<L(#$X,7TL"2\J(+4@*B\*"0E[)W`G+"`G<"<L(#$X,GTL"2\J7
XM(+8@*B\*"0E[)WXG+"`G+B<L(#$X,WTL"2\J(+<@*B\*"0E[)RPG+"`G+"<L`
XM(#$X-'TL"2\J(+@@*B\*"0E[)S$G+"`G,2<L(#$X-7TL"2\J(+D@*B\*"0E[8
XM)V\G+"`G+2<L(#$X-GTL"2\J(+H@*B\*"0E[)SXG+"`G/B<L(#$X-WTL"2\J_
XM(+L@*B\*"0E[)S$G+"`G-"<L(#$X.'TL"2\J(+P@*B\*"0E[)S$G+"`G,B<L3
XM(#$X.7TL"2\J(+T@*B\*"0E[)S,G+"`G-"<L(#$Y,'TL"2\J(+X@*B\*"0E[H
XM)WXG+"`G/R<L(#$Y,7TL"2\J(+\@*B\*"0E[)T$G+"`G8"<L(#$Y,GTL"2\J"
XM(,`@*B\*"0E[)T$G+"`G7"<G+"`Q.3-]+`DO*B#!("HO"@D)>R=!)RP@)UXG(
XM+"`Q.31]+`DO*B#"("HO"@D)>R=!)RP@)WXG+"`Q.35]+`DO*B##("HO"@D)\
XM>R=!)RP@)R(G+"`Q.39]+`DO*B#$("HO"@D)>R=!)RP@)T`G+"`Q.3=]+`DOH
XM*B#%("HO"@D)>R=!)RP@)T4G+"`Q.3A]+`DO*B#&("HO"@D)>R=#)RP@)RPG3
XM+"`Q.3E]+`DO*B#'("HO"@D)>R=%)RP@)V`G+"`R,#!]+`DO*B#(("HO"@D)D
XM>R=%)RP@)UPG)RP@,C`Q?2P)+RH@R2`J+PH)"7LG12<L("=>)RP@,C`R?2P)K
XM+RH@RB`J+PH)"7LG12<L("<B)RP@,C`S?2P)+RH@RR`J+PH)"7LG22<L("=@S
XM)RP@,C`T?2P)+RH@S"`J+PH)"7LG22<L("=<)R<L(#(P-7TL"2\J(,T@*B\*B
XM"0E[)TDG+"`G7B<L(#(P-GTL"2\J(,X@*B\*"0E[)TDG+"`G(B<L(#(P-WTLJ
XM"2\J(,\@*B\*"0E[)T0G+"`G+2<L(#(P.'TL"2\J(-`@*B\*"0E[)TXG+"`GZ
XM?B<L(#(P.7TL"2\J(-$@*B\*"0E[)T\G+"`G8"<L(#(Q,'TL"2\J(-(@*B\*.
XM"0E[)T\G+"`G7"<G+"`R,3%]+`DO*B#3("HO"@D)>R=/)RP@)UXG+"`R,3)]H
XM+`DO*B#4("HO"@D)>R=/)RP@)WXG+"`R,3-]+`DO*B#5("HO"@D)>R=/)RP@B
XM)R(G+"`R,31]+`DO*B#6("HO"@D)>R<O)RP@)UQ<)RP@,C$U?2P)+RH@UR`JC
XM+PH)"7LG3R<L("<O)RP@,C$V?2P)+RH@V"`J+PH)"7LG52<L("=@)RP@,C$WG
XM?2P)+RH@V2`J+PH)"7LG52<L("=<)R<L(#(Q.'TL"2\J(-H@*B\*"0E[)U4GS
XM+"`G7B<L(#(Q.7TL"2\J(-L@*B\*"0E[)U4G+"`G(B<L(#(R,'TL"2\J(-P@<
XM*B\*"0E[)UDG+"`G7"<G+"`R,C%]+`DO*B#=("HO"@D)>R=))RP@)W`G+"`R,
XM,C)]+`DO*B#>("HO"@D)>R=S)RP@)W,G+"`R,C-]+`DO*B#?("HO"@D)>R=A0
XM)RP@)V`G+"`R,C1]+`DO*B#@("HO"@D)>R=A)RP@)UPG)RP@,C(U?2P)+RH@\
XMX2`J+PH)"7LG82<L("=>)RP@,C(V?2P)+RH@XB`J+PH)"7LG82<L("=^)RP@N
XM,C(W?2P)+RH@XR`J+PH)"7LG82<L("<B)RP@,C(X?2P)+RH@Y"`J+PH)"7LG2
XM82<L("=`)RP@,C(Y?2P)+RH@Y2`J+PH)"7LG82<L("=E)RP@,C,P?2P)+RH@E
XMYB`J+PH)"7LG8R<L("<L)RP@,C,Q?2P)+RH@YR`J+PH)"7LG92<L("=@)RP@J
XM,C,R?2P)+RH@Z"`J+PH)"7LG92<L("=<)R<L(#(S,WTL"2\J(.D@*B\*"0E[2
XM)V4G+"`G7B<L(#(S-'TL"2\J(.H@*B\*"0E[)V4G+"`G(B<L(#(S-7TL"2\J5
XM(.L@*B\*"0E[)VDG+"`G8"<L(#(S-GTL"2\J(.P@*B\*"0E[)VDG+"`G7"<GN
XM+"`R,S=]+`DO*B#M("HO"@D)>R=I)RP@)UXG+"`R,SA]+`DO*B#N("HO"@D)6
XM>R=I)RP@)R(G+"`R,SE]+`DO*B#O("HO"@D)>R=D)RP@)RTG+"`R-#!]+`DO^
XM*B#P("HO"@D)>R=N)RP@)WXG+"`R-#%]+`DO*B#Q("HO"@D)>R=O)RP@)V`GD
XM+"`R-#)]+`DO*B#R("HO"@D)>R=O)RP@)UPG)RP@,C0S?2P)+RH@\R`J+PH)Z
XM"7LG;R<L("=>)RP@,C0T?2P)+RH@]"`J+PH)"7LG;R<L("=^)RP@,C0U?2P)\
XM+RH@]2`J+PH)"7LG;R<L("<B)RP@,C0V?2P)+RH@]B`J+PH)"7LG.B<L("<MX
XM)RP@,C0W?2P)+RH@]R`J+PH)"7LG;R<L("<O)RP@,C0X?2P)+RH@^"`J+PH)A
XM"7LG=2<L("=@)RP@,C0Y?2P)+RH@^2`J+PH)"7LG=2<L("=<)R<L(#(U,'TL,
XM"2\J(/H@*B\*"0E[)W4G+"`G7B<L(#(U,7TL"2\J(/L@*B\*"0E[)W4G+"`G7
XM(B<L(#(U,GTL"2\J(/P@*B\*"0E[)WDG+"`G7"<G+"`R-3-]+`DO*B#]("HO0
XM"@D)>R=I)RP@)W`G+"`R-31]+`DO*B#^("HO"@D)>R=Y)RP@)R(G+"`R-35]@
XM+`DO*B#_("HO"@D)>TY53"P@3E5,+"!.54Q]"@D)?3L*(V5N9&EF"2\J($U3(
XM1$]3("HO"B`*+RH*("H@:&%N9&QE(&1I9W)A<&AS(&%F=&5R('1Y<&EN9R!AL
XM(&-H87)A8W1E<@H@*B\*"6EN=`ID;V1I9W)A<&@H8RD*"6EN=`D)8SL*>PH)$
XM<W1A=&EC(&EN=`EB86-K<W!A8V5D.PD)+RH@8VAA<F%C=&5R(&)E9F]R92!"E
XM4R`J+PH)<W1A=&EC(&EN=`EL87-T8VAA<CL)"2\J(&QA<W0@='EP960@8VAAY
XM<F%C=&5R("HO"@H):68@*&,@/3T@+3$I"0DO*B!I;FET('9A;'5E<R`J+PH)-
XM>PH)"6)A8VMS<&%C960@/2`M,3L*"7T*"65L<V4@:68@*'!?9&<I"@E["@D)>
XM:68@*&)A8VMS<&%C960@/CT@,"D*"0D)8R`](&=E=&1I9W)A<&@H8F%C:W-PL
XM86-E9"P@8RD["@D)8F%C:W-P86-E9"`]("TQ.PH)"6EF("AC(#T]($)3("8FD
XM(&QA<W1C:&%R(#X](#`I"@D)"6)A8VMS<&%C960@/2!L87-T8VAA<CL*"7T*0
XM"6QA<W1C:&%R(#T@8SL*"7)E='5R;B!C.PI]"@HO*@H@*B!L;V]K=7`@=&AE*
XM('!A:7(@8VAA<C$L(&-H87(R(&EN('1H92!D:6=R87!H('1A8FQE<PH@*B!IF
XM9B!N;R!M871C:"P@<F5T=7)N(&-H87(R"B`J+PH):6YT"F=E=&1I9W)A<&@H>
XM8VAA<C$L(&-H87(R*0H):6YT"6-H87(Q.PH):6YT"6-H87(R.PI["@EI;G0)C
XM"6D["@EI;G0)"7)E='9A;#L*"@ER971V86P@/2`P.PH)9F]R("AI(#T@,#L@,
XM.R`K*VDI"0D)+RH@<V5A<F-H(&%D9&5D(&1I9W)A<&AS(&9I<G-T("HO"@E[@
XM"@D):68@*&D@/3T@9&EG<F%P:&-O=6YT*0DO*B!E;F0@;V8@861D960@=&%B>
XM;&4L('-E87)C:"!D969A=6QT<R`J+PH)"7L*"0D)9F]R("AI(#T@,#L@9&EGT
XM<F%P:&1E9F%U;'1;:5U;,%T@(3T@,#L@*RMI*0H)"0D):68@*&1I9W)A<&ADR
XM969A=6QT6VE=6S!=(#T](&-H87(Q("8F(&1I9W)A<&AD969A=6QT6VE=6S%=M
XM(#T](&-H87(R*0H)"0D)>PH)"0D)"7)E='9A;"`](&1I9W)A<&AD969A=6QTB
XM6VE=6S)=.PH)"0D)"6)R96%K.PH)"0D)?0H)"0EB<F5A:SL*"0E]"@D):68@Q
XM*&1I9W)A<&AN97=;:5U;,%T@/3T@8VAA<C$@)B8@9&EG<F%P:&YE=UMI75LQ%
XM72`]/2!C:&%R,BD*"0E["@D)"7)E='9A;"`](&1I9W)A<&AN97=;:5U;,ET[&
XM"@D)"6)R96%K.PH)"7T*"7T*"@EI9B`H<F5T=F%L(#T](#`I"2\J(&1I9W)AL
XM<&@@9&5L971E9"!O<B!N;W0@9F]U;F0@*B\*"0ER971U<FX@8VAA<C(["@ERB
XM971U<FX@<F5T=F%L.PI]"@HO*@H@*B!P=70@=&AE(&1I9W)A<&AS(&EN('1H>
XM92!A<F=U;65N="!S=')I;F<@:6X@=&AE(&1I9W)A<&@@=&%B;&4*("H@9F]R9
XM;6%T.B![8S%]>V,R?2!C:&%R('MC,7U[8S)](&-H87(@+BXN"B`J+PH)=F]IX
XM9`IP=71D:6=R87!H*'-T<BD*"6-H87(@*G-T<CL*>PH):6YT"0EC:&%R,2P@O
XM8VAA<C(L(&X["@EU7V-H87()*"IN97=T86(I6S-=.PH):6YT"0EI.PH*"7=H%
XM:6QE("@J<W1R*0H)>PH)"7-K:7!S<&%C92@F<W1R*3L*"0EC:&%R,2`]("ISK
XM='(K*SL*"0EC:&%R,B`]("IS='(K*SL*"0EI9B`H8VAA<C$@/3T@,"!\?"!C[
XM:&%R,B`]/2`P*0H)"0ER971U<FX["@D)<VMI<'-P86-E*"9S='(I.PH)"6EF5
XM("@A:7-D:6=I="@J<W1R*2D*"0E["@D)"65M<V<H95]N=6UB97(I.PH)"0ERK
XM971U<FX["@D)?0H)"6X@/2!G971D:6=I=',H)G-T<BD["@D):68@*&1I9W)A2
XM<&AN97<I"0DO*B!S96%R8V@@=&AE('1A8FQE(&9O<B!E>&ES=&EN9R!E;G1R@
XM>2`J+PH)"7L*"0D)9F]R("AI(#T@,#L@:2`\(&1I9W)A<&AC;W5N=#L@*RMIU
XM*0H)"0D):68@*&1I9W)A<&AN97=;:5U;,%T@/3T@8VAA<C$@)B8@9&EG<F%PL
XM:&YE=UMI75LQ72`]/2!C:&%R,BD*"0D)"7L*"0D)"0ED:6=R87!H;F5W6VE=9
XM6S)=(#T@;CL*"0D)"0EB<F5A:SL*"0D)"7T*"0D):68@*&D@/"!D:6=R87!HR
XM8V]U;G0I"@D)"0EC;VYT:6YU93L*"0E]"@D);F5W=&%B(#T@*'5?8VAA<B`HU
XM*BE;,UTI86QL;V,H9&EG<F%P:&-O=6YT("H@,R`K(#,I.PH)"6EF("AN97=TR
XM86(I"@D)>PH)"0EM96UM;W9E*"AC:&%R("HI;F5W=&%B+"`H8VAA<B`J*61I2
XM9W)A<&AN97<L("AS:7IE7W0I*&1I9W)A<&AC;W5N="`J(#,I*3L*"0D)9G)E#
XM92AD:6=R87!H;F5W*3L*"0D)9&EG<F%P:&YE=R`](&YE=W1A8CL*"0D)9&EGZ
XM<F%P:&YE=UMD:6=R87!H8V]U;G1=6S!=(#T@8VAA<C$["@D)"61I9W)A<&AN6
XM97=;9&EG<F%P:&-O=6YT75LQ72`](&-H87(R.PH)"0ED:6=R87!H;F5W6V1I#
XM9W)A<&AC;W5N=%U;,ET@/2!N.PH)"0DK*V1I9W)A<&AC;W5N=#L*"0E]"@E]/
XM"GT*"@EV;VED"FQI<W1D:6=R87!H<R@I"GL*"6EN=`D):3L*"@EP<FEN=&1IO
XM9W)A<&@H3E5,3"D["@EF;W(@*&D@/2`P.R!D:6=R87!H9&5F875L=%MI75LP<
XM73L@*RMI*0H)"6EF("AG971D:6=R87!H*&1I9W)A<&AD969A=6QT6VE=6S!=G
XM+"!D:6=R87!H9&5F875L=%MI75LQ72D@/3T@9&EG<F%P:&1E9F%U;'1;:5U;]
XM,ETI"@D)"7!R:6YT9&EG<F%P:"AD:6=R87!H9&5F875L=%MI72D["@EF;W(@4
XM*&D@/2`P.R!I(#P@9&EG<F%P:&-O=6YT.R`K*VDI"@D)<')I;G1D:6=R87!HQ
XM*&1I9W)A<&AN97=;:5TI.PH);W5T8VAA<B@G7&XG*3L*"7=A:71?<F5T=7)N*
XM*%12544I.PI]"@H)<W1A=&EC('9O:60*<')I;G1D:6=R87!H*'`I"@EU7V-H3
XM87(@*G`["GL*"6-H87()"6)U9ELY73L*"7-T871I8R!I;G0);&5N.PH*"6EFN
XM("AP(#T]($Y53$PI"@D);&5N(#T@,#L*"65L<V4@:68@*'!;,ET@(3T@,"D*G
XM"7L*"0EI9B`H;&5N(#X@0V]L=6UN<R`M(#$Q*0H)"7L*"0D);W5T8VAA<B@G.
XM7&XG*3L*"0D);&5N(#T@,#L*"0E]"@D):68@*&QE;BD*"0D);W5T<W1R;B@BC
XM("`@(BD["@D)<W!R:6YT9BAB=68L("(E8R5C("5C("4S9"(L('!;,%TL('!;,
XM,5TL('!;,ETL('!;,ETI.PH)"6]U='-T<FXH8G5F*3L*"0EL96X@*ST@,3$[B
X="@E]"GT*"B-E;F1I9B`O*B!$24=205!(4R`J+PIFH
X``
Xend
Xsize 7904
END_OF_FILE
if test 11106 -ne `wc -c <'vim/src/digrap_c.uue'`; then
echo shar: \"'vim/src/digrap_c.uue'\" unpacked with wrong size!
fi
chmod +x 'vim/src/digrap_c.uue'
# end of 'vim/src/digrap_c.uue'
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'\" \(11534 characters\)
sed "s/^X//" >'vim/src/main.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 [errorfile]\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 -b -r -x -d device -s scriptin -w scriptout -T terminal\n");
X#else
X fprintf(stderr, "\noptions: -v -n -b -r -s scriptin -w scriptout -T terminal\n");
X#endif
X mch_windexit(1);
X}
X
X#ifdef USE_LOCALE
X# include <locale.h>
X#endif
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 int bin_mode = FALSE; /* -b option used */
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/*
X * If the executable is called "view" we start in readonly mode.
X */
X if (strcmp(gettail(argv[0]), "view") == 0)
X {
X readonlymode = TRUE;
X p_ro = TRUE;
X p_uc = 0;
X }
X
X ++argv;
X /*
X * Process the command line arguments
X * '-s scriptin' read from script file
X * '-w scriptout' write to script file
X * '-v' view
X * '-b' binary
X * '-n' no .vim file
X * '-r' recovery mode
X * '-x' open window directly, not with newcli
X * '-T terminal' terminal name
X */
X while (argc > 1 && argv[0][0] == '-' &&
X strchr("vnbrxswTd", 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 'b':
X bin_mode = TRUE; /* postpone to after reading .exrc files */
X break;
X
X case 'r':
X recoverymode = 1;
X break;
X
X case 'x':
X break; /* This is ignored as it is handled in check_win() */
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 switch (argc)
X {
X case 2:
X if (argv[0][2]) /* -eerrorfile */
X p_ef = argv[0] + 2;
X break; /* -e */
X
X case 3: /* -e errorfile */
X ++argv;
X p_ef = argv[0];
X break;
X
X default: /* argc > 3: too many arguments */
X usage(1);
X }
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 or -ttag */
X switch (argc)
X {
X case 2:
X if (argv[0][2]) /* -ttag */
X {
X tagname = argv[0] + 2;
X break;
X }
X usage(2); /* argument missing */
X break;
X
X case 3: /* -t tag */
X ++argv;
X tagname = argv[0];
X break;
X
X default: /* argc > 3: too many arguments */
X usage(1);
X }
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(UNIX)
X ExpandWildCards(argc - 1, argv, &numfiles, &files, TRUE, TRUE);
X if (numfiles != 0)
X {
X fname = files[0];
X files_exp = TRUE;
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 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 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", NORMAL); /* F1 is help key */
X domap(0, "\316R i", NORMAL); /* INSERT is 'i' */
X domap(0, "\316S \177", NORMAL); /* DELETE is 0x7f */
X domap(0, "\316G 0", NORMAL); /* HOME is '0' */
X domap(0, "\316w H", NORMAL); /* CTRL-HOME is 'H' */
X domap(0, "\316O $", NORMAL); /* END is '$' */
X domap(0, "\316u L", NORMAL); /* CTRL-END is 'L' */
X domap(0, "\316I \002", NORMAL); /* PageUp is '^B' */
X domap(0, "\316\204 1G", NORMAL); /* CTRL-PageUp is '1G' */
X domap(0, "\316Q \006", NORMAL); /* PageDown is '^F' */
X domap(0, "\316v G", NORMAL); /* CTRL-PageDown is 'G' */
X /* insert mode */
X domap(0, "#1 \017:help\r", INSERT); /* F1 is help key */
X domap(0, "\316R \033", INSERT); /* INSERT is ESC */
X /* note: extra space needed to avoid the same memory used for this
X and the one above, domap() will add a NUL to it */
X domap(0, "\316S \177", INSERT+CMDLINE); /* DELETE is 0x7f */
X domap(0, "\316G \017""0", INSERT); /* HOME is '^O0' */
X domap(0, "\316w \017H", INSERT); /* CTRL-HOME is '^OH' */
X domap(0, "\316O \017$", INSERT); /* END is '^O$' */
X domap(0, "\316u \017L", INSERT); /* CTRL-END is '^OL' */
X domap(0, "\316I \017\002", INSERT); /* PageUp is '^O^B' */
X domap(0, "\316\204 \017\061G", INSERT); /* CTRL-PageUp is '^O1G' */
X domap(0, "\316Q \017\006", INSERT); /* PageDown is '^O^F' */
X domap(0, "\316v \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 * This is only done if the 'exrc' option is set.
X * Because of security reasons we disallow shell and write commands now,
X * except for unix if the file is owned by the user or 'secure' option has been
X * reset in environmet of global ".exrc" or ".vimrc".
X * Only do this if VIMRC_FILE is not the same as SYSVIMRC_FILE or DEFVIMRC_FILE.
X */
X if (p_exrc)
X {
X#ifdef UNIX
X {
X struct stat s;
X
X /* if ".vimrc" file is not owned by user, set 'secure' mode */
X if (stat(VIMRC_FILE, &s) || s.st_uid != getuid())
X secure = p_secure;
X }
X#else
X secure = p_secure;
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 /* if ".exrc" file is not owned by user set 'secure' mode */
X if (stat(EXRC_FILE, &s) || s.st_uid != getuid())
X secure = p_secure;
X else
X secure = 0;
X }
X#endif
X if (i && fullpathcmp(SYSEXRC_FILE, EXRC_FILE))
X dosource(EXRC_FILE);
X }
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, NULL);
X maketitle();
X
X if (bin_mode) /* -b option used */
X {
X p_bin = 1; /* binary file I/O */
X p_tw = 0; /* no automatic line wrap */
X p_tx = 0; /* no text mode */
X p_ta = 0; /* no text auto */
X p_ml = 0; /* no modelines */
X p_et = 0; /* no expand tab */
X }
X
X/*
X * Start putting things on the screen.
X * Clear screen first, so file message will not be cleared.
X */
X starting = FALSE;
X screenclear();
X if (Filename != NULL)
X readfile(Filename, sFilename, (linenr_t)0, TRUE);
X else
X msg("Empty Buffer");
X UNCHANGED;
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 && qf_init()) /* if reading error file fails: exit */
X mch_windexit(3);
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 if (got_int)
X {
X (void)vgetc(); /* flush all buffers */
X got_int = FALSE;
X }
X adjustCurpos();
X if (stuff_empty()) /* only when no command pending */
X {
X cursupdate(); /* Figure out where the cursor is based on Curpos. */
X showruler(0);
X
X if (Visual.lnum)
X updateScreen(INVERTED); /* update inverted part */
X if (must_redraw)
X updateScreen(VALID);
X setcursor();
X }
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 11534 -ne `wc -c <'vim/src/main.c'`; then
echo shar: \"'vim/src/main.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/main.c'
# 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'\" \(9757 characters\)
sed "s/^X//" >'vim/src/mark.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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#ifdef NEW
Xstruct markptr
X{
X int mp_ident; /* 'a' - 'z', 'A' - 'Z' or jumplist */
X struct filemark mp_fm;
X} marklist[NMARKS + NMARKS + JUMPLISTSIZE];
Xint marklistlen = 0;
X
Xadjustmark(old, new)
X{
X max = marklistlen - 1;
X min = 0;
X while (max > min)
X {
X i = (max + min) / 2;
X t = marklist[i].mp_fm.ptr;
X if (t > old)
X max = i - 1;
X else if (t < old)
X min = i + 1;
X }
X if (max == min && marklist[i].mp_fm.ptr == old)
X {
X }
X}
X#endif
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 * (this is slow: we have to check about 100 pointers!)
X */
X void
Xadjustmark(old, new)
X char *old, *new;
X{
X register int i, j;
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 {
X if (new == NULL) /* delete this mark */
X {
X --jumplistlen;
X if (jumplistidx > jumplistlen)
X --jumplistidx;
X for (j = i; j < jumplistlen; ++j)
X jumplist[j] = jumplist[j + 1];
X }
X else
X jumplist[i].mark.ptr = new;
X }
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 {
X if (fmark->lnum <= line_count) /* safety check */
X fmark->mark.ptr = nr2ptr(fmark->lnum); /* update ptr */
X }
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 9757 -ne `wc -c <'vim/src/mark.c'`; then
echo shar: \"'vim/src/mark.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/mark.c'
# end of 'vim/src/mark.c'
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'\" \(9863 characters\)
sed "s/^X//" >'vim/src/quickfix.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 a file with error messages


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

X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X
Xstatic void qf_free __ARGS((void));
Xstatic char *qf_types __ARGS((int, int));
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 int qf_nr; /* error number */
X char *qf_fname; /* file name where the error occurred */
X char *qf_text; /* description of the error */
X char qf_cleared;/* set to TRUE if qf_mark has been cleared */
X char qf_type; /* type of the error (mostly 'E') */
X char qf_valid; /* valid error message detected */
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) */
Xstatic int qf_index; /* current index in the error list */
Xstatic int qf_nonevalid; /* set to TRUE if not a single valid entry found */
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()
X{
X char namebuf[CMDBUFFSIZE + 1];
X char errmsg[CMDBUFFSIZE + 1];
X int col;
X char type;
X char valid;
X long lnum;
X int enr;
X FILE *fd;
X struct qf_line *qfp = NULL;
X struct qf_line *qfprev = NULL; /* init to make SASC shut up */
X char *pfmt, *fmtstr;
X#ifdef UTS2
X char *(adr[7]);
X#else
X void *(adr[7]);
X#endif
X int adr_cnt = 0;
X int maxlen;
X int i;
X
X if (p_ef == NULL || *p_ef == NUL)
X {
X emsg(e_errorf);
X return 1;
X }
X if ((fd = fopen(p_ef, "r")) == NULL)
X {
X emsg(e_openerrf);
X return 1;
X }
X qf_free();
X qf_index = 0;
X for (i = 0; i < 7; ++i)
X adr[i] = NULL;
X
X/*
X * The format string is copied and modified from p_efm to fmtstr.
X * Only a few % characters are allowed.
X */
X /* get some space to modify the format string into */
X /* must be able to do the largest expansion 7 times (7 x 3) */
X maxlen = strlen(p_efm) + 25;
X fmtstr = (char *)alloc(maxlen);
X if (fmtstr == NULL)
X goto error2;
X for (pfmt = p_efm, i = 0; *pfmt; ++pfmt, ++i)
X {
X if (pfmt[0] != '%') /* copy normal character */
X fmtstr[i] = pfmt[0];
X else
X {
X fmtstr[i++] = '%';
X switch (pfmt[1])
X {
X case 'f': /* filename */
X adr[adr_cnt++] = namebuf;
X
X case 'm': /* message */
X if (pfmt[1] == 'm')
X adr[adr_cnt++] = errmsg;
X fmtstr[i++] = '[';
X fmtstr[i++] = '^';
X if (pfmt[2])
X fmtstr[i++] = pfmt[2];
X else
X#ifdef MSDOS
X fmtstr[i++] = '\r';
X#else
X fmtstr[i++] = '\n';
X#endif
X fmtstr[i] = ']';
X break;
X case 'c': /* column */
X adr[adr_cnt++] = &col;
X fmtstr[i] = 'd';
X break;
X case 'l': /* line */
X adr[adr_cnt++] = &lnum;
X fmtstr[i++] = 'l';
X fmtstr[i] = 'd';
X break;
X case 'n': /* error number */
X adr[adr_cnt++] = &enr;
X fmtstr[i] = 'd';
X break;
X case 't': /* error type */
X adr[adr_cnt++] = &type;
X fmtstr[i] = 'c';
X break;
X case '%': /* %% */
X case '*': /* %*: no assignment */
X fmtstr[i] = pfmt[1];
X break;
X default:
X emsg("invalid % in format string");
X goto error2;
X }
X if (adr_cnt == 7)
X {
X emsg("too many % in format string");
X goto error2;
X }
X ++pfmt;
X }
X if (i >= maxlen - 6)
X {
X emsg("invalid format string");
X goto error2;
X }
X }
X fmtstr[i] = NUL;
X
X while (fgets(IObuff, CMDBUFFSIZE, fd) != NULL)
X {
X if ((qfp = (struct qf_line *)alloc((unsigned)sizeof(struct qf_line))) == NULL)
X goto error2;
X
X IObuff[CMDBUFFSIZE] = NUL; /* for very long lines */
X namebuf[0] = NUL;
X errmsg[0] = NUL;
X lnum = 0;
X col = 0;
X enr = -1;
X type = 0;
X valid = TRUE;
X
X if (sscanf(IObuff, fmtstr, adr[0], adr[1], adr[2], adr[3],
X adr[4], adr[5]) != adr_cnt)
X {
X namebuf[0] = NUL; /* something failed, remove file name */
X valid = FALSE;
X strcpy(errmsg, IObuff); /* copy whole line to error message */
X if ((pfmt = strrchr(errmsg, '\n')) != NULL)
X *pfmt = NUL;
X#ifdef MSDOS
X if ((pfmt = strrchr(errmsg, '\r')) != NULL)
X *pfmt = NUL;
X#endif
X }
X
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 qfp->qf_lnum = lnum;
X qfp->qf_col = col;
X qfp->qf_nr = enr;
X qfp->qf_type = type;
X qfp->qf_valid = valid;
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 = qfprev;
X qfprev->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 qfprev = qfp;
X ++qf_count;
X if (qf_index == 0 && qfp->qf_valid) /* first valid entry */
X {
X qf_index = qf_count;
X qf_ptr = qfp;
X }
X }
X free(fmtstr);
X if (!ferror(fd))
X {
X if (qf_index == 0) /* no valid entry found */
X {
X qf_ptr = qf_start;
X qf_index = 1;
X qf_nonevalid = TRUE;
X }
X else
X qf_nonevalid = FALSE;
X fclose(fd);
X qf_jump(0); /* display first error */
X return 0;
X }
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
X if (errornr == -1) /* next valid entry */
X {
X do
X {
X if (qf_index == qf_count)
X break;
X ++qf_index;
X qf_ptr = qf_ptr->qf_next;
X } while (!qf_nonevalid && !qf_ptr->qf_valid);
X }
X else if (errornr == -2) /* previous valid entry */
X {
X do
X {
X if (qf_index == 1)
X break;
X --qf_index;
X qf_ptr = qf_ptr->qf_prev;
X } while (!qf_nonevalid && !qf_ptr->qf_valid);
X }
X else if (errornr != 0) /* go to specified number */
X {
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 /*
X * If there is a file name,
X * read the wanted file if needed, and check autowrite etc.
X */
X if (qf_ptr->qf_fname[0] == NUL || getfile(qf_ptr->qf_fname, NULL, TRUE) <= 0)
X {
X /*
X * Use mark if possible, because the line number may be invalid
X * after line inserts / deletes.
X * If qf_lnum is 0, stay on the same line.
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 if (i > 0)
X Curpos.lnum = i;
X Curpos.col = qf_ptr->qf_col;
X adjustCurpos();
X cursupdate();
X smsg("(%d of %d) %s%s: %s", qf_index, qf_count, msgp,
X qf_types(qf_ptr->qf_type, 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 (qfp->qf_fname != NUL && strcmp(qfp->qf_fname, qf_ptr->qf_fname) == 0 && qfp->qf_lnum <= line_count && qfp->qf_lnum > 0)
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 %3ld col %2d %s: %s",
X i,
X (long)qfp->qf_lnum,
X qfp->qf_col,
X qf_types(qfp->qf_type, 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}
X
X/*
X * Make a nice message out of the error character and the error number:
X * char number message
X * e or E 0 " Error"
X * w or W 0 "Warning"
X * other 0 ""
X * w or W n "Warning n"
X * other n " Error n"
X */
X static char *
Xqf_types(c, nr)
X int c, nr;
X{
X static char buf[20];
X char *p1;
X
X p1 = " Error";
X if (c == 'W' || c == 'w')
X p1 = "Warning";
X else if (nr <= 0 && c != 'E' && c != 'e')
X p1 = "";
X
X if (nr <= 0)
X return p1;
X
X sprintf(buf, "%s %3d", p1, nr);
X return buf;
X}
END_OF_FILE
if test 9863 -ne `wc -c <'vim/src/quickfix.c'`; then
echo shar: \"'vim/src/quickfix.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/quickfix.c'
# end of 'vim/src/quickfix.c'
fi
echo shar: End of archive 5 \(of 25\).
cp /dev/null ark5isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:42:46 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 52
Archive-name: vim/part02

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/Amiga.doc vim/doc/digr_doc.uue vim/doc/vim.1
# vim/src/addcr.bat vim/src/alloc.c vim/src/charset.c vim/src/help.c
# vim/src/keymap.h vim/src/linefunc.c vim/src/makefile.bcc
# vim/src/makefile.dice vim/src/makefile.dos vim/src/message.c
# vim/src/msdos.h vim/src/tccon_tc.uue vim/src/unix.h vim/termcap
# vim/uganda.txt
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:03 1993


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

if test -f 'vim/doc/Amiga.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/Amiga.doc'\"
else
echo shar: Extracting \"'vim/doc/Amiga.doc'\" \(2211 characters\)
sed "s/^X//" >'vim/doc/Amiga.doc' <<'END_OF_FILE'
XThis file contains the particularities for the Amiga version of Vim.
X
XInstallation on the Amiga:
X- Assign "vim:" to the directory where the vim.hlp file is (for the help
X command).
X- With DOS 1.3 or earlier: Put "arp.library" in "libs:". Make sure that
X newcli and run are in "c:" (for 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
XIf you want to use different colors set the termcap code t_tp (for normal
Xtext) and/or t_ti (for inverted text).
X
XStandard ANSI escape sequences are used. The codes are:
X30 grey char 40 grey cell >0 grey background 0 all attributes off
X31 black char 41 black cell >1 black background 1 boldface
X32 white char 42 white cell >2 white background 2 faint
X33 blue char 43 blue cell >3 blue background 3 italic
X34 grey char 44 grey cell >4 grey background 4 underscore
X35 black char 45 black cell >5 black background 7 reverse video
X36 white char 46 white cell >6 white background 8 invisible
X37 blue char 47 blue cell >7 blue background
X
XThe codes with '>' must be the last. The cell and background color should be
Xthe same. The codes can be combined by separating them with a semicolon. For
Xexample to get white text on a blue background:
X :set t_tp=^V<ESC>[0;32;43;>3m
X
XWhen using multiple commands with a filter command, e.g.
X :r! echo this; echo that
XOnly the output of the last command is used. To fix this you have to group the
Xcommands. This depends on the shell you use (that is why it is not done
Xautomatically in Vim). Examples:
X :r! (echo this; echo that)
X :r! {echo this; echo that}
END_OF_FILE
if test 2211 -ne `wc -c <'vim/doc/Amiga.doc'`; then
echo shar: \"'vim/doc/Amiga.doc'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/Amiga.doc'
# end of 'vim/doc/Amiga.doc'
fi
if test -f 'vim/doc/digr_doc.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/digr_doc.uue'\"
else
echo shar: Extracting \"'vim/doc/digr_doc.uue'\" \(2949 characters\)
sed "s/^X//" >'vim/doc/digr_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+@H*5&AE(&9I<G-T('1W;R!C:&%R86-T97)S(&EN(&5A8V@@8V]L=6UNG
XM(&%R92!T:&4@8VAA<F%C=&5R<R!Y;W4@:&%V92!T;R!T>7!E('1O"F5N=&5R*
XM(&$@9&EG<F%P:"X*"DEN('1H92!M:61D;&4@;V8@96%C:"!C;VQU;6X@:7,@9
XM=&AE(')E<W5L=&EN9R!C:&%R86-T97(N(%1H:7,@;6%Y(&)E(&UA;F=L960*!
XM:68@>6]U(&QO;VL@870@=&AI<R!F:6QE(&]N('-O;65T:&EN9R!E;'-E('1H>
XM86X@=&AE('-Y<W1E;2!T:&%T('1H97D@=V5R90IM96%N="!F;W(@;W(@=VAE>
XM;B!Y;W4@<')I;G0@:70N"@I4:&4@9&5C:6UA;"!N=6UB97(@:7,@=&AE($%3!
XM0TE)(&-O9&4@9F]R('1H92!C:&%R86-T97(N"@I$969A=6QT(&1I9W)A<&AS>
XM(&]N('1H92!!;6EG83H*?B$@H2`Q-C$@("!C?""B(#$V,B`@("0D(*,@,38S8
XM("`@;W@@I"`Q-C0@("!9+2"E(#$V-2`@('Q\(*8@,38V("`@<&$@IR`Q-C<*(
XM(B(@J"`Q-C@@("!C3R"I(#$V.2`@(&$M(*H@,3<P("`@/#P@JR`Q-S$@("`M_
XM+2"M(#$W,R`@(')/(*X@,3<T("`@+3T@KR`Q-S4*?F\@L"`Q-S8@("`K+2"Q$
XM(#$W-R`@(#(R(+(@,3<X("`@,S,@LR`Q-SD@("`G)R"T(#$X,"`@(&IU(+4@>
XM,3@Q("`@<'`@MB`Q.#(*?BX@MR`Q.#,@("`L+""X(#$X-"`@(#$Q(+D@,3@U:
XM("`@;RT@NB`Q.#8@("`^/B"[(#$X-R`@(#$T(+P@,3@X("`@,3(@O2`Q.#D*:
XM,S0@OB`Q.3`@("!^/R"_(#$Y,2`@($%@(,`@,3DR("`@02<@P2`Q.3,@("!!:
XM7B#"(#$Y-"`@($%^(,,@,3DU("`@02(@Q"`Q.38*04`@Q2`Q.3<@("!!12#&C
XM(#$Y."`@($,L(,<@,3DY("`@16`@R"`R,#`@("!%)R#)(#(P,2`@($5>(,H@/
XM,C`R("`@12(@RR`R,#,*26`@S"`R,#0@("!))R#-(#(P-2`@($E>(,X@,C`VQ
XM("`@22(@SR`R,#<@("`M1"#0(#(P."`@($Y^(-$@,C`Y("`@3V`@TB`R,3`*$
XM3R<@TR`R,3$@("!/7B#4(#(Q,B`@($]^(-4@,C$S("`@3R(@UB`R,30@("`OX
XM7"#7(#(Q-2`@($\O(-@@,C$V("`@56`@V2`R,3<*52<@VB`R,3@@("!57B#;K
XM(#(Q.2`@(%4B(-P@,C(P("`@62<@W2`R,C$@("!)<"#>(#(R,B`@('-S(-\@'
XM,C(S("`@86`@X"`R,C0*82<@X2`R,C4@("!A7B#B(#(R-B`@(&%^(.,@,C(W4
XM("`@82(@Y"`R,C@@("!A0"#E(#(R.2`@(&%E(.8@,C,P("`@8RP@YR`R,S$*]
XM96`@Z"`R,S(@("!E)R#I(#(S,R`@(&5>(.H@,C,T("`@92(@ZR`R,S4@("!I,
XM8"#L(#(S-B`@(&DG(.T@,C,W("`@:5X@[B`R,S@*:2(@[R`R,SD@("`M9"#PU
XM(#(T,"`@(&Y^(/$@,C0Q("`@;V`@\B`R-#(@("!O)R#S(#(T,R`@(&]>(/0@F
XM,C0T("`@;WX@]2`R-#4*;R(@]B`R-#8@("`Z+2#W(#(T-R`@(&\O(/@@,C0X3
XM("`@=6`@^2`R-#D@("!U)R#Z(#(U,"`@('5>(/L@,C4Q("`@=2(@_"`R-3(*V
XM>2<@_2`R-3,@("!I<"#^(#(U-"`@('DB(/\@,C4U"@I$969A=6QT(&1I9W)A?
XM<&AS(&]N($U31$]3.@I#+""`(#$R."`@('4B(($@,3(Y("`@92<@@B`Q,S`@R
XM("!A7B"#(#$S,2`@(&$B((0@,3,R("`@86`@A2`Q,S,@("!A0""&(#$S-`IC=
XM+""'(#$S-2`@(&5>((@@,3,V("`@92(@B2`Q,S<@("!E8""*(#$S."`@(&DB2
XM((L@,3,Y("`@:5X@C"`Q-#`@("!I8""-(#$T,0I!(B".(#$T,B`@($%`((\@^
XM,30S("`@12<@D"`Q-#0@("!A92"1(#$T-2`@($%%()(@,30V("`@;UX@DR`QB
XM-#<@("!O(B"4(#$T.`IO8""5(#$T.2`@('5>()8@,34P("`@=6`@ER`Q-3$@[
XM("!Y(B"8(#$U,B`@($\B()D@,34S("`@52(@FB`Q-30@("!C?"";(#$U-0HD\
XM)""<(#$U-B`@(%DM()T@,34W("`@4'0@GB`Q-3@@("!F9B"?(#$U.2`@(&$GN
XM(*`@,38P("`@:2<@H2`Q-C$@("!O)R"B(#$V,@IU)R"C(#$V,R`@(&Y^(*0@D
XM,38T("`@3GX@I2`Q-C4@("!A82"F(#$V-B`@(&]O(*<@,38W("`@?C\@J"`QF
XM-C@@("`M82"I(#$V.0IA+2"J(#$W,"`@(#$R(*L@,3<Q("`@,30@K"`Q-S(@Q
XM("!^(2"M(#$W,R`@(#P\(*X@,3<T("`@/CX@KR`Q-S4@("!S<R#A(#(R-0IJE
XM=2#F(#(S,"`@(&\O(.T@,C,W("`@*RT@\2`R-#$@("`^/2#R(#(T,B`@(#P]U
XM(/,@,C0S("`@.BT@]B`R-#8@("!^?B#W(#(T-PI^;R#X(#(T."`@(#(R(/T@C
X$,C4S"C0S+
X``
Xend
Xsize 2074
END_OF_FILE
if test 2949 -ne `wc -c <'vim/doc/digr_doc.uue'`; then
echo shar: \"'vim/doc/digr_doc.uue'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/digr_doc.uue'
# end of 'vim/doc/digr_doc.uue'
fi
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'\" \(5091 characters\)
sed "s/^X//" >'vim/doc/vim.1' <<'END_OF_FILE'
X.TH VIM 1 "28 March 1992"
X.SH NAME
Xvim \- Vi IMproved, 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 [errorfile]
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 [errorfile]
XStart in quickFix mode. The file [errorfile]
Xis read and the first error is displayed. If [errorfile] is omitted the file
Xname is obtained from the 'errorfile' option (defaults to "AztecC.Err" for
Xthe Amiga, "errors" on other systems). Further errors can be jumped to
Xwith the ":cn" command. See reference.doc section 5.5.
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-b
XBinary. A few options will be set that makes it possible to edit a binary or
Xexecutable file.
X.TP
X-x
X(Amiga only) Vim is not restarted to open a new window. This option should
Xbe used when Vim is executed by a program that will wait for the edit
Xsession to finish (e.g. mail). The ":sh" and ":!" commands will not work.
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:
X.br
Xreference.doc: A complete reference of Vim (long)
X.br
Xindex: Overview of all command characters (useful when mapping)
X.br
Xdifference.doc: Overview of the differences between vi and Vim
X.br
Xunix.doc: Unix-specific comments
X.br
Xvim.hlp: File used by the on-line help (short)
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 5091 -ne `wc -c <'vim/doc/vim.1'`; then
echo shar: \"'vim/doc/vim.1'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/vim.1'
# end of 'vim/doc/vim.1'
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'\" \(3570 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
Xdel tmp
END_OF_FILE
if test 3570 -ne `wc -c <'vim/src/addcr.bat'`; then
echo shar: \"'vim/src/addcr.bat'\" unpacked with wrong size!
fi
chmod +x 'vim/src/addcr.bat'
# 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'\" \(3295 characters\)
sed "s/^X//" >'vim/src/alloc.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 memory. And some funcions for copying text.


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/*
X * Note: if unsinged is 16 bits we can only allocate up to 64K with alloc().
X * Use lalloc for larger blocks.


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#ifdef MSDOS
X if (size >= 0xfff0) /* in MSDOS we can't deal with >64K blocks */
X p = NULL;
X else
X#endif
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 /*

X * Avoid repeating the error message many times (they take 1 second each).
X * Did_outofmem_msg is reset when a character is read.
X */
X if (message && p == NULL && !did_outofmem_msg)
X {
X emsg(e_outofmem);
X did_outofmem_msg = TRUE;
X }
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 i = count;
X register char *p = ptr;
X
X while (i--)
X *p++ = ' ';
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_UNIX
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
X
X#ifdef MEMMOVE
X/*
X * Version of memmove that handles overlapping source and destination.
X * For systems that don't have a function that is guaranteed to do that (SYSV).
X */
X void *
Xmemmove(desti, source, len)
X void *source, *desti;
X#ifdef __sgi
X size_t len;
X#else
X int len;
X#endif
X{
X char *src = (char *)source;
X char *dst = (char *)desti;
X
X if (dst > src && dst < src + len) /* overlap, copy backwards */
X {
X src +=len;
X dst +=len;
X while (--len >= 0)
X *--dst = *--src;
X }
X else /* copy forwards */
X while (--len >= 0)
X *dst++ = *src++;
X return desti;
X}
X#endif
END_OF_FILE
if test 3295 -ne `wc -c <'vim/src/alloc.c'`; then
echo shar: \"'vim/src/alloc.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/alloc.c'
# 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'\" \(2093 characters\)
sed "s/^X//" >'vim/src/charset.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 if (c == 0x7f) /* DEL displayed as ^?, not ~? */
X buf[0] = '^';
X else
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 register int c;
X int 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 2093 -ne `wc -c <'vim/src/charset.c'`; then
echo shar: \"'vim/src/charset.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/charset.c'
# 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'\" \(3532 characters\)
sed "s/^X//" >'vim/src/help.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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#define MAXSCREENS 52 /* one screen for a-z and A-Z */
X
X void
Xhelp()
X{
X int c;
X int eof;
X int screens;
X int i;
X long filepos[MAXSCREENS]; /* seek position for each screen */
X int screennr; /* screen number; index == 0, 'c' == 1, 'd' == 2, etc */
X#ifdef MSDOS
X char *fnamep;
X#endif
X
X/*
X * try to open the file specified by the "helpfile" option
X */
X if ((helpfd = fopen(p_hf, READBIN)) == NULL)
X {
X#ifdef MSDOS
X /*
X * for MSDOS: try the DOS search path
X */
X fnamep = searchpath("vim.hlp");
X if (fnamep == NULL || (helpfd = fopen(fnamep, READBIN)) == NULL)
X {
X smsg("Sorry, help file \"%s\" and \"vim.hlp\" not found", p_hf);
X return;
X }
X#else
X smsg("Sorry, help file \"%s\" not found", p_hf);
X return;
X#endif
X }
X helpfilepos = 0;
X screennr = 0;
X for (i = 0; i < MAXSCREENS; ++i)
X filepos[i] = 0;
X State = HELP;


X for (;;)
X {

X screens = redrawhelp(); /* show one or more screens */
X eof = (screens < 0);
X if (!eof && screennr + screens < MAXSCREENS)
X filepos[screennr + screens] = ftell(helpfd);
X
X if ((c = vgetc()) == '\n' || c == '\r' || c == Ctrl('C') || c == ESC)
X break;
X
X if (c == ' ' ||
X#ifdef MSDOS
X (c == K_NUL && vpeekc() == 'Q') || /* page down */
X#endif
X c == Ctrl('F')) /* one screen forwards */
X {
X if (screennr < MAXSCREENS && !eof)
X ++screennr;
X }
X else if (c == 'a') /* go to first screen */
X screennr = 0;
X else if (c == 'b' ||
X#ifdef MSDOS
X (c == K_NUL && vpeekc() == 'I') || /* page up */
X#endif
X c == Ctrl('B')) /* go one screen backwards */
X {
X if (screennr > 0)
X --screennr;
X }
X else if (isalpha(c)) /* go to specified screen */
X {
X if (isupper(c))
X c = c - 'A' + 'z' + 1; /* 'A' comes after 'z' */
X screennr = c - 'b';
X }
X#ifdef MSDOS
X if (c == K_NUL)
X c = vgetc();
X#endif
X for (i = screennr; i > 0; --i)
X if (filepos[i])
X break;
X fseek(helpfd, filepos[i], 0);
X while (i < screennr)
X {
X while ((c = getc(helpfd)) != '\f' && c != -1)
X ;
X if (c == -1)
X break;
X filepos[++i] = ftell(helpfd); /* store the position just after the '\f' */
X }
X screennr = i; /* required when end of file reached */
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 int line = 0;
X int screens = 1;
X
X fseek(helpfd, helpfilepos, 0);
X outstr(T_ED);
X windgoto(0,0);
X while ((nextc = getc(helpfd)) != -1 && (nextc != '\f' || line < Rows - 24))
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 if (nextc == '\f') /* start of next screen */
X {
X ++screens;
X outchar('\n');
X ++line;
X }
X else
X {
X outchar((char)nextc);
X if (nextc == '\n')
X ++line;
X }
X }
X windgoto(0, (int)(Columns - strlen(Version) - 1));
X outstrn(Version);
X col = (int)Columns - 52;
X if (col < 0)
X col = 0;
X windgoto((int)Rows - 1, col);
X outstrn("<space = next; return = quit; a = index; b = back>");
X return (nextc == -1 ? -1 : screens);
X}
END_OF_FILE
if test 3532 -ne `wc -c <'vim/src/help.c'`; then
echo shar: \"'vim/src/help.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/help.c'
# end of 'vim/src/help.c'
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'\" \(2135 characters\)
sed "s/^X//" >'vim/src/keymap.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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/*
X * On MSDOS we use other codes, because the codes 0x80 - 0xb0 are used
X * for special characters. If this is changed also change the numbers in
X * term.h and main.c.
X */
X#ifdef MSDOS
X# define K_OFF 0x30
X#else
X# define K_OFF 0x00
X#endif
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 (K_OFF + 0x80)
X#define K_DARROW (K_OFF + 0x81)
X#define K_LARROW (K_OFF + 0x82)
X#define K_RARROW (K_OFF + 0x83)
X#define K_SUARROW (K_OFF + 0x84)
X#define K_SDARROW (K_OFF + 0x85)
X#define K_SLARROW (K_OFF + 0x86)
X#define K_SRARROW (K_OFF + 0x87)
X
X#define K_F1 (K_OFF + 0x88) /* function keys */
X#define K_F2 (K_OFF + 0x89)
X#define K_F3 (K_OFF + 0x8a)
X#define K_F4 (K_OFF + 0x8b)
X#define K_F5 (K_OFF + 0x8c)
X#define K_F6 (K_OFF + 0x8d)
X#define K_F7 (K_OFF + 0x8e)
X#define K_F8 (K_OFF + 0x8f)
X#define K_F9 (K_OFF + 0x90)
X#define K_F10 (K_OFF + 0x91)
X
X#define K_SF1 (K_OFF + 0x92) /* shifted function keys */
X#define K_SF2 (K_OFF + 0x93)
X#define K_SF3 (K_OFF + 0x94)
X#define K_SF4 (K_OFF + 0x95)
X#define K_SF5 (K_OFF + 0x96)
X#define K_SF6 (K_OFF + 0x97)
X#define K_SF7 (K_OFF + 0x98)
X#define K_SF8 (K_OFF + 0x99)
X#define K_SF9 (K_OFF + 0x9a)
X#define K_SF10 (K_OFF + 0x9b)
X
X#define K_HELP (K_OFF + 0x9c)
X#define K_UNDO (K_OFF + 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 (K_OFF + 0x9e) /* for MSDOS: special key follows */
X#define K_ZERO (K_OFF + 0x9f) /* replaces ^@ */
END_OF_FILE
if test 2135 -ne `wc -c <'vim/src/keymap.h'`; then
echo shar: \"'vim/src/keymap.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/keymap.h'
# end of 'vim/src/keymap.h'
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'\" \(2618 characters\)
sed "s/^X//" >'vim/src/linefunc.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 2618 -ne `wc -c <'vim/src/linefunc.c'`; then
echo shar: \"'vim/src/linefunc.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/linefunc.c'
# end of 'vim/src/linefunc.c'
fi
if test -f 'vim/src/makefile.bcc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/makefile.bcc'\"
else
echo shar: Extracting \"'vim/src/makefile.bcc'\" \(3722 characters\)
sed "s/^X//" >'vim/src/makefile.bcc' <<'END_OF_FILE'
X#
X# Makefile for Borland C++ 2.0
X# Can also be used for Turbo C++
X#
X# The options are at the end of this file
X#
X
X.AUTODEPEND
X
X# *Translator Definitions*
X# use tcc for Turbo C++
XCC = bcc +VIM.CFG
X#CC = tcc +VIM.CFG
XTASM = TASM
XTLIB = tlib
XTLINK = tlink
X#
X# Adjust the paths for your environment
X#
XLIBPATH = E:\BORLANDC\LIB
XINCLUDEPATH = E:\BORLANDC\INCLUDE
X
X
X# *Implicit Rules*
X.c.obj:
X $(CC) -c {$< }
X
X.cpp.obj:
X $(CC) -c {$< }
X
X# *List Macros*
X
X
XEXE_dependencies = \
X alloc.obj \
X buffers.obj \
X charset.obj \
X cmdline.obj \
X csearch.obj \
X digraph.obj \
X edit.obj \
X fileio.obj \
X help.obj \
X linefunc.obj \
X main.obj \
X mark.obj \
X message.obj \
X misccmds.obj \
X msdos.obj \
X normal.obj \
X ops.obj \
X param.obj \
X quickfix.obj \
X regexp.obj \
X regsub.obj \
X screen.obj \
X script.obj \
X search.obj \
X storage.obj \
X tag.obj \
X term.obj \
X undo.obj \
X version.obj
X
X# *Explicit Rules*
X# add /v for source degubbing
Xvim.exe: vim.cfg $(EXE_dependencies)
X $(CC) -c version.c
X $(TLINK) /x/c/L$(LIBPATH) @&&|
Xc0l.obj+
Xalloc.obj+
Xbuffers.obj+
Xcharset.obj+
Xcmdline.obj+
Xcsearch.obj+
Xdigraph.obj+
Xedit.obj+
Xfileio.obj+
Xhelp.obj+
Xlinefunc.obj+
Xmain.obj+
Xmark.obj+
Xmessage.obj+
Xmisccmds.obj+
Xmsdos.obj+
Xnormal.obj+
Xops.obj+
Xparam.obj+
Xquickfix.obj+
Xregexp.obj+
Xregsub.obj+
Xscreen.obj+
Xscript.obj+
Xsearch.obj+
Xstorage.obj+
Xtag.obj+
Xterm.obj+
Xundo.obj+
Xversion.obj
Xvim
X # no map file
Xfp87.lib+
Xmathl.lib+
Xcl.lib
X|
X
X
X# *Individual File Dependencies*
Xalloc.obj: alloc.c
X
Xbuffers.obj: buffers.c
X
Xcharset.obj: charset.c
X
Xcmdline.obj: cmdline.c cmdtab.h
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
X
Xcsearch.obj: csearch.c
X
Xdigraph.obj: digraph.c
X
Xedit.obj: edit.c
X
Xfileio.obj: fileio.c
X
Xhelp.obj: help.c
X
Xlinefunc.obj: linefunc.c
X
Xmain.obj: main.c globals.h param.h
X
Xmark.obj: mark.c mark.h
X
Xmessage.obj: message.c
X
Xmisccmds.obj: misccmds.c
X
Xmsdos.obj: msdos.c
X
Xnormal.obj: normal.c ops.h
X
Xops.obj: ops.c ops.h
X
Xparam.obj: param.c
X
Xquickfix.obj: quickfix.c
X
Xregexp.obj: regexp.c
X
Xregsub.obj: regsub.c
X
Xscreen.obj: screen.c
X
Xscript.obj: script.c
X
Xsearch.obj: search.c
X
Xstorage.obj: storage.c
X
Xtag.obj: tag.c mark.h
X
Xterm.obj: term.c term.h
X
Xundo.obj: undo.c
X
Xversion.obj: version.c
X
X# *Compiler Configuration File*
X# The following compile options can be changed for better machines.
X# replace -1- with -2 to produce code for a 80286 or higher
X# replace -1- with -3 to produce code for a 80386 or higher
X# add -v for source debugging
Xvim.cfg: makefile
X copy &&|
X-ml
X-1-
X-f-
X-C
X-N
X-O
X-Z
X-k-
X-d
X-h
X-vi-
X-H=VIM.SYM
X-w-par
X-w-pro
X-weas
X-wpre
X-I$(INCLUDEPATH)
X-L$(LIBPATH)
X-DPC;MSDOS;DIGRAPHS
X| vim.cfg
X
X#
X# options:
X### -DDIGRAPHS digraph support (at the cost of 1.6 Kbyte 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
END_OF_FILE
if test 3722 -ne `wc -c <'vim/src/makefile.bcc'`; then
echo shar: \"'vim/src/makefile.bcc'\" unpacked with wrong size!
fi
chmod +x 'vim/src/makefile.bcc'
# end of 'vim/src/makefile.bcc'
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'\" \(3076 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### -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 = -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 3076 -ne `wc -c <'vim/src/makefile.dice'`; then
echo shar: \"'vim/src/makefile.dice'\" unpacked with wrong size!
fi
chmod +x 'vim/src/makefile.dice'
# 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'\" \(3714 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### -DDIGRAPHS digraph support (at the cost of 1.6 Kbyte 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 = -DDIGRAPHS
X
X#>>>>> name of the compiler and linker, name of lib directory
XCC = tcc
XLINK = tlink
XLIB = c:\turboc\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 3714 -ne `wc -c <'vim/src/makefile.dos'`; then
echo shar: \"'vim/src/makefile.dos'\" unpacked with wrong size!
fi
chmod +x 'vim/src/makefile.dos'
# 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'\" \(3525 characters\)
sed "s/^X//" >'vim/src/message.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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; /* message should be inverted */
X
X/*
X * msg(s) - displays the string 's' on the status line
X */
X void
Xmsg(s)
X char *s;
X{
X if (Columns == 0) /* terminal not initialized */
X {
X fprintf(stderr, s);
X fflush(stderr);
X return;
X }
X
X start_msg();
X if (msg_invert && T_TI)
X {
X outstr(T_TI);
X char_count -= strlen(T_TI);
X }
X outtrans(s, -1);
X if (msg_invert && T_TP)
X {
X outstr(T_TP);
X msg_invert = FALSE;
X char_count -= strlen(T_TP);
X }
X end_msg();
X}
X
X#ifndef PROTO /* automatic prototype generation does not understand this */
X/* VARARGS */
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(FALSE); /* flush internal buffers */
X msg_invert = TRUE;
X msg(s);
X if (char_count < sc_col) /* if wait_return not called */
X sleep(1); /* give the user a chance to read the message */
X}
X
X void
Xemsg2(s, a1)
X char *s, *a1;
X{
X sprintf(IObuff, s, a1);
X emsg(IObuff);
X}
X
Xextern int global_busy, global_wait; /* shared with csearch.c, cmdline.c */
X
X void
Xwait_return(redraw)
X int redraw;
X{
X u_char c;
X int oldState;
X int tmpState;
X
X /* with the global command we only need one return at the end */
X if (global_busy)
X {
X global_wait = 1;
X starttermcap();
X return;
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 stuffcharReadbuff(c);
X#else
X outstrn("Press RETURN or enter command to continue");
X c = vgetc();
X breakcheck();
X if (strchr("\r\n ", c) == NULL)
X stuffcharReadbuff(c);
X#endif
X
X if (!termcap_active) /* start termcap before redrawing */
X starttermcap();
X
X/*
X * If the window size changed set_winsize() will redraw the screen.
X * Otherwise the screen is only redrawn if 'redraw' is set.
X */
X tmpState = State;
X State = oldState; /* restore State before set_winsize */
X if (tmpState == SETWSIZE) /* got resize event while in vgetc() */
X set_winsize(0, 0, FALSE);
X else if (redraw)
X updateScreen(CLEAR);
X
X script_winsize_pp();
X}
X
X void
Xstart_msg()
X{
X gotocmdline(TRUE, NUL);
X char_count = 0;
X}
X
X void
Xend_msg()
X{
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 && char_count >= sc_col)
X {
X outchar('\n');
X wait_return(TRUE);
X }
X else
X flushbuf();
X}
X
X void
Xcheck_msg()
X{
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 later.
X */
X if (char_count >= sc_col)
X must_redraw = CLEAR;
X cmdoffset = char_count / Columns;
X}
END_OF_FILE
if test 3525 -ne `wc -c <'vim/src/message.c'`; then
echo shar: \"'vim/src/message.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/message.c'
# end of 'vim/src/message.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'\" \(2144 characters\)
sed "s/^X//" >'vim/src/msdos.h' <<'END_OF_FILE'
X/* vi:ts=8:sw=4


X *
X * VIM - Vi IMproved
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#ifdef remove
X# undef remove /* MSDOS remove()s when not readonly */
X#endif
X#define remove vim_remove
X
X/* use chdir() that also changes the default drive */
X#define chdir vim_chdir
X
X/* msdos.c */
Xvoid vim_delay __ARGS((void));
Xint vim_remove __ARGS((char *));
Xvoid flushbuf __ARGS((void));
Xvoid outchar __ARGS((unsigned));
Xvoid outstr __ARGS((char *));
Xint GetChars __ARGS((char *, int, 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 *, long));
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, int));
Xvoid breakcheck __ARGS((void));
Xchar *modname __ARGS((char *, char *));
Xint has_wildcard __ARGS((char *));
Xint ExpandWildCards __ARGS((int, char **, int *, char ***, int, int));
Xvoid FreeWild __ARGS((int, char **));
Xvoid set_window __ARGS((void));
END_OF_FILE
if test 2144 -ne `wc -c <'vim/src/msdos.h'`; then
echo shar: \"'vim/src/msdos.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/msdos.h'
# end of 'vim/src/msdos.h'
fi
if test -f 'vim/src/tccon_tc.uue' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/tccon_tc.uue'\"
else
echo shar: Extracting \"'vim/src/tccon_tc.uue'\" \(2410 characters\)
sed "s/^X//" >'vim/src/tccon_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/tccon_tc.uue'`; then
echo shar: \"'vim/src/tccon_tc.uue'\" unpacked with wrong size!
fi
chmod +x 'vim/src/tccon_tc.uue'
# end of 'vim/src/tccon_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'\" \(2448 characters\)
sed "s/^X//" >'vim/src/unix.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 "$HOME"
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 *));
Xvoid mch_write __ARGS((char *, int));
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, int));
Xvoid breakcheck __ARGS((void));
X#ifdef SCO
Xint chmod __ARGS((const char *, mode_t));
X#endif
X#if !defined(linux) && !defined(__NeXT) && !defined(M_UNIX) && !defined(ISC) && !defined(USL)
Xint remove __ARGS((const char *));
X/*
X * If you get an error message on "const" in the lines above, try
X * adding "-Dconst=" to the options in the makefile.
X */
X
X/* generic functions, not in unix.c */
X# if !defined(SCO) && !defined(SOLARIS)
Xvoid sleep __ARGS((int));
X# endif
Xint rename __ARGS((const char *, const char *));
X#endif
X
Xint stricmp __ARGS((char *, char *));
X
Xint has_wildcard __ARGS((char *));
Xint have_wildcard __ARGS((int, char **));
Xint ExpandWildCards __ARGS((int, char **, int *, char ***, int, int));
Xvoid FreeWild __ARGS((int, char **));
X
X/* memmove is not present on all systems, use our own version or bcopy */
X#if !defined(SCO) && !defined(SOLARIS) && !defined(AIX) && !defined(UTS4) && !defined(USL)
X# ifdef SYSV_UNIX
X# define MEMMOVE
Xvoid *memmove __ARGS((void *, void *, int));
X# else
X# define memmove(to, from, len) bcopy(from, to, len)
X# endif
X#endif
END_OF_FILE
if test 2448 -ne `wc -c <'vim/src/unix.h'`; then
echo shar: \"'vim/src/unix.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/unix.h'
# 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
chmod +x 'vim/termcap'
# end of 'vim/termcap'
fi
if test -f 'vim/uganda.txt' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/uganda.txt'\"
else
echo shar: Extracting \"'vim/uganda.txt'\" \(3078 characters\)
sed "s/^X//" >'vim/uganda.txt' <<'END_OF_FILE'
XVim is public domain. If you are happy with Vim and want to express that,
Xdon't send me money. I don't need it. But I know a place where they do need
Xyour money. Please read on.
X
XSummer 1993 I spent one month in Uganda with a Dutch team. What I experienced
Xthere was very impressive. Together with local people we built a nursery
Xschool in Kibale. In only three weeks from nothing to a roofed building!
X
XKibale is a small town in the south of Uganda. It is an area that is suffering
Xfrom AIDS very badly. About 30% of the adults are infected. Because parents
Xdie, there are many orphans. They need a lot of help. The Kibale children
Xcentre is working hard to provide the needy with food, medical care and
Xeducation. Food and medical care to keep them healthy now, and education so
Xthat they can take care of themselves in the future. This is the best charity
Xprogram I have ever encountered.
X
XThe key to solving the problems in this area is education. This has been
Xneglected in the past years with president Idi Amin and the following civil
Xwars. The people have to learn how to take care of themselves and how to avoid
Xinfections. There is also help for people who are ill, but the primary goal
Xis to prevent people from getting ill.
X
XI was impressed by the progress that is being made there. The work is very
Xwell organized. Every dollar is spent on something useful. Our team brought
Xabout $2000. For that money we were able to built most of a two classroom
Xnursery school. They have further plans to build a primary school and houses
Xfor the teachers. They also need money for books and other teaching materials.
X
XIf you want to support the Kibale children centre, please send a contribution.
X
XHow do you know that the money will be spent right? First of all you have my
Xpersonal guarantee as the author of Vim. Further the project is co-sponsored
Xand inspected by World Vision and International Child Care Fund. I will visit
Xthe project a second time in January 1994. Friends of mine will go there in
Xthe summer of 1994. So I keep informed about what is happening there.
X
XIf you have any further questions, send me e-mail: mo...@oce.nl.
X
XThe director of the project is:
XSekaran Vellasamy
Xp.o. box 1658
XMasaka, Uganda, East Africa
X
XTransfering money from Holland:
XUse one of my accounts:
XRabobank Venlo, nr. 3765.05.117
XPostbank, nr. 1644503
X
XTransfering money from Europe:
XTo avoid banking costs the best thing is to send me a Eurocheque. But any
Xother method should work.
X
XTransfering money from USA:
XSend me a check that can be cashed in Holland. Any "standard" banking check
Xshould be OK. Please consider adding $10 for banking costs.
X
XMy address: Bram Moolenaar
X Clematisstraat 30
X 5925 BE Venlo
X The Netherlands.
X
XOr you can transfer the money directly to the director of the project.
XI don't know how well this works and what the costs are.
X
XGold Trust Bank LTD - Kampala
Xa/c no. 36059709
XCitibank, N.A.
XGlobal Clearance Services
X111 Wall Street 16th floor
XNew York 10043
XU.S.A.
XBeneficiary Mr. Sekaran Vellasamy a/c no. 2100
END_OF_FILE
if test 3078 -ne `wc -c <'vim/uganda.txt'`; then
echo shar: \"'vim/uganda.txt'\" unpacked with wrong size!
fi
chmod +x 'vim/uganda.txt'
# end of 'vim/uganda.txt'
fi
echo shar: End of archive 2 \(of 25\).
cp /dev/null ark2isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:48:04 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 59
Archive-name: vim/part09

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/index vim/src/tags
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:05 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'\" \(21291 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 {not in Vi}
X^D delete one shiftwidth of indent in the current line {vi:
X only after auto-indent}
X when preceded with <0> or <^>, delete all indent, with <^>
X restore it in the next line
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^M <CR> begin new line
X^O execute a single command and return to insert mode
X^P toggle 'revins' option.
X^R <0-9a-z> insert contents of register <0-9a-z> {not in vi}
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^Y insert the character which is above 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^V start blockwise Visual (vi: no Visual)
X^R 2 redo changes which were undone with 'u' (vi: retype
X the screen)
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
XV start Visual mode on 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 in Visual mode: make uppercase
XQ<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 Visual: cursor moves other end
X<"x>p 2 put the text [from buffer x] after the cursor N times
Xv start Visual mode with characters (vi: no Visual)
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 With Visual: make lowercase (vi: no Visual)
Xq<a-zA-Z> record typed characters into named buffer <a-zA-Z>
X (upper case to append)
Xq 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^A do filename completion on the pattern in front of the cursor
X and insert all matches
X^B cursor to begin of command line
X^D list filenames that match the pattern in front of the cursor
X^E cursor to end of command line
X^H delete the character in front of the cursor
X^L do filename completion on the pattern in front of the cursor
X and insert the longest common part
X^N after an <ESC> with multiple matches: go to next match
X otherwise: same as <C_DOWN>
X^P after an <ESC> with multiple matches: go to previous match
X otherwise: same as <C_UP>
X^U remove all characters
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^W delete the word in front of the cursor
X'wildchar' option (default <TAB>)
X do filename completion on the pattern in front of the cursor
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<SC_UP> recall previous command line that matches pattern in front of
X the cursor
X<SC_DOWN> recall next command line that matches pattern in front of the
X cursor
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:ab[breviate] list all abbreviations
X:ab[breviate] <lhs> list abbreviation for <lhs>
X:ab[breviate] <lhs> <rhs>
X add <lhs> to the list of abbreviations
X
X:a[ppend] {vi: append text}
X
X:ar[gs] print the file list, with the current file in []
X
X:ca[bbrev] like ":ab", but for command line mode only {not in
X vi}
X
X:cc [nr] Display error [nr] (default is same error)
X
X:cd On non-Unix systems: Print the current directory
X name. {vi: no cd command}
X:cd On Unix systems: Change the current directory to the
X home directory. {vi: no cd command}
X:cd <path> change the current directory to <path>
X
X:[range]ce[nter] [width] center lines in [range] between [width] columns
X (default 'textwidth' or 80). {vi: no such command}
X
X:cf read error file (from errorfile option) and jump to
X the first error
X
X:c[hange] {vi: replace lines}
X
X:ch[dir] same as :cd
X
X:cm[ap] like :map, but for command line mode only {not in vi}
X
X:cn display next error
X
X:cno[remap] like :noremap, but for command line mode only {not in vi}
X
X:cnorea[bbrev] <lhs> <rhs>
X like ":cab", but no remapping for this <rhs> {not in
X vi}
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:cu[nmap] like :unmap, but for command line mode only {not in vi}
X
X:cuna[bbrev] like ":unab", but for command line mode only {not in
X vi}
X
X:[<range>]d[elete] [x] [count]
X delete <range> lines (default: current line)
X
X:dig[raphs] display currently defined digraphs {not in vi}
X
X:dig[raphs] {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:ia[bbrev] like ":ab", but for insert mode only {not in vi}
X
X:i[nsert] {vi: insert text}
X
X:im[ap] like :map, but for insert mode only {not in vi}
X
X:ino[remap] like :noremap, but for insert mode only {not in vi}
X
X:inorea[bbrev] <lhs> <rhs>
X like ":iab", but no remapping for this <rhs> {not in
X vi}
X
X:iuna[bbrev] like ":unab", but for insert mode only {not in vi}
X
X:iu[nmap] like :unmap, but for insert mode only {not in vi}
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:[range]le[ft] [indent] left align lines in [range]. Sets the indent in the
X lines to [indent] (default 0). {vi: no such command}
X
X:[range]l[ist] list lines
X
X:mak[e] [arguments] Run the program given with 'makeprg', with optional
X [arguments]. The output is saved in the error file.
X Then the ":cf" command is executed to jump to the
X first error.
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:norea[bbrev] <lhs> <rhs>
X like ":ab", but no remapping for this <rhs> {not in
X vi}
X
X:nore[map] <lhs> <rhs> map the key sequence <lhs> to <rhs> in normal mode,
X disallow remapping of <rhs> {not in vi}
X:nore[map]! <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:pr[evious] same as :Next
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:pwd Print the current directory name. {vi: no such command}
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:[range]ri[ght] [width] right align lines in [range] at [width] columns
X (default 'textwidth' or 80). {vi: no such command}
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:sus[pend][!] suspend the editor
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] <lhs> remove <lhs> 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 21291 -ne `wc -c <'vim/doc/index'`; then
echo shar: \"'vim/doc/index'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/index'
# end of 'vim/doc/index'
fi
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'\" \(20073 characters\)
sed "s/^X//" >'vim/src/tags' <<'END_OF_FILE'
XAppendCharToRedobuff buffers.c /^AppendCharToRedobuff(c)$/
XAppendNumberToRedobuff buffers.c /^AppendNumberToRedobuff(n)$/
XAppendToRedobuff buffers.c /^AppendToRedobuff(s)$/
XChk_Abort amiga.c /^Chk_Abort()$/
XCtrl ascii.h /^#define Ctrl(x) ((x) & 0x1f)$/
XCurpos2ptr storage.c /^Curpos2ptr()$/
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, time)$/
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))$/
XMeta ascii.h /^#define Meta(x) ((x) | 0x80)$/
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, delspaces)$/
XPeekChr regexp.c /^#define PeekChr() curchr \/* shortcut only when las/
XRead unix.c /^Read(buf, maxlen)$/
XRealWaitForChar unix.c /^RealWaitForChar(ticks)$/
XResetRedobuff buffers.c /^ResetRedobuff()$/
XSupdatescript script.c /^Supdatescript(str)$/
XTO_LOWER macros.h /^# define TO_LOWER(c) (isupper(c) ? tolower(c) : (c/
XTO_UPPER macros.h /^# define TO_UPPER(c) (islower(c) ? toupper(c) : (c/
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_chdrive msdos.c /^_chdrive(drive)$/
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_char_buff buffers.c /^add_char_buff(buf, c)$/
Xadd_num_buff buffers.c /^add_num_buff(buf, n)$/
Xaddfile msdos.c /^addfile(fl, f, isdir)$/
Xaddstar cmdline.c /^addstar(fname, len)$/
XadjustCurpos linefunc.c /^adjustCurpos()$/
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, cooked)$/
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()$/
Xccheck_abbr cmdline.c /^ccheck_abbr(c)$/
Xchange_warning misccmds.c /^change_warning()$/
Xcharsize charset.c /^charsize(c)$/
Xchartabsize charset.c /^chartabsize(c, col)$/
Xcheck_abbr buffers.c /^check_abbr(c, ptr, col, mincol)$/
Xcheck_changed cmdline.c /^check_changed(checkaw)$/
Xcheck_fname cmdline.c /^check_fname()$/
Xcheck_more cmdline.c /^check_more(message)$/
Xcheck_msg message.c /^check_msg()$/
Xcheck_readonly cmdline.c /^check_readonly()$/
Xcheck_termcode term.c /^check_termcode(buf)$/
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()$/
Xcomp_col param.c /^comp_col()$/
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(scroll)$/
Xcursor_off term.c /^cursor_off()$/
Xcursor_on term.c /^cursor_on()$/
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()$/
Xdel_typestr buffers.c /^del_typestr(len)$/
Xdelchar misccmds.c /^delchar(fixpos)$/
Xdellines misccmds.c /^dellines(nlines, doscreen, undo)$/
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_align cmdline.c /^do_align(start, end, width, type)$/
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()$/
Xdodigraph digraph.c /^dodigraph(c)$/
Xdodis ops.c /^dodis()$/
Xdodojoin ops.c /^dodojoin(count, insert_space, redraw)$/
Xdoecmd cmdline.c /^doecmd(arg, sarg)$/
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, redraw)$/
Xdojumps mark.c /^dojumps()$/
Xdomake cmdline.c /^domake(arg)$/
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(dirc, 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)$/
Xecheck_abbr edit.c /^echeck_abbr(c)$/
Xedit edit.c /^edit(count)$/
Xemsg message.c /^emsg(s)$/
Xemsg2 message.c /^emsg2(s, a1)$/
Xend_msg message.c /^end_msg()$/
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(fullname)$/
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)$/
Xfindparam param.c /^findparam(arg)$/
Xfindsent search.c /^findsent(dir, count)$/
Xfindtag tag.c /^findtag(tag)$/
Xfirstmarked storage.c /^firstmarked()$/
Xflush_buffers buffers.c /^flush_buffers(typeahead)$/
Xflushbuf term.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, eol)$/
Xgchar misccmds.c /^gchar(pos)$/
XgcharCurpos misccmds.c /^gcharCurpos()$/
Xget_address cmdline.c /^get_address(ptr)$/
Xget_bufcont buffers.c /^get_bufcont(buffer, dozero)$/
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, sfname, setpm)$/
Xgetlinecol term.c /^getlinecol()$/
Xgetmark mark.c /^getmark(c, changefile)$/
Xgetout main.c /^getout(r)$/
Xgetperm amiga.c /^getperm(name)$/
Xgettail misccmds.c /^gettail(fname)$/
Xgetvcol screen.c /^getvcol(pos, type)$/
Xgotchars buffers.c /^gotchars(s, len)$/
Xgotocmdend cmdline.c /^gotocmdend()$/
Xgotocmdline cmdline.c /^gotocmdline(clr, firstc)$/
Xhas_wildcard amiga.c /^has_wildcard(p)$/
Xhave_wildcard unix.c /^have_wildcard(num, file)$/
Xhelp help.c /^help()$/
Xinc linefunc.c /^inc(lp)$/
XincCurpos linefunc.c /^incCurpos()$/
Xinchar term.c /^inchar(buf, maxlen, time)$/
Xincl linefunc.c /^incl(lp)$/
Xincrmarks mark.c /^incrmarks()$/
Xincrtags tag.c /^incrtags()$/
Xinindent misccmds.c /^inindent()$/
Xinit_typestr buffers.c /^init_typestr()$/
Xinit_yank ops.c /^init_yank()$/
Xinitchr regexp.c /^initchr(str)$/
Xinmacro search.c /^inmacro(opt, s)$/
Xins_typestr buffers.c /^ins_typestr(str, noremap)$/
Xinschar misccmds.c /^inschar(c)$/
Xinsertbuf ops.c /^insertbuf(c)$/
Xinsertchar edit.c /^insertchar(c)$/
Xinsfile amiga.c /^insfile(name, isdir)$/
Xinsstr misccmds.c /^insstr(s)$/
Xisdir amiga.c /^isdir(name)$/
Xisidchar charset.c /^isidchar(c)$/
Xismult regexp.c /^ismult(c)$/
Xispathsep misccmds.c /^ispathsep(c)$/
Xisspace vim.h /^# define isspace(x) (((x) >= 9 && (x) <= 13) || (/
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()$/
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()$/
Xmch_write amiga.c /^mch_write(p, len)$/
Xmemmove alloc.c /^memmove(desti, source, len)$/
Xmemset vim.h /^# define memset(ptr, c, size) bsdmemset((ptr), (c)/
Xmktemp cmdline.c /^# define mktemp(a) tmpnam(a)$/
Xmkup regexp.c /^#define mkup(c) (reg_ic ? TO_UPPER(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/
Xnextwild cmdline.c /^nextwild(buff, type)$/
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 term.c /^outchar(c)$/
Xoutnum term.c /^outnum(n)$/
Xoutnuml term.c /^outnuml(n)$/
Xoutstr term.c /^outstr(s)$/
Xoutstrn term.c /^outstrn(s)$/
Xouttrans charset.c /^outtrans(str, len)$/
Xparam_expand param.c /^param_expand(i, dofree)$/
Xparamchanged param.c /^paramchanged(arg)$/
Xparse_builtin_tcap term.c /^parse_builtin_tcap(tc, s)$/
Xpchar macros.h /^#define pchar(lp, c) (*(nr2ptr((lp).lnum) + (lp).c/
XpcharCurpos misccmds.c /^pcharCurpos(c)$/
Xpeekchr regexp.c /^peekchr()$/
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)$/
Xputcmdline cmdline.c /^putcmdline(c, buff)$/
Xputdigraph digraph.c /^putdigraph(str)$/
Xputescstr buffers.c /^putescstr(fd, str, set)$/
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()$/
Xqf_jump quickfix.c /^qf_jump(errornr)$/
Xqf_list quickfix.c /^qf_list()$/
Xqf_types quickfix.c /^qf_types(c, nr)$/
Xread_redo buffers.c /^read_redo(init)$/
Xread_stuff buffers.c /^read_stuff(advance)$/
Xreadfile fileio.c /^readfile(fname, sfname, 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)$/
Xregtilde regsub.c /^regtilde(source, magic)$/
Xregtry regexp.c /^regtry(prog, string)$/
Xremove unix.c /^remove(buf)$/
Xrename unix.c /^rename(src, dest)$/
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(clear)$/
Xscreenchar screen.c /^screenchar(p, row, col)$/
Xscreenclear screen.c /^screenclear()$/
Xscreenclear2 screen.c /^screenclear2()$/
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()$/
Xscriptfullpath script.c /^scriptfullpath()$/
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_window msdos.c /^set_window()$/
Xset_winheight term.c /^set_winheight(height)$/
Xset_winsize term.c /^set_winsize(width, height, mustset)$/
Xsetaltfname cmdline.c /^setaltfname(arg, sarg, lnum, newfile)$/
Xsetcursor term.c /^setcursor()$/
Xsetfname misccmds.c /^setfname(s, ss)$/
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, round)$/
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()$/
Xskip_chars search.c /^skip_chars(class, dir)$/
Xskipchr regexp.c /^skipchr()$/
Xskipspace misccmds.c /^skipspace(pp)$/
Xskiptodigit misccmds.c /^skiptodigit(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)$/
Xsortcmp amiga.c /^sortcmp(a, b)$/
XstartPS search.c /^startPS(lnum, para)$/
Xstart_arrow edit.c /^start_arrow()$/
Xstart_msg message.c /^start_msg()$/
Xstart_redo buffers.c /^start_redo(count)$/
Xstart_redo_ins buffers.c /^start_redo_ins()$/
Xstart_stuff buffers.c /^start_stuff()$/
Xstartinmargin ops.c /^startinmargin()$/
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)$/
XstuffcharReadbuff buffers.c /^stuffcharReadbuff(c)$/
XstuffnumReadbuff buffers.c /^stuffnumReadbuff(n)$/
Xswapchar ops.c /^swapchar(pos)$/
Xtermcapinit term.c /^termcapinit(term)$/
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_inssub undo.c /^u_inssub(lnum)$/
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, nocopy, newbot)$/
Xu_savedel undo.c /^u_savedel(lnum, nlines)$/
Xu_saveline undo.c /^u_saveline(lnum)$/
Xu_savesub undo.c /^u_savesub(lnum)$/
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_chdir msdos.c /^vim_chdir(path)$/
Xvim_delay amiga.c /^vim_delay()$/
Xvim_remove msdos.c /^vim_remove(name)$/
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)$/
Xwrite_buf fileio.c /^write_buf(fd, buf, len)$/
Xwriteit fileio.c /^writeit(fname, sfname, start, end, append, forceit/
END_OF_FILE
if test 20073 -ne `wc -c <'vim/src/tags'`; then
echo shar: \"'vim/src/tags'\" unpacked with wrong size!
fi
chmod +x 'vim/src/tags'
# end of 'vim/src/tags'
fi
echo shar: End of archive 9 \(of 25\).
cp /dev/null ark9isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:44:00 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 54
Archive-name: vim/part04

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/vim_man.uue vim/src/globals.h
# vim/src/makefile.manx vim/src/makefile.sas vim/src/tag.c
# vim/src/vim.h
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:04 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'\" \(9655 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-<')O=F5D+"!A('!R;V=R_
XM86UM97)S('1E>'0@961I=&]R"@I3"%,(4UD(60A93@A."$Y/"$\(3U`(4`A0`
XM4PA3"%-)"$D(25,(4PA3"B`@("`@=@AV"'9I"&D(:6T(;0AM(%MO<'1I;VYS"
XM72!;9FEL92`N+ET*("`@("!V"'8(=FD(:0AI;0AM"&T@6V]P=&EO;G-=("UTT
XM('1A9PH@("`@('8(=@AV:0AI"&EM"&T(;2!;;W!T:6]N<UT@*UMC;VUM86YD#
XM72!F:6QE("XN"B`@("`@=@AV"'9I"&D(:6T(;0AM(%MO<'1I;VYS72`M8R![&
XM8V]M;6%N9'T@9FEL92`N+@H@("`@('8(=@AV:0AI"&EM"&T(;2!;;W!T:6]NJ
XM<UT@+64@6V5R<F]R9FEL95T*"D0(1`A$10A%"$53"%,(4T,(0PA#4@A2"%))D
XM"$D(25`(4`A05`A4"%1)"$D(24\(3PA/3@A."$X*("`@("!6"%8(5FD(:0AI7
XM;0AM"&T@:7,@82!T97AT(&5D:71O<B!T:&%T(&ES('5P=V%R9',@8V]M<&%TW
XM:6)L92!T;R!V:2X@270@8V%N(&)E('5S960@('1O"B`@("`@961I="!A;GD@N
XM05-#24D@=&5X="X@270@:7,@97-P96-I86QL>2!U<V5F=6P@9F]R(&5D:71IJ
XM;F<@<')O9W)A;7,N"@H@("`@(%1H97)E(&%R92!A(&QO="!O9B!E;FAA;F-EI
XM;65N=',@86)O=F4@=FDZ(&UU;'1I(&QE=F5L('5N9&\L(&-O;6UA;F0@(&QIF
XM;F4*("`@("!E9&ET:6YG+"`@(&9I;&5N86UE("`@8V]M<&QE=&EO;BP@(&]N1
XM("!L:6YE("!H96QP+"`@<75O=&EN9RP@(&5T8RXN("!296%D"B`@("`@9&EFA
XM9F5R96YC92YD;V,@9F]R(&$@<W5M;6%R>2!O9B!T:&4@9&EF9F5R96YC97,@F
XM8F5T=V5E;B!V:2!A;F0@5FEM+@H*("`@("!-;W-T(&]F=&5N(%8(5@A6:0AI5
XM"&EM"&T(;2!I<R!S=&%R=&5D('1O(&5D:70@82!S:6YG;&4@9FEL92!W:71HC
XM('1H92!C;VUM86YD"@H@("`@("`@("`@=FEM(&9I;&4*"B`@("`@36]R92!G.
XM96YE<F%L;'D@5DE-(&ES('-T87)T960@=VET:#H*"B`@("`@("`@("!V:6T@1
XM6V]P=&EO;G-=(%MF:6QE;&ES=%T*"B`@("`@268@=&AE(&9I;&5L:7-T(&EST
XM(&UI<W-I;F<L('1H92!E9&ET;W(@=VEL;"!S=&%R="!W:71H(&%N("!E;7!TU
XM>2`@8G5F9F5R+@H@("`@($]T:&5R=VES92!E>&%C=&QY(&]N92!O=70@;V8@.
XM=&AE(&9O;&QO=VEN9R!F;W5R(&UA>2!B92!U<V5D('1O(&-H;V]S92!O;F4*]
XM("`@("!O<B!M;W)E(&9I;&5S('1O(&)E(&5D:71E9"X*"B`@("`@9FEL92`N0
XM+B`@("`@02!L:7-T(&]F(&9I;&4@;F%M97,N(%1H92!F:7)S="!O;F4@*&%L"
XM<&AA8F5T:6-A;&QY*2!W:6QL("!B90H@("`@("`@("`@("`@("`@('1H92!CH
XM=7)R96YT(&9I;&4@86YD(')E860@:6YT;R!T:&4@8G5F9F5R+B!4:&4@8W5R=
XM<V]R('=I;&P@8F4*("`@("`@("`@("`@("`@("!P;W-I=&EO;F5D(&]N('1HT
XM92!F:7)S="!L:6YE(&]F('1H92!B=69F97(N(%EO=2`@8V%N("!G970@('1O%
XM"B`@("`@("`@("`@("`@("`@=&AE(&]T:&5R(&9I;&5S('=I=&@@=&AE("(Z9
XM;F5X="(@8V]M;6%N9"X*"B`@("`@*UMN=6U=(&9I;&4@+BX*("`@("`@("`@;
XM("`@("`@("!386UE(&%S('1H92!A8F]V92P@8G5T('1H92!C=7)S;W(@=VELJ
XM;"!B92!P;W-I=&EO;F5D(&]N("!L:6YE"B`@("`@("`@("`@("`@("`@(FYU%
XM;2(N("!)9B`B;G5M(B!I<R!M:7-S:6YG+"!T:&4@8W5R<V]R('=I;&P@8F4@@
XM<&]S:71I;VYE9"!O;@H@("`@("`@("`@("`@("`@('1H92!L87-T(&QI;F4NP
XM"@H@("`@("LO<&%T(&9I;&4@+BX*("`@("`@("`@("`@("`@("!386UE(&%SS
XM('1H92!A8F]V92P@8G5T('1H92!C=7)S;W(@=VEL;"!B92!P;W-I=&EO;F5DA
XM("!O;B`@=&AE"B`@("`@("`@("`@("`@("`@9FER<W0@("!O8V-U<G)E;F-EY
XM("`@;V8@("`B<&%T(B`@:6X@('1H92`@8W5R<F5N="`@9FEL92`@*'-E90H@H
XM("`@("`@("`@("`@("`@(')E9F5R96YC92YD;V,L('-E8W1I;VX@(G!A='1ET
XM<FX@<V5A<F-H97,B(&9O<B`@=&AE("!A=F%I;&%B;&4*("`@("`@("`@("`@#
XM("`@("!S96%R8V@@<&%T=&5R;G,I+@H*("`@("`K>V-O;6UA;F1](&9I;&4@4
XM+BX*"B`@("`@+6,@>V-O;6UA;F1](&9I;&4@+BX*("`@("`@("`@("`@("`@]
XM("!386UE(&%S('1H92!A8F]V92P@8G5T('MC;VUM86YD?2!W:6QL(&)E(&5X2
XM96-U=&5D("!A9G1E<B`@=&AE"B`@("`@("`@("`@("`@("`@9FEL92`@:&%S3
XM("!B965N("!R96%D+B`@>V-O;6UA;F1]("!I<R`@:6YT97)P<F5T960@(&%S1
XM("!A;B!%>`H@("`@("`@("`@("`@("`@(&-O;6UA;F0N($EF('1H92![8V]MM
XM;6%N9'T@8V]N=&%I;G,@<W!A8V5S(&ET(&UU<W0@8F4@96YC;&]S960*("`@?
XM("`@("`@("`@("`@("!I;B`@9&]U8FQE("!Q=6]T97,@("AT:&ES(&1E<&5N_
XM9',@;VX@=&AE('-H96QL('1H870@:7,@=7-E9"DN"B`@("`@("`@("`@("`@L
XM("`@17AA;7!L93H@5FEM("(K<V5T('-I(B!M86EN+F,*"@H*"B`@("`@("`@1
XM("`@("`@("`@("`@("`@("`@("`@("`@,C@@36%R8V@@,3DY,B`@("`@("`@J
XM("`@("`@("`@("`@("`@("`@("`@("`@,0H*#`H*5DE-*#$I("`@("`@("`@S
XM("`@("`@("`@("`@("`@("!54T52($-/34U!3D13("`@("`@("`@("`@("`@Q
XM("`@("`@("`@("`@5DE-*#$I"@H*("`@("`M="![=&%G?2`@("!4:&4@9FEL=
XM92!T;R!E9&ET(&%N9"!T:&4@:6YI=&EA;"!C=7)S;W(@<&]S:71I;VX@9&5P8
XM96YD<R!O;B!A"B`@("`@("`@("`@("`@("`@(G1A9R(L("!A("!S;W)T(&]F<
XM(&=O=&\@;&%B96PN('MT86=](&ES(&QO;VME9"!U<"!I;B!T:&4@=&%G<PH@K
XM("`@("`@("`@("`@("`@(&9I;&4L('1H92!A<W-O8VEA=&5D(&9I;&4@8F5CW
XM;VUE<R!T:&4@8W5R<F5N="`@9FEL92`@86YD("!T:&4*("`@("`@("`@("`@6
XM("`@("!A<W-O8VEA=&5D("!C;VUM86YD("!I<R`@97AE8W5T960N("!-;W-TC
XM;'D@=&AI<R!I<R!U<V5D(&9O<B!#"B`@("`@("`@("`@("`@("`@<')O9W)A)
XM;7,N('MT86=]('1H96X@<VAO=6QD(&)E(&$@9G5N8W1I;VX@;F%M92X@5&AE^
XM(&5F9F5C="!I<PH@("`@("`@("`@("`@("`@('1H870@('1H92`@9FEL92`@%
XM8V]N=&%I;FEN9R!T:&%T(&9U;F-T:6]N(&)E8V]M97,@=&AE(&-U<G)E;G0*-
XM("`@("`@("`@("`@("`@("!F:6QE(&%N9"!T:&4@(&-U<G-O<B`@:7,@('!O-
XM<VET:6]N960@(&]N("!T:&4@('-T87)T("!O9B`@=&AE"B`@("`@("`@("`@K
XM("`@("`@9G5N8W1I;VX@*'-E92!R969E<F5N8V4N9&]C+"!S96-T:6]N(")T5
XM86<@<V5A<F-H97,B*2X*"B`@("`@+64@6V5R<F]R9FEL95T*("`@("`@("`@!
XM("`@("`@("!3=&%R="!I;B!Q=6EC:T9I>"!M;V1E+B!4:&4@9FEL92!;97)RA
XM;W)F:6QE72!I<R!R96%D(&%N9"`@=&AE"B`@("`@("`@("`@("`@("`@9FER5
XM<W0@(&5R<F]R(&ES(&1I<W!L87EE9"X@268@6V5R<F]R9FEL95T@:7,@;VUIL
XM='1E9"!T:&4@9FEL90H@("`@("`@("`@("`@("`@(&YA;64@:7,@;V)T86ENV
XM960@9G)O;2!T:&4@("=E<G)O<F9I;&4G("!O<'1I;VX@("AD969A=6QT<R`@O
XM=&\*("`@("`@("`@("`@("`@("`B07IT96-#+D5R<B(@(&9O<B`@=&AE("!!K
XM;6EG82P@(")E<G)O<G,B("!O;B`@;W1H97(@<WES=&5M<RDN"B`@("`@("`@#
XM("`@("`@("`@1G5R=&AE<B!E<G)O<G,@8V%N(&)E(&IU;7!E9"!T;R!W:71HZ
XM('1H92`B.F-N(B`@8V]M;6%N9"X@(%-E90H@("`@("`@("`@("`@("`@(')E[
XM9F5R96YC92YD;V,@<V5C=&EO;B`U+C4N"@I/"$\(3U`(4`A05`A4"%1)"$D(V
XM24\(3PA/3@A."$Y3"%,(4PH@("`@(%1H92!O<'1I;VYS+"!I9B!P<F5S96YT\
XM+"!M=7-T('!R96-E9&4@=&AE(&9I;&5L:7-T+B!4:&4@(&]P=&EO;G,@(&UAS
XM>2`@8F4*("`@("!G:79E;B!I;B!A;GD@;W)D97(N"@H@("`@("UR("`@("`@?
XM("`@(%)E8V]V97)Y(&UO9&4N(%1H92!A=71O<V-R:7!T("!F:6QE("!I<R`@M
XM<F5A9"`@=&\@(')E8V]V97(@(&$*("`@("`@("`@("`@("`@("!C<F%S:&5D:
XM(&5D:71I;F<@<V5S<VEO;BX@270@:&%S(&%L;6]S="!T:&4@<V%M92!E9F9E<
XM8W0@87,@(BUS"B`@("`@("`@("`@("`@("`@9FEL92YV:6TB+B`@4V5E("!R0
XM969E<F5N8V4N9&]C+"`@8VAA<'1E<B`@(E)E8V]V97)Y("!A9G1E<B`@80H@"
XM("`@("`@("`@("`@("`@(&-R87-H(BX*"B`@("`@+78@("`@("`@("`@5FEE<
XM=R!M;V1E+B!4:&4@)W)E861O;FQY)R!O<'1I;VX@=VEL;"!B92!S970N(%EOQ
XM=2`@8V%N("!S=&EL;`H@("`@("`@("`@("`@("`@(&5D:70@('1H92`@8G5F=
XM9F5R+"`@8G5T("!W:6QL("!B92`@<')E=F5N=&5D("!F<F]M(&%C8VED96YT/
XM86P*("`@("`@("`@("`@("`@("!O=F5R=W)I=&EN9R!A(&9I;&4N($EF('EO]
XM=2!D;R!W86YT('1O(&]V97)W<FET92!A("!F:6QE+"`@861D"B`@("`@("`@,
XM("`@("`@("`@86X@(&5X8VQA;6%T:6]N("!M87)K("!T;R`@=&AE("!%>"`@0
XM8V]M;6%N9"P@87,@:6X@(CIW(2(N(%1H90H@("`@("`@("`@("`@("`@("=R>
XM96%D;VYL>2<@(&]P=&EO;B`@8V%N("!B92`@<F5S970@('=I=&@@("(Z<V5TL
XM("!N;W)O(B`@("AS964*("`@("`@("`@("`@("`@("!R969E<F5N8V4N9&]CB
XM+"!O<'1I;VYS(&-H87!T97(I+@H*("`@("`M8B`@("`@("`@("!":6YA<GDN,
XM($$@9F5W(&]P=&EO;G,@=VEL;"!B92!S970@=&AA="!M86ME<R!I="`@<&]SK
XM<VEB;&4@('1O"B`@("`@("`@("`@("`@("`@961I="!A(&)I;F%R>2!O<B!EN
XM>&5C=71A8FQE(&9I;&4N"@H@("`@("UX("`@("`@("`@("A!;6EG82!O;FQYM
XM*2!6:6T@:7,@;F]T(')E<W1A<G1E9"!T;R!O<&5N(&$@;F5W('=I;F1O=RX@6
XM(%1H:7,*("`@("`@("`@("`@("`@("!O<'1I;VX@('-H;W5L9"!B92!U<V5D"
XM('=H96X@5FEM(&ES(&5X96-U=&5D(&)Y(&$@<')O9W)A;2!T:&%T"B`@("`@@
XM("`@("`@("`@("`@=VEL;"!W86ET(&9O<B!T:&4@961I="!S97-S:6]N('1O"
XM("!F:6YI<V@@("AE+F<N("!M86EL*2X@(%1H90H@("`@("`@("`@("`@("`@V
XM("(Z<V@B(&%N9"`B.B$B(&-O;6UA;F1S('=I;&P@;F]T('=O<FLN"@H@("`@K
XM("UN("`@("`@("`@($YO(&%U=&]S8W)I<'0@9FEL92!W:6QL(&)E('=R:71T_
XM96XN(%)E8V]V97)Y("!A9G1E<B`@82`@8W)A<V@*("`@("`@("`@("`@("`@>
XM("!W:6QL("!B92`@:6UP;W-S:6)L92X@($AA;F1Y("!I9B!Y;W4@=V%N="!T2
XM;R!E9&ET(&$@9FEL92!O;B!A"B`@("`@("`@("`@("`@("`@=F5R>2!S;&]W)
XM(&UE9&EU;2`H92YG+B!F;&]P<'DI+B!#86X@86QS;R!B92!D;VYE("!W:71H,
XM("`B.G-E=`H@("`@("`@("`@("`@("`@('5C/3`B+@H*("`@("`M<R![<V-R>
XM:7!T:6Y]"B`@("`@("`@("`@("`@("`@5&AE('-C<FEP="!F:6QE('MS8W)IM
XM<'1I;GT@:7,@<F5A9"X@(%1H92`@8VAA<F%C=&5R<R`@:6X@('1H90H@("`@!
XM("`@("`@("`@("`@(&9I;&4@(&%R92`@:6YT97)P<F5T960@87,@:68@>6]U^
XM(&AA9"!T>7!E9"!T:&5M+B!4:&4@<V%M92!C86X*("`@("`@("`@("`@("`@2
XM("!B92!D;VYE('=I=&@@=&AE(&-O;6UA;F0@(CIS;W5R8V4A('MS8W)I<'1I0
XM;GTB+B!)9B!T:&4@96YD(&]F"B`@("`@("`@("`@("`@("`@=&AE("`@9FEL]
XM92`@:7,@(')E86-H960@(&)E9F]R92`@=&AE("!E9&ET;W(@(&5X:71S+"`@A
XM9G5R=&AE<@H@("`@("`@("`@("`@("`@(&-H87)A8W1E<G,@87)E(')E860@^
XM9G)O;2!T:&4@:V5Y8F]A<F0N"@H@("`@("UW('MS8W)I<'1O=71]"B`@("`@[
XM("`@("`@("`@("`@06QL('1H92!C:&%R86-T97)S('1H870@>6]U('1Y<&4@*
XM87)E("!R96-O<F1E9"`@:6X@('1H92`@9FEL90H@("`@("`@("`@("`@("`@"
XM('MS8W)I<'1O=71]+"`@=6YT:6P@('EO=2!E>&ET(%9)32X@5&AI<R!I<R!U7
XM<V5F=6P@:68@>6]U('=A;G0*"@H@("`@("`@("`@("`@("`@("`@("`@("`@C
XM("`@("`@(#(X($UA<F-H(#$Y.3(@("`@("`@("`@("`@("`@("`@("`@("`@J
XM("`@("`@(#(*"@P*"E9)32@Q*2`@("`@("`@("`@("`@("`@("`@("`@("`@T
XM55-%4B!#3TU-04Y$4R`@("`@("`@("`@("`@("`@("`@("`@("`@(%9)32@Q6
XM*0H*"B`@("`@("`@("`@("`@("`@=&\@8W)E871E("!A("!S8W)I<'0@(&9IC
XM;&4@('1O("!B92`@=7-E9"`@=VET:"`@(G9I;2`@+7,B("!O<@H@("`@("`@C
XM("`@("`@("`@("(Z<V]U<F-E(2(N"@H@("`@("U4('1E<FUI;F%L(%1E;&QSS
XM(%9I;2!T:&4@;F%M92!O9B!T:&4@=&5R;6EN86P@>6]U(&%R92!U<VEN9RX@I
XM4VAO=6QD(&)E(&$*("`@("`@("`@("`@("`@("!T97)M:6YA;"`@:VYO=VX@J
XM('1O("!6:6T@("AB=6EL=&EN*2!O<B!D969I;F5D(&EN('1H92!T97)M8V%P+
XM"B`@("`@("`@("`@("`@("`@9FEL92X*"B`@("`@+60@9&5V:6-E("`@3W!E1
XM;B`B9&5V:6-E(B!F;W(@=7-E(&%S("!A("!T97)M:6YA;"X@($]N;'D@(&]NT
XM("!T:&4@($%M:6=A+@H@("`@("`@("`@("`@("`@($5X86UP;&4Z("`B+60@1
XM8V]N.C(P+S,P+S8P,"\Q-3`B+@H*4PA3"%-%"$4(144(10A%($$(00A!3`A,V
XM"$Q3"%,(4T\(3PA/"B`@("`@5FEM("!D;V-U;65N=&%T:6]N.B`@4F5F97)E]
XM;F-E+F1O8RP@(&EN9&5X+"`@(&1I9F9E<F5N8V4N9&]C+"`@('5N:7@N9&]C-
XM+`H@("`@('9I;2YH;'`N"@I!"$$(054(50A55`A4"%1("$@(2$\(3PA/4@A25
XM"%(*("`@("!-;W-T(&]F(%9)32!W87,@;6%D92!B>2!"<F%M($UO;VQE;F%AS
XM<BX*("`@("!624T@:7,@8F%S960@;VX@4W1E=FEE+"!W;W)K960@;VX@8GDZH
XM(%1I;2!4:&]M<'-O;BP@5&]N>2!!;F1R97=S(&%N9"!'+E(N"B`@("`@*$9R>
XM960I(%=A;'1E<@H*0@A""$)5"%4(54<(1PA'4PA3"%,*("`@("!0<F]B86)L4
XM>2X*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"@H*"B`@("`@#
XM("`@("`@("`@("`@("`@("`@("`@("`@("`@,C@@36%R8V@@,3DY,B`@("`@J
X>("`@("`@("`@("`@("`@("`@("`@("`@("`@,PH*G
X``
Xend
Xsize 6870
END_OF_FILE
if test 9655 -ne `wc -c <'vim/doc/vim_man.uue'`; then
echo shar: \"'vim/doc/vim_man.uue'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/vim_man.uue'
# end of 'vim/doc/vim_man.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'\" \(9305 characters\)
sed "s/^X//" >'vim/src/globals.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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
X/*
X * Number of Rows and Columns in the current window.
X * Must be long to be able to use them as options in param.c.
X */
XEXTERN long Rows; /* currently used nr. of rows */
XEXTERN long Columns;
XEXTERN long Rows_max; /* maximal physical nr. of rows */
X
XEXTERN char *Filename INIT(= NULL); /* Current file name */
XEXTERN char *sFilename INIT(= NULL); /* Filename without path */
XEXTERN char *xFilename INIT(= NULL); /* Filename maybe without path */
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 int redraw_msg INIT(= TRUE);
X /* TRUE when "insert mode" needs updating */
XEXTERN int emptyrows INIT(= 0); /* number of '~' rows on 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 cmdoffset INIT(= 0); /* offset for command line position */
XEXTERN int ru_col; /* column for ruler */
XEXTERN int sc_col; /* column for shown command */
X
XEXTERN int char_count; /* number of characters sent to screen */
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 Visual; /* start position of Visual
X * (Visual.lnum == 0 when not active) */
XEXTERN int Visual_block INIT(= FALSE);
X /* Visual 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 old_indent INIT(= 0); /* for ^^D command in insert mode */
X
X/*
X * This flag is set after doing a reverse replace in column 0.
X * An extra space has been inserted in column 0.
X */
XEXTERN int extraspace 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 register */
XEXTERN int Exec_reg INIT(= FALSE); /* TRUE when executing a register */
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 NotEdited INIT(= FALSE);/* Set to TRUE with ":file xxx" command,
X * reset when file is 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 int did_cd INIT(= FALSE); /* TRUE when :cd dir used */
XEXTERN int no_abbr INIT(= TRUE); /* TRUE when no abbreviations loaded */
X
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 */
XEXTERN int must_redraw INIT(= 0); /* type of redraw necessary */
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 */
XEXTERN int files_exp INIT(= FALSE); /* *files must be freed */
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 termcap_active INIT(= FALSE); /* set to TRUE by starttermcap() */
XEXTERN int bangredo INIT(= FALSE); /* set to TRUE whith ! command */
XEXTERN int searchcmdlen; /* length of previous search command */
XEXTERN int did_outofmem_msg INIT(= FALSE); /* set after out of memory msg */
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/*
X * The error messages that can be shared are included here.
X * Excluded are very specific errors and debugging messages.
X */
XEXTERN char e_abbr[] INIT(="No such abbreviation");
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(="Command not allowed from 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_scroll[] INIT(="Invalid scroll 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 9305 -ne `wc -c <'vim/src/globals.h'`; then
echo shar: \"'vim/src/globals.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/globals.h'
# end of 'vim/src/globals.h'
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'\" \(8112 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### -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### -Dconst for compilers that don't have type const


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 = -DDIGRAPHS -DSOME_BUILTIN_TCAPS -DVIM_ISSPACE


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 8112 -ne `wc -c <'vim/src/makefile.manx'`; then
echo shar: \"'vim/src/makefile.manx'\" unpacked with wrong size!
fi
chmod +x 'vim/src/makefile.manx'
# end of 'vim/src/makefile.manx'
fi
if test -f 'vim/src/makefile.sas' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/makefile.sas'\"
else
echo shar: Extracting \"'vim/src/makefile.sas'\" \(7825 characters\)
sed "s/^X//" >'vim/src/makefile.sas' <<'END_OF_FILE'
X#
X# Makefile for VIM on the Amiga, using SAS/Lattice C 6.0 to 6.3
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 and 6.3 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=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=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 to 6.3, 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 7825 -ne `wc -c <'vim/src/makefile.sas'`; then
echo shar: \"'vim/src/makefile.sas'\" unpacked with wrong size!
fi
chmod +x 'vim/src/makefile.sas'
# end of 'vim/src/makefile.sas'
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'\" \(9080 characters\)
sed "s/^X//" >'vim/src/tag.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 *));
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 = "No tags file";
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 continue;
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 white space */
X fname = lbuf;
X skiptospace(&fname); /* skip tag */
X if (*fname == NUL)
X goto erret;
X *fname++ = '\0';
X
X if (strncmp(lbuf, tag, (size_t)cmplen) == 0) /* Tag found */
X {
X fclose(tp);
X skipspace(&fname);
X
X /* find start of search command, after second white space */
X str = fname;
X skiptospace(&str);
X if (*str == NUL)
X goto erret;
X *str++ = '\0';
X skipspace(&str);
X
X /*
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 '\r':

X case '\n': *p++ = pbuf[0]; /* copy '/' or '?' */
X *str = 'n'; /* no setpcmark() for search */
X str[1] = NUL; /* delete NL after CR */
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 the search char */
X break;
X /* last char */
X if (str[1] == '\n' || str[1] == '\r')
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 /* expand filename (for environment variables) */
X if ((p = ExpandOne((u_char *)fname, 1, -1)) != NULL)
X fname = p;
X i = getfile(fname, NULL, TRUE);
X if (p)
X free(p);


X if (i <= 0)
X {

X set_want_col = TRUE;


X
X RedrawingDisabled = FALSE;

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 /* print the file message after redraw */
X if (p_im && i == -1)
X stuffReadbuff("\033\007i"); /* ESC CTRL-G i */
X else
X stuffcharReadbuff('\007'); /* CTRL-G */
X return 1;
X }
X RedrawingDisabled = FALSE;


X return 0;
X }
X }

X m = NULL;
X
Xerret:
X fclose(tp);
X if (m)
X {
X emsg2(m, sbuf);
X sleep(1);
X }
X }
X if (m == NULL)
X emsg("tag not found");
X else if (*np == NUL)
X emsg(m);
X return 0;
X}
END_OF_FILE
if test 9080 -ne `wc -c <'vim/src/tag.c'`; then
echo shar: \"'vim/src/tag.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/tag.c'
# end of 'vim/src/tag.c'
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'\" \(8136 characters\)
sed "s/^X//" >'vim/src/vim.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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_UNIX) || defined(BSD_UNIX)
X# ifndef UNIX
X# define UNIX
X# endif
X#endif
X
X#include "debug.h"
X
X#include <stdio.h>
X
X#include <ctype.h>
X#ifndef DOMAIN
X#include <limits.h> /* For MAX_INT, remove this if it does not exist */
X#endif
X
X#ifdef BSD_UNIX
X# include <strings.h>
X# ifdef __STDC__
X# include <string.h>
X# endif
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#ifndef DOMAIN
X# include <stdlib.h>
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 SOLARIS
X# include <stdlib.h>
X# include <unistd.h>
X#endif
X
X#ifdef UNIX
X# ifdef SCO
X# undef M_XENIX
X# include <sys/ndir.h> /* for MAXNAMLEN */
X# else
X# if defined(SOLARIS) || defined(AIX)
X# include <dirent.h> /* for MAXNAMLEN */
X# else
X# include <sys/dir.h> /* for MAXNAMLEN */
X# endif
X# endif
X# ifdef USL
X# define MAXNAMLEN DIRSIZ
X# endif
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 before .99p3 */
X# endif
X# if !defined(MAXNAMLEN)
X# define MAXNAMLEN 512 /* for all other Unix */
X# endif
X#endif
X
X#ifdef UNICOS /* would make sense for other systems too */
X# include <errno.h>
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) && !defined(SOLARIS)
X# include "sun_stdlib.h"
X# endif
X# if defined(linux) || defined(SCO) || defined(M_UNIX)
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/*
X * The lowest three bits are used to distinguish normal/cmdline/insert+replace
X * mode. This is used for mapping.
X */
X#define NORMAL 0x01
X#define NORMAL_BUSY 0x11 /* busy interpreting a command */
X#define CMDLINE 0x02
X#define INSERT 0x04
X#define REPLACE 0x24 /* replace mode */
X#define HELP 0x30 /* displaying help */
X#define NOMAPPING 0x40 /* no :mapping mode for vgetc() */
X#define HITRETURN 0x51 /* waiting for a return */
X#define SETWSIZE 0x60 /* window size has changed */
X#define ABBREV 0x80 /* abbreviation instead of mapping */
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 VISUALLINE MAXCOL /* Visual 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 width
X */
X#define MAX_COLUMNS 255L
X
X/*
X * Buffer sizes
X */
X#ifdef UNIX /* Unix has plenty of memory */
X# define CMDBUFFSIZE 1024 /* size of the command processing buffer */
X#else
X# define CMDBUFFSIZE 256 /* size of the command processing buffer */
X#endif
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_UNIX) && !defined(linux) && !defined(SASC) && !defined(__sgi) && !defined(SCO) && !defined(hpux) && !defined(SOLARIS) && !defined(M_UNIX) && !defined(AIX) && !defined(_UTS) && !defined(USL)
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#if defined(BSD_UNIX) && !defined(__STDC__)
X# define strchr(ptr, c) index((ptr), (c))
X# define strrchr(ptr, c) rindex((ptr), (c))
X#endif
X
X#ifdef BSD_UNIX
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#ifdef MAX_INT
X# define MAXCOL MAX_INT /* maximum column number */
X#else
X# define MAXCOL 32767 /* maximum column number */
X#endif
X
Xstruct fpos
X{
X linenr_t lnum; /* line number */
X colnr_t col; /* column number */
X};
X
X/*
X * Some versions of isspace() handle Meta character like a space!
X * This define fixes that.
X */
X#ifdef VIM_ISSPACE
X# ifdef isspace
X# undef isspace
X# endif /* isspace */
X# define isspace(x) (((x) >= 9 && (x) <= 13) || ((x) == 32))
X#endif /* VIM_ISSPACE */
END_OF_FILE
if test 8136 -ne `wc -c <'vim/src/vim.h'`; then
echo shar: \"'vim/src/vim.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/vim.h'
# end of 'vim/src/vim.h'
fi
echo shar: End of archive 4 \(of 25\).
cp /dev/null ark4isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:44:49 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 56
Archive-name: vim/part06

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/script.c vim/src/term.h vim/src/termlib.c
# vim/src/undo.c
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:05 1993


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

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'\" \(12921 characters\)
sed "s/^X//" >'vim/src/script.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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#ifdef UNIX
X# ifdef SCO

X mode_t oldmask;
X# else
X int oldmask;
X# endif
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) && xFilename && getperm(xFilename) < 0)
X dummyfd = fopen(xFilename, "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 UNIX
X /*
X * Disallow others to read our .vim file. This is useful if the
X * .vim file is put in some public place like /tmp.
X */
X# ifdef SCO
X oldmask = umask((mode_t)066); /* rw------- */
X# else
X oldmask = umask(066); /* rw------- */
X# endif
X#endif
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#ifdef UNIX
X umask(oldmask); /* back to default umask */
X#endif
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 if (!recoverymode)
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(xFilename);
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 recoverymode = 0;
X if (got_int)
X emsg("Recovery Interrupted");
X else
X msg("Recovery completed; If everything is OK: Save this file and delete the .vim file");
X /* The cursor will be in the wrong place after the msg() */
X /* We need to fix it here because we are called from inchar() */
X setcursor();
X flushbuf();
X }
X else
X {
X fname = makescriptname();
X if (fname)
X {
X recoverymode = 2;
X if (xFilename != NULL &&
X stat(xFilename, &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(xFilename, ".vim");
X if (*p_dir == 0 || r == NULL)
X return r;
X
X fname = gettail(r);
X s = alloc((unsigned)(strlen(p_dir) + strlen(fname) + 1));
X if (s != NULL)
X {
X strcpy(s, p_dir);
X if (*s && !ispathsep(*(s + strlen(s) - 1))) /* don't add '/' after ':' */
X strcat(s, PATHSEPSTR);
X strcat(s, fname);
X }
X free(r);
X return s;
X}
X
X/*
X * add full path to auto script name, used before first :cd command.
X */
X void
Xscriptfullpath()
X{
X char *s;
X
X if (!autoscriptfd)
X return; /* nothing to do */
X /*
X * on the Amiga we cannot get the full path name while the file is open
X * so we close it for a moment
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#endif
X
X if (FullName(scriptname, IObuff, IOSIZE))
X {
X s = strsave(IObuff);
X if (s)
X {
X free(scriptname);
X scriptname = s;
X }
X }
X
X#ifdef AMIGA
X# ifndef NO_ARP
X if (dos2)
X# endif
X {
X autoscriptfd = (FILE *)Open((UBYTE *)scriptname, (long)MODE_OLDFILE);
X if (autoscriptfd)
X Seek((BPTR)autoscriptfd, 0L, (long)OFFSET_END);
X }
X# ifndef NO_ARP
X else
X autoscriptfd = fopen(scriptname, "a");
X# endif
X#endif
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 if (ispathsep(*ptr))
X break;
X }
X ptr++;
X
X /* the filename has at most BASENAMELEN characters. */
X if (strlen(ptr) > (unsigned)BASENAMELEN)
X ptr[BASENAMELEN] = '\0';
X#ifndef MSDOS
X if ((p_sn || thisfile_sn) && strlen(ptr) > (unsigned)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 12921 -ne `wc -c <'vim/src/script.c'`; then
echo shar: \"'vim/src/script.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/script.c'
# end of 'vim/src/script.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'\" \(13223 characters\)
sed "s/^X//" >'vim/src/term.h' <<'END_OF_FILE'


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

X * term.h -- VIM - Vi IMproved


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 TERMINFO
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 nansi.sys or equivalent has been installed.
X * Function keys on a PC are preceded with a NUL. These are converted into
X * K_NUL '\316' in GetChars(), because we cannot handle NULs in key codes.
X * CTRL-arrow is used instead of SHIFT-arrow.
X */
X# define PCANSI_TCAP "pcansi\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\316H\0\
X\0\316P\0\
X\0\316K\0\
X\0\316M\0\
X\2\316s\0\
X\0\316t\0\
X\0\316;\0\
X\0\316<\0\
X\0\316=\0\
X\0\316>\0\
X\0\316?\0\
X\0\316@\0\
X\0\316A\0\
X\0\316B\0\
X\0\316C\0\
X\0\316D\0\
X\0\316T\0\
X\0\316U\0\
X\0\316V\0\
X\0\316W\0\
X\0\316X\0\
X\0\316Y\0\
X\0\316Z\0\
X\0\316[\0\
X\0\316\\\0\
X\0\316]\0\
X\0\0"
X
X/*
X * These codes are valid for the pc video.
X * The entries that start with ESC | are translated into conio calls in msdos.c.
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|J\0\
X\2\033|0m\0\
X\0\033|79m\0\
X\0\033|%i%d;%dH\0\
X\7\316H\0\
X\0\316P\0\
X\0\316K\0\
X\0\316M\0\
X\2\316s\0\
X\0\316t\0\
X\0\316;\0\
X\0\316<\0\
X\0\316=\0\
X\0\316>\0\
X\0\316?\0\
X\0\316@\0\
X\0\316A\0\
X\0\316B\0\
X\0\316C\0\
X\0\316D\0\
X\0\316T\0\
X\0\316U\0\
X\0\316V\0\
X\0\316W\0\
X\0\316X\0\
X\0\316Y\0\
X\0\316Z\0\
X\0\316[\0\
X\0\316\\\0\
X\0\316]\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/*
X * The xterm termcap is missing F14 and F15, because they send the same
X * codes as the undo and help key, although they don't work on all keyboards.
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[H\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\033=\0\
X\0\033[?1l\033>\0\
X\0\0337\033[?47h\0\
X\0\033[2J\033[?47l\0338\0\
X\0\033OA\0\
X\0\033OB\0\
X\0\033OD\0\
X\0\033OC\0\
X\0\033Ox\0\
X\0\033Or\0\
X\0\033Ot\0\
X\0\033Ov\0\
X\0\033[11~\0\
X\0\033[12~\0\
X\0\033[13~\0\
X\0\033[14~\0\
X\0\033[15~\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\0\033[25~\0\
X\2\033[29~\0\
X\0\033[31~\0\
X\0\033[32~\0\
X\0\033[33~\0\
X\0\033[34~\0\
X\0\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# else /* NO_BUILTIN_TCAPS */
X# define DUMB_TCAP "dumb\0\
X\5\014\0\
X\4\033[%i%d;%dH\0\
X\0\0"
X# endif /* NO_BUILTIN_TCAPS */
X
X#else /* TERMINFO */
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[%p1%dL\0\
X\0\033[M\0\
X\0\033[%p1%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%p1%d;%p2%dH\0\
X\1\033[%p1%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[%p1%dL\0\
X\0\033[M\0\
X\0\033[%p1%dM\0\
X\0\033[2J\0\
X\2\033[0m\0\
X\0\033[7m\0\
X\0\033[%i%p1%d;%p2%dH\0\
X\1\033[%p1%dC\0\
X\0\0"
X
X/*
X * These codes are valid when nansi.sys or equivalent has been installed.
X * Function keys on a PC are preceded with a NUL. These are converted into
X * K_NUL '\316' in GetChars(), because we cannot handle NULs in key codes.
X * CTRL-arrow is used instead of SHIFT-arrow.
X */
X# define PCANSI_TCAP "pcansi\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%p1%d;%p2%dH\0\
X\1\033[%p1%dC\0\
X\5\316H\0\
X\0\316P\0\
X\0\316K\0\
X\0\316M\0\
X\2\316s\0\
X\0\316t\0\
X\0\316;\0\
X\0\316<\0\
X\0\316=\0\
X\0\316>\0\
X\0\316?\0\
X\0\316@\0\
X\0\316A\0\
X\0\316B\0\
X\0\316C\0\
X\0\316D\0\
X\0\316T\0\
X\0\316U\0\
X\0\316V\0\
X\0\316W\0\
X\0\316X\0\
X\0\316Y\0\
X\0\316Z\0\
X\0\316[\0\
X\0\316\\\0\
X\0\316]\0\
X\0\0"
X
X/*
X * These codes are valid for the pc video.
X * The entries that start with ESC | are translated into conio calls in msdos.c.
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|J\0\
X\2\033|0m\0\
X\0\033|79m\0\
X\0\033|%i%p1%d;%p2%dH\0\
X\7\316H\0\
X\0\316P\0\
X\0\316K\0\
X\0\316M\0\
X\2\316s\0\
X\0\316t\0\
X\0\316;\0\
X\0\316<\0\
X\0\316=\0\
X\0\316>\0\
X\0\316?\0\
X\0\316@\0\
X\0\316A\0\
X\0\316B\0\
X\0\316C\0\
X\0\316D\0\
X\0\316T\0\
X\0\316U\0\
X\0\316V\0\
X\0\316W\0\
X\0\316X\0\
X\0\316Y\0\
X\0\316Z\0\
X\0\316[\0\
X\0\316\\\0\
X\0\316]\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/*
X * The xterm termcap is missing F14 and F15, because they send the same
X * codes as the undo and help key, although they don't work on all keyboards.
X */
X# define XTERM_TCAP "xterm\0\
X\0\033[K\0\
X\0\033[L\0\
X\0\033[%p1%dL\0\
X\0\033[M\0\
X\0\033[%p1%dM\0\
X\0\033[H\033[2J\0\
X\2\033[m\0\
X\0\033[7m\0\
X\0\033[%i%p1%d;%p2%dH\0\
X\0\033M\0\
X\0\033[%p1%dC\0\
X\1\033[?1h\033=\0\
X\0\033[?1l\033>\0\
X\0\0337\033[?47h\0\
X\0\033[2J\033[?47l\0338\0\
X\0\033OA\0\
X\0\033OB\0\
X\0\033OD\0\
X\0\033OC\0\
X\0\033Ox\0\
X\0\033Or\0\
X\0\033Ot\0\
X\0\033Ov\0\
X\0\033[11~\0\
X\0\033[12~\0\
X\0\033[13~\0\
X\0\033[14~\0\
X\0\033[15~\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\0\033[25~\0\
X\2\033[29~\0\
X\0\033[31~\0\
X\0\033[32~\0\
X\0\033[33~\0\
X\0\033[34~\0\
X\0\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%p1%d]\0\
X\0[DL]\0\
X\0[CDL%p1%d]\0\
X\0[ED]\0\
X\0[CI]\0\
X\0[CV]\0\
X\0[TP]\0\
X\0[TI]\0\
X\0[%p1%dCM%p2%d]\0\
X\0[SR]\0\
X\0[CRI%p1%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# else /* NO_BUILTIN_TCAPS */
X/*
X * The most minimal terminal: only clear screen and cursor positioning
X */
X# define DUMB_TCAP "dumb\0\
X\5\014\0\
X\4\033[%i%p1%d;%p2%dH\0\
X\0\0"
X# endif /* NO_BUILTIN_TCAPS */
X
X#endif
END_OF_FILE
if test 13223 -ne `wc -c <'vim/src/term.h'`; then
echo shar: \"'vim/src/term.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/term.h'
# end of 'vim/src/term.h'
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
chmod +x 'vim/src/termlib.c'
# end of 'vim/src/termlib.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'\" \(14257 characters\)
sed "s/^X//" >'vim/src/undo.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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, linenr_t));
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, FALSE, (linenr_t)0));
X}
X
X/*
X * save the line "lnum" (used by :s command)
X * the line is handed over to the undo routines
X * The line is replaced, so the new bottom line is lnum + 1.
X */
X int
Xu_savesub(lnum)
X linenr_t lnum;
X{
X return (u_savecommon(lnum - 1, lnum + 1, TRUE, lnum + 1));
X}
X
X/*
X * a new line is inserted before line "lnum" (used by :s command)
X * The line is inserted, so the new bottom line is lnum + 1.
X */
X int
Xu_inssub(lnum)
X linenr_t lnum;
X{
X return (u_savecommon(lnum - 1, lnum, TRUE, lnum + 1));
X}
X
X/*
X * save the lines "lnum" - "lnum" + nlines (used by delete command)
X * the lines are handed over to the undo routines
X * The lines are deleted, so the new bottom line is lnum.
X */
X int
Xu_savedel(lnum, nlines)
X linenr_t lnum;
X long nlines;
X{
X return (u_savecommon(lnum - 1, lnum + nlines, TRUE, lnum));
X}
X
X static int
Xu_savecommon(top, bot, nocopy, newbot)
X linenr_t top, bot;
X int nocopy;
X linenr_t newbot;


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 if (p_ul < 0) /* no undo at all */
X goto noundo;
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 size = bot - top - 1;
X#ifndef UNIX
X /*
X * With Amiga and MSDOS we can't handle big undo's, because then
X * alloc_line would have to allocate a block larger than 32K
X */
X if (size >= 8000)
X goto nomem;
X#endif
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 uep->ue_size = size;
X uep->ue_top = top;
X uep->ue_botptr = NULL;
X if (newbot)
X uep->ue_bot = newbot;
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 for (i = 0, lnum = top + 1; i < size; ++i)
X {
X if (nocopy)
X uep->ue_array[i] = nr2ptr(lnum++);
X else if ((uep->ue_array[i] = save_line(nr2ptr(lnum++))) == NULL)
X {
X u_freeentry(uep, i);
X goto nomem;
X }
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 (ask_yesno("no undo possible; continue anyway") == 'y')
X {
Xnoundo:
X if (nocopy)
X for (lnum = top + 1; lnum < bot; ++lnum)
X free_line(nr2ptr(lnum));


X return TRUE;
X }
X return FALSE;
X}
X

X void
Xu_undo(count)
X int count;
X{
X /*
X * If we get an undo command while executing a macro, we behave like the
X * original vi. If this happens twice in one macro the result will not
X * be compatible.
X */
X if (u_synced == FALSE)
X {
X u_sync();
X count = 1;
X }
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;
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 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 || bot > line_count + 1)
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, oldsize != newsize);
X }
X
X /* adjust the marks if the number of lines does not change */
X if (oldsize == newsize)
X for (i = 0; i < oldsize; ++i)
X adjustmark(newarray[i], uep->ue_array[i]);
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 = top + newsize + 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 changes (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 change%s", 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, FALSE, (linenr_t)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 14257 -ne `wc -c <'vim/src/undo.c'`; then
echo shar: \"'vim/src/undo.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/undo.c'
# end of 'vim/src/undo.c'
fi
echo shar: End of archive 6 \(of 25\).
cp /dev/null ark6isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:43:42 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 53
Archive-name: vim/part03

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/msdos.doc vim/src/arp_proto.h vim/src/cmdtab.h
# vim/src/cmdtab.tab vim/src/makefile.unix vim/src/param.h
# vim/src/regsub.c vim/todo
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:04 1993


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

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'\" \(6542 characters\)
sed "s/^X//" >'vim/doc/msdos.doc' <<'END_OF_FILE'
XThis file contains the particularities for the MSDOS version of Vim.
X
XThe default output method is to use bios calls. This will work right away on
Xmost systems. You do not need ansi.sys.
X
XYou can set the color used in vim with two termcap options:
X
X ":set t_tp=^V^[\|xxm" for normal text
X ":set t_ti=^V^[\|xxm" for error messages and visual mode
X
X^V is CTRL-V
X^[ is ESC
Xxx must be replaced by a decimal code: The foreground color number and
X background color number added together:
X
XCOLOR FOREGROUND BACKGROUND
Xblack 0 0
Xblue 1 16
Xgreen 2 32
Xcyan 3 48
Xred 4 64
Xmagenta 5 80
Xbrown 6 96
Xlighgray 7 112
Xdarkgray 8
Xlightblue 9
Xlightgreen 10
Xlighcyan 11
Xlightred 12
Xlighmagenta 13
Xyellow 14
Xwhite 15
Xblink 128
X
XWhen you use 0, the color is reset to the one used when you started Vim. This
Xis the default for t_tp. The default for t_ti is white on red, 15 + 64 = 79.
X
XThe termcap codes that are translated into bios calls are:
X ESC |J clear screen
X ESC |K clear to end of line
X ESC |L insert line
X ESC |M delete line
X ESC |row;colH position cursor
X ESC |attrm set character attribute
X
XIf you want to use another output method (e.g. when using a terminal on a COM
Xport), set the terminal name to "pcansi". You can change the termcap options
Xwhen needed (see chapter 20 of reference.doc). Note that the normal IBM
Xansi.sys does not support all the codes of the builtin pcansi terminal. If
Xyou use ansi.sys you will need to delete the termcap entries t_il and t_dl
Xwith
X ":set t_il= t_dl=".
XOtherwise the screen will not be updated correctly. It is better to use
Xnansi.sys, nnansi.sys or the like instead of ansi.sys.
X
XIf you want to use Vim on a terminal connected to a COM: port, reset the
X'bioskey' option. Otherwise the commands will be read from the PC keyboard.
XCTRL-C and CTRL-P may not work correctly with 'bioskey' reset.
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>. If the "tx" option is not set the single <LF> will be used for
Xend-of-line. A <CR> will be shown as ^M. You can use Vim to replace <LF> by
X<CR><LF> by reading in any mode and writing in text mode. You can use Vim to
Xreplace <CR><LF> by <LF> by reading in text mode and writing in non-text
Xmode. 'textmode' is set automatically when 'textauto' is on (which is the
Xdefault), so you don't really have to worry about what you are doing.
X
XIf you want to edit a script file or a binary file you should reset the
X'textmode' and 'textauto' options before loading the file. Script files
Xcontain single <LF> characters which would be replaced by <CR><LF>. You can
Xdo this by starting Vim with the "-b" (binary) option.
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 ":cd" command recognizes the drive specifier and changes the current
Xdrive. Use ":cd c:" to make drive C the active drive. Use ":cd d:\dos" to go
Xto the directory "dos" in the root of drive D.
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". To use the file "c:\_vimrc" use the command "set vim=c:".
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
XIf you want to use different colors set the termcap code t_tp (for normal
Xtext) and/or t_ti (for inverted text).
X
XStandard ANSI escape sequences are used. The codes are:

X30 black foreground 40 black background 0 all attributes off
X31 red foreground 41 red background 1 high intensity (bold)
X32 green foreground 42 green background 2 normal intensity
X33 yellow foreground 43 yellow background 4 underline
X34 blue foreground 44 blue background 5 blinking
X35 magenta foreground 45 magenta background 7 reverse video
X36 cyan foreground 46 cyan background 8 invisible
X37 white foreground 47 white background
X
XThe codes can be combined by separating them with a semicolon. For example to
Xget white text on a blue background:
X :set t_tp=^V<ESC>[0;37;44m
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 Borland-C++ version 3.1, using
Xmakefile.bcc. Other compilers should also work. Use makefile.dos for Turbo-C
X2.0. Use makefile.bcc for other Borland compilers, also Turbo-C++ 3.0 (with
Xsmall changes). If you get all kinds of strange error messages when compiling,
Xyou have to add <CR> characters at the end of each line. This can be done with
Xthe addcr program: "make addcr". This will compile addcr.c to addcr.exe and
Xexecute the addcr.bat file. Sometimes this fails. Then execute the addcr.bat
Xfile from the DOS prompt.
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. Setting 'undolevels' to 0 saves some memory. Running the
Xmaze macros on a big maze is guaranteed to run out of memory, because each
Xchange is remembered for undo. In this case set 'undolevels' to a negative
Xnumber. This will switch off undo completely. In a future release extended
Xmemory and/or a swap file will be used to avoid these problems.
X
XThe *.info files are for the Amiga. You don't need them with MSDOS.
END_OF_FILE
if test 6542 -ne `wc -c <'vim/doc/msdos.doc'`; then
echo shar: \"'vim/doc/msdos.doc'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/msdos.doc'
# end of 'vim/doc/msdos.doc'
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
chmod +x 'vim/src/arp_proto.h'
# 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'\" \(7223 characters\)
sed "s/^X//" >'vim/src/cmdtab.h' <<'END_OF_FILE'
X/* vi:ts=4


X *
X * VIM - Vi IMproved
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+USECTRLV},
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 {"cabbrev", EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_cabbrev 4
X {"cc", TRLBAR+WORD1+BANG},
X#define CMD_cc 5
X {"cd", NAMEDF+TRLBAR},
X#define CMD_cd 6
X {"center", TRLBAR+RANGE+EXTRA},
X#define CMD_center 7
X {"cf", TRLBAR+FILE1+BANG},
X#define CMD_cf 8
X {"chdir", NAMEDF+TRLBAR},
X#define CMD_chdir 9
X {"cl", TRLBAR},
X#define CMD_cl 10
X {"cmap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_cmap 11
X {"cn", TRLBAR+BANG},
X#define CMD_cn 12
X {"cnoremap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_cnoremap 13
X {"cnoreabbrev", EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_cnoreabbrev 14
X {"copy", RANGE+EXTRA+TRLBAR},
X#define CMD_copy 15
X {"cp", TRLBAR+BANG},
X#define CMD_cp 16
X {"cq", TRLBAR+BANG},
X#define CMD_cq 17
X {"cunmap", BANG+EXTRA+TRLBAR+USECTRLV},
X#define CMD_cunmap 18
X {"cunabbrev", EXTRA+TRLBAR+USECTRLV},
X#define CMD_cunabbrev 19
X {"delete", RANGE+REGSTR+COUNT+TRLBAR},
X#define CMD_delete 20
X {"display", TRLBAR},
X#define CMD_display 21
X {"digraphs", EXTRA+TRLBAR},
X#define CMD_digraphs 22
X {"edit", BANG+FILE1+TRLBAR},
X#define CMD_edit 23
X {"ex", BANG+FILE1+TRLBAR},
X#define CMD_ex 24
X {"file", FILE1+TRLBAR},
X#define CMD_file 25
X {"files", TRLBAR},
X#define CMD_files 26
X {"global", RANGE+BANG+EXTRA+DFLALL},
X#define CMD_global 27
X {"help", TRLBAR},
X#define CMD_help 28
X {"insert", BANG+RANGE+TRLBAR}, /* not supported */
X#define CMD_insert 29
X {"iabbrev", EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_iabbrev 30
X {"imap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_imap 31
X {"inoremap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_inoremap 32
X {"inoreabbrev", EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_inoreabbrev 33
X {"iunmap", BANG+EXTRA+TRLBAR+USECTRLV},
X#define CMD_iunmap 34
X {"iunabbrev", EXTRA+TRLBAR+USECTRLV},
X#define CMD_iunabbrev 35
X {"join", RANGE+COUNT+TRLBAR},
X#define CMD_join 36
X {"jumps", TRLBAR},
X#define CMD_jumps 37
X {"k", RANGE+WORD1+TRLBAR},
X#define CMD_k 38
X {"list", RANGE+COUNT+TRLBAR},
X#define CMD_list 39
X {"left", TRLBAR+RANGE+EXTRA},
X#define CMD_left 40
X {"move", RANGE+EXTRA+TRLBAR},
X#define CMD_move 41
X {"mark", RANGE+WORD1+TRLBAR},
X#define CMD_mark 42
X {"marks", TRLBAR},
X#define CMD_marks 43
X {"map", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_map 44
X {"make", NEEDARG+EXTRA+TRLBAR+XFILE},
X#define CMD_make 45
X {"mkexrc", BANG+FILE1+TRLBAR},
X#define CMD_mkexrc 46
X {"mkvimrc", BANG+FILE1+TRLBAR},
X#define CMD_mkvimrc 47
X {"next", RANGE+BANG+NAMEDFS+TRLBAR},
X#define CMD_next 48
X {"number", RANGE+COUNT+TRLBAR},
X#define CMD_number 49
X {"noremap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_noremap 50
X {"noreabbrev", EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X#define CMD_noreabbrev 51
X {"Next", RANGE+BANG+TRLBAR},
X#define CMD_Next 52
X {"print", RANGE+COUNT+TRLBAR},
X#define CMD_print 53
X {"pop", RANGE+TRLBAR+ZEROR},
X#define CMD_pop 54
X {"put", RANGE+BANG+REGSTR+TRLBAR},
X#define CMD_put 55
X {"previous", RANGE+BANG+TRLBAR},
X#define CMD_previous 56
X {"pwd", TRLBAR},
X#define CMD_pwd 57
X {"quit", BANG+TRLBAR},
X#define CMD_quit 58
X {"read", RANGE+NAMEDF+NEEDARG+TRLBAR+ZEROR},
X#define CMD_read 59
X {"rewind", BANG+TRLBAR},
X#define CMD_rewind 60
X {"recover", FILE1+TRLBAR}, /* not supported */
X#define CMD_recover 61
X {"redo", TRLBAR},
X#define CMD_redo 62
X {"right", TRLBAR+RANGE+EXTRA},
X#define CMD_right 63
X {"substitute", RANGE+EXTRA},
X#define CMD_substitute 64
X {"suspend", TRLBAR+BANG},
X#define CMD_suspend 65
X {"set", EXTRA+TRLBAR},
X#define CMD_set 66
X {"setkeymap", NAMEDF+TRLBAR},
X#define CMD_setkeymap 67
X {"shell", TRLBAR},
X#define CMD_shell 68
X {"source", NAMEDF+NEEDARG+TRLBAR},
X#define CMD_source 69
X {"stop", TRLBAR+BANG},
X#define CMD_stop 70
X {"t", RANGE+EXTRA+TRLBAR},
X#define CMD_t 71
X {"tag", RANGE+BANG+WORD1+TRLBAR+ZEROR},
X#define CMD_tag 72
X {"tags", TRLBAR},
X#define CMD_tags 73
X {"undo", TRLBAR},
X#define CMD_undo 74
X {"unabbreviate", EXTRA+TRLBAR+USECTRLV},
X#define CMD_unabbreviate 75
X {"unmap", BANG+EXTRA+TRLBAR+USECTRLV},
X#define CMD_unmap 76
X {"vglobal", RANGE+EXTRA+DFLALL},
X#define CMD_vglobal 77
X {"version", TRLBAR},
X#define CMD_version 78
X {"visual", RANGE+BANG+FILE1+TRLBAR},
X#define CMD_visual 79
X {"write", RANGE+BANG+FILE1+DFLALL+TRLBAR},
X#define CMD_write 80
X {"wnext", RANGE+BANG+FILE1+TRLBAR},
X#define CMD_wnext 81
X {"winsize", EXTRA+NEEDARG+TRLBAR},
X#define CMD_winsize 82
X {"wq", BANG+FILE1+DFLALL+TRLBAR},
X#define CMD_wq 83
X {"xit", BANG+FILE1+DFLALL+TRLBAR},
X#define CMD_xit 84
X {"yank", RANGE+REGSTR+COUNT+TRLBAR},
X#define CMD_yank 85
X {"z", RANGE+COUNT+TRLBAR}, /* not supported */
X#define CMD_z 86
X {"@", RANGE+EXTRA+TRLBAR},
X#define CMD_at 87
X {"!", RANGE+NAMEDFS},
X#define CMD_bang 88
X {"<", RANGE+COUNT+TRLBAR},
X#define CMD_lshift 89
X {">", RANGE+COUNT+TRLBAR},
X#define CMD_rshift 90
X {"=", RANGE+TRLBAR},
X#define CMD_equal 91
X {"&", RANGE+EXTRA},
X#define CMD_and 92
X {"~", RANGE+TRLBAR} /* not supported */
X#define CMD_tilde 93
X#define CMD_SIZE 94
X
X};
END_OF_FILE
if test 7223 -ne `wc -c <'vim/src/cmdtab.h'`; then
echo shar: \"'vim/src/cmdtab.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/cmdtab.h'
# 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'\" \(5314 characters\)
sed "s/^X//" >'vim/src/cmdtab.tab' <<'END_OF_FILE'
X/* vi:ts=4


X *
X * VIM - Vi IMproved
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+USECTRLV},
X {"args", TRLBAR},
X {"change", BANG+RANGE+COUNT+TRLBAR}, /* not supported */
X {"cabbrev", EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"cc", TRLBAR+WORD1+BANG},
X {"cd", NAMEDF+TRLBAR},
X {"center", TRLBAR+RANGE+EXTRA},
X {"cf", TRLBAR+FILE1+BANG},
X {"chdir", NAMEDF+TRLBAR},
X {"cl", TRLBAR},
X {"cmap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"cn", TRLBAR+BANG},
X {"cnoremap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"cnoreabbrev", EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"copy", RANGE+EXTRA+TRLBAR},
X {"cp", TRLBAR+BANG},
X {"cq", TRLBAR+BANG},
X {"cunmap", BANG+EXTRA+TRLBAR+USECTRLV},
X {"cunabbrev", EXTRA+TRLBAR+USECTRLV},
X {"delete", RANGE+REGSTR+COUNT+TRLBAR},
X {"display", TRLBAR},
X {"digraphs", 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 {"iabbrev", EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"imap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"inoremap", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"inoreabbrev", EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"iunmap", BANG+EXTRA+TRLBAR+USECTRLV},
X {"iunabbrev", EXTRA+TRLBAR+USECTRLV},
X {"join", RANGE+COUNT+TRLBAR},
X {"jumps", TRLBAR},
X {"k", RANGE+WORD1+TRLBAR},
X {"list", RANGE+COUNT+TRLBAR},
X {"left", TRLBAR+RANGE+EXTRA},
X {"move", RANGE+EXTRA+TRLBAR},
X {"mark", RANGE+WORD1+TRLBAR},
X {"marks", TRLBAR},
X {"map", BANG+EXTRA+TRLBAR+NOTRLCOM+USECTRLV},
X {"make", NEEDARG+EXTRA+TRLBAR+XFILE},
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 {"noreabbrev", 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 {"pwd", TRLBAR},
X {"quit", BANG+TRLBAR},
X {"read", RANGE+NAMEDF+NEEDARG+TRLBAR+ZEROR},
X {"rewind", BANG+TRLBAR},
X {"recover", FILE1+TRLBAR}, /* not supported */
X {"redo", TRLBAR},
X {"right", TRLBAR+RANGE+EXTRA},
X {"substitute", RANGE+EXTRA},
X {"suspend", TRLBAR+BANG},
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+USECTRLV},
X {"unmap", BANG+EXTRA+TRLBAR+USECTRLV},
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 5314 -ne `wc -c <'vim/src/cmdtab.tab'`; then
echo shar: \"'vim/src/cmdtab.tab'\" unpacked with wrong size!
fi
chmod +x 'vim/src/cmdtab.tab'
# 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'\" \(7083 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_UNIX for Sun, Linux, IRIX, NeXT, POSIX and SYSV R4
X# or Apollo DOMAIN (with SYSTYPE = bsd4.3, change CC below)
X# or BSD_UNIX with TERMINFO for HPUX
X# or BSD_UNIX for Convex
X# or SYSV_UNIX for Dynix/PTX, SCO-UNIX, UNICOS and SYSV R3
X# or SOLARIS
X# or UNICOS
X# or AIX (rs6000) (disable termcap below)
X# or UTS2 for Amdahl UTS 2.1.x (disable termcap below)
X# or UTS4 for Amdahl UTS 4.x
X# or USL for Unix Systems Laboratories (SYSV 4.2)
XMACHINE = -DBSD_UNIX
X#MACHINE = -DBSD_UNIX -DDOMAIN
X#MACHINE = -DBSD_UNIX -DTERMINFO
X#MACHINE = -DBSD_UNIX -DCONVEX
X#
X#MACHINE = -DSYSV_UNIX
X#MACHINE = -DSYSV_UNIX -DSOLARIS -DTERMINFO
X#MACHINE = -DSYSV_UNIX -DUNICOS
X#MACHINE = -DSYSV_UNIX -DAIX
X#MACHINE = -DSYSV_UNIX -DUTS2
X#MACHINE = -DSYSV_UNIX -DUTS4 -Xa
X#MACHINE = -DSYSV_UNIX -DUSL
X
X#>>>>> choose one compiler
X### standard C compiler, with optimizer, debugger or vanilla
XCC=cc -O
X#CC=cc -g
X#CC=cc
X
X### GCC on sun, Dynix
X#CC=gcc -O -Wall -traditional
X
X### GCC 2.2.2d on Linux (works for Sun OS also)
X#CC=gcc -O6 -Wall
X
X### GCC on SCO 3.2 and GCC 2.4.5 on NeXT
X#CC=gcc -O -Wall
X
X### GCC on another SCO Unix
X#CC=gcc -O6 -g -fpcc-struct-return -fwritable-strings
X
X### CenterLine cc
X#CC=clcc -O
X
X### Apollo Domain cc
X#CC=cc -O -A systype,bsd4.3
X
X#>>>>> choose options for install
X### Name of target
XTARGET = vim
X
X### Prefix for location of files
XPREFIX = /usr/local
X
X### Location of binary
XBINLOC = $(PREFIX)/bin
X
X### Location of man page
XMANLOC = $(PREFIX)/man/man1
X
X### Location of help file
XHELPLOC = $(PREFIX)/lib
X
X### Permissions for vim binary
XBINMOD = 755
X
X### Permissions for man page
XMANMOD = 644
X
X### Permissions for help file
XHELPMOD = 644
X
XMANFILE = ../doc/vim.1
X
XHELPFILE = ../doc/vim.hlp


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

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


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### -DTERMINFO use terminfo entries for builtin termcaps


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### -Dconst= for compilers that don't have type const


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

X### -DUSE_SYSTEM use system() instead of fork/exec for starting a shell
X### -DVIM_ISSPACE use when isspace() can't handle meta chars
X### -DSCO SCO UNIX
X### -UM_XENIX needed on SCO UNIX when using gcc
XDEFS = -DDIGRAPHS -DTERMCAP -DSOME_BUILTIN_TCAPS -DNO_FREE_NULL \
X -DSYSVIMRC_FILE=\"\$$HOME/.vimrc\" -DSYSEXRC_FILE=\"\$$HOME/.exrc\" \
X -DDEFVIMRC_FILE=\"/etc/vimrc\" -DVIM_HLP=\"$(HELPLOC)/vim.hlp\"
X
X#>>>>> link with termlib or termcap only if TERMCAP is defined
X### default
XLIBS = -ltermlib
X
X### termcap is for linux, HPUX, NeXT and others
X#LIBS = -ltermcap
X
X### for IRIX (Silicon Graphics Indigo, __sgi will be defined)
X#LIBS = -ltermlib -lmalloc -lc_s
X
X### UTS 2.1.6a (Amdahl UTS, _UTS will be defined)
X#LIBS = -ltermlib -lsocket
X
X### for SCO UNIX 3.2
X#LIBS = -ltinfo
X
X### for some SCO UNIX with gcc
X#LIBS = -ltermlib -lmalloc
X
X### without TERMCAP defined
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$(TARGET): $(OBJ) version.c
X $(CC) $(CFLAGS) version.c
X $(CC) -o $(TARGET) $(OBJ) version.o $(LIBS)
X
Xdebug: $(OBJ) version.c
X $(CC) $(CFLAGS) version.c
X $(CC) -o $(TARGET) -g $(OBJ) version.o $(LIBS)


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

Xinstall: $(TARGET)
X chmod $(BINMOD) $(TARGET)
X cp $(TARGET) $(BINLOC)
X chmod $(MANMOD) $(MANFILE)
X cp $(MANFILE) $(MANLOC)
X chmod $(HELPMOD) $(HELPFILE)
X cp $(HELPFILE) $(HELPLOC)
X
Xclean:
X -rm -f $(OBJ) mkcmdtab.o version.o core $(TARGET) mkcmdtab
X -rm -f *.bak
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 7083 -ne `wc -c <'vim/src/makefile.unix'`; then
echo shar: \"'vim/src/makefile.unix'\" unpacked with wrong size!
fi
chmod +x 'vim/src/makefile.unix'
# 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'\" \(6735 characters\)
sed "s/^X//" >'vim/src/param.h' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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
XEXTERN int p_bin INIT(= FALSE); /* editing binary file */
X#ifdef MSDOS
XEXTERN int p_biosk INIT(= TRUE); /* Use bioskey() instead of kbhit() */
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_ed INIT(= FALSE); /* :s is ed compatible */
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(= "errors"); /* name of errorfile */
X#endif
X#ifdef AMIGA
XEXTERN char *p_efm INIT(= "%f>%l:%c:%t:%n:%m");/* error format */
X#else
XEXTERN char *p_efm INIT(= "\"%f\",%*[^0123456789]%l: %m"); /* error format */
X#endif
X#ifdef COMPATIBLE
XEXTERN int p_ek INIT(= FALSE); /* function keys with ESC in insert mode */
X#else
XEXTERN int p_ek INIT(= TRUE); /* function keys with ESC in insert mode */
X#endif
XEXTERN int p_et INIT(= FALSE); /* expand tabs into spaces */
XEXTERN int p_exrc INIT(= FALSE); /* read .exrc in current dir */
XEXTERN char *p_fp INIT(= ""); /* name of format program */
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 char *p_mp INIT(= "make"); /* program for :make command */
XEXTERN int p_ml INIT(= TRUE); /* mode lines on/off */
XEXTERN long p_mls INIT(= 5); /* number of mode lines */
XEXTERN int p_nu INIT(= FALSE); /* number lines on the screen */
XEXTERN int p_paste INIT(= FALSE); /* paste mode */
XEXTERN char *p_para INIT(= "IPLPPPQPP LIpplpipbp"); /* paragraphs */
XEXTERN int p_ro INIT(= FALSE); /* readonly */
XEXTERN int p_remap INIT(= TRUE); /* remap */
XEXTERN long p_report INIT(= 2); /* minimum number of lines for report */
XEXTERN int p_ru INIT(= FALSE); /* show column/line number */
XEXTERN int p_ri INIT(= FALSE); /* reverse direction of insert */
XEXTERN int p_secure INIT(= FALSE); /* do .exrc and .vimrc in secure mode */
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_ss INIT(= 0); /* sideways scrolling offset */
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#if defined(COMPATIBLE) || defined(UNIX)
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#if defined(COMPATIBLE)
XEXTERN int p_smd INIT(= FALSE); /* show mode */
X#else
XEXTERN int p_smd 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 */
X#if defined(COMPATIBLE)
XEXTERN int p_ta INIT(= FALSE); /* auto textmode detection */
X#else
XEXTERN int p_ta INIT(= TRUE); /* auto textmode detection */
X#endif
X#ifdef MSDOS
XEXTERN int p_tx INIT(= TRUE); /* textmode for file I/O */
X#else
XEXTERN int p_tx INIT(= FALSE); /* textmode for file I/O */
X#endif
XEXTERN long p_tw INIT(= 0); /* textwidth */
XEXTERN int p_to INIT(= FALSE); /* tilde is an operator */
XEXTERN int p_timeout INIT(= TRUE); /* mappings entered within one second */
XEXTERN long p_tm INIT(= 1000); /* timeoutlen (msec) */
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_wrap INIT(= TRUE); /* wrap long lines */
XEXTERN int p_warn INIT(= TRUE); /* warn for changes at shell command */
XEXTERN int p_ws INIT(= TRUE); /* wrap scan */
X#ifdef COMPATIBLE
XEXTERN long p_wc INIT(= Ctrl('E')); /* character for wildcard exapansion */
X#else
XEXTERN long p_wc INIT(= TAB); /* character for wildcard exapansion */
X#endif
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 6735 -ne `wc -c <'vim/src/param.h'`; then
echo shar: \"'vim/src/param.h'\" unpacked with wrong size!
fi
chmod +x 'vim/src/param.h'
# end of 'vim/src/param.h'
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'\" \(7440 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#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
X /*
X * We should define ftpr as a pointer to a function returning a pointer to
X * a function returning a pointer to a function ...
X * This is impossible, so we declare a pointer to a function returning a
X * pointer to a function returning void. This should work for all compilers.
X */
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 = TO_UPPER(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 = TO_UPPER(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 = TO_LOWER(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 = TO_LOWER(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 * regtilde: replace tildes in the pattern by the old pattern
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... but we 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 * New solution: The tilde's are parsed once before the first call to regsub().
X * In the old solution (tilde handled in regsub()) is was possible to get an
X * endless loop.


X */
X char *

Xregtilde(source, magic)
X char *source;
X int magic;
X{
X char *newsub = NULL;
X char *tmpsub;
X char *p;
X int len;
X int prevlen;
X
X for (p = source; *p; ++p)
X {
X if ((*p == '~' && magic) || (*p == '\\' && *(p + 1) == '~' && !magic))
X {
X if (reg_prev_sub)
X {
X /* length = len(current) - 1 + len(previous) + 1 */
X prevlen = strlen(reg_prev_sub);
X tmpsub = alloc((unsigned)(strlen(source) + prevlen));
X if (tmpsub)
X {
X /* copy prefix */
X len = (int)(p - source); /* not including ~ */
X strncpy(tmpsub, source, (size_t)len);
X /* interpretate tilde */
X strcpy(tmpsub + len, reg_prev_sub);
X /* copy postfix */
X if (!magic)
X ++p; /* back off \ */
X strcat(tmpsub + len, p + 1);
X
X free(newsub);
X newsub = tmpsub;
X p = newsub + len + prevlen;
X }
X }
X else if (magic)
X strcpy(p, p + 1); /* remove '~' */
X else
X strcpy(p, p + 2); /* remove '\~' */
X }
X else if (*p == '\\' && p[1]) /* skip escaped characters */
X ++p;
X }
X
X free(reg_prev_sub);
X if (newsub)
X {
X source = newsub;
X reg_prev_sub = newsub;
X }
X else
X reg_prev_sub = strsave(source);
X return source;
X}
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
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 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 = (int)(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
Xexit:
X return (int)((dst - dest) + 1);
X}
END_OF_FILE
if test 7440 -ne `wc -c <'vim/src/regsub.c'`; then
echo shar: \"'vim/src/regsub.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/regsub.c'
# end of 'vim/src/regsub.c'
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'\" \(6733 characters\)
sed "s/^X//" >'vim/todo' <<'END_OF_FILE'
XKnown problems:
X
XNone at the moment!
X
X
XProblems that will probably not be solved:
X
XSetting the size of the window with ":win" does not always work as expected.
XAmiga: When using quickfix with the Manx compiler we only get the first 25
X errors. How do we get the rest?
XAmiga: The ":cq" command does not always abort the Manx compiler. Why?
X
X
XFurther extentions:
X
XIn visual select mode: Inclusion or exclusion of char under cursor depends
X on movement command. "vwd" and "dw" do the same.
XFind out why macros of Stephen Riehm are working strange.
X:s///p prints the line after a substitution.
XWhen using the up/down cursor keys in insertmode keep the same column.
XMake CTRL-R (insert register contents) also work in command line mode.
XUpdatescript() can be done faster with a string instead of a char.
XWith :args, when there is only one line, don't call wait_return().
XAdd arguments to ":args", like ":next".
XWhen 'wrapscan' off give message "search hit BOTTOM without matching pattern".
XWhen 'wrapscan' on give message "search hit BOTTOM, continuing at TOP".
XAdd \! to search patterns: matches string that does not match previous atom.
XScreen updating is inefficient with CTRL-F and CTRL-B when there are long lines.
XAdd last inserted text to :display.
XMake z<nr><CR> more useful: put ruler and command on bottom line, reserve
X more space for command line and messages (less need for hitreturn).
XUse 'backupdir' for all backup files? (Caughey)
XUse CTRL-E and CTRL-Y in insert mode for scroll up/down?
XWhen undone all changes reset the Changed flag.
XUppercase characters in ex commands can be made lowercase?
XAdd t_del, code for delete key (termcap 'kD') and maybe some other keys:
X 'kI' insert key, 'kL' delete line, etc.
XCTRL-V > should move the block, not whole lines.
XFiltering a block should only apply to the block, not to the whole lines. When
X the number of lines is increased, add lines. When decreased, padd with
X spaces or delete?
XIn out-of-memory situations: Free allocated space in undo (after asking).
XWith '#' and '*' commands: search whole words only (using \< and \>)?
X8-bit codes between 0x80 and 0xa0 cannot be typed directly (mostly msdos
X problem). Need more codes for delete key and more function keys. Use
X 2-byte code?
XInsert octal numbers with CTRL-V o, hexadecimal with CTRL-V x and binary
X with CTRL-V b.
XList mappings: Once with and without ^ and ~ (meta keys)
XIf ':' hit after "hit return to continue" no screen redraw required.
XAdd option that tells which characters to display directly, e.g.
X ":set gr=32-126,140-244", others are displayed with ^ and ~ and +
XAdd option to show character value in octal, decimal, hex and screen code.
XHow does vi detect whether a filter has messed up the screen? Check source.
X After ":w !command" a wait_return?
XWith 'p' command on last line: scroll screen up (also for terminals without
X insert line command).
XAmiga: ExpandWildCards in amiga.c: don't expand if there are no wildcards.
Xunix: Speedup wildcard expansion of "*", "~" and "$": do it internally, more
X complicated things can still be done with the shell.
XOnly do wildcard expansion with 'wildchar' when entering a command that has a
X file name as argument (:r :w :! :e :f :n)?
XIn regexp.c: "\^" after "\|" or "\(" is start of line, and "\$" before "\|"
X and "\)" is end of line.
XRemember the "last changed" time of the edited file and check it before
X overwriting; another user may have changed it.
XSupport for command lines longer than 256 characters (for EXINIT).
XOption for filter when reading/writing a file for compression or crypting.
XOption to set time for emsg() sleep.
XMake adjustmark() faster (sorted list of pointers? Hash list?)
XAdd "next tag" command for tags that have multiple hits.
XSupport static tags: first search for tags with current filename: "foo.c:bar",
X then for global tags (without a filename).
XHistory stack for . command?
XWith CTRL-^ command swap the two entries at the top of the file list. Put filename
X in the list only if it is not already there???
XUse insert/delete char when terminal supports it.
XWith undo with simple line delete/insert: optimize screen updating.
XOptimize screen redraw for slow terminals.
X"edit" option: when off changing the buffer is not possible.
XAdd "-d null" for editing from a script file without displaying.
XMSDOS: 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 <key1>, all together with <key2>.
XAmiga: Add possibility to set a keymap. The code in amiga.c does not work yet.
XImplement 'redraw' option.
XAdd possibility to put the value of an option into the text: "'lines'p
XAdd 'crown' option to 'Q' command: preserve indent of second line.
XUnix: WildExpand: Without csh file name with embedded space will be split in two.
XAdd special code to 'sections' option to define something else but '{' or '}'
X as the start of a section (e.g. one shiftwidth to the right).
XNopaste option: Mappings with non-printable characters are OK.
XAdd 'indent' option: Always use this amount of indent when starting a new line
X and when formatting text.
XAdd option 'comment', initally "/*,*,*/,#", giving the characters at start of
X a line that should be left alone by the internal formatting.
XAdd 'scrolloff': scroll when cursor is less then 'scrolloff' lines from top/bottom.
XAdd option to switch off ignoring braces inside quotes for "%" command??
XUse pipes for filtering on unix.
XAllow for +command and -option on any position in argv[].
XWith CTRL-O commands in insert mode: Allow to go to after last char in line.
XAdd commands like ]] and [[ that do not include the line jumped to.
X
XFrom Elvis:
Xfontchanges recognized "\\fB" etc.
X:color command
X:if and friends, conditional statements
XChange cursor shape in command/insert mode.
X
X
XFar future extentions:
X
XMSdos: use extended or expanded memory.
XUse disk swap file when editing very large files.
XWhen executing macro's: Save each line for undo only once.
XSmart cut/paste: recognize words and adjust spaces before/after them.
XAdd 'notwsuffixes' option: suffixes for files where 'tw' should be 0.
XKeyword completion: first look in the file for a match, then in a dictionary.
XSupport mouse control.
XSupport multiple windows (like xvi or emacs)
XOption verbose; when on keep the screen uptodate, when off only redisplay when
X input needed.
XRemember message line for redraw. Integrate the command line in updateScreen().
XMode to keep text formatted while inserting/deleting.
XMode to keep C-code formatted (sort of on-line indent). Use colors for
X keywords, comments, etc.
XKorn-shell like command line editing (like editing a single line with vi). Use
X :cmap! for mappings.
END_OF_FILE
if test 6733 -ne `wc -c <'vim/todo'`; then
echo shar: \"'vim/todo'\" unpacked with wrong size!
fi
chmod +x 'vim/todo'
# end of 'vim/todo'
fi
echo shar: End of archive 3 \(of 25\).
cp /dev/null ark3isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:45:10 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 57
Archive-name: vim/part07

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/macros/maze/maze_mac.uue vim/src/misccmds.c
# vim/src/version.c
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:05 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
chmod +x 'vim/macros/maze/maze_mac.uue'
# end of 'vim/macros/maze/maze_mac.uue'
fi
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'\" \(16465 characters\)
sed "s/^X//" >'vim/src/misccmds.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 += (int)p_ts - (count % (int)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 if (!p_et) /* if 'expandtab' is set, don't use TABs */
X while (size >= (int)p_ts)
X {
X inschar(TAB);
X size -= (int)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, delspaces)
X int dir;
X int redraw;
X int delspaces;
X{
X char *l;
X char *ptr, *pp;
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 if (newindent == 0)
X newindent = old_indent; /* for ^^D command in insert mode */
X old_indent = 0;
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 && *ptr != NUL)
X {
X char *p;
X char *pp;
X int i, save;
X
X if (dir == FORWARD)
X {
X p = ptr + strlen(ptr) - 1;
X while (p > ptr && isspace(*p)) /* find last non-blank in line */
X --p;
X if (*p == '{') /* line ends in '{': do indent */
X {
X did_si = TRUE;
X no_si = TRUE;
X }
X else /* look for "if" and the like */
X {
X p = ptr;
X skipspace(&p);
X for (pp = p; islower(*pp); ++pp)
X ;
X if (!isidchar(*pp)) /* careful for vars starting with "if" */
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 p = ptr;
X skipspace(&p);
X if (*p == '}') /* if line starts with '}': do indent */
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 {
X pp = ptr + Curpos.col;
X if (p_ai && delspaces)
X skipspace(&pp);
X extra = strlen(pp);
X }
X if ((l = alloc_line(extra)) == NULL)
X return (FALSE);
X if (extra)
X {
X strcpy(l, pp);
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 % (int)p_sw;
X newindent += (int)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 || State == INSERT || State == REPLACE)
X {
X if (truncate)
X *ptr = NUL;
X else
X *(ptr + Curpos.col) = NUL; /* truncate current line at cursor */
X canincrease(0);
X }
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 if (!p_wrap)
X return 1;
X
X s = (u_char *)nr2ptr(p);
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 col = (col + ((int)Columns - 1)) / (int)Columns;
X if (col < Rows)
X return col;
X return (int)(Rows - 1); /* maximum length */
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(fullname)
X int fullname;
X{
X if (bufempty())
X {
X msg("Buffer Empty");
X return;
X }
X sprintf(IObuff, "\"%s\"%s%s%s line %ld of %ld -- %d %% --",
X (!fullname && sFilename != NULL) ? sFilename :
X ((Filename != NULL) ? Filename : "No File"),
X Changed ? " [Modified]" : "",
X NotEdited ? " [Not edited]" : "",
X p_ro ? " [readonly]" : "",
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/*
X * Set the current file name to 's'.
X * The file name with the full path is also remembered, for when :cd is used.
X */
X void
Xsetfname(s, ss)
X char *s, *ss;
X{
X free(Filename);
X free(sFilename);
X if (s == NULL || *s == NUL)
X {
X Filename = NULL;
X sFilename = NULL;
X }
X else
X {
X if (ss == NULL)
X ss = s;
X sFilename = (char *)strsave(ss);
X FullName(s, IObuff, IOSIZE);
X Filename = (char *)strsave(IObuff);
X }
X if (did_cd)
X xFilename = Filename;
X else
X xFilename = sFilename;
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 int rir0; /* reverse replace in column 0 */
X
X p = Curpos2ptr();
X rir0 = (State == REPLACE && p_ri && Curpos.col == 0);
X if (rir0 || State != REPLACE || *p == NUL)
X {
X /* make room for the new char. */
X if (!canincrease(1)) /* make room for the new char */
X return;
X
X p = Curpos2ptr(); /* get p again, canincrease() may have changed it */
X memmove(p + 1, p, strlen(p) + 1); /* move following text and NUL */
X }
X if (rir0) /* reverse replace in column 0 */
X {
X *(p + 1) = c; /* replace the char that was in column 0 */
X c = ' '; /* insert a space */
X extraspace = TRUE;
X }
X *p = 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 showruler(0);
X setcursor();
X flushbuf();
X vim_delay(); /* brief pause */
X Curpos = csave; /* restore cursor position */
X cursupdate();
X }
X }
X if (!p_ri) /* normal insert: cursor right */
X ++Curpos.col;
X else if (State == REPLACE && !rir0) /* reverse replace mode: cursor left */
X --Curpos.col;
X CHANGED;
X}
X
X void
Xinsstr(s)
X register char *s;
X{
X register char *p;
X register int n = strlen(s);
X
X if (!canincrease(n)) /* make room for the new string */
X return;
X
X p = Curpos2ptr();
X memmove(p + n, p, strlen(p) + 1);
X memmove(p, s, (size_t)n);
X Curpos.col += n;
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 = Curpos2ptr();
X
X if (*ptr == NUL) /* can't do anything (happens with replace mode) */
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)
X --Curpos.col;
X
X (void)canincrease(0);
X CHANGED;


X return TRUE;
X}
X

X void
Xdellines(nlines, doscreen, undo)
X long nlines; /* number of lines to delete */
X int doscreen; /* if true, update the screen */
X int undo; /* if true, prepare for undo */
X{
X int num_plines = 0;
X char *ptr;
X
X if (nlines <= 0)
X return;
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 - Cursrow) && doscreen)
X {
X doscreen = FALSE;
X /* flaky way to clear rest of screen */
X s_del(Cursrow, (int)Rows - 1, TRUE);
X }
X if (undo && !u_savedel(Curpos.lnum, nlines))
X return;
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 ptr = delsline(Curpos.lnum, TRUE);
X if (!undo)
X free_line(ptr);
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)(*(Curpos2ptr()));
X}
X
X void
XpcharCurpos(c)
X int c;
X{
X *(Curpos2ptr()) = c;
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 * skiptodigit: skip over text until digit found
X *
X * note: you must give a pointer to a char pointer!
X */
X void
Xskiptodigit(pp)
X char **pp;


X{
X register char *p;

X
X for (p = *pp; !isdigit(*p) && *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 * Don't use emsg(), because it flushes the macro buffer.
X */
X void
Xset_Changed()
X{
X change_warning();
X Changed = 1;
X Updated = 1;
X}
X
X void
Xchange_warning()
X{
X if (Changed == 0 && p_ro)
X {
X msg("Warning: Changing a readonly file");
X sleep(1); /* give him some time to think about it */
X }
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 if (r == Ctrl('C'))
X r = 'n';
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(FALSE); /* flush internal 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 showmode(); /* may have deleted the mode message */
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 - 1;
X while (c-- > 0 && *tail && isidchar(*tail))
X *var++ = *tail++;
X *var = NUL;
X/*
X * It is possible that vimgetenv() uses IObuff for the expansion, and that the
X * 'dst' is also IObuff. This works, as long as 'var' is the first to be copied
X * to 'dst'!
X */
X var = (char *)vimgetenv(dst);
X if (var && (strlen(var) + strlen(tail) + 1 < (unsigned)dstlen))
X {
X strcpy(dst, var);
X strcat(dst, 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 if (stat(buf1, &st1) == 0 && stat(s2, &st2) == 0 &&
X 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}
X
X/*
X * get the tail of a path: the file name.


X */
X char *

Xgettail(fname)
X char *fname;
X{
X register char *p1, *p2;
X
X for (p1 = p2 = fname; *p2; ++p2) /* find last part of path */
X {
X if (ispathsep(*p2))
X p1 = p2 + 1;
X }
X return p1;
X}
X
X/*
X * return TRUE if 'c' is a path separator.
X */
X int
Xispathsep(c)
X int c;
X{
X#ifdef UNIX
X return (c == PATHSEP); /* UNIX has ':' inside file names */
X#else
X# ifdef MSDOS
X return (c == ':' || c == PATHSEP || c == '/');
X# else
X return (c == ':' || c == PATHSEP);
X# endif
X#endif
X}
END_OF_FILE
if test 16465 -ne `wc -c <'vim/src/misccmds.c'`; then
echo shar: \"'vim/src/misccmds.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/misccmds.c'
# end of 'vim/src/misccmds.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'\" \(15699 characters\)
sed "s/^X//" >'vim/src/version.c' <<'END_OF_FILE'
X/* vi:ts=4 sw=4 tw=77
X *


X *
X * VIM - Vi IMproved
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 Vim 1.29 to 1.31 and Vim 2.0 See ../readme2.0.
X
X Vim 2.0 When reading and writing files and in some other cases use short
X filename if ":cd" not used. Fixes problem with networks. Deleted
X "#include <ctype.h>" from regexp.c. ":v" without argument was not
X handled correctly in doglob(). Check for tail recursion removed
X again, because it forbids ":map! foo ^]foo", which is OK. Removed
X redraw on exit for msdos. Fixed return value for FullName in
X unix.c. Call_shell does not always use cooked mode, fixes problem
X with typing CR while doing filename completion in unix. "r<TAB>"
X now done by edit() to make expandtab works. Implemented FullName
X for msdos. Implemented the drive specifier for the :cd command for
X MSDOS. Added CTRL-B and CTRL-E to command line editing. Del key
X for msdos not mapped to "x" in command mode, could not delete last
X char of count. Fixed screen being messed up with long commands
X when 'sc' is set. Fixed use of CR-LF in tags file. Added check
X for abbreviation when typing ESC or CTRL-O in insert mode. Doing
X a ":w file" does overwrite when "file" is the current file. Unmap
X will check for 'to' string if there is no match with 'from'
X string; Fixes ":unab foo" after ":ab foo bar". Fixed problem in
X addstar() for msdos: Check for negative index. Added possibility
X to switch off undo ":set ul=-1". Allow parameters to be set to
X numbers >32000 for machines with 16 bit ints.
X*/
X
Xchar *Version = "VIM 2.0";
X#if !defined(__DATE__) || !defined(__TIME__)
Xchar *longVersion = "Vi IMproved 2.0 (1993 Dec 14) by Bram Moolenaar";
X#else
Xchar *longVersion = "Vi IMproved 2.0 (" __DATE__ " " __TIME__ ") by Bram Moolenaar";
X#endif
END_OF_FILE
if test 15699 -ne `wc -c <'vim/src/version.c'`; then
echo shar: \"'vim/src/version.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/version.c'
# end of 'vim/src/version.c'
fi
echo shar: End of archive 7 \(of 25\).
cp /dev/null ark7isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:45:35 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 58
Archive-name: vim/part08

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/difference.doc vim/src/msdos.c vim/src/term.c


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:05 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'\" \(18596 characters\)
sed "s/^X//" >'vim/doc/difference.doc' <<'END_OF_FILE'
X
X
XThis is a summary of the differences between VIM and vi.
X
X
XThe most interesting additions:
X
XVi compatibility.
XWhen the 'compatible' option is set, all options are given a vi-compatible
Xvalue. Vim will behave like the "real" vi as much as possible.
X
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'q'<c> starts recording typed characters into named register <c> (append to
Xthe register if register name is upper case). A subsequent 'q' stops
Xrecording. The register can then be executed with the '@'<c> command. This is
Xvery useful to repeat 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
XVisual mode.
XVisual 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. 'v'
Xand 'V' are used to start Visual mode. 'v' works on characters and 'V' on
Xlines. Move the cursor to extend the Visual part. It is shown highlighted on
Xthe screen. By typing 'o' the other end of the Visual text can be moved. The
XVisual 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 Visual lines.
X Q format text to 'textwidth' columns
X J join lines
X ~ swap case
X u make lowercase
X U make uppercase
X
X
XBlock operators.
XWith Visual a rectangular block of text can be selected. Start Visual with
XCTRL-V. The block can be deleted ('d'), yanked ('y') or its case can be
Xchanged ('~', 'u' and 'U'). A deleted or yanked block can be put into the
Xtext with the '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. CTRL-B/CTRL-E can be used to go to the begin/end
Xof the command line.
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) <TAB> 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. The 'wildchar' option can be set to the
Xcharacter for filename completion, <TAB> is the default. CTRL-D can be typed
Xafter an (incomplete) file name wildcard; all matching files will be listed.
XCTRL-A will insert all matching files. CTRL-L will insert the longest common
Xpart of the matching files.
X
X
XHorizontal scrolling.
XIf the 'wrap' option is off, long lines will not wrap and only part of them
Xwill be shown. When the cursor is moved to a part that is not shown, the
Xscreen will scroll horizontally. The minimal number of columns to scroll can
Xbe set with the 'sidescroll' option.
X
X
XText formatting.
XThe 'textwidth' (tw) option can be used to automatically limit the line
Xlength. This supplements the 'wrapmargin' option of Vi, which was not very
Xuseful. The 'Q' operator can be used to format a piece of text ("Q}" formats
Xa paragraph). Commands for text alignment: ":center", ":left" and ":right".
X
X
XEdit-compile-edit speedup.
XThe ":make" command can be used to run the compilation and jump to the first
Xerror. Alternatively Vim can be started with the "-e" option from the
Xcompiler. A file with compiler error messages is interpreted. Each line in
Xthe error file is scanned for the name of a file, line number and error
Xmessage. Vim starts editing at the first error. Optionally the name of the
Xerror file can be given with "-e errorfile". The ":cn" command can be used to
Xjump to the next error. ":cl" lists all the error messages. Other commands
Xare available (almost the same as with Manx's Z editor). The 'errorfile'
Xoption has the name of the file with error messages. The 'errorformat' option
Xcan be set to a scanf-like string to handle output from many compilers. The
X'makeprg' option contains the name of the program to be executed with the
X":make" command.
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 "-b" (Binary) then some options are set to be able
Xto edit binary or executable files.
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
XThe "-e" option starts Vim in quickfix mode.
X
X
XIn command mode:
X
XMissing command: 'Q' (go to Ex mode).
XMissing Ex commands: append, change, insert, open, preserve, recover,
Xvisual, 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 <LF> internally. This allows editing of
Xbinary files (more or less).
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. The normal '%' function to jump to the matching
Xbrace skips braces inside quotes.
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
X"5r<CR>" replaces five characters by five line breaks. Vi replaces five
Xcharacters with a single line break.
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 register.
X
XPreviously used file names are remembered in the alternate file name list.
X":files" command shows the list of alternate filenames.
X'#'<N> is replaced by the <N>th alternate filename in the list.
X"#<" is replaced by the current filename without extension.
X
XFlags after command not supported (no plans to include it).
X
XOn non-UNIX systems ":cd" command shows current directory instead of going to
Xthe home directory. ":pwd" prints the current directory on all systems.
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
XNo check for "tail recursion" with mappings. This allows things like
X":map! foo ^]foo".
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. ":cmap", ":cunmap" and
X":cnoremap" can be used for mapping in command line editing only. ":imap",
X":iunmap" and ":inoremap" can be used for mapping in insert mode only.
XSimilar commands exist for abbreviations: ":noreabbrev", ":iabbrev"
X":cabbrev", ":iunabbrev", ":cunabbrev", ":inoreabbrev", ":cnoreabbrev".
X
XIn vi the command ":map foo bar" would remove a previous mapping
X":map bug foo". This is considered a bug, so it is not included in Vim.
X":unmap! foo" does remove ":map! bug foo", because unmapping would be very
Xdifficult otherwise (this is vi compatible).
X
X":@r" command executes register 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
XIn both Vi and Vim you can create a line break with the ":substitute" command
Xby using a CTRL-M. For Vi this means you cannot insert a real CTRL-M in the
Xtext. With Vim you can put a real CTRL-M in the text by preceding it with a
XCTRL-V.
X
X
XIn insert mode:
X
XIf the 'revins' option is set, insert happens backwards. This is for typing
XHebrew. When inserting normal characters the cursor will not be shifted and
Xthe text moves rightwards. In replace mode the cursor will move leftwards.
XBackspace, CTRL-W and CTRL-U will also work in the opposite direction. CTRL-P
Xtoggles the 'revins' option.
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 line breaks 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
XWhen the 'paste' option is set, a few option are reset and mapping in insert
Xmode and abbreviation are disabled. This allows for pasting text in windowing
Xsystems without unexpected results. When the 'paste' option is reset, the old
Xoption values are restored.
X
XCTRL-T/CTRL-D always insert/delete an indent in the current line, no matter
Xwhat column the cursor is in.
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-R <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-Y 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
XIn command line mode:
X
XESC terminates the command line without executing it. In vi the command line
Xwould be executed, which is not what most people expect (hitting ESC should
Xalways get you back to command mode). To avoid problems with some
Xobscure macros, an ESC in a macro will execute the command. If you want a
Xtyped ESC to execute the command like vi does you can fix this with
X ":cmap ^V<ESC> ^V<CR>"
X
Xgeneral:
X
XMissing options: autoprint (ap), beautify (bf), edcompatible, hardtabs (ht),
Xlisp, mesg, open, optimize (op), prompt, redraw, slowopen (slow), terse,
Xwindow, w300, w1200 and w9600. These options can be set but are otherwise
Xignored.
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. The 'timoutlen' option
Xgives the number of milliseconds that is waited for. If the 'esckeys' option
Xis not set, cursor and function keys that start with <ESC> are not recognized
Xin insert mode.
X
XThere is an option for each terminal string. Can be used when termcap is not
Xsupported or to change individual strings.
X
XWhen the 'textmode' option is set (default for MSDOS) <CR><LF> is used as
Xline separator. When reset (default for Unix and Amiga) <LF> is used. When
Xthe 'textauto' option is set, Vim tries to detect the type of line separator
Xused by reading up to the first <LF>. The 'textmode' option is set
Xaccordingly.
X
XOn systems that have no job control (most systems but BSD-UNIX) the CTRL-Z,
X":stop" or ":suspend" 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).
XThis can be overrided with the 'secure' option.
X
XLine lenght can be at least upto the maximum value of an int (for the Amiga
X32767 characters, for most 32-bit systems much larger). Editing such lines is
Xnot always possible. File length upto 2147483646 lines. If a line is larger
Xthan the screen, the last line is filled with <@>s and only the part of the
Xline before that is shown (unless 'wrap' option is reset).
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
XIf the 'binary' option is set and the file does not have an end-of-line for
Xthe last line, the end-of-line is not appended when writing.
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>, <LF> and <SPACE> are interpreted as the (start of) a
Xcommand. (Vi only accepts a command starting with ':').
X
XThe contents of the numbered and unnamed registers is remembered when
Xchanging files.
X
XThe AUX: device of the Amiga is supported.
X
Xvi:tw=77:
END_OF_FILE
if test 18596 -ne `wc -c <'vim/doc/difference.doc'`; then
echo shar: \"'vim/doc/difference.doc'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/difference.doc'
# end of 'vim/doc/difference.doc'
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'\" \(17132 characters\)
sed "s/^X//" >'vim/src/msdos.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 <io.h>
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
Xtypedef struct filelist
X{
X char **file;
X int nfiles;
X int maxfiles;
X} FileList;
X
Xstatic void addfile __ARGS((FileList *, char *, int));
Xstatic int pstrcmp(); /* __ARGS((char **, char **)); BCC does not like this */
Xstatic void strlowcpy __ARGS((char *, char *));
Xstatic int expandpath __ARGS((FileList *, char *, int, int, int));
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#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
Xvim_remove(name)
X char *name;
X{
X setperm(name, 0); /* default permissions */
X return unlink(name);
X}
X
X/*
X * mch_write(): write the output buffer to the screen
X */
X void
Xmch_write(s, len)
X char *s;
X int len;
X{
X char *p;
X int row, col;
X
X if (term_console) /* translate ESC | sequences into bios calls */
X while (len--)
X {
X if (s[0] == '\n')
X putch('\r');
X else if (s[0] == ESC && len > 1 && s[1] == '|')
X {
X switch (s[2])
X {
X case 'J': clrscr();
X goto got3;
X
X case 'K': clreol();
X goto got3;
X
X case 'L': insline();
X goto got3;
X
X case 'M': delline();
Xgot3: s += 3;
X len -= 2;
X continue;
X
X case '0':


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': p = s + 2;
X row = getdigits(&p); /* no check for length! */
X if (p > s + len)
X break;


X if (*p == ';')

X {
X ++p;
X col = getdigits(&p); /* no check for length! */
X if (p > s + len)
X break;
X if (*p == 'H')
X {
X gotoxy(col, row);
X len -= p - s;
X s = p + 1;
X continue;
X }
X }
X else if (*p == 'm')
X {
X if (row == 0)
X normvideo();
X else
X textattr(row);
X len -= p - s;
X s = p + 1;
X continue;
X }
X }
X }
X putch(*s++);
X }
X else
X write(1, s, (unsigned)len);
X}
X
X#define POLL_SPEED 10 /* milliseconds between polls */
X
X/*
X * Simulate WaitForChar() by slowly polling with bioskey(1) or kbhit().
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 and CTRL-P
X * will be catched by DOS (mool).


X */
X
X static int

XWaitForChar(msec)
X int msec;
X{
X do
X {
X if ((p_biosk ? bioskey(1) : kbhit()) || cbrk_pressed)
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 funcion.
X * Get a characters from the keyboard.
X * If time == 0 do not wait for characters.
X * If time == n wait a short time for characters.
X * If time == -1 wait forever for characters.
X */
X int
XGetChars(buf, maxlen, time)
X char *buf;
X int maxlen;
X int time;
X{
X int len = 0;
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 if (time >= 0)
X {
X if (time == 0) /* don't know if time == 0 is allowed */
X time = 1;
X if (WaitForChar(time) == 0) /* no character available */
X return 0;
X }
X else /* time == -1 */
X {
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 if (p_biosk)
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 else
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 return len;
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 call_shell(NULL, 0, TRUE);
X}
X
Xextern int _fmode;
X/*
X * we do not use windows, there is not much to do here
X */
X void
Xmch_windinit()
X{
X _fmode = O_BINARY; /* we do our own CR-LF translation */
X flushbuf();
X mch_get_winsize();
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 * In some cases with DOS 6.0 on a NEC notebook there is a 12 seconds
X * delay when starting up that can be avoided by the next two lines.
X * Don't ask me why!
X * This could be fixed by removing setver.sys from config.sys. Forget it.
X gotoxy(1,1);
X cputs(" ");
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 * Return non-zero for success.
X */
X int
Xdirname(buf, len)
X char *buf;
X int len;
X{
X return (getcwd(buf, len) != NULL);
X}
X
X/*
X * Change default drive (for Turbo C, Borland C already has it)
X */
X#ifndef __BORLANDC__
X int
X_chdrive(drive)
X int drive;
X{
X unsigned dummy;
X union REGS regs;
X
X regs.h.ah = 0x0e;
X regs.h.dl = drive - 1;
X intdos(&regs, &regs); /* set default drive */
X regs.h.ah = 0x19;
X intdos(&regs, &regs); /* get default drive */
X if (regs.h.al == drive - 1)
X return 0;
X else
X return -1;
X}
X#endif
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 if (fname == NULL) /* always fail */
X return 0;
X
X#ifdef __BORLANDC__ /* the old Turbo C does not have this */
X if (_fullpath(buf, fname, len) == NULL)
X {
X strncpy(buf, fname, len); /* failed, use the relative path name */
X return 0;
X }
X return 1;
X#else /* almost the same as FullName in unix.c */
X {
X int l;
X char olddir[MAXPATHL];
X char *p, *q;
X int c;
X int retval = 1;
X
X *buf = 0;
X /*
X * change to the directory for a moment,
X * and then do the getwd() (and get back to where we were).
X * This will get the correct path name with "../" things.
X */
X p = strrchr(fname, '/');
X q = strrchr(fname, '\\');
X if (q && (p == NULL || q > p))
X p = q;
X q = strrchr(fname, ':');
X if (q && (p == NULL || q > p))
X p = q;
X if (p != NULL)
X {
X if (getcwd(olddir, MAXPATHL) == NULL)
X {
X p = NULL; /* can't get current dir: don't chdir */
X retval = 0;
X }
X else
X {
X if (*p == ':' || (p > fname && p[-1] == ':'))
X q = p + 1;
X else
X q = p;
X c = *q;
X *q = NUL;
X if (chdir(fname))
X retval = 0;
X else
X fname = p + 1;
X *q = c;
X }
X }
X if (getcwd(buf, len) == NULL)
X {
X retval = 0;
X *buf = NUL;
X }
X l = strlen(buf);
X if (l && buf[l - 1] != '/' && buf[l - 1] != '\\')
X strcat(buf, "\\");
X if (p)
X chdir(olddir);
X strcat(buf, fname);
X return retval;
X }
X#endif
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 long perm;
X{
X perm &= ~FA_ARCH;
X return _chmod(name, 1, (int)perm);
X}
X
X/*
X * check if "name" is a directory
X */
X int
Xisdir(name)
X char *name;
X{
X int f;
X
X f = _chmod(name, 0, 0);
X if (f == -1)
X return -1; /* file does not exist at all */
X if ((f & FA_DIREC) == 0)
X return 0; /* not a directory */


X return 1;
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() and kbhit() work 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 if (term_console)
X outstr(T_TP); /* set colors */
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 if (term_console)
X normvideo(); /* restore screen colors */
X }
X}
X
X/*
X * Structure used by Turbo-C/Borland-C to store video parameters.
X */
Xextern struct text_info _video;
X
X int
Xmch_get_winsize()
X{
X int i;
X struct text_info ti;
X/*
X * The screenwidth is returned by the BIOS OK.
X * The screenheight is in a location in the bios RAM, if the display is EGA or VGA.
X */
X if (!term_console)
X return 1;
X gettextinfo(&ti);
X Columns = ti.screenwidth;
X Rows = ti.screenheight;
X if (ti.currmode > 10)
X Rows = *(char far *)MK_FP(0x40, 0x84) + 1;
X set_window();
X
X if (Columns < 5 || Columns > MAX_COLUMNS ||
X Rows < 2 || Rows > MAX_COLUMNS)
X {
X /* these values are overwritten by termcap size or default */
X Columns = 80;
X Rows = 25;
X return 1;
X }
X Rows_max = Rows; /* remember physical max height */
X
X check_winsize();
X script_winsize();
X
X return 0;
X}
X
X/*
X * Set the active window for delline/insline.
X */
X void
Xset_window()
X{
X _video.screenheight = Rows;
X window(1, 1, Columns, Rows);
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, cooked)
X char *cmd;
X int filter; /* if != 0: called by dofilter() */
X int cooked;
X{
X int x;
X char newcmd[200];
X
X flushbuf();
X
X if (cooked)
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 if (cooked)
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 }
X}
X
X#define FL_CHUNK 32
X
X static void
Xaddfile(fl, f, isdir)
X FileList *fl;
X char *f;
X int isdir;


X{
X char *p;
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 **)lalloc(sizeof(char *) * (fl->maxfiles + FL_CHUNK), TRUE);
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 p = alloc((unsigned)(strlen(f) + 1 + isdir));
X if (p)
X {
X strcpy(p, f);
X if (isdir)
X strcat(p, "\\");
X }
X fl->file[fl->nfiles++] = p;


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 we are expanding wildcards we try both files and directories */
X if ((c = findfirst(buf, &fb, (*path || !notf) ? FA_DIREC : 0)) != 0)
X {
X /* not found */
X strcpy(e, path);
X if (notf)
X addfile(fl, buf, FALSE);
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, buf, (isdir(buf) > 0));
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, pat[i], files_only ? FALSE : (isdir(pat[i]) > 0));
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 else
X {
X *num_file = 0;
X *file = NULL;


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
X/*
X * The normal chdir() does not change the default drive.
X * This one does.
X */
X#undef chdir
X int
Xvim_chdir(path)
X char *path;
X{
X if (path[0] == NUL) /* just checking... */
X return 0;
X if (path[1] == ':') /* has a drive name */
X {
X if (_chdrive(toupper(path[0]) - 'A' + 1))
X return -1; /* invalid drive name */
X path += 2;
X }
X if (*path == NUL) /* drive name only */
X return 0;
X return chdir(path); /* let the normal chdir() do the rest */
X}
END_OF_FILE
if test 17132 -ne `wc -c <'vim/src/msdos.c'`; then
echo shar: \"'vim/src/msdos.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/msdos.c'
# end of 'vim/src/msdos.c'
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'\" \(18021 characters\)
sed "s/^X//" >'vim/src/term.c' <<'END_OF_FILE'
X/* vi:sw=4:ts=4:
X *
X * term.c -- VIM - Vi IMproved
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(MSDOS) || defined(ALL_BUILTIN_TCAPS)
X PCANSI_TCAP,
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 DUMB_TCAP, /* minimal termcap, used when everything else fails */
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
Xchar *UP, *BC, PC; /* should be extern, but some don't have them */
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 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 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 }
X else if (i == 0)
X {
X emsg("terminal entry not found");
X builtin = 1;
X }
X else
X {
X clear_termparam(); /* clear old parameters */
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 /* if 'mr' or 'me' is not defined use 'so' and 'se' */
X if (T_TP == NULL || *T_TP == NUL || T_TI == NULL || *T_TI == NUL)
X {
X T_TP = tgetstr("se", &tp);
X T_TI = tgetstr("so", &tp);
X }
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 /* if cursor-left == backspace, ignore it (televideo 925) */
X if (term_strings.t_kl != NULL && *term_strings.t_kl == Ctrl('H'))
X term_strings.t_kl = NULL;
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 }
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:\r\n", term);
X for (p = builtin_tcaps; *p; p++)
X#ifdef TERMCAP
X fprintf(stderr, "\tbuiltin_%s\r\n", *p);
X#else
X fprintf(stderr, "\t%s\r\n", *p);
X#endif
X if (!starting) /* when user typed :set term=xxx, quit here */
X {
X wait_return(TRUE);
X return;
X }
X sleep(2);
X fprintf(stderr, "defaulting to '%s'\r\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 clear_termparam(); /* clear old parameters */
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#ifdef MSDOS
X height = 25; /* console is often 25 lines */
X#else
X height = 24; /* most terminals are 24 lines */
X#endif
X }
X Rows_max = Rows; /* remember max. physical nr. of Rows */
X set_winsize(width, height, FALSE); /* may change Rows_max */
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 * the number of calls to mch_write is reduced by using the buffer "outbuf"
X */
X#undef BSIZE /* hpux has BSIZE in sys/param.h */
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 mch_write((char *)outbuf, 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#ifdef UNIX
X if (c == '\n') /* turn LF into CR-LF (CRMOD does not seem to do this) */
X outchar('\r');
X#endif
X outbuf[bpos] = c;
X ++bpos;
X if (bpos >= BSIZE)
X flushbuf();
X if (c == '\n')
X char_count += Columns;
X else
X ++char_count;
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 if (bpos > BSIZE - 20) /* avoid terminal strings being split up */
X flushbuf();
X while (*s)
X outchar(*s++);
X}
X
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 (bpos > BSIZE - 20) /* avoid terminal strings being split up */
X flushbuf();
X if (s)
X#ifdef TERMCAP
X tputs(s, 1, TPUTSFUNCAST outchar);
X#else
X while (*s)
X outchar(*s++);
X#endif
X}
X
X/*
X * cursor positioning using termcap parser. (jw)
X */
X void
Xwindgoto(row, col)
X int row;
X int col;
X{
X outstr(tgoto(T_CM, col, row));
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 one character from
X * 1. a scriptfile
X * 2. the keyboard
X *
X * As much characters as we can get (upto 'maxlen') are put in buf and
X * NUL terminated (buffer length must be 'maxlen' + 1).
X *
X * If we got an interrupt all input is read until none is available.
X *
X * If time == 0 there is no waiting for the char.
X * If time == n we wait for n msec for a character to arrive.
X * If time == -1 we wait forever for a character to arrive.
X *
X * Return the number of obtained characters.


X */
X
X int

Xinchar(buf, maxlen, time)
X char *buf;
X int maxlen;
X int time; /* milli seconds */
X{
X int len;
X int retesc = FALSE; /* return ESC with gotint */
X register int c;
X register int i;
X
X if (time == -1) /* flush output before blocking */
X flushbuf();
X did_outofmem_msg = FALSE; /* display out of memory message (again) */
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 || (c = getc(scriptin[curscript])) < 0) /* reached EOF */
X {
X /* when reading script file is interrupted, return an ESC to
X get back to normal mode */
X if (got_int)
X retesc = TRUE;
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 *buf++ = c;
X *buf = NUL;


X return 1;
X }
X

X/*
X * If we got an interrupt, skip all previously typed characters and
X * return TRUE if quit reading script file.
X */
X if (got_int) /* skip typed characters */
X {
X while (GetChars(buf, maxlen, T_PEEK))
X ;
X return retesc;
X }
X len = GetChars(buf, maxlen, time);
X
X for (i = len; --i >= 0; ++buf)
X if (*buf == 0)
X *(u_char *)buf = K_ZERO; /* replace ^@ with special code */
X *buf = NUL; /* add trailing NUL */
X return len;
X}
X
X/*
X * Check if buf[] begins with a terminal key code.
X * Return 0 for no match, -1 for partial match, > 0 for full match.
X * With a match the replacement code is put in buf[0], the match is
X * removed and the number characters in buf is returned.
X */
X int
Xcheck_termcode(buf)
X char *buf;
X{
X char **p;
X int slen;
X int len;
X
X len = strlen(buf);
X for (p = (char **)&term_strings.t_ku; p != (char **)&term_strings.t_undo + 1; ++p)
X {
X if (*p == NULL || (slen = strlen(*p)) == 0) /* empty entry */
X continue;
X if (strncmp(*p, buf, (size_t)(slen > len ? len : slen)) == 0)
X {
X if (len >= slen) /* got the complete sequence */
X {
X len -= slen;
X memmove(buf + 1, buf + slen, (size_t)(len + 1));
X /* this relies on the Key numbers to be consecutive! */
X buf[0] = K_UARROW + (p - (char **)&term_strings.t_ku);
X return (len + 1);
X }
X return -1; /* got a partial sequence */
X }
X }
X return 0; /* no match found */
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/*
X * outnuml - output a (big) number fast and return the number of characters
X */
X int
Xoutnuml(n)


X register long n;
X{

X char *s;
X
X s = tltoa((unsigned long)n);
X outstrn(s);
X return (int)strlen(s);
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 || State == SETWSIZE) /* postpone the resizing */
X {
X State = SETWSIZE;
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/*
X * set active window height (for "z<number><CR>" command)
X */
X void
Xset_winheight(height)
X int height;
X{
X if (height > Rows_max) /* can't make it larger */
X height = Rows_max;
X Rows = height;
X check_winsize();
X updateScreen(CLEAR);
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 flushbuf();
X termcap_active = TRUE;
X}
X
X void
Xstoptermcap()
X{
X outstr(T_KE); /* stop "keypad transmit" mode */
X outstr(T_TE); /* stop termcap mode */
X flushbuf();
X termcap_active = FALSE;
X}
X
X/*
X * enable cursor, unless in Visual mode or no inversion possible
X */
X void
Xcursor_on()
X{
X if (!Visual.lnum || T_TI == NULL || *T_TI == NUL)
X outstr(T_CV);
X}
X
X void
Xcursor_off()
X{
X outstr(T_CI); /* disable cursor */
X}
END_OF_FILE
if test 18021 -ne `wc -c <'vim/src/term.c'`; then
echo shar: \"'vim/src/term.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/term.c'
# end of 'vim/src/term.c'
fi
echo shar: End of archive 8 \(of 25\).
cp /dev/null ark8isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:49:31 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 60
Archive-name: vim/part10

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/edit.c vim/src/unix.c


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:05 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'\" \(22105 characters\)
sed "s/^X//" >'vim/src/edit.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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));
Xstatic int echeck_abbr __ARGS((int));
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 = 0; /* 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 u_char *saved_line = NULL; /* saved line for replace mode */
X linenr_t saved_lnum = 0; /* lnum of saved line */
X int saved_char = NUL; /* char replaced by NL */
X linenr_t lnum;
X int temp = 0;
X int mode;
X int nextc = 0;
X int lastc = 0;
X colnr_t mincol;
X
X if (restart_edit)
X {
X arrow_used = TRUE;
X restart_edit = 0;
X }
X else
X arrow_used = FALSE;
X
X#ifdef DIGRAPHS
X dodigraph(-1); /* clear digraphs */
X#endif
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 old_indent = 0;
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 showruler(0);
X setcursor();
X if (nextc) /* character remaining from CTRL-V */
X {
X c = nextc;
X nextc = 0;
X }
X else
X {
X c = vgetc();
X if (c == Ctrl('C') && got_int)
X got_int = FALSE;
X }
X if (c != Ctrl('D')) /* remember to detect ^^D and 0^D */
X lastc = c;
X
X/*
X * In replace mode a backspace puts the original text back.
X * We save the current line to be able to do that.
X * If characters are appended to the line, they will be deleted.
X * If we start a new line (with CR) the saved line will be empty, thus
X * the characters will be deleted.
X * If we backspace over the new line, that line will be saved.
X */
X if (State == REPLACE && saved_lnum != Curpos.lnum)
X {
X free(saved_line);
X saved_line = (u_char *)strsave((char *)nr2ptr(Curpos.lnum));
X saved_lnum = Curpos.lnum;
X }
X
X#ifdef DIGRAPHS
X c = dodigraph(c);
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 || (cc == TAB && !p_list))
X outchar(' ');
X else
X outstrn(transchar(cc));
X
X if (isidchar(c) || !echeck_abbr(c))
X insertchar(c);
X continue;
X }
X switch (c) /* handle character in insert mode */
X {
X case Ctrl('O'): /* execute one command */
X if (echeck_abbr(Ctrl('O') + 0x100))
X break;
X count = 0;
X if (State == INSERT)
X restart_edit = 'I';
X else
X restart_edit = 'R';
X goto doESCkey;
X
X case ESC: /* an escape ends input mode */
X if (echeck_abbr(ESC + 0x100))
X break;
X /*FALLTHROUGH*/
X
X case Ctrl('C'):
XdoESCkey:
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) && !p_ri)
X decCurpos();
X if (extraspace) /* did reverse replace in column 0 */
X {
X delchar(FALSE);
X updateline();
X extraspace = FALSE;


X }
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_smd)
X msg("");
X free(saved_line);
X old_indent = 0;
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('R'):
X if (!insertbuf(vgetc()))
X beep();
X break;
X
X case Ctrl('P'): /* toggle reverse insert mode */
X p_ri = !p_ri;
X showmode();
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 AppendCharToRedobuff(c);
X if ((lastc == '0' || lastc == '^') && Curpos.col)
X {
X --Curpos.col;
X delchar(FALSE); /* delete the '^' or '0' */
X if (lastc == '^')
X old_indent = get_indent(); /* remember current indent */
X
X /* determine offset from first non-blank */
X temp = Curpos.col;
X beginline(TRUE);
X temp -= Curpos.col;
X set_indent(0, TRUE); /* remove all indent */
X }
X else
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'), TRUE);
X
X /* try to put cursor on same character */
X temp += Curpos.col;
X }
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 delete anything in an empty file */
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 (bufempty() || (!p_ri &&
X ((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 (p_ri)
X incCurpos();
X if (Curpos.col <= 0) /* delete newline! */
X {
X lnum = Insstart.lnum;
X if (Curpos.lnum == Insstart.lnum || p_ri)
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, in the line we started replacing, we
X only move the cursor */
X if (State != REPLACE || Curpos.lnum > lnum)
X {
X temp = gcharCurpos(); /* remember current char */
X --Curpos.lnum;
X dojoin(FALSE, TRUE);
X if (temp == NUL && gcharCurpos() != NUL)
X ++Curpos.col;
X if (saved_char) /* restore what NL replaced */
X {
X State = NORMAL; /* no replace for this char */
X inschar(saved_char); /* but no showmatch */
X State = REPLACE;
X saved_char = NUL;
X if (!p_ri)
X decCurpos();
X }
X else if (p_ri) /* in reverse mode */
X saved_lnum = 0; /* save this line again */
X }
X else
X decCurpos();
X did_ai = FALSE;
X }
X else
X {
X if (p_ri && State != REPLACE)
X decCurpos();
X mincol = 0;
X if (mode == 3 && !p_ri && p_ai) /* keep indent */
X {
X temp = Curpos.col;
X beginline(TRUE);
X if (Curpos.col < temp)
X mincol = Curpos.col;
X Curpos.col = temp;
X }
X
X /* delete upto starting point, start of line or previous word */
X do
X {
X if (!p_ri)
X decCurpos();
X
X /* start of word? */
X if (mode == 1 && !isspace(gcharCurpos()))
X {
X mode = 2;
X temp = isidchar(gcharCurpos());
X }
X /* end of word? */
X else if (mode == 2 && (isspace(cc = gcharCurpos()) || isidchar(cc) != temp))
X {
X if (!p_ri)
X incCurpos();
X else if (State == REPLACE)
X decCurpos();
X break;
X }
X if (State == REPLACE)
X {
X if (saved_line)
X {
X if (extraspace)
X {
X if ((int)strlen(nr2ptr(Curpos.lnum)) - 1 > (int)strlen((char *)saved_line))
X delchar(FALSE);
X else
X {
X decCurpos();
X delchar(FALSE);
X extraspace = FALSE;
X pcharCurpos(*saved_line);
X }
X }
X else if (Curpos.col < strlen((char *)saved_line))
X pcharCurpos(saved_line[Curpos.col]);
X else if (!p_ri)
X delchar(FALSE);
X }
X }
X else /* State != REPLACE */
X {
X delchar(FALSE);
X if (p_ri && gcharCurpos() == NUL)
X break;
X }
X if (mode == 0) /* just a single backspace */
X break;
X if (p_ri && State == REPLACE && incCurpos())
X break;
X } while (p_ri || (Curpos.col > mincol && (Curpos.lnum != Insstart.lnum ||
X Curpos.col != Insstart.col)));
X if (extraspace)
X decCurpos();
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 AppendCharToRedobuff(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'): /* delete word before cursor */
X mode = 1;
X goto dodel;
X
X case Ctrl('U'): /* delete inserted text in current line */
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, 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 (echeck_abbr(TAB + 0x100))
X break;
X if (!p_et || (p_ri && State == REPLACE))
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 temp = (int)p_ts - Curpos.col % (int)p_ts;
X inschar(' '); /* delete one char in replace mode */
X while (--temp)
X insstr(" "); /* insstr does not delete chars */
X AppendToRedobuff("\t");
X goto redraw;
X
X case CR:
X case NL:
X if (echeck_abbr(c + 0x100))
X break;
X stop_arrow();
X if (State == REPLACE)
X {
X saved_char = gcharCurpos();
X delchar(FALSE);
X }
X AppendToRedobuff(NL_STR);
X if (!Opencmd(FORWARD, TRUE, State == INSERT))
X goto doESCkey; /* out of memory */
X if (p_ri)
X {
X decCurpos();
X if (State == REPLACE && Curpos.col > 0)
X decCurpos();
X }
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('Y'): /* copy from previous line */
X lnum = Curpos.lnum - 1;
X goto copychar;
X
X case Ctrl('E'): /* copy from next line */
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, TRUE);
X
X if (isidchar(c) || !echeck_abbr(c))
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 if (got_int)
X {

X *nextc = NUL;
X return Ctrl('C');
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 if (cc == K_ZERO) /* NUL is stored as NL */
X cc = '\n';
X }
X else if (cc == 0) /* NUL is stored as NL */
X cc = '\n';


X
X State = oldstate;

X *nextc = nc;
X got_int = FALSE; /* CTRL-C typed after CTRL-V is not an interrupt */
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 haveto_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. If p_tw == 0 it does nothing.
X */
X if (c == NUL || !isspace(c))
X {
X while (p_tw && 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
X if ((startcol = Curpos.col) == 0)
X break;
X coladvance((int)p_tw); /* find column of textwidth border */
X wantcol = Curpos.col;
X
X Curpos.col = startcol - 1;
X foundcol = 0;
X while (Curpos.col > 0) /* find position to break at */
X {
X if (isspace(gcharCurpos()))
X {
X while (Curpos.col > 0 && isspace(gcharCurpos()))
X --Curpos.col;
X if (Curpos.col == 0) /* only spaces in front of text */
X break;
X foundcol = Curpos.col + 1;
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; /* put cursor after pos. to break line */
X startcol -= foundcol;
X Opencmd(FORWARD, FALSE, FALSE);
X while (isspace(gcharCurpos()) && startcol) /* delete blanks */
X {
X delchar(FALSE);
X --startcol; /* adjust cursor pos. */
X }
X Curpos.col += startcol;
X curs_columns(FALSE); /* update Cursvcol */
X haveto_redraw = TRUE;
X }
X if (c == NUL) /* formatting only */
X return;
X if (haveto_redraw)
X {
X /*
X * If the cursor ended up just below the screen we scroll up here
X * to avoid a redraw of the whole screen in the most common cases.
X */
X if (Curpos.lnum == Botline && !emptyrows)
X s_del(0, 1, TRUE);
X updateScreen(CURSUPD);
X }
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 && !p_ri)
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 (!p_tw || (Cursvcol += charsize(p[i - 1])) < p_tw) &&
X !(!no_abbr && !isidchar(c) && isidchar(p[i - 1])))
X p[i++] = vgetc();
X p[i] = '\0';
X insstr(p);
X AppendToRedobuff(p);
X }
X else
X {
X inschar(c);
X AppendCharToRedobuff(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 ResetRedobuff();
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 if (p_list) /* the deletion is only seen in list mode */
X updateline();
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 = Curpos2ptr();
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 if (dir == FORWARD)
X {

X if (Botline > line_count) /* at end of file */
X Topline = line_count;
X else if (plines(Botline) >= Rows - 3 || /* next line is big */
X Botline - Topline <= 3) /* just three lines on screen */
X Topline = Botline;
X else
X Topline = Botline - 2;
X Curpos.lnum = Topline;
X if (count != 1)
X comp_Botline();
X }
X else /* dir == BACKWARDS */
X {
X lp = Topline;
X /*
X * If the first two lines on the screen are not too big, we keep
X * them on the screen.
X */
X if ((n = plines(lp)) > Rows / 2)
X --lp;
X else if (lp < line_count && n + plines(lp + 1) < Rows / 2)
X ++lp;
X Curpos.lnum = lp;
X n = 0;
X while (n <= Rows - 1 && lp >= 1)
X {
X n += plines(lp);
X --lp;
X }
X if (n <= Rows - 1) /* at begin of file */
X Topline = 1;
X else if (lp >= Topline - 2) /* happens with very long lines */
X {
X --Topline;
X comp_Botline();
X Curpos.lnum = Botline - 1;
X }
X else
X Topline = lp + 2;
X }
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 emsg("No inserted text yet");
X return;
X }
X if (c)
X stuffcharReadbuff(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}
X
X/*
X * Check the word in front of the cursor for an abbreviation.
X * Called when the non-id character "c" has been entered.
X * When an abbreviation is recognized it is removed from the text and
X * the replacement string is inserted in typestr, followed by "c".


X */
X static int

Xecheck_abbr(c)
X int c;
X{
X if (p_paste || no_abbr) /* no abbreviations or in paste mode */
X return FALSE;
X
X return check_abbr(c, nr2ptr(Curpos.lnum), Curpos.col,
X Curpos.lnum == Insstart.lnum ? Insstart.col : 0);
X}
END_OF_FILE
if test 22105 -ne `wc -c <'vim/src/edit.c'`; then
echo shar: \"'vim/src/edit.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/edit.c'
# end of 'vim/src/edit.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'\" \(21532 characters\)
sed "s/^X//" >'vim/src/unix.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X *
X * VIM - Vi IMproved
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#ifndef USE_SYSTEM /* use fork/exec to start the shell */
X# include <sys/wait.h>
X# if !defined(SCO) && !defined(SOLARIS) /* SCO returns pid_t */
Xextern int fork();
X# endif
X# if !defined(linux) && !defined(SOLARIS) && !defined(USL)
Xextern int execvp __ARGS((const char *, const char **));
X# endif
X#endif
X
X#ifdef SYSV_UNIX
X# if defined(__sgi) || defined(UTS2) || defined(UTS4)
X# include <sys/time.h>
X# endif
X# if defined(M_XENIX) || defined(SCO) || defined(UNICOS)
X# ifndef UNICOS
X# include <stropts.h>
X# endif
X# include <sys/select.h>
X# define bzero(a, b) memset((a), 0, (b))
X# else
X# include <poll.h>
X# endif
X# if defined(SCO) || defined(ISC)
X# include <sys/stream.h>
X# include <sys/ptem.h>
X# endif
X# if defined(M_UNIX) && !defined(SCO)
X# include <sys/time.h>
X# endif /* M_UNIX */
X# ifdef ISC
X# include <termios.h>
X# endif
X# include <termio.h>
X#else /* SYSV_UNIX */
X# include <sys/time.h>
X# if defined(hpux) || defined(linux)
X# include <termio.h>
X# if defined(hpux) && !defined(SIGWINCH) /* hpux 9.01 has it */
X# define SIGWINCH SIGWINDOW
X# endif
X# else
X# include <sgtty.h>
X# endif /* hpux */
X#endif /* !SYSV_UNIX */
X
X#if (defined(pyr) || defined(NO_FD_ZERO)) && defined(SYSV_UNIX) && defined(FD_ZERO)
X# undef FD_ZERO
X#endif
X
X#if defined(ESIX) || defined(M_UNIX)
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#ifdef USL
Xstatic void sig_winch __ARGS((int));
X#else
X# if defined(SIGWINCH) && !defined(linux) && !defined(__alpha) && !defined(mips) && !defined(_SEQUENT_) && !defined(SCO) && !defined(SOLARIS) && !defined(ISC)
Xstatic void sig_winch __ARGS((int, int, struct sigcontext *));
X# endif
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 void
Xmch_write(s, len)
X char *s;
X int len;
X{

X write(1, s, len);


X}
X
X/*
X * GetChars(): low level input funcion.
X * Get a characters from the keyboard.
X * If time == 0 do not wait for characters.
X * If time == n wait a short time for characters.
X * If time == -1 wait forever for characters.
X */
X int
XGetChars(buf, maxlen, time)
X char *buf;
X int maxlen;
X int time;
X{

X int len;


X
X if (time >= 0)
X {

X if (time < 20) /* don't know if this is necessary */
X time = 20;


X if (WaitForChar(time) == 0) /* no character available */
X return 0;
X }
X else /* time == -1 */
X {
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#if defined(SYSV_UNIX) && !defined(M_XENIX) && !defined(UNICOS)
X void
Xvim_delay()
X{
X poll(0, 0, 500);
X}
X#else
Xextern int select __ARGS((int, fd_set *, fd_set *, fd_set *, struct timeval *));


X
X void
Xvim_delay()
X{

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}
X#endif
X
X static void
X#if defined(__alpha) || defined(mips)
Xsig_winch()
X#else
X# if defined(_SEQUENT_) || defined(SCO) || defined(ISC)
Xsig_winch(sig, code)
X int sig;
X int code;
X# else
X# if defined(USL)
Xsig_winch(sig)
X int sig;
X# else
Xsig_winch(sig, code, scp)
X int sig;
X int code;
X struct sigcontext *scp;


X# endif
X# endif
X#endif

X{
X#if defined(SIGWINCH) && (defined(SYSV_UNIX) || defined(linux) || defined(hpux) || defined(USL))
X signal(SIGWINCH, (void (*)())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 kill(0, SIGTSTP); /* send ourselves a STOP signal */
X settmode(1);
X#else


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

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, (void (*)())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 * Return non-zero for success.
X */
X int
Xdirname(buf, len)
X char *buf;
X int len;
X{

X#if defined(SYSV_UNIX) || defined(hpux) || defined(linux)
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 0;
X }
X return 1;
X#else

X return (getwd(buf) != NULL);
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 int l;
X char olddir[MAXPATHL];

X char *p;


X int c;
X int retval = 1;
X

X if (fname == NULL) /* always fail */
X return 0;
X

X *buf = 0;
X if (*fname != '/')
X {
X /*
X * If the file name has a path, change to that directory for a moment,


X * and then do the getwd() (and get back to where we were).
X * This will get the correct path name with "../" things.
X */

X if ((p = strrchr(fname, '/')) != NULL)
X {
X#if defined(SYSV_UNIX) || defined(hpux) || defined(linux)


X if (getcwd(olddir, MAXPATHL) == NULL)

X#else
X if (getwd(olddir) == NULL)
X#endif


X {
X p = NULL; /* can't get current dir: don't chdir */
X retval = 0;
X }
X else
X {

X c = *p;
X *p = NUL;


X if (chdir(fname))
X retval = 0;
X else
X fname = p + 1;

X *p = c;
X }
X }

X#if defined(SYSV_UNIX) || defined(hpux) || defined(linux)


X if (getcwd(buf, len) == NULL)

X#else
X if (getwd(buf) == NULL)
X#endif


X {
X retval = 0;
X *buf = NUL;
X }
X l = strlen(buf);

X if (l && buf[l - 1] != '/')
X strcat(buf, "/");


X if (p)
X chdir(olddir);
X }
X strcat(buf, fname);
X return retval;
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#ifdef SCO
X return chmod(name, (mode_t)perm);
X#else
X return chmod(name, perm);
X#endif
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#ifdef _POSIX_SOURCE
X return S_ISDIR(statb.st_mode);
X#else
X return (statb.st_mode & S_IFMT) == S_IFDIR;
X#endif
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) && !defined(__NeXT__)
X /* for "new" tty systems */
X# ifdef CONVEX
X static struct termios told;
X struct termios tnew;
X# else
X static struct termio told;
X struct termio tnew;
X# endif
X#ifdef TIOCLGET
X static unsigned long tty_local;
X#endif


X
X if (raw)
X {

X#ifdef TIOCLGET
X ioctl(0, TIOCLGET, &tty_local);
X#endif
X ioctl(0, TCGETA, &told);
X tnew = told;
X tnew.c_iflag &= ~(ICRNL | IXON); /* ICRNL enables typing ^V^M */
X /* IXON enables typing ^S/^Q */
X tnew.c_lflag &= ~(ICANON | ECHO | ISIG | ECHOE
X#ifdef IEXTEN
X | IEXTEN /* IEXTEN enables typing ^V on SOLARIS */
X#endif
X );
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 {
X ioctl(0, TCSETA, &told);
X#ifdef TIOCLGET
X ioctl(0, TIOCLSET, &tty_local);
X#endif
X }
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/*
X * Try to get the current window size:
X * 1. with an ioctl(), most accurate method
X * 2. from the environment variables LINES and COLUMNS
X * 3. from the termcap
X * 4. keep using the old values
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 * 1. try using an ioctl. It is the most accurate method.
X */
X# ifdef TIOCGSIZE
X {
X struct ttysize ts;
X
X if (ioctl(0, TIOCGSIZE, &ts) == 0)
X {
X Columns = ts.ts_cols;
X Rows = ts.ts_lines;
X }
X }
X# else /* TIOCGSIZE */
X# ifdef TIOCGWINSZ
X {
X struct winsize ws;
X
X if (ioctl(0, TIOCGWINSZ, &ws) == 0)
X {
X Columns = ws.ws_col;
X Rows = ws.ws_row;
X }
X }
X# endif /* TIOCGWINSZ */
X# endif /* TIOCGSIZE */
X
X/*
X * 2. get size from environment
X */
X if (Columns == 0 || Rows == 0)
X {
X if ((p = (char *)getenv("LINES")))
X Rows = atoi(p);
X if ((p = (char *)getenv("COLUMNS")))
X Columns = atoi(p);
X }
X
X#ifdef TERMCAP
X/*
X * 3. 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 * 4. 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 Rows_max = Rows; /* remember physical max height */
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, cooked)
X char *cmd;
X int dummy;
X int cooked;
X{
X#ifdef USE_SYSTEM /* use system() to start the shell: simple but slow */
X
X int x;
X char newcmd[1024];


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

X sprintf(newcmd, "%s -c \"%s\"", p_sh, cmd);


X x = system(newcmd);
X }

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


X outchar('\n');
X }

X else if (x)


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

X return x;
X
X#else /* USE_SYSTEM */ /* first attempt at not using system() */
X
X char newcmd[1024];
X int pid;
X int status = -1;
X char **argv = NULL;
X int argc;
X int i;
X char *p;
X int inquote;
X
X flushbuf();
X signal(SIGINT, SIG_IGN); /* we don't want to be killed here */


X if (cooked)
X settmode(0); /* set to cooked mode */
X

X /*
X * 1: find number of arguments
X * 2: separate them and built argv[]
X */
X strcpy(newcmd, p_sh);
X for (i = 0; i < 2; ++i)
X {
X p = newcmd;
X inquote = FALSE;
X argc = 0;


X for (;;)
X {

X if (i == 1)

X argv[argc] = p;
X ++argc;
X while (*p && (inquote || (*p != ' ' && *p != TAB)))
X {
X if (*p == '"')
X inquote = !inquote;
X ++p;
X }
X if (*p == NUL)
X break;


X if (i == 1)

X *p++ = NUL;
X skipspace(&p);
X }
X if (i == 0)
X {
X argv = (char **)alloc((unsigned)((argc + 3) * sizeof(char *)));
X if (argv == NULL) /* out of memory */
X goto error;
X }
X }
X if (cmd != NULL)
X {
X argv[argc++] = "-c";
X argv[argc++] = cmd;
X }
X argv[argc] = NULL;
X
X if ((pid = fork()) == -1) /* maybe we should use vfork() */
X emsg("Cannot fork");
X else if (pid == 0) /* child */
X {
X signal(SIGINT, SIG_DFL);
X execvp(argv[0], argv);
X exit(127); /* exec failed, return failure code */
X }
X else /* parent */
X {
X wait(&status);
X status = (status >> 8) & 255;
X if (status)
X {
X if (status == 127)
X emsg2("Cannot execute shell %s", p_sh);
X else
X smsg("%d returned", status);


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

X free(argv);
X
Xerror:


X if (cooked)
X settmode(1); /* set to raw mode */

X signal(SIGINT, SIG_DFL);
X return status;
X
X#endif /* USE_SYSTEM */
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 }

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#if !defined(__alpha) && !defined(mips) && !defined(SCO) && !defined(remove) && !defined(CONVEX)
X int
Xremove(buf)
X# if defined(linux) || defined(__STDC__) || defined(__NeXT__) || defined(M_UNIX)
X const
X# endif
X char *buf;
X{
X return unlink(buf);
X}
X#endif
X
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 int dir;
X size_t len;
X FILE *fd;
X char *buffer;
X char *p;
X int use_glob = FALSE;
X
X *num_file = 0; /* default: no files found */
X *file = (char **)"";
X
X /*
X * If there are no wildcards, just copy the names to allocated memory.
X * Saves a lot of time, because we don't have to start a new shell.
X */
X if (!have_wildcard(num_pat, pat))
X {
X *file = (char **)alloc(num_pat * sizeof(char *));
X if (*file == NULL)
X {
X *file = (char **)"";
X return 1;
X }


X for (i = 0; i < num_pat; i++)

X (*file)[i] = strsave(pat[i]);
X *num_file = num_pat;


X return 0;
X }
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 * If we use csh, glob will work better than echo.
X */
X if ((len = strlen(p_sh)) >= 3 && strcmp(p_sh + len - 3, "csh") == 0)
X use_glob = TRUE;
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 if (use_glob)
X strcpy(command, "glob >"); /* built the shell command */
X else
X strcpy(command, "echo >"); /* built the shell command */
X strcat(command, tmpname);
X for (i = 0; i < num_pat; ++i)
X {
X#ifdef USE_SYSTEM
X strcat(command, " \""); /* need extra quotes because we */
X strcat(command, pat[i]); /* start the shell twice */
X strcat(command, "\"");
X#else
X strcat(command, " ");
X strcat(command, pat[i]);
X#endif
X }
X i = call_shell(command, 0, FALSE); /* 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 must_redraw = 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

X if (use_glob) /* file names are separated with NUL */
X {
X buffer[len] = NUL; /* make sure the buffers ends in NUL */
X i = 0;
X for (p = buffer; p < buffer + len; ++p)
X if (*p == NUL) /* count entry */
X ++i;
X if (len)
X ++i; /* count last entry */
X }
X else /* file names are separated with SPACE */
X {
X buffer[len] = '\n'; /* make sure the buffers ends in NL */
X p = buffer;
X for (i = 0; *p != '\n'; ++i) /* count number of entries */
X {
X while (*p != ' ' && *p != '\n') /* skip entry */
X ++p;
X skipspace(&p); /* skip to next entry */
X }
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 if (use_glob)
X {
X while (*p && p < buffer + len) /* skip entry */
X ++p;
X ++p; /* skip NUL */
X }
X else
X {
X while (*p != ' ' && *p != '\n') /* skip entry */
X ++p;
X if (*p == '\n') /* last entry */
X *p = NUL;
X else
X {
X *p++ = NUL;
X skipspace(&p); /* skip to next entry */
X }
X }
X }
X for (i = 0; i < *num_file; ++i)
X {
X dir = (isdir((*file)[i]) > 0);
X if (dir < 0) /* if file doesn't exist don't add '/' */
X dir = 0;
X p = alloc((unsigned)(strlen((*file)[i]) + 1 + dir));
X if (p)
X {
X strcpy(p, (*file)[i]);
X if (dir)
X strcat(p, "/");
X }
X (*file)[i] = p;
X }
X free(buffer);


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 while (num--)
X free(file[num]);
X free(file);
X}
X

X int
Xhas_wildcard(p)
X char *p;
X{
X#ifdef __STDC__
X return strpbrk(p, "*?[{`~$") != NULL;
X#else
X for ( ; *p; ++p)
X if (strchr("*?[{`~$", *p) != NULL)


X return 1;
X return 0;

X#endif
X}
X
X int

Xhave_wildcard(num, file)


X int num;
X char **file;
X{

X register int i;
X

X for (i = 0; i < num; i++)
X if (has_wildcard(file[i]))


X return 1;
X return 0;
X}
X

X#if defined(M_XENIX) || defined(UTS2)
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, dest)
X char *src, *dest;
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 || UTS2 */
END_OF_FILE
if test 21532 -ne `wc -c <'vim/src/unix.c'`; then
echo shar: \"'vim/src/unix.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/unix.c'
# end of 'vim/src/unix.c'
fi
echo shar: End of archive 10 \(of 25\).
cp /dev/null ark10isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:50:09 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 61
Archive-name: vim/part11

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/fileio.c vim/src/storage.c


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:05 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH

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'\" \(22193 characters\)
sed "s/^X//" >'vim/src/fileio.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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#ifdef MSDOS
X# include <io.h>
X#endif


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
Xstatic int noendofline = FALSE; /* Set to TRUE when last line has no
X EOL in binary mode */
X
X#define BUFSIZE 4096 /* size of normal write buffer */
X#define SBUFSIZE 256 /* size of emergency write buffer */
X
Xstatic int write_buf __ARGS((int, char *, int));
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, sfname, from, newfile)
X char *fname;
X char *sfname;
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 register u_char *p;
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 int firstpart = TRUE; /* reading first part */
X#ifdef UNIX
X int perm;
X#endif
X int textmode = p_tx; /* accept CR-LF for line break */
X
X if (sfname == NULL)
X sfname = fname;
X /*
X * Use the short filename whenever possible.
X * Avoids problems with networks and when directory names are changed.
X */
X if (!did_cd)
X fname = sfname;
X
X if (bufempty()) /* special case: buffer has no lines */
X linecnt = 0;
X
X#ifdef UNIX
X /*
X * On Unix it is possible to read a directory, so we have to
X * check for it before the open().
X */
X perm = getperm(fname);
X#ifdef _POSIX_SOURCE
X if (perm >= 0 && !S_ISREG(perm)) /* not a regular file */
X#else
X if (perm >= 0 && (perm & S_IFMT) != S_IFREG) /* not a regular file */
X#endif
X {
X#ifdef _POSIX_SOURCE
X if (S_ISDIR(perm))
X#else
X if ((perm & S_IFMT) == S_IFDIR)
X#endif
X filemess(fname, "is a directory");
X else
X filemess(fname, "is not a file");
X return TRUE;


X }
X#endif
X
X if (

X#ifdef UNIX
X !(perm & 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#ifdef MSDOS
X /*
X * The screen may be messed up by the "insert disk
X * in drive b: and hit return" message
X */
X updateScreen(CLEAR);
X#endif
X
X#ifndef UNIX
X /*
X * On MSDOS and Amiga we can't open a directory, check here.
X */
X if (isdir(fname) > 0)
X filemess(fname, "is a directory");
X else
X#endif
X if (newfile)
X filemess(fname, "[New File]");
X
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 (newfile)
X noendofline = FALSE;
X
X if ((filesize = lseek(fd, 0L, 2)) < 0) /* get length of file */
X filesize = UNKNOWN;
X lseek(fd, 0L, 0);
X
X filemess(fname, ""); /* show that we are busy */
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 (and other things).
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 * when reading the first part of a file: guess EOL type
X */
X if (firstpart && p_ta)
X {
X for (p = ptr; p < ptr + size; ++p)
X if (*p == NL)
X {
X if (p > ptr && p[-1] == CR) /* found CR-NL */
X textmode = TRUE;
X else /* found a single NL */
X textmode = FALSE;
X /* if editing a new file: may set p_tx */
X if (newfile && p_tx != textmode)
X {
X p_tx = textmode;
X paramchanged("tx");
X }


X break;
X }
X }
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 (textmode && ptr[-1] == CR) /* remove CR */
X ptr[-1] = NUL;
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 firstpart = FALSE;
X }
X if (lnum != from && !newfile) /* added at least one line */
X CHANGED;
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 if (newfile && p_bin) /* remember for when writing */
X noendofline = TRUE;
X *ptr = NUL;
X if (!appendline(lnum, (char *)buffer))
X error = 1;
X else if (!newfile)
X CHANGED;
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%s%ld line%s, %ld character%s",
X fname,
X p_ro ? "[readonly] " : "",
X incomplete ? "[Incomplete last line] " : "",
X error ? "[READ ERRORS] " : "",
X#ifdef MSDOS
X textmode ? "" : "[notextmode] ",
X#else
X textmode ? "[textmode] " : "",
X#endif
X (long)linecnt, plural((long)linecnt),
X filesize, plural(filesize));
X
X if (error && newfile) /* with errors we should not write the file */
X {
X p_ro = TRUE;
X paramchanged("ro");
X }
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 * When whole is TRUE and start == 1 and end == line_count, reset Changed.
X */
X int
Xwriteit(fname, sfname, start, end, append, forceit, whole)
X char *fname;
X char *sfname;
X linenr_t start, end;
X int append;
X int forceit;
X int whole;
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 char smallbuf[SBUFSIZE];
X int bufsize;
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 if (sfname == NULL)
X sfname = fname;
X /*
X * Use the short filename whenever possible.
X * Avoids problems with networks and when directory names are changed.
X */
X if (!did_cd)
X fname = sfname;
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 if (exiting)
X settmode(0); /* when exiting allow typahead now */
X
X filemess(fname, ""); /* show that we are busy */
X
X buffer = alloc(BUFSIZE);
X if (buffer == NULL) /* can't allocate big buffer, use small one */
X {
X buffer = smallbuf;
X bufsize = SBUFSIZE;
X }
X else
X bufsize = BUFSIZE;
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 {
X#ifdef _POSIX_SOURCE
X if (!S_ISREG(old.st_mode)) /* not a file */
X#else
X if ((old.st_mode & S_IFMT) != S_IFREG) /* not a file */
X#endif
X {
X#ifdef _POSIX_SOURCE
X if (S_ISDIR(old.st_mode))
X#else
X if ((old.st_mode & S_IFMT) == S_IFDIR)
X#endif
X errmsg = "is a directory";
X else
X errmsg = "is not a file";
X goto fail;
X }
X perm = old.st_mode;
X }
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;
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_CREAT, ) 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 if (!stat(backup, &new) &&
X 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 (use ! to override)";
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 /*
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 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 if (!stat(backup, &new) &&
X new.st_dev == old.st_dev && new.st_ino == old.st_ino)
X {
X errmsg = "Invalid backup file (use ! to override)";
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 (use ! to override)";
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 if (write_buf(bfd, buf, buflen) == -1)
X {
X errmsg = "Can't write to backup file (use ! to override)";
X goto writeerr;
X }
X }
Xwriteerr:
X close(bfd);
X if (buflen < 0)
X errmsg = "Can't read file for backup (use ! to override)";
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 setperm(fname, perm);
X made_writable = TRUE;
X /* if we are writing to the current file, readonly makes no sense */
X if (fname == Filename || fname == sFilename)
X p_ro = FALSE;
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 else if (isdir(fname) > 0)
X {
X errmsg = "is a directory";
X goto fail;
X }
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 (use ! to override)";
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 * Appending will fail if the file does not exist and forceit is FALSE.
X */
X while ((fd = open(fname, O_WRONLY | (append ?
X (forceit ? (O_APPEND | O_CREAT) : O_APPEND) :
X (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 if (!append) /* don't remove when appending */
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 if (end > line_count)
X end = line_count;
X len = 0;
X s = buffer;
X nchars = 0;
X for (lnum = start; lnum <= end; ++lnum)
X {
X /*
X * The next while 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_buf(fd, buffer, bufsize) == -1)
X {
X end = 0; /* write error: break loop */
X break;
X }
X nchars += bufsize;
X s = buffer;
X len = 0;
X }
X /* write failed or last line has no EOL: stop here */
X if (end == 0 || (p_bin && lnum == line_count && noendofline))
X break;
X if (p_tx) /* write CR-NL */
X {
X *s = CR;
X ++s;
X if (++len == bufsize)
X {
X if (write_buf(fd, buffer, bufsize) == -1)
X {
X end = 0; /* write error: break loop */
X break;
X }
X nchars += bufsize;
X s = buffer;
X len = 0;
X }
X }
X *s = NL;
X ++s;
X if (++len == bufsize && end)
X {
X if (write_buf(fd, buffer, bufsize) == -1)
X {
X end = 0; /* write error: break loop */
X break;
X }
X nchars += bufsize;
X s = buffer;
X len = 0;
X }
X }
X if (len && end)
X {
X if (write_buf(fd, buffer, 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 if (!exiting)
X updateScreen(CLEAR);
X#endif
X
X lnum -= start; /* compute number of written lines */
X smsg("\"%s\"%s%s %ld line%s, %ld character%s",
X fname,
X newfile ? " [New File]" : " ",
X#ifdef MSDOS
X p_tx ? "" : "[notextmode]",
X#else
X p_tx ? "[textmode]" : "",
X#endif
X (long)lnum, plural((long)lnum),
X nchars, plural(nchars));
X if (whole && start == 1 && end == line_count) /* when written everything */
X {
X UNCHANGED;
X NotEdited = FALSE;
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 * write_buf: call write() to write a buffer


X */
X static int

Xwrite_buf(fd, buf, len)
X int fd;


X char *buf;
X int len;
X{

X int wlen;
X
X while (len)
X {
X wlen = write(fd, buf, (size_t)len);
X if (wlen <= 0) /* error! */
X return -1;
X len -= wlen;
X buf += wlen;
X }


X return 0;
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 (!p_ml || (nmlines = (int)p_mls) == 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 || strncmp(s, "vim:", (size_t)4) == 0))
X {
X do
X ++s;
X while (s[-1] != ':');
X s = cs = strsave(s);
X if (cs == NULL)
X break;
X end = FALSE;
X while (end == FALSE)
X {
X while (*s == ' ' || *s == TAB)
X ++s;
X if (*s == NUL)
X break;
X for (e = s; (*e != ':' || *(e - 1) == '\\') && *e != NUL; ++e)
X ;
X if (*e == NUL)
X end = TRUE;
X *e = NUL;
X if (strncmp(s, "set ", (size_t)4) == 0) /* "vi:set opt opt opt: foo" */
X {
X doset(s + 4);
X break;
X }
X if (doset(s)) /* stop if error found */
X break;
X s = e + 1;
X }
X free(cs);
X break;
X }
X prev = *s;
X }
X}
END_OF_FILE
if test 22193 -ne `wc -c <'vim/src/fileio.c'`; then
echo shar: \"'vim/src/fileio.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/fileio.c'
# end of 'vim/src/fileio.c'
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'\" \(23385 characters\)
sed "s/^X//" >'vim/src/storage.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 block_head. They are all freed
X * when abandoning a file, so we don't have to free every single line. The
X * list is kept sorted on memory address.
X * block_alloc() allocates a block.
X * m_blockfree() frees all blocks.
X *
X * The available chunks of memory are kept in free chunk lists. There is
X * one free list for each block of allocated memory. The list is kept sorted
X * on memory address.
X * alloc_line() gets a chunk from the free lists.
X * free_line() returns a chunk to the free lists.
X * m_search points to the chunk before the chunk that was freed/allocated the
X * last time.
X * mb_current points to the b_head where m_search points into the free list.
X *
X *
X * block_head /---> block #1 /---> block #2
X * mb_next ---/ mb_next ---/ mb_next ---> NULL
X * mb_info mb_info mb_info


X * | | |
X * V V V

X * NULL free chunk #1.1 free chunk #2.1


X * | |
X * V V

X * free chunk #1.2 NULL


X * |
X * V

X * NULL
X *
X * When a single free chunk list would have been used, it could take a lot
X * of time in free_line() to find the correct place to insert a chunk in the
X * free list. The single free list would become very long when many lines are
X * changed (e.g. with :%s/^M$//).
X */
X
X /*
X * this blocksize is used when allocating new lines
X * When reading files larger blocks are used (see fileio.c)
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 */
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 one of the free chunk lists. It must still
X * end in 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 (32 or 64 bit) aligned.
X * On most other systems they are short (16 bit) aligned.
X */
X
X#ifdef UNIX
X# define ALIGN_LONG /* longword alignment and use filler byte */
X# define ALIGN_SIZE (sizeof(long))
X# define ALIGN_MASK (ALIGN_SIZE - 1)
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

X/*
X * stucture used to link chunks in one of the free chunk lists.
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
X/*
X * structure used to link blocks in the list of allocated blocks.
X */
Xstruct m_block
X{
X struct m_block *mb_next; /* pointer to next allocated block */
X info_t mb_info; /* head of free chuck list for this block */
X};
X
Xstatic struct m_block block_head = {NULL, {0, NULL}};
X /* head of allocated memory block list */
X
Xstatic info_t *m_search = NULL; /* pointer to chunk before previously
X allocated/freed chunk */
Xstatic struct m_block *mb_current = NULL; /* block where m_search points in */
X
X/*
X * Allocate a block of memory and link it in the allocated block list.


X */
X char *

Xm_blockalloc(size, message)


X u_long size;
X int message;
X{

X struct m_block *p;
X struct m_block *mp, *next;
X
X p = (struct m_block *)lalloc(size + sizeof(struct m_block), message);


X if (p != NULL)
X {

X /* Insert the block into the allocated block list, keeping it
X sorted on address. */
X for (mp = &block_head; (next = mp->mb_next) != NULL && next < p; mp = next)
X ;
X p->mb_next = next; /* link in block list */
X mp->mb_next = p;
X p->mb_info.m_next = NULL; /* clear free list */
X p->mb_info.m_size = 0;
X mb_current = p; /* remember current block */
X m_search = NULL;
X p++; /* return usable memory */
X }
X return (char *)p;
X}
X
X/*
X * free all allocated memory blocks
X */
X void
Xm_blockfree()
X{
X struct m_block *p, *np;
X
X for (p = block_head.mb_next; p != NULL; p = np)
X {
X np = p->mb_next;
X free((char *)p);
X }
X block_head.mb_next = NULL;
X m_search = NULL;
X mb_current = 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 correct free list, keeping it sorted on address.
X */
X void
Xfree_line(ptr)
X char *ptr;
X{
X register info_t *next;
X register info_t *prev, *curr;
X register info_t *mp;
X long len;
X struct m_block *nextb;
X
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 & ALIGN_MASK)) != 0) /* lose some bytes */
X {
X c = ALIGN_SIZE - c;
X ptr += c;
X len -= c;
X }
X#else /* use short (16 bit) alignment */
X len = strlen(ptr) + 1;
X if (len > 0xff00) /* can't handle this large (cannot happen?) */
X len = 0xff00;
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 /* illegal situation: there is no NUL or 0xff in front of the line */
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 /* find block where chunk could be a part off */
X /* if we change mb_current, m_search is set to NULL */
X if (mb_current == NULL || mp < (info_t *)mb_current)
X {
X mb_current = block_head.mb_next;
X m_search = NULL;
X }
X if ((nextb = mb_current->mb_next) != NULL && (info_t *)nextb < mp)
X {
X mb_current = nextb;
X m_search = NULL;
X }
X while ((nextb = mb_current->mb_next) != NULL && (info_t *)nextb < mp)
X mb_current = nextb;
X
X curr = NULL;
X /* if mp is smaller than m_search->m_next we go to the start of the free list */
X if (m_search == NULL || mp < (m_search->m_next))
X next = &(mb_current->mb_info);
X else
X next = m_search;
X /*
X * The following loop is executed very often.
X * Therefore it has been optimized at the cost of readability.
X * Keep it fast!
X */
X#ifdef SLOW_BUT_EASY_TO_READ
X do
X {
X prev = curr;
X curr = next;
X next = next->m_next;
X }
X while (mp > next && next != NULL);
X#else
X do /* first, middle, last */
X {
X prev = next->m_next; /* curr, next, prev */
X if (prev == NULL || mp <= prev)
X {
X prev = curr;
X curr = next;
X next = next->m_next;
X break;
X }
X curr = prev->m_next; /* next, prev, curr */
X if (curr == NULL || mp <= curr)
X {
X prev = next;
X curr = prev->m_next;
X next = curr->m_next;
X break;
X }
X next = curr->m_next; /* prev, curr, next */
X }
X while (mp > next && next != NULL);
X#endif
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}
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 struct m_block *mbp;
X int size_align;
X
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 + ALIGN_MASK) & ~ALIGN_MASK;
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 (uninitialized free list) we start at block_head */
X if (mb_current == NULL || m_search == NULL)
X {
X mb_current = &block_head;
X m_search = &(block_head.mb_info);
X }
X
X/* search for space in free list */
X mprev = m_search;
X mbp = mb_current;
X mp = m_search->m_next;
X if (mp == NULL)
X {
X if (mbp->mb_next)
X mbp = mbp->mb_next;
X else
X mbp = &block_head;
X mp = m_search = &(mbp->mb_info);
X }
X while (mp->m_size < size)
X {
X if (mp == m_search) /* back where we started in free chunk list */
X {
X if (mbp->mb_next)
X mbp = mbp->mb_next;
X else
X mbp = &block_head;
X mp = m_search = &(mbp->mb_info);
X if (mbp == mb_current) /* back where we started in block list */
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 mbp = mb_current;
X }
X }
X mprev = mp;
X if ((mp = mp->m_next) == NULL) /* at end of the list */
X mp = &(mbp->mb_info); /* wrap around to begin */
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 mb_current = mbp;
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
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 char *b_ptr[BLOCK_SIZE]; /* pointers to the lines */
X char b_flags[BLOCK_SIZE]; /* see below */
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};
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 */
Xstatic linenr_t curr_count_max; /* curr_count + curr_block->b_count */
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 UNCHANGED;
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 = curr_count;
X
X /*
X * if we don't have a current block or the line is not in the current block,
X * make the block containing the line the current block.
X */
X if (count == 0 || nr >= curr_count_max || nr < count)
X {
X register block_t *bp = curr_block;
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_count_max = count + bp->b_count;
X curr_block = bp;
X }
X return (curr_block->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 char *

XCurpos2ptr()
X{
X return (nr2ptr(Curpos.lnum) + Curpos.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 u_short 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 ++curr_count_max;


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 curr_count_max = curr_count + bp->b_count;
X }


X return TRUE;
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 (slow!) */
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 else
X --curr_count_max;
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 23385 -ne `wc -c <'vim/src/storage.c'`; then
echo shar: \"'vim/src/storage.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/storage.c'
# end of 'vim/src/storage.c'
fi
echo shar: End of archive 11 \(of 25\).
cp /dev/null ark11isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:50:36 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 62
Archive-name: vim/part12

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/readme2.0 vim/src/param.c
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:06 1993


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

if test -f 'vim/readme2.0' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/readme2.0'\"
else
echo shar: Extracting \"'vim/readme2.0'\" \(23966 characters\)
sed "s/^X//" >'vim/readme2.0' <<'END_OF_FILE'
XThis is a summary of the modifications from Vim version 1.27 to version 2.0.
X
XIncompatible changes
X====================
X
XThe 'exrc' and 'secure' options are default off. If you want Vim to read a
X.exrc or .vimrc in the current directory, you will have to set 'exrc' in your
Xglobal .exrc or .vimrc. People doing this are supposed to know about the
Xsecurity problems, so they don't need the 'secure' option set. This is also
Xmore vi-compatible.
X
XRenamed quoting to visual select and swapped 'q' and 'v' keys to avoid
Xproblems with CTRL-Q. This is also more Elvis compatible. The commands now are:
X 'v' start character-wise visual select
X 'V' start line-wise visual select
X CTRL-V start block-wise visual select
X
X 'q' start recording
X 'Q' formatting operator
X
XChanged CTRL-R into CTRL-Y for insert mode (copy character from line above).
XThis is more logical when comparing the meaning of CTRL-E and CTRL-Y in
Xcommand mode and insert mode.
X
XReplaced CTRL-B with CTRL-R (insert contents of a register) in insert mode.
XThis mnemonic is more logical, because "register" is used in the documentation.
X
XAdded ":pwd" command and made ":cd" without an argument for Unix go to home
Xdirectory. This is more vi-compatible and behaves the same as the unix cd
Xcommand. The ":cd" command for MSDOS and Amiga versions is unchanged, these
Xmachines don't have a home directory.
X
XWith the 'confirm' option to :s anything but 'y', 'n', ESC, CTRL-C or 'q' is
Xignored. Nothing happens until you type a valid character. Quit substitution
Xwith <q>, ESC and CTRL-C.
X
XSwapped 'u' and 'U' for visual mode. 'u' makes lower case, 'U' upper. This is
Xmore logical.
X
XAdded 'wildchar' option for filename completion. The default is <TAB> instead
Xof <ESC>. Most other programs use this and it avoids problems with terminal
Xsequences that start with <ESC> (one second wait before filename completion
Xstarts).
X
XChanged short name of 'showmode' option from "mo" to "smd".
X
XChanged short name of 'modelines' from 'ml' into 'mls'. This is vi-compatible.
X
XChanged meaning of the argument to :cf. The 'errorfile' option will now be
Xset to the argument.
X
X
XMajor improvements
X==================
X
XAdded horizontal scrolling and 'wrap' option. This allows the user to choose
Xbetween line wrap (you see all the text but long lines mess up the layout)
Xand horizontal scrolling (correct layout but you see only a part of long
Xlines).
X
XAdded 'sidescroll' option. It is the number of columns to jump when the
Xcursor gets off of the screen while the 'wrap' option is off. The default is
X0, which means that the cursor is centered on the screen. Set it to a small
Xnumber if you have fast screen I/O.
X
XWildcard expansion has been made more compatible with other programs. Added
X'wildchar' option; default is <TAB> instead of <ESC>. With multiple matches
Xfirst match is inserted. CTRL-A inserts all matches. With CTRL-D command: If
Xfile is a dir '/' is added. WILD_CARDS code now always included, no
Xcompile-time option anymore. 'wildchar' is only recognized when typed, not in
Xa macro (prevents problems with macros containing TABs).
X
XCTRL-L on commandline inserts longest common part of filename completion. Now
Xyou can choose between using TAB (or 'wildchar') for getting the first match
Xor CTRL-L for getting the longest match.
X
XAdded automatic textmode (lines ending in CR-LF instead of LF) detection and
X'textauto' option. This works when starting to edit a file and when doing a
X":r" command. This is useful on MS-DOS systems with a network file system and
Xwhen editing an MS-DOS floppy on Unix or Amiga. Added [(no)textmode] message
Xto readfile() and writeit(). Now you can see when unexpected line separators
Xhave been detected or are being used.
X
XAdded "-b" command line option. This makes it more easy to edit binary files
Xwithout unexpected effects.
X
XAdded ":make" command, 'errorformat' option and argument to -e option. Now you
Xcan do your compiling from within Vim and automatically jump to the line where
Xthe error is. Can be adjusted to work with many compilers. The command to be
Xexecuted with ":make" can be set with the 'makeprg' option. '%' and '#' in
Xthe 'makeprg' option are expanded as usual in a command line.
X
XAdded reverse insert mode, 'revins' option and CTRL-P command. Now you can
Xtype backwards!
X
XAdded abbreviations. They work in insert mode and in command line mode, just
Xlike Vi. Also added :iabbr, :cabbr and friends: abbreviations for command line
Xonly or insert mode only. Added dumping of abbreviations to :mkexrc.
X
XAdded ":center" (center the lines), ":left" (left adjustment) and ":right"
X(right adjustment). ":center" and ":right" use the 'textwith' option.
X
XAdded bios calls for MSDOS screen output, ansi.sys no longer required.
XScreen updating much faster now and works with more video modes. Added pcansi
Xtermcap for when not using the console.
X
X
XOther improvements
X==================
X
XIf 'expandtab' is set, spaces will also be used in indents.
X
X'tabstop' maximum removed.
X
XDigraphs also work in the command line.
X
XAdded :redo, same as CTRL-R.
X
XAdded '-x' option for the Amiga version. The current window will be used, but
Xshell commands are not possible. Handy when starting Vim from a mail program.
X
XAdded 'secure' option. When reset you don't get the warnings from reading a
X.vimrc/.exrc file in the current directory.
X
XAdded 'exrc' option. Now you can switch the reading of ".exrc/.vimrc" off.
X
XAdded "vim:" modelines. Other vi versions allowed all ex commands in
Xmodelines, vim only allows set commands. Use "vim:" to avoid confusion.
X
XOptimized position of ruler and shown command.
X
XImproved redrawing of long command lines.
X
XAdded <SC_UP> and <SC_DOWN> to command line editing. This finds the
Xnext/previous command that starts with the text in front of the cursor.
X
XAdded CTRL-B and CTRL-E to command line editing. Go to begin/end of the
Xcommand line.
X
XWith ":w!" readonly is reset.
X
XIf possible the cursor is switched off while visual selecting. Makes it more
Xclear what is selected.
X
XFormat deletes blanks at end of lines. This makes it possible to use
Xformatting to limit the text to a certain number of columns (e.g. 80).
X
XModelines quits after first error. This avoids a long list of errors when
Xediting a text with "vi:" accidently embedded (e.g. vim.hlp).
X
XOptimized undo for delete. Now only 2/3 of the memory used and less copying of
Xlines. Speed up when deleting a lot of lines in a big file.
X
XAdded :suspend, same as CTRL-Z.
X
XAdded command-line-only mapping ":cmap", insert-mode-only ":imap" and the
Xassociated unmap and noremap commands. Now you can enter mappings for every
Xmode (command/insert/command-line) separately.
X
XChanged smart-indent a little.
X
XNow one free chunk list per allocated block in storage.c. Makes editing big
Xfiles a bit faster.
X
XAdded repeat to visual select. now you can select the same area again.
X
XImproved showmatch() for uneven number of quotes.
X
XAdded 'paste' option. This makes it easy to swith between typing and inserting
Xtext with a cut/paste method. Doing ":set nopaste" before ":set paste" does
Xnot do anything.
X
XAdded sFilename: Filename without path. Mostly only the name you typed is
Xshown, but internally the full path name is remembered. Otherwise the ":cd"
Xcommand would mess up the real file name. Use short file name as long as :cd
Xnot used. If one does not use :cd the short file name will be valid. This
Xwill avoid long path names to be printed on the status line and having to
X"hit return to continue". It is also better to avoid problems with some
Xnetworks where the absolute path is not valid after a while. If :cd has been
Xused the full path name needs to be used to get to the right file.
X
XChanged :digraph in :digraphs. Now "digraph" and "digraphs" both work.
X
XAdded emsg2() for more informative error messages. For example: "Cannot open
X<filename> for writing" with :mkexrc.
X
XMade 'r' command use get_literal(). Now you enter the decimal code for the
Xreplacement character with CTRL-V nnn, where nnn is any decimal number.
X
XAdded default digraphs for MSDOS.
X
XAdded 'timoutlen' option. One can set this depending on the speed of the
Xterminal used. Helps when cursor keys start with ESC while working on the
Xconsole: get out of insert mode fast. Or when using a terminal over a very
Xslow line, although you better set 'notimeout' then.
X
XAdded wildcard expansion to tags, so environment variables in the file name
Xget expanded.
X
XNo error message for a non-existant tags file, only for a not-found tag.
X
XExpandWildCards() in unix.c does not start the shell when there are no
Xwildcards. Speeds up editing new files.
X
X:set can now show several values in one command, e.g. ":set columns lines".
X
XIn MSDOS use $COMSPEC to init 'shell' option.
X
XAdded 'formatprg' option for external formatting. This is the program to use
Xwhen the 'Q' command is given. If it is an empty string (which is the
Xdefault) the internal formatting is used.
X
XMade ioctl() first in mch_get_winsize() in unix.c. The environment variables
Xare now only used if the ioctl() fails. This works without problems on more
Xsystems.
X
XAdded second column number to ruler. Now you can see both the column number
Xin the file and on the screen.
X
XWith MSDOS also accept '/' as file name separator. Works better in combination
Xwith 4dos.
X
XScreen redrawn after t_tp set. You can now directly see the result of the new
Xcolors.
X
XImproved error handling from write() in writeit(). Made the write_buf
Xfunction to repeat write() until all characters have been written or an error
Xis detected. Fixes a possible problem with signals (which has never been
Xreported).
X
XWorkaround for cursor key that sends ^H. The televideo 925 sends codes for
Xcursor keys that cannot be distinguished from normal commands. At least the
Xbackspace is working again now.
X
XIf you are using a csh use 'glob' instead of 'echo' in WildExpand in unix.c.
XThis makes it possible to find file names with embedded spaces. Spaces in the
Xentered file name are still not possible (vi can't do it either).
X
XCall_shell() in unix.c uses fork/exec instead of system. This makes it about
Xtwice as fast and fixes problems with special characters in the command, e.g.
X"!!awk '{ print "ok" }'.
X
XFixed call_shell in amiga.c for space in shell option. You can now give
Xoptions to the shell command, but the name of the shell cannot contain
Xspaces anymore (big deal).
X
XWarn if no inversion is possible. Poor user, now you can't use visual select.
X
XUse termcap entries 'se' and 'so' when 'mr' or 'me' are not available. Makes
Xusing inversion possible on more terminals.
X
XAdded 'esckeys' option. If your special keys have codes that start with an
XESC you can switch them off in insert mode. When typing ESC you will
Xdirectly exit insert mode, instead of having to wait for more characters to
Xfind out if it might be a special key.
X
XAdded register name "% for the current file name. Handy when you want to use
Xthe current file name in macros.
X
XAdded <"> as a name for the unnamed register. Added the use of more registers
Xto some commands.
X
XAdded expansion of environment variable to most string parameters. Any non-id
Xcharacter can be used after the environment variable name.
X
XTrailing '/' in 'dir' option not required.
X
XAdded [Not edited] message to ":file".
X
XIf errors occur when starting to edit a file (e.g. out of memory) the
Xreadonly flag is set to prevent accidently overwriting the original file with
Xa truncated version.
X
XTrailing spaces are removed from ":" commands (except map, abbreviate, ":s",
X":g" and ":!" commands and after <|>). Useful when accidently typing a space
Xafter a filename.
X
XAdded TIOCLGET to mch_settmode() in unix.c. Restores some terminal settings
Xafter exiting Vim.
X
XA "recursive mapping" followed by another "recursive mapping" would loop
Xvery long.
X
XAllow entering CTRL-@ in command line mode.
X
XAdded 'A' - 'Z' for helpfile pages. You can add your own pages if you like.
X
XDisplay several help pages at once on a big screen.
X
XDon't give ".vim file exists" message when recovering.
X
XPut command line terminated with ESC in history. If you accidently try to
Xuse ESC for wildcard completion, you can get back what you typed.
X
XChanged display method for CTRL-D on command line. Now the redraw is done
Xafter the whole command line has been entered. Big speed win on slow
Xterminals.
X
XDon't call flushbuf() in normal() when p_sc is off (speeds up "x").
X
XDon't redisplay in main() when there is something in the stuff buffer. Speeds
Xup display a bit.
X
X:tag shows short filename. Reduces the need for "hit return to continue".
X
XAdded "#<" for command line: current filename without extension.
X
XChanged digraphs 208 and 240. Fixed digraph 172.
X
XIn help mode the keys CTRL-B and CTRL-F go one page back or forward. With
XMSDOS page-up and page-down can also be used.
X
XImplemented the drive specifier for the :cd command on MSDOS, ":cd c:" goes
Xto the C drive.
X
XImplemented FullName for msdos. Makes ":cd" really work.
X
XWhen the cursor is off the screen, put it at 1/2 of the screen. Used to be 1/3
Xor 2/3, depending on the direction.
X
X
XBug fixes
X=========
X
XFixed small screen updating bug in dodelete().
X
XInserting tab in Replace mode with 'et' option set did not delete char.
X
XFixed bug when start and end of operator are the same, e.g. "^d^".
X
XFixed 'w' on last word in file and 'b' on first word in the file.
X
XFixed 'dw' on empty line.
X
XFixed storage.c for 64 bit longs.
X
XFixed :w[!]>>newfile. Without the '!' the file must already exist.
X
XIn insert mode ^O had to be typed twice before the change command.
X
XFixed ":r !ls *". Wildcard expansion was done on "!ls".
X
XChanged flag not reset with ":w !wc".
X
XAfter CTRL-C go to normal mode. You could end up in insert mode when
Xinterrupting a macro (e.g. with the maze solving macros).
X
Xdoarglist() called FreeWild() with argv[]. This could cause a crash!
X
XRepaired FullName() in unix.c. Now "../" and links are correctly dealth with.
XAdded error handling. If a file or directory does not exist this is dealth
Xwith correctly.
X
XFixed ":g/pat/p". There is now a wait for "hit return" at the end.
XAlso fixed a double redraw.
X
XChanged key codes for MSDOS. The old ones overlapped with a few useful
Xaccented characters. Now only some graphics characters cannot be entered
Xdirectly from the keyboard.
X
XDelete "recording" when p_smd is off.
X
XFixed ":/pat" on last line. It would give an "illegal nr" error.
X
XFixed "invalid chunk" bug in insertchar(). Too many blanks were deleted when
Xdoing text formatting when the cursor is just after several blanks.
X
XBlockwise quoting did not work with upper case operators.
X
XRemoved forceit from getfile(); makes autowrite work with CTRL-^ after :n!.
X
XNo beep when search fails. When errorbells option was set you would get two
Xbeeps.
X
XIsdir() in msdos.c now returns -1 when file does not exist. It would see a
Xnon-existant file as a directory.
X
XFixed [new file] message for MSDOS.
X
XFixed screen updating in edit.c when entering CTRL-V TAB in front of a TAB.
XThe '^' would not be deleted.
X
XMade t_ options working again. You couldn't set them at all!
X
XSetting a terminal option to an empty string caused a hang.
X
XChanged flag was set for an option when it was printed.
X
XFixed makeset() for spaces in string options. Now a backslash is prepended.
X
XFixed makemap() for special characters. Now a CTRL-V is prepended.
X
XFixed dosource() for a line containing CTRL-V newline. The following line is
Xnow appended.
X
XMakeset() and makemap() add '\r' for MSDOS.
X
X'r' command no longer uses replace mode, except for CR, LF and TAB. Some
Xreplacement characters would give strange results, e.g. CTRL-O.
X
XFixed screen updating with ":s/a/A/gc". Now the screen is updated after each
Xreplacement, not after finishing a line.
X
XFixed MSDOS problem in lalloc(): Cannot handle block >64K.
X
XFixed bug in writeit(): Faulty write to memory when write() fails. This was a
Xnasty one, caused my Amiga to crash when writing to a full disk!
X
XFixed problem with cursor keys in xterm. This stupid terminal emulator sends
Xonly one character at each read().
X
XFixed problem with linewise visual and 'o' command. The column would be
Xchanged, making the visual mode character wise.
X
XFixed bug in u_undoredo() when newsize and oldsize are both zero. You would
Xget an error message when doing "!!foo", 'u', CTRL-R, 'u', when the command
X'foo' does not exist.
X
XFixed bug: not doing all lines with ":%s/ /^M/g" in dosub(). The number of
Xlines processed was not incremented by the number of new lines created.
X
XFixed crash caused by call to MatchEnd() while using ARP. This would mean
Xthat you could not use Vim with DOS 1.3. Only one person complained! Is
Xnobody using 1.3 anymore?
X
XIn out-of-memory situations writeit() would fail. It needed to allocate a
Xbuffer of 4K. It would be impossible to save your changes! Now a small
Xemergency buffer is used.
X
XFixed illegal memory access when not-set terminal option was printed.
X
XFixed hang with V~ on last line in file when the line was empty.
X
XFixed crash when typing "//".
X
XUpdated builtin termcap entry for xterm. Function keys now work.
X
XFixed bug with allocating argv in call_shell() for unix. Could cause a crash.
X
XFixed deletion of "no write since last change" message with :q command.
X
XAdded call to screenalloc() in screenclear(), fixes crash when resizing
Xwindow while viewing help.
X
XFixed screen updating with '$' in block mode.
X
XRedisplay INSERT message after visual bell.
X
XFixed backspace in column 1 in reverse insert mode.
XFixed "illegal nr" when doing i^P^H in an empty file.
X
XFixed ruler on empty line. Column number was wrong.
X
XTypehead not flushed with every error, fixes problems with 'notimeout' and
Xerrors in scripts (recovery!).
X
XNo beep with "qxq".
X
XAdded setting of Changed flag to readfile(), needed for :r !cmd.
X
XJumplist entries were not deleted properly, causing "no alternate file" and
X"illegal nr" errors.
X
XFixed entering CTRL-V CTRL-@ in insert mode.
X
XDefault values for 'showcommand' and 'showmode' for unix exchanged.
X
XPut braces around filter command for unix, allows ":r! echo this; echo that".
X
XFixed screen redraw after ".vim file exists" message with :e command.
X
XChanged CTRL-W for insert mode: stop before spaces.
X
XWhen changing more than 8000 lines at once undo is prohibited on Amiga and
XMSDOS (used to cause out of memory errors with "10000dd").
X
XFixed problem with undo after delete without undo. (?)
X
XFixed error messages with ":set".
X
XTerminal type not reset to default with ":set term=xxx", where xxx is not a
Xvalid terminal type.
X
XFixed problem in search pattern: With 'ignorecase' set the first character
Xafter '*' was case-sensitive.
X
XUpdate screen with ":g/the/s//THE/c".
X
XWith "hit return" use command-mode mappings.
X
XFixed "(" and ")" for sentence ending at end of line.
X
XFixed screen updating with very long lines. Cursor could end up in the middle
Xof nowhere.
X
XFixed message for yank with blockwise visual (was one line off).
X
XFixed :copy when destination is within source range.
X
X"r" in visual mode wanted to get another character.
X
XWith 'nowrapscan' "Q}" scrolled the screen horizontally.
X
XDon't allocate screen if Rows or Columns is 0.
X
XFixed CTRL-D in insert mode: First round indent to multiple of shiftwidth.
X
X"z<number><CR>" is limited to physical screen height. Fixes screen updating
Xproblems when set to large number. Also fixed screen updating for CTRL-D on
Xcommand line and for ":set all".
X
XRe-inserted forceit in getfile to make ":ta!" work. Now forceit is reset at
Xthe end of DoOneCmd() to keep CTRL-^ working.
X
XCheck for :unmap without valid number of arguments in domap(). Ctrl-V was
Xremoved twice from :unmap.
X
XAdded noremaplist in buffers.c; makes mixing @a and noremap mappings work.
X
XDo not check for terminal-code in mapped characters.
X
XRecording now stores the trailing 'q' in the register; the 'q' command is
Xdisabled while executing a register (solves problem when final 'q' is result
Xfrom mapping).
X
XFixed '\~' in substitute string being recognized as '~'.
X
XFixed ":s/ */ /g", inserted one space per line instead of one space per
Xcharacter.
X
XFixed ungetchr() in regexp.c: backslashed characters were not handled
Xcorrectly.
X
XFixed screen being messed up with long commands when 'sc' is set.
X
X
XVi-compatibility fixes
X======================
X
XWhen not editing last file in a file list, typing :q twice will quit.
X
XAdded [readonly] to fileinfo().
X
XUndo in macros allowed. But it only works correctly once.
X
XAdded hidden options to avoid error messages when reading .exrc.
X
XAllow '-ttag' (no space after -t) on command line.
X
XChanged short name for 'showmode' option from "mo" to "smd".
X
XAdded check for "view" in main(). Vim will start in readonly mode. On Unix you
Xcan make a link from "view" to "vim".
X
XUndo keeps marks if line count does not change.
X
XFixed operators to be linewise in some cases.
X
XCTRL-Z is :stop instead of :stop!.
X
X'}' command does not stop at '{' at start of line.
X
XWith :s lines are split at CR, unless preceded with a CTRL-V. In fact this is
Xbetter than Vi, because vi can't insert a CR in the text with :s.
X
XTextwidth now off when 0, also when wrapmargin set to 0.
X
XFixed autoindent when inserting <CR> in front of some blanks.
X
XRemoved 'repdel' option: BS in replace mode puts replaced character back
X(within one line).
X
XOption 'sect' short for 'sections'.
X
XAdjusted 'M' when '~' lines on screen. Now put cursor in the middle of the
Xlines that are present on the screen, not on the middle of the screen.
X
XMultiple spaces to separate fields in tags file allowed.
X
XDEL displayed as ^? instead of ~?.
X
XAdded 'mesg', 'edcompatible', 'modeline', 'sourceany' and 'ttytype' options.
XOnly 'edcompatible' is really implemented.
X
XAdded test for trying to edit/read/write a direcory. Now you get an error
Xmessage instead of [new file] (on Amiga/MSDOS) or garbage (Unix).
X
X'%' now works on \(this\).
X
XIn UNIX and MSDOS ignore spaces after filename. In Amiga the spaces may be
Xpart of the filename, on other systems this is very unlikely.
X
XMoved code from inchar() to vgetorpeek(): Key sequences can now be mapped
Xbefore recogized as key codes. But they are still stored with a special code
Xin the script files, which makes them terminal-independent.
X
XAdded recognition of vi-compatible modeline with set command.
X
XImplemented 'warn' option.
X
XAdded CTRL-W to command line editing.
X
XImplemented 0^D and ^^D in insert mode.
X
XNon-linewise deletes within one line do not go into numbered registers.
X
XSet previous context mark with 'L', 'M' and 'H' commands.
X
XMake "cc" work like "S": indent not deleted when 'autoindent' set.
XCTRL-U in insert mode does not delete indent when 'autoindent' set.
X
XWith the "J" command the cursor is put just after the first line instead of
Xat the start of the second.
X
XConcatenated mapstr and typestr in buffers.c; makes ":map x y" ":map yz foo"
Xwork (mixing mapped and typed characters in another mapping).
X
XCTRL-C quits command line and insert mode.
X
XESC in macro executes command line (but typed ESC still quits command line).
X
XDeleted "#include <ctype.h>" from regexp.c.
X
XCall_shell does not always use cooked mode, fixes problem with typing CR
Xwhile doing filename completion in unix.
X
XFixed return value for FullName in unix.c.
X
XRemoved redraw on exit for msdos.
X
X":v" without argument was not handled correctly in doglob().
X
XCR-LF in tags file was not handled correctly.
X
X
XPorting
X=======
X
XAdded _UNIX to BSD and SYSV because 'BSD' already used by Alpha.
X
XAdded three changes for Apollo DOMAIN.
X
XAdded a few things for Amdahl UTS.
X
XUse fork() in unix.c, not all systems have vfork().
X
XAdded POSIX compatible file type checking.
X
XAdded small changes for USL 4.2.
X
XAdded additional set of termcap entries for terminfo.
X
XAdded memmove() function for SYSV. Not all versions of memcpy() can handle
Xoverlapped areas.
X
XSmall fixes for a few unix versions: AIX (on rs6000) and NeXT.
X
XChanged SETWINSIZE to SETWSIZE and a few other changes for Convex.
X
XAdded a few changes for Borland C++. Phew, it compiles really fast!
X
XMany other small changes for different Unix versions.
END_OF_FILE
if test 23966 -ne `wc -c <'vim/readme2.0'`; then
echo shar: \"'vim/readme2.0'\" unpacked with wrong size!
fi
chmod +x 'vim/readme2.0'
# end of 'vim/readme2.0'
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'\" \(23470 characters\)
sed "s/^X//" >'vim/src/param.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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#define P_EXPAND 0x10 /* environment expansion */
X
X/*
X * The param structure is initialized here.
X * The order of the parameters should be alfabetic
X * The parameters with a NULL variable are 'hidden': a set command for
X * them is ignored and they are not printed.
X */
Xstruct param params[] =
X{
X {"autoindent", "ai", P_BOOL, (char *)&p_ai},
X {"autoprint", "ap", P_BOOL, (char *)NULL},
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|P_EXPAND, (char *)&p_bdir},
X#endif
X {"beautify", "bf", P_BOOL, (char *)NULL},
X {"binary", "bin", P_BOOL, (char *)&p_bin},
X#ifdef MSDOS
X {"bioskey", "biosk",P_BOOL, (char *)&p_biosk},
X#endif
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|P_EXPAND, (char *)&p_dir},
X {"edcompatible",NULL, P_BOOL, (char *)&p_ed},
X {"equalprg", "ep", P_STRING|P_EXPAND, (char *)&p_ep},
X {"errorbells", "eb", P_BOOL, (char *)&p_eb},
X {"errorfile", "ef", P_STRING|P_EXPAND, (char *)&p_ef},
X {"errorformat", "efm", P_STRING, (char *)&p_efm},
X {"esckeys", "ek", P_BOOL, (char *)&p_ek},
X {"expandtab", "et", P_BOOL, (char *)&p_et},
X {"exrc", NULL, P_BOOL, (char *)&p_exrc},
X {"formatprg", "fp", P_STRING|P_EXPAND, (char *)&p_fp},
X {"graphic", "gr", P_BOOL, (char *)&p_gr},
X {"hardtabs", "ht", P_NUM, (char *)NULL},
X {"helpfile", "hf", P_STRING|P_EXPAND, (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|P_EXPAND, (char *)&p_kp},
X {"lines", NULL, P_NUM, (char *)&Rows},
X {"lisp", NULL, P_BOOL, (char *)NULL},
X {"list", NULL, P_BOOL, (char *)&p_list},
X {"magic", NULL, P_BOOL, (char *)&p_magic},
X {"makeprg", "mp", P_STRING|P_EXPAND, (char *)&p_mp},
X {"mesg", NULL, P_BOOL, (char *)NULL},
X {"modeline", "ml", P_BOOL, (char *)&p_ml},
X {"modelines", "mls", P_NUM, (char *)&p_mls},
X {"number", "nu", P_BOOL, (char *)&p_nu},
X {"open", NULL, P_BOOL, (char *)NULL},
X {"optimize", "opt", P_BOOL, (char *)NULL},
X {"paragraphs", "para", P_STRING, (char *)&p_para},
X {"paste", NULL, P_BOOL, (char *)&p_paste},
X {"prompt", NULL, P_BOOL, (char *)NULL},
X {"readonly", "ro", P_BOOL, (char *)&p_ro},
X {"redraw", NULL, P_BOOL, (char *)NULL},
X {"remap", NULL, P_BOOL, (char *)&p_remap},
X {"report", NULL, P_NUM, (char *)&p_report},
X {"revins", "ri", P_BOOL, (char *)&p_ri},
X {"ruler", "ru", P_BOOL, (char *)&p_ru},
X {"secure", NULL, P_BOOL, (char *)&p_secure},
X {"scroll", NULL, P_NUM, (char *)&p_scroll},
X {"scrolljump", "sj", P_NUM, (char *)&p_sj},
X {"sections", "sect", P_STRING, (char *)&p_sections},
X {"shell", "sh", P_STRING|P_EXPAND, (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", "smd", P_BOOL, (char *)&p_smd},
X {"sidescroll", "ss", P_NUM, (char *)&p_ss},
X {"slowopen", "slow", P_BOOL, (char *)NULL},
X {"smartindent", "si", P_BOOL, (char *)&p_si},
X {"sourceany", NULL, P_BOOL, (char *)NULL},
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|P_EXPAND, (char *)&p_tags},
X {"term", NULL, P_STRING|P_EXPAND, (char *)&term_strings.t_name},
X {"terse", NULL, P_BOOL, (char *)NULL},
X {"textauto", "ta", P_BOOL, (char *)&p_ta},
X {"textmode", "tx", P_BOOL, (char *)&p_tx},
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 {"timeoutlen", "tm", P_NUM, (char *)&p_tm},
X {"ttimeout", NULL, P_BOOL, (char *)&p_ttimeout},
X {"ttytype", NULL, P_STRING, (char *)NULL},
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 {"wildchar", "wc", P_NUM, (char *)&p_wc},
X {"window", NULL, P_NUM, (char *)NULL},
X {"w300", NULL, P_NUM, (char *)NULL},
X {"w1200", NULL, P_NUM, (char *)NULL},
X {"w9600", NULL, P_NUM, (char *)NULL},
X {"wrap", NULL, P_BOOL, (char *)&p_wrap},
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 param_expand __ARGS((int, int));
Xstatic int findparam __ARGS((char *));
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 int i;
X
X if ((p = (char *)vimgetenv("SHELL")) != NULL
X#ifdef MSDOS
X || (p = (char *)vimgetenv("COMSPEC")) != NULL
X#endif
X )
X {
X p = strsave(p);
X if (p != NULL) /* we don't want a NULL */
X p_sh = p;
X }
X
X p_scroll = (Rows >> 1);
X comp_col();
X
X /*
X * expand environment variables in some string options
X */
X for (i = 0; params[i].fullname != NULL; i++)
X param_expand(i, FALSE);
X}
X
X/*
X * parse 'arg' for option settings
X * 'arg' may be IObuff, but only when no errors can be present.
X */
X int
Xdoset(arg)
X char *arg; /* parameter string (may be written to!) */
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;
X int flags;
X long value;
X long olduc = p_uc; /* remember old update count */
X long oldRows = Rows; /* remember old Rows */
X int errcnt = 0; /* number of errornous entries */
X static long save_tw = 0; /* saved options for 'paste' */
X static int save_ai = 0;
X static int save_si = 0;
X static int save_sm = 0;
X static int save_ru = 0;
X static int save_ri = 0;
X static int did_paste = FALSE; /* when TRUE saved values have been set */
X int do_wait = FALSE; /* call wait_return() at the end */
X int did_show = FALSE; /* already showed one value */
X
X if (*arg == NUL)
X {
X showparams(0);


X return 0;
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 /* find end of name */
X for (len = 0; isalnum(arg[len]) || arg[len] == '_'; ++len)
X ;
X nextchar = arg[len];
X arg[len] = 0; /* name ends with 0 */
X i = findparam(arg);
X arg[len] = nextchar; /* restore nextchar */
X
X if (i == -1) /* found a mismatch: skip the rest */
X {
X errmsg = "Unknown option";
X goto skip;
X }
X
X if (!params[i].var) /* hidden option */
X goto skip;
X
X flags = params[i].flags;
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 if (did_show)
X {
X outchar('\n'); /* cursor below last one */
X do_wait = TRUE; /* have to call wait_return() */
X }
X else
X {
X gotocmdline(TRUE, NUL); /* cursor at status line */
X did_show = TRUE; /* remember that we did a line */
X }
X showonep(&params[i]);
X
X /* check if the message is too long to fit in one line */
X if ((flags & P_STRING) && strlen(params[i].fullname) +
X (*(char **)(params[i].var) == NULL ? 0 :
X strsize(*(char **)(params[i].var))) + 1 >= (unsigned)sc_col)
X do_wait = TRUE;
X }
X else
X {
X if (nextchar != NUL && strchr("=: \t", nextchar) == NULL)
X {
X errmsg = e_invarg;
X goto skip;
X }
X else if (flags & P_BOOL) /* boolean */
X {
X if (nextchar == '=' || nextchar == ':')
X {
X errmsg = e_invarg;
X goto skip;
X }
X /*
X * in secure mode, setting of the secure option is not allowed
X */
X if (secure && (int *)params[i].var == &p_secure)
X {
X errmsg = "not allowed here";
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 /* handle compatbile option here */
X if ((int *)params[i].var == &p_cp && p_cp)
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_ek = 0; /* no ESC keys in insert mode */
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_ru = 0; /* no ruler */
X p_ri = 0; /* no reverse insert */
X p_sj = 1; /* no scrolljump */
X p_sr = 0; /* do not round indent to shiftwidth */
X p_sc = 0; /* no showcommand */
X p_smd = 0; /* no showmode */
X p_si = 0; /* no smartindent */
X p_ta = 0; /* no automatic textmode detection */


X p_tw = 0; /* no automatic line wrap */

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 if (p_wc == TAB)
X p_wc = Ctrl('E'); /* normal use for TAB */
X p_ye = 0; /* no yank to end of line */
X }
X if ((int *)params[i].var == &p_bin && p_bin) /* handle bin */
X {


X p_tw = 0; /* no automatic line wrap */
X p_tx = 0; /* no text mode */
X p_ta = 0; /* no text auto */
X p_ml = 0; /* no modelines */
X p_et = 0; /* no expandtab */
X }

X if ((int *)params[i].var == &p_paste) /* handle paste here */
X {
X if (p_paste)
X {
X save_tw = p_tw; /* save current values */
X save_ai = p_ai;
X save_si = p_si;
X save_sm = p_sm;
X save_ru = p_ru;
X save_ri = p_ri;
X p_tw = 0; /* textwidth is 0 */
X p_ai = 0; /* no auto-indent */
X p_si = 0; /* no smart-indent */
X p_sm = 0; /* no showmatch */
X p_ru = 0; /* no ruler */
X p_ri = 0; /* no reverse insert */
X did_paste = TRUE;
X }
X else if (did_paste) /* restore old values */
X {
X p_tw = save_tw;
X p_ai = save_ai;
X p_si = save_si;
X p_sm = save_sm;
X p_ru = save_ru;
X p_ri = save_ri;
X }
X }
X }
X else /* numeric or string */
X {
X if ((nextchar != '=' && nextchar != ':') || prefix != 1)
X {
X errmsg = e_invarg;
X goto skip;
X }
X if (flags & P_NUM) /* numeric */
X {
X value = atol(arg + len + 1);
X /* wrapmargin is translated into textwidth */
X if ((long *)params[i].var == &p_wm)
X {
X if (value == 0) /* switch it off */
X p_tw = 0;
X else
X {
X if (value >= (int)Columns)
X value = (int)Columns - 1;
X p_tw = Columns - value;
X }
X }
X *(long *)(params[i].var) = value;
X }
X else /* string */
X {
X arg += len + 1; /* jump to after the '=' */
X prefix = *arg; /* remember first char of arg */
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 != ' ')
X {
X if (*arg == '\\' && *(arg + 1)) /* skip over escaped chars */
X ++arg;
X *s++ = *arg++;
X }
X *s = NUL;
X if (prefix == '$')
X param_expand(i, TRUE); /* expand environment variables */
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 {
X ttest(FALSE);
X if (params[i].var == (char *)&term_strings.t_tp)
X {
X outstr(T_TP);


X updateScreen(CLEAR);
X }
X }
X }

X }
X params[i].flags |= P_CHANGED;
X }
X }
X
Xskip:
X /*
X * Check the bounds for numeric parameters here
X */
X if (Rows < 2)
X {
X Rows = 2;
X errmsg = "Need at least 2 lines";
X }
X /*
X * If the screenheight has been changed, assume it is the physical
X * screenheight, set Rows_max.
X */
X if (oldRows != Rows)


X {
X Rows_max = Rows;

X#ifdef MSDOS
X set_window(); /* active window may have changed */
X#endif
X }
X
X if (p_ts <= 0)
X {
X errmsg = e_positive;
X p_ts = 8;
X }
X if (p_tm < 0)
X {
X errmsg = e_positive;
X p_tm = 0;
X }
X if (p_scroll <= 0 || p_scroll > Rows)
X {
X if (p_scroll != 0)
X errmsg = e_scroll;


X p_scroll = Rows >> 1;
X }

X if (p_report < 0)
X {
X errmsg = e_positive;
X p_report = 1;
X }
X if (p_sj < 0 || p_sj >= Rows)
X {
X errmsg = e_scroll;
X p_sj = 1;
X }
X if (p_uc < 0)
X {
X errmsg = e_positive;
X p_uc = 100;
X }
X if (p_ut < 0)
X {
X errmsg = e_positive;
X p_ut = 2000;
X }
X if (p_ss < 0)
X {
X errmsg = e_positive;
X p_ss = 0;
X }
X if (errmsg)
X {
X strcpy(IObuff, errmsg);
X strcat(IObuff, ": ");
X s = IObuff + strlen(IObuff);
X while (*startarg && !isspace(*startarg))
X *s++ = *startarg++;
X *s = NUL;
X emsg(IObuff);
X arg = startarg; /* skip to next argument */
X ++errcnt; /* count number of errors */
X }
X skiptospace(&arg); /* skip to next white space */
X skipspace(&arg); /* skip spaces */
X }
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 comp_col();
X
X /*
X * Update the screen in case we changed something like "tabstop" or
X * "lines" or "list" that will change its appearance.
X * If we messed up the screen by showing more than one line of param
X * values call wait_return(), which will also update the screen..
X */
X if (do_wait)
X {
X outchar('\n');


X wait_return(TRUE);
X }
X else

X updateScreen(NOT_VALID);
X return errcnt;
X}
X
X/*
X * expand environment variable at the start of some string options


X */
X static void

Xparam_expand(i, dofree)
X int i;
X int dofree;
X{
X char *p;
X
X if ((params[i].flags & P_EXPAND) && (p = *(char **)(params[i].var)) != NULL && *p == '$')
X {
X expand_env(*(char **)(params[i].var), IObuff, IOSIZE);
X p = strsave(IObuff);
X if (p)
X {
X if (dofree)
X free(*(char **)(params[i].var));
X *(char **)(params[i].var) = p;
X }
X }
X}
X
X/*
X * find index for option 'arg'
X * return -1 if not found


X */
X static int

Xfindparam(arg)
X char *arg;
X{
X int i;
X char *s;
X
X for (i = 0; (s = params[i].fullname) != NULL; i++)
X {
X if (strcmp(arg, 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 && strcmp(arg, s) == 0) /* match short name */
X break;
X s = NULL;
X }


X }
X if (s == NULL)

X i = -1;
X return i;
X}
X
X/*
X * mark option 'arg' changed
X */
X void
Xparamchanged(arg)
X char *arg;
X{
X int i;
X
X i = findparam(arg);


X if (i >= 0)

X params[i].flags |= P_CHANGED;
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 (p->var && (
X (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 {
X inc = strlen(p->fullname) + strsize(*(char **)(p->var)) + 1;
X if (inc < 18)
X inc = 18;
X }
X else
X inc = 18;
X if (col + inc >= Columns)
X {
X col = 0;
X if (Rows != Rows_max)
X windgoto((int)Rows_max - 1, 0);
X outchar('\n'); /* scroll screen one line up */
X }
X windgoto((int)Rows - 1, col); /* make columns */
X showonep(p);
X col += inc;
X col += 19 - col % 19;
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/*
X * showonep: show the value of one option
X * must not be called with a hidden option!


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) && p->var)
X {
X if (p->flags & P_BOOL)
X fprintf(fd, "set %s%s", *(int *)(p->var) ? "" : "no", p->fullname);
X else if (p->flags & P_NUM)
X fprintf(fd, "set %s=%ld", p->fullname, *(long *)(p->var));
X else
X {
X fprintf(fd, "set %s=", p->fullname);
X s = *(char **)(p->var);
X /* some characters hav to be escaped with CTRL-V or backslash */
X if (s != NULL && putescstr(fd, s, TRUE) < 0)
X return 1;
X }
X#ifdef MSDOS
X putc('\r', fd);
X#endif
X /*
X * Only check error for this putc, should catch at least
X * the "disk full" situation.
X */
X e = putc('\n', fd);
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)) /* terminal parameters must never be hidden */
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}
X
X/*
X * Compute columns for ruler and shown command. 'sc_col' is also used to
X * decide what the maximum length of a message on the status line can be.
X */
X
X#define COL_SHOWCMD 10 /* columns needed by shown command */
X#define COL_RULER 17 /* columns needed by ruler */
X
X void
Xcomp_col()
X{
X sc_col = 0;
X ru_col = 0;
X if (p_ru)
X ru_col = sc_col = COL_RULER + 1;
X if (p_sc)
X {
X sc_col += COL_SHOWCMD;
X if (!p_ru)
X ++sc_col;
X }
X sc_col = Columns - sc_col;
X ru_col = Columns - ru_col;
X}
END_OF_FILE
if test 23470 -ne `wc -c <'vim/src/param.c'`; then
echo shar: \"'vim/src/param.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/param.c'
# end of 'vim/src/param.c'
fi
echo shar: End of archive 12 \(of 25\).
cp /dev/null ark12isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:51:11 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 63
Archive-name: vim/part13

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/search.c vim/tutor/tutor


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:06 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH

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'\" \(24021 characters\)
sed "s/^X//" >'vim/src/search.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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#include "ops.h" /* for mincl */
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 'dirc'
X * If 'dirc' 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(dirc, str, reverse, count, echo)
X int dirc;
X char *str;
X int reverse;
X long count;
X int echo;
X{
X FPOS pos; /* position of the last match */
X char *searchstr;
X static int lastsdir = '/'; /* 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 (dirc == 0)
X dirc = lastsdir;
X else
X lastsdir = dirc;
X if (reverse)
X {
X if (dirc == '/')
X dirc = '?';
X else
X dirc = '/';
X }
X searchstr = str;
X /* use previous string */
X if (str == NULL || *str == NUL || *str == dirc)
X {
X if (search_pattern == NULL)
X {
X emsg(e_noprevre);
X return 0;
X }
X searchstr = ""; /* will use search_pattern in myregcomp() */
X }
X if (str != NULL && *str != NUL) /* look for (new) offset */
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': /* do not call setpcmark() */
X nosetpm = TRUE;
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 if (isdigit(*(p + 1)))
X lastoff = atol(p); /* '+nr' or '-nr' */
X else if (*p == '-') /* single '-' */
X lastoff = -1;
X else /* single '+' */
X lastoff = 1;
X ++p;
X while (isdigit(*p)) /* skip number */
X ++p;
X }
X searchcmdlen = p - str; /* compute lenght of search command
X for get_address() */
X }
X
X if (echo)
X {
X start_msg();
X outchar(dirc);
X outtrans(*searchstr == NUL ? search_pattern : searchstr, -1);
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 check_msg();
X
X gotocmdline(FALSE, NUL);
X flushbuf();
X }
X
X pos = Curpos;
X
X c = searchit(&pos, dirc == '/' ? FORWARD : BACKWARD, searchstr, 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 * Improvement over vi: Braces inside quotes are ignored.


X */
X FPOS *

Xshowmatch()
X{
X static FPOS pos; /* current search position */
X char initc; /* brace under or after the cursor */
X char findc; /* matching brace */
X char c;
X int count = 0; /* cumulative number of braces */
X int idx;
X static char table[6] = {'(', ')', '[', ']', '{', '}'};
X int inquote = 0; /* non-zero when inside quotes */
X register char *linep; /* pointer to current line */
X register char *ptr;
X int do_quotes; /* check for quotes in current line */
X
X pos = Curpos;
X
X /*
X * find the brace under or after the cursor
X */
X linep = nr2ptr(pos.lnum);

X for (;;)
X {

X initc = linep[pos.col];
X if (initc == NUL)
X return (FPOS *) NULL;
X
X for (idx = 0; idx < 6; ++idx)
X if (table[idx] == initc)
X break;
X if (idx != 6)
X break;
X ++pos.col;
X }
X
X findc = table[idx ^ 1]; /* get matching brace */
X idx &= 1;
X
X do_quotes = -1;
X while (!got_int)
X {
X /*
X * Go to the next position, forward or backward. We could use
X * inc() and dec() here, but that is much slower
X */
X if (idx) /* 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 linep = nr2ptr(pos.lnum);
X pos.col = strlen(linep); /* put pos.col on trailing NUL */
X do_quotes = -1;
X }
X else
X --pos.col;
X }
X else /* forward search */
X {
X if (linep[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 linep = nr2ptr(pos.lnum);
X pos.col = 0;
X do_quotes = -1;
X }
X else
X ++pos.col;
X }
X
X if (do_quotes == -1) /* count number of quotes in this line */
X {
X /* we only do a breakcheck() once for every 16 lines */
X if ((pos.lnum & 15) == 0)
X breakcheck();
X
X /*
X * count the number of quotes in the line, skipping \" and '"'
X */
X for (ptr = linep; *ptr; ++ptr)
X if (*ptr == '"' && (ptr == linep || ptr[-1] != '\\') &&
X (ptr == linep || ptr[-1] != '\'' || ptr[1] != '\''))
X ++do_quotes;
X do_quotes &= 1; /* result is 1 with even number of quotes */
X
X /*
X * If we find an uneven count, check current line and previous
X * one for a '\' at the end.
X */
X if (!do_quotes)
X {
X inquote = FALSE;
X if (ptr[-1] == '\\')
X {
X do_quotes = 1;
X if (idx) /* backward search */
X inquote = TRUE;
X }
X if (pos.lnum > 1)
X {
X ptr = nr2ptr(pos.lnum - 1);
X if (*ptr && *(ptr + strlen(ptr) - 1) == '\\')
X {
X do_quotes = 1;
X if (!idx) /* forward search */
X inquote = TRUE;


X }
X }
X }
X }
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 * In lines with an uneven number of quotes (without preceding '\')
X * we do not know which part to ignore. Therefore we only set
X * inquote if the number of quotes in a line is even,
X * unless this line or the previous one ends in a '\'.
X * Complicated, isn't it?
X */
X switch (c = linep[pos.col])
X {
X case NUL:
X inquote = FALSE;
X break;
X
X case '"':
X /* a quote that is preceded with a backslash is ignored */
X if (do_quotes && (pos.col == 0 || linep[pos.col - 1] != '\\'))
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 not skipped, there is never a
X * brace in them.
X */
X case '\'':
X if (idx) /* backward search */
X {
X if (pos.col > 1)
X {
X if (linep[pos.col - 2] == '\'')
X pos.col -= 2;
X else if (linep[pos.col - 2] == '\\' && pos.col > 2 && linep[pos.col - 3] == '\'')
X pos.col -= 3;
X }
X }
X else if (linep[pos.col + 1]) /* forward search */
X {
X if (linep[pos.col + 1] == '\\' && linep[pos.col + 2] && linep[pos.col + 3] == '\'')
X pos.col += 3;
X else if (linep[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 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 or
X * a line break. Also stop 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 int noskip = FALSE; /* do not skip blanks */
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 && c != NUL))
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 && c != NUL);
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 noskip = TRUE;
X break;
X }
X }
Xfound:
X /* skip white space */
X while (!noskip && ((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 mincl = TRUE;
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 (*s == para || *s == '\f')
X return TRUE;
X if (*s == '.' && (inmacro(p_sections, s + 1) || (!para && inmacro(p_para, s + 1))))
X return TRUE;
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, eol) - move forward one word
X *
X * Returns TRUE if the cursor was already at the end of the file.
X * If eol is TRUE, last word stops at end of line (for operators).
X */
X int
Xfwd_word(count, type, eol)
X long count;
X int type;
X int eol;
X{
X int sclass; /* starting class */
X int i;
X
X stype = type;
X while (--count >= 0)
X {
X sclass = cls();
X
X /*
X * We always move at least one character.
X */
X i = incCurpos();


X if (i == -1)

X return TRUE;
X if (i == 1 && eol && count == 0) /* started at last char in line */
X return FALSE;
X
X if (sclass != 0)
X while (cls() == sclass)
X {
X i = incCurpos();
X if (i == -1 || (i == 1 && eol && count == 0))
X return FALSE;
X }
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 i = incCurpos();
X if (i == -1 || (i == 1 && eol && count == 0))


X return FALSE;
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) /* started at start of file */
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) /* hit start of file, stop here */
X return FALSE;
X }
X sclass = cls();
X }
X
X /*
X * Move backward to start of this word.
X */
X if (skip_chars(sclass, BACKWARD))
X return FALSE;
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 TRUE;
X return FALSE;
X}
END_OF_FILE
if test 24021 -ne `wc -c <'vim/src/search.c'`; then
echo shar: \"'vim/src/search.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/search.c'
# end of 'vim/src/search.c'
fi
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
chmod +x 'vim/tutor/tutor'
# end of 'vim/tutor/tutor'
fi
echo shar: End of archive 13 \(of 25\).
cp /dev/null ark13isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 20, 1993, 10:51:46 PM12/20/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 64
Archive-name: vim/part14

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/amiga.c vim/src/buffers.c


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:06 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'\" \(30444 characters\)
sed "s/^X//" >'vim/src/amiga.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 *));
Xstatic int sortcmp __ARGS((char **a, char **b));
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;
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 void
Xmch_write(p, len)


X char *p;
X int len;
X{

X Write(raw_out, p, (long)len);
X}
X
X/*


X * GetChars(): low level input funcion.
X * Get a characters from the keyboard.
X * If time == 0 do not wait for characters.
X * If time == n wait a short time for characters.
X * If time == -1 wait forever for characters.
X */
X int
XGetChars(buf, maxlen, time)

X char *buf;


X int maxlen;
X int time; /* milli seconds */

X{
X int len;
X long utime;
X
X if (time >= 0)
X {
X if (time == 0)
X utime = 100L; /* time = 0 causes problems in DOS 1.2 */
X else
X utime = time * 1000L; /* convert from milli to micro secs */
X if (WaitForChar(raw_in, utime) == 0) /* no character available */
X return 0;
X }
X else /* time == -1 */
X {
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 call_shell(NULL, 0, TRUE);
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) and -x 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 int usewin = FALSE;
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', '-x' 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 case 'x':
X usewin = 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 * We do the same with the '-x' option, for mail, rn, etc.
X */
X if (usewin)
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 * Return non-zero for success.
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("Vim 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 Rows_max = Rows; /* remember physical max height */
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, cooked)
X char *cmd;


X int filter; /* if != 0: called by dofilter() */
X int cooked;
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 or -x option");


X return 1;
X }
X

X if (term_console)
X win_resize_off(); /* window resize events de-activated */


X flushbuf();
X
X if (cooked)
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 emsg2("Cannot execute shell %s", p_sh);
X else

X emsg2("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 /* LATTICE */
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); /* find start of arguments */
X if (*shellarg != NUL)
X {
X *shellarg++ = NUL;
X skipspace(&shellarg);
X }
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 emsg2("Cannot execute %s", cmd == NULL ? p_sh : cmd);
X else
X emsg2("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 if (cooked)
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 got_int = TRUE;
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/*
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 *, int));
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, isdir)
X char *name;
X int isdir;
X{
X struct onefile *new;
X
X new = (struct onefile *)alloc((unsigned)(sizeof(struct onefile) + strlen(name) + isdir));


X if (new == NULL)

X return -1;
X strcpy(&(new->name[0]), name);
X if (isdir)
X strcat(&(new->name[0]), "/");
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
X static int
Xsortcmp(a, b)


X char **a, **b;
X{

X return strcmp(*a, *b);
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 int foundone;


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 foundone = FALSE;
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, Anchor->ap_Info.fib_DirEntryType >= 0))
X {
XOUT_OF_MEMORY:
X errmsg = "Out of memory";
X goto Return;
X }
X foundone = TRUE;
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 (!foundone)
X {
X if (list_notfound) /* put object with error in list */
X {
X (*num_file)++;
X if (insfile(pat[i], FALSE))
X goto OUT_OF_MEMORY;
X }
X else if (Result != ERROR_OBJECT_NOT_FOUND && Result != ERROR_NO_MORE_ENTRIES)
X {
X errmsg = "I/O ERROR";
X goto Return;
X }
X }
X#ifndef NO_ARP
X if (dos2)
X#endif
X MatchEnd(Anchor);
X#ifndef NO_ARP
X else
X {
X FreeAnchorChain(Anchor);
X Anchor = NULL; /* is this right or wrong? */
X }
X#endif
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 qsort((void *)*file, (size_t)*num_file, sizeof(char *), sortcmp);
X }
XReturn:
X if (domatchend)
X {
X#ifndef NO_ARP
X if (dos2)
X#endif
X MatchEnd(Anchor);
X#ifndef NO_ARP
X else
X {
X FreeAnchorChain(Anchor);
X Anchor = NULL; /* is this right or wrong? */
X }
X#endif
X }
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

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
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

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 30444 -ne `wc -c <'vim/src/amiga.c'`; then
echo shar: \"'vim/src/amiga.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/amiga.c'
# end of 'vim/src/amiga.c'
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'\" \(29561 characters\)
sed "s/^X//" >'vim/src/buffers.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 * 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
X/*
X * structure used for mapping
X */
Xstruct mapblock
X{
X struct mapblock *m_next; /* next mapblock */
X char *m_keys; /* mapped from */
X int m_keylen; /* strlen(m_keys) */
X char *m_str; /* mapped to */
X int m_mode; /* valid mode */
X int m_noremap; /* if non-zero no re-mapping for m_str */
X};
X
Xstatic struct mapblock maplist = {NULL, NULL, 0, NULL, 0, 0};
X /* first dummy entry in maplist */
X
X/*
X * variables used by vgetorpeek() and flush_buffers()
X *
X * typestr contains all characters that are not consumed yet.
X * The part in front may contain the result of mappings and @a commands.
X * The lenght of this part is typemaplen.
X * After it are characters that come from the terminal.
X * Some parts of typestr may not be mapped. These parts are remembered in
X * the noremaplist.
X */
X#define MAXMAPLEN 50 /* maximum length of key sequence to be mapped */
X /* must be able to hold an Amiga resize report */
Xstatic char *typestr = NULL; /* NUL-terminated buffer for typeahead characters */
Xstatic char typebuf[MAXMAPLEN + 3]; /* initial typestr */
X
Xstatic int typemaplen = 0; /* number of mapped characters in typestr */
X
X/*
X * parts int typestr that should not be mapped are remembered with a list
X * of noremap structs. Noremaplist is the first.
X */
Xstruct noremap
X{
X int nr_off; /* offset to not remappable chars */
X int nr_len; /* number of not remappable chars */
X struct noremap *nr_next; /* next entry in the list */
X};
X
Xstatic struct noremap noremaplist = {0, 0, NULL};
X
Xstatic void free_buff __ARGS((struct buffheader *));
Xstatic u_char *get_bufcont __ARGS((struct buffheader *, int));
Xstatic void add_buff __ARGS((struct buffheader *, char *));
Xstatic void add_num_buff __ARGS((struct buffheader *, long));
Xstatic void add_char_buff __ARGS((struct buffheader *, int));
Xstatic u_char read_stuff __ARGS((int));
Xstatic int start_stuff __ARGS((void));
Xstatic int read_redo __ARGS((int));
Xstatic void gotchars __ARGS((char *, int));
Xstatic void init_typestr __ARGS((void));
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 static u_char *
Xget_bufcont(buffer, dozero)
X struct buffheader *buffer;
X int dozero; /* count == zero is not an error */
X{
X u_long 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 || dozero) && (p = (u_char *)lalloc(count + 1, TRUE)) != 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, TRUE);
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, FALSE));
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 u_long n;
X u_long 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 *)lalloc((u_long)(sizeof(struct bufblock) + len), TRUE);
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 static void

Xadd_char_buff(buf, c)
X struct buffheader *buf;
X int c;
X{
X char temp[2];
X
X temp[0] = c;
X temp[1] = NUL;
X add_buff(buf, temp);
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 return (stuffbuff.bh_first.b_next == NULL);
X}
X
X/*
X * Remove the contents of the stuff buffer and the mapped characters in the
X * typeahead buffer (used in case of an error). If 'typeahead' is true,
X * flush all typeahead characters (used when interrupted by a CTRL-C).
X */
X void
Xflush_buffers(typeahead)
X int typeahead;
X{
X struct noremap *p;
X
X init_typestr();
X
X start_stuff();
X while (read_stuff(TRUE) != NUL)
X ;
X
X if (typeahead) /* remove all typeahead */
X {
X /*
X * We have to get all characters, because we may delete the first
X * part of an escape sequence.
X * In an xterm we get one char at a time and we have to get them all.
X */
X while (inchar(typestr, MAXMAPLEN, 10))
X ;
X *typestr = NUL;
X }
X else /* remove mapped characters only */
X strcpy(typestr, typestr + typemaplen);
X typemaplen = 0;
X noremaplist.nr_len = 0;
X noremaplist.nr_off = 0;
X while (noremaplist.nr_next)
X {
X p = noremaplist.nr_next->nr_next;
X free(noremaplist.nr_next);
X noremaplist.nr_next = p;
X }
X}
X
X void
XResetRedobuff()
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
XAppendCharToRedobuff(c)
X int c;
X{
X if (!block_redo)
X add_char_buff(&redobuff, c);
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
XstuffcharReadbuff(c)
X int c;
X{
X add_char_buff(&stuffbuff, c);
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 stuffcharReadbuff(c);
X}
X
Xextern int redo_Visual_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_char_buff(&stuffbuff, c);
X c = read_redo(FALSE);
X }
X
X if (c == 'v') /* redo Visual */
X {
X Visual = Curpos;
X redo_Visual_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_char_buff(&stuffbuff, 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
X * the redo buffer 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 = TO_UPPER(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
X/*
X * insert a string in front of the typeahead buffer (for '@' command and vgetorpeek)
X */
X int
Xins_typestr(str, noremap)
X char *str;
X int noremap;


X{
X register char *s;

X register int newlen;
X register int addlen;
X
X init_typestr();
X
X /*
X * In typestr there must always be room for MAXMAPLEN + 3 characters
X */
X addlen = strlen(str);
X newlen = strlen(typestr) + addlen + MAXMAPLEN + 3;
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) /* out of memory */
X return -1;
X
X strcpy(s, str);
X strcat(s, typestr);
X if (typestr != typebuf)
X free(typestr);
X typestr = s;
X typemaplen += addlen; /* the inserted string is not typed */
X if (noremap)
X {
X if (noremaplist.nr_off == 0)
X noremaplist.nr_len += addlen;
X else
X {
X struct noremap *p;
X
X p = (struct noremap *)alloc((int)sizeof(struct noremap));


X if (p != NULL)

X {
X p->nr_next = noremaplist.nr_next;
X p->nr_off = noremaplist.nr_off;
X p->nr_len = noremaplist.nr_len;
X noremaplist.nr_next = p;
X noremaplist.nr_len = addlen;
X noremaplist.nr_off = 0;
X }
X }
X }
X else if (noremaplist.nr_len)
X noremaplist.nr_off += addlen;


X return 0;
X}
X

X/*
X * remove "len" characters from the front of typestr
X */
X void
Xdel_typestr(len)
X int len;
X{
X struct noremap *p;
X
X strcpy(typestr, typestr + len); /* remove chars from the buffer */
X if ((typemaplen -= len) <= 0) /* adjust typemaplen */
X typemaplen = 0;
X while (len) /* adjust noremaplist */
X {
X if (noremaplist.nr_off >= len)
X {
X noremaplist.nr_off -= len;
X break;
X }
X len -= noremaplist.nr_off;
X noremaplist.nr_off = 0;
X if (noremaplist.nr_len > len)
X {
X noremaplist.nr_len -= len;
X break;
X }
X len -= noremaplist.nr_len;
X p = noremaplist.nr_next;
X if (p == NULL)
X {
X noremaplist.nr_len = 0;
X break;
X }
X noremaplist.nr_next = p->nr_next;
X noremaplist.nr_len = p->nr_len;
X noremaplist.nr_off = p->nr_off;
X free(p);
X }
X}
X
Xextern int arrow_used; /* this is in edit.c */
X
X/*
X * Write typed characters to script file.
X * If recording is on put the character in the recordbuffer.


X */
X static void

Xgotchars(s, len)
X char *s;
X int len;
X{
X while (len--)
X {
X updatescript(*s & 255);
X
X if (Recording)
X add_char_buff(&recordbuff, (*s & 255));
X ++s;
X }
X
X /* do not sync in insert mode, unless cursor key has been used */
X if (!(State & (INSERT + CMDLINE)) || arrow_used)
X u_sync();
X}
X
X/*
X * Initialize typestr to point to typebuf.
X * Alloc() cannot be used here: In out-of-memory situations it would
X * be impossible to type anything.


X */
X static void

Xinit_typestr()
X{
X if (typestr == NULL)
X {
X typestr = typebuf;
X typebuf[0] = NUL;
X }
X}
X
X#define NEEDMORET 9999 /* value for incomplete mapping or key-code */
X
X/*
X * get a character: 1. from the stuffbuffer
X * 2. from the typeahead buffer
X * 3. 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 int len;
X#ifdef AMIGA
X char *s;
X#endif
X register struct mapblock *mp;
X int timedout = FALSE; /* waited for more than 1 second
X for mapping to complete */
X int mapdepth = 0; /* check for recursive mapping */
X int mode_deleted = FALSE; /* set when mode has been deleted */
X
X init_typestr();
X start_stuff();
X if (typemaplen == 0)
X Exec_reg = FALSE;
X do
X {
X c = read_stuff(advance);
X if (c != NUL && !got_int)
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 * If a mapped key sequence is found we go back to the start to
X * try re-mapping.
X */
X
X for (;;)
X {
X len = strlen(typestr);
X breakcheck(); /* check for CTRL-C */
X if (got_int)
X {
X c = inchar(typestr, MAXMAPLEN, 0); /* flush all input */
X /*
X * If inchar returns TRUE (script file was active) or we are
X * inside a mapping, get out of insert mode.
X * Otherwise we behave like having gotten a CTRL-C.
X * As a result typing CTRL-C in insert mode will
X * really insert a CTRL-C.
X */
X if ((c || typemaplen) && (State & (INSERT + CMDLINE)))
X c = ESC;
X else
X c = Ctrl('C');
X flush_buffers(TRUE); /* flush all typeahead */
X break;
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 && (typemaplen == 0 || (p_remap &&
X (noremaplist.nr_len == 0 || noremaplist.nr_off != 0)))
X && !((State & (INSERT + CMDLINE)) && p_paste))
X {
X for (mp = maplist.m_next; mp; mp = mp->m_next)
X {
X if ((mp->m_mode & ABBREV) || !(mp->m_mode & State))
X continue;
X n = mp->m_keylen;
X if (noremaplist.nr_off != 0 && n > noremaplist.nr_off)
X continue;
X if (!strncmp(mp->m_keys, typestr, (size_t)(n > len ? len : n)))
X break;
X }
X }
X if (mp == NULL) /* no match found */
X {
X /*
X * check if we have a terminal code, when
X * mapping is allowed,
X * keys have not been mapped,
X * and not an ESC sequence, not in insert mode or
X * p_ek is on,
X * and when not timed out,
X */
X if (State != NOMAPPING &&
X typemaplen == 0 &&
X (typestr[0] != ESC || p_ek || !(State & INSERT)) &&
X !timedout)
X n = check_termcode(typestr);
X else
X n = 0;
X if (n == 0) /* no matching terminal code */
X {
X#ifdef AMIGA /* check for window bounds report */
X if (typemaplen == 0 && (typestr[0] & 0xff) == CSI)
X {
X for (s = typestr + 1; isdigit(*s) || *s == ';' || *s == ' '; ++s)
X ;
X if (*s == 'r' || *s == '|') /* found one */
X {
X strcpy(typestr, s + 1);
X set_winsize(0, 0, FALSE); /* get size and redraw screen */
X continue;
X }
X if (*s == NUL) /* need more characters */
X n = -1;
X }
X if (n != -1) /* got a single character */
X#endif
X {
X c = typestr[0] & 255;
X if (typemaplen)
X KeyTyped = FALSE;
X else
X {
X KeyTyped = TRUE;
X if (advance) /* write char to script file(s) */
X gotchars(typestr, 1);
X }
X if (advance) /* remove chars from typestr */
X del_typestr(1);
X break; /* got character, break for loop */
X }
X }
X if (n > 0) /* full matching terminal code */
X continue; /* try mapping again */
X
X /* partial match: get some more characters */
X n = NEEDMORET;
X }
X if (n <= len) /* complete match */
X {
X if (n > typemaplen) /* write chars to script file(s) */
X gotchars(typestr + typemaplen, n - typemaplen);
X
X del_typestr(n); /* remove the mapped keys */
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 if (State == CMDLINE)
X redrawcmdline();
X else
X setcursor();

X flush_buffers(FALSE);
X mapdepth = 0; /* for next one */
X c = -1;
X break;
X }
X if (ins_typestr(mp->m_str, mp->m_noremap) < 0)
X {
X c = -1;
X break;
X }
X continue;
X }
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 c = 0;
X if (advance && len == 1 && typestr[0] == ESC && typemaplen == 0 && (State & INSERT) && (p_timeout || (n == NEEDMORET && p_ttimeout)) && (c = inchar(typestr + len, 2, 0)) == 0)
X {
X if (p_smd)
X {
X delmode();
X mode_deleted = TRUE;
X }
X if (Curscol) /* move cursor one left if possible */
X --Curscol;
X else if (p_wrap && Curpos.col != 0 && Cursrow)
X {
X --Cursrow;
X Curscol = Columns - 1;
X }


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

X len += c;
X
X if (len >= typemaplen + MAXMAPLEN) /* buffer full, don't map */
X {
X timedout = TRUE;
X continue;
X }
X c = inchar(typestr + len, typemaplen + MAXMAPLEN - len, !advance ? 0 : ((len == 0 || !(p_timeout || (p_ttimeout && n == NEEDMORET))) ? -1 : (int)p_tm));
X if (c <= NUL) /* no character available */
X {
X if (!advance)
X break;
X if (len) /* timed out */
X {
X timedout = TRUE;
X continue;
X }
X }
X else
X {
X if (mode_deleted) /* character entered after ESC */
X {
X showmode();
X mode_deleted = FALSE;
X }
X }
X } /* for (;;) */
X } /* if (!character from stuffbuf) */
X
X /* if advance is FALSE don't loop on NULs */
X } while (c < 0 || (advance && c == NUL));
X
X /* delete "INSERT" message if we return an ESC */
X if (c == ESC && p_smd && !mode_deleted && (State & INSERT))
X delmode();
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 * 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 * unmap[!] {lhs} : remove key mapping for {lhs}
X * abbr : show all abbreviations
X * abbr {lhs} : show abbreviations for {lhs}
X * abbr {lhs} {rhs} : set abbreviation for {lhs} to {rhs}
X * noreabbr {lhs} {rhs} : same, but no remapping for {rhs}
X * unabbr {lhs} : remove abbreviation for {lhs}
X *
X * maptype == 1 for unmap command, 2 for noremap command.
X *
X * keys is pointer to any arguments.
X *
X * for :map mode is NORMAL
X * for :map! mode is INSERT + CMDLINE
X * for :cmap mode is CMDLINE
X * for :imap mode is INSERT
X * for :abbr mode is INSERT + CMDLINE + ABBREV
X * for :iabbr mode is INSERT + ABBREV
X * for :cabbr mode is CMDLINE + ABBREV
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 int haskey;
X int did_it = FALSE;
X int abbrev = 0;
X int round;
X
X if (mode & ABBREV) /* not a mapping but an abbreviation */
X {
X abbrev = ABBREV;
X mode &= ~ABBREV;
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 arg = p;
X hasarg = (*arg != NUL);
X haskey = (*keys != NUL);
X
X /* check for :unmap with not one argument */
X if (maptype == 1 && (!haskey || hasarg))

X return 1;
X
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 (haskey)
X {
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 MAXMAPLEN chars */


X return 2;
X }
X

X if (haskey && hasarg && abbrev) /* will add an abbreviation */
X no_abbr = FALSE;
X
X#ifdef AMIGA
X if (!haskey || (maptype != 1 && !hasarg))


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

X/*
X * Find an entry in the maplist that matches.
X * For :unmap we may loop two times: once to try to unmap an entry with a
X * matching 'from' part, a second time, if the first fails, to unmap an
X * entry with a matching 'to' part. This was done to allow ":ab foo bar" to be
X * unmapped by typing ":unab foo", where "foo" will be replaced by "bar" because
X * of the abbreviation.
X */
X for (round = 0; (round == 0 || maptype == 1) && round <= 1 && !did_it; ++round)
X {
X for (mp = maplist.m_next, mprev = &maplist; mp; mprev = mp, mp = mp->m_next)
X {
X /* skip entries with wrong mode */
X if (!(mp->m_mode & mode) || (mp->m_mode & ABBREV) != abbrev)
X continue;
X if (!haskey) /* show all entries */
X {
X showmap(mp);
X did_it = TRUE;
X }
X else /* do we have a match? */
X {
X if (round) /* second round: try 'to' string for unmap */
X {
X n = strlen(mp->m_str);
X p = mp->m_str;
X }
X else
X {
X n = mp->m_keylen;
X p = mp->m_keys;
X }
X if (!strncmp(p, keys, (size_t)(n < len ? n : len)))
X {
X if (maptype == 1) /* delete entry */
X {
X if (n != len) /* not a full match */
X continue;
X /*
X * We reset the indicated mode bits. If nothing is left the
X * entry is deleted below.
X */
X mp->m_mode &= (~mode | ABBREV);
X did_it = TRUE; /* remember that we did something */
X }
X else if (!hasarg) /* show matching entry */
X {
X showmap(mp);
X did_it = TRUE;
X }
X else if (n != len) /* new entry is ambigious */
X {
X return 3;
X }
X else
X {
X mp->m_mode &= (~mode | ABBREV); /* remove mode bits */
X if (!(mp->m_mode & ~ABBREV) && !did_it) /* reuse 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 mp->m_mode = mode + abbrev;
X did_it = TRUE;
X }
X }
X if (!(mp->m_mode & ~ABBREV)) /* entry can be deleted */
X {
X free(mp->m_keys);
X free(mp->m_str);


X mprev->m_next = mp->m_next;

X free(mp);
X mp = mprev; /* continue with next entry */


X }
X }
X }
X }
X }
X

X if (maptype == 1) /* delete entry */
X {
X if (did_it)
X return 0; /* removed OK */
X else
X return 2; /* no match */
X }
X
X if (!haskey || !hasarg) /* print entries */
X {


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

X if (did_it)
X wait_return(TRUE);
X else if (abbrev)
X msg("No abbreviation found");
X else
X msg("No mapping found");
X return 0; /* listing finished */
X }
X
X if (did_it) /* have added the new entry already */
X return 0;
X/*
X * get here when we have to add a new entry
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_keylen = strlen(mp->m_keys);
X mp->m_noremap = maptype;
X mp->m_mode = mode + abbrev;
X
X /* add the new entry in front of the maplist */
X mp->m_next = maplist.m_next;
X maplist.m_next = mp;
X
X return 0; /* added OK */


X}
X
X static void

Xshowmap(mp)
X struct mapblock *mp;
X{
X int len;
X
X if ((mp->m_mode & (INSERT + CMDLINE)) == INSERT + CMDLINE)
X outstr("! ");
X else if (mp->m_mode & INSERT)
X outstr("i ");
X else if (mp->m_mode & CMDLINE)
X outstr("c ");
X len = outtrans(mp->m_keys, -1); /* get length of what we have written */
X do
X {
X outchar(' '); /* padd with blanks */
X ++len;
X } while (len < 12);
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 * Check for an abbreviation.
X * Cursor is at ptr[col]. When inserting, mincol is where insert started.
X * "c" is the character typed before check_abbr was called.
X */
X int
Xcheck_abbr(c, ptr, col, mincol)
X int c;
X char *ptr;
X int col;
X int mincol;
X{
X int len;
X int j;
X char tb[3];
X struct mapblock *mp;
X
X for (len = col; len > 0 && isidchar(ptr[len - 1]); --len)
X ;
X if (len < mincol)
X len = mincol;
X if (len < col) /* there is a word in front of the cursor */
X {
X ptr += len;
X len = col - len;
X for (mp = maplist.m_next; mp; mp = mp->m_next)
X {
X /* find entries with right mode and keys */
X if ((mp->m_mode & ABBREV) == ABBREV &&
X (mp->m_mode & State) &&
X mp->m_keylen == len &&
X !strncmp(mp->m_keys, ptr, (size_t)len))
X break;
X }
X if (mp) /* found a match */
X {
X j = 0;
X if (c < 0x100 && (c < ' ' || c > '~'))
X tb[j++] = Ctrl('V'); /* special char needs CTRL-V */
X tb[j++] = c;
X tb[j] = NUL;
X ins_typestr(tb, TRUE); /* insert the last typed char */
X ins_typestr(mp->m_str, mp->m_noremap); /* insert the to string */
X while (len--)
X ins_typestr("\b", TRUE); /* delete the from string */


X return TRUE;
X }
X }

X return FALSE;
X}
X
X/*

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


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

Xmakemap(fd)
X FILE *fd;
X{
X struct mapblock *mp;
X char c1;
X char *p;
X
X for (mp = maplist.m_next; mp; mp = mp->m_next)
X {
X c1 = NUL;
X p = "map";
X switch (mp->m_mode)
X {
X case NORMAL:
X break;
X case CMDLINE + INSERT:
X p = "map!";
X break;
X case CMDLINE:
X c1 = 'c';
X break;
X case INSERT:
X c1 = 'i';
X break;
X case INSERT + CMDLINE + ABBREV:
X p = "abbr";
X break;
X case CMDLINE + ABBREV:
X c1 = 'c';
X p = "abbr";
X break;
X case INSERT + ABBREV:
X c1 = 'i';
X p = "abbr";
X break;
X default:
X emsg("makemap: Illegal mode");
X return 1;
X }
X if (c1 && putc(c1, fd) < 0)
X return 1;
X if (mp->m_noremap && fprintf(fd, "nore") < 0)
X return 1;
X if (fprintf(fd, p) < 0)
X return 1;
X
X if ( putc(' ', fd) < 0 || putescstr(fd, mp->m_keys, FALSE) < 0 ||
X putc(' ', fd) < 0 || putescstr(fd, mp->m_str, FALSE) < 0 ||
X#ifdef MSDOS
X putc('\r', fd) < 0 ||
X#endif
X putc('\n', fd) < 0)


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

X int
Xputescstr(fd, str, set)
X FILE *fd;
X char *str;
X int set; /* TRUE for makeset, FALSE for makemap */
X{
X for ( ; *str; ++str)
X {
X /*
X * some characters have to be escaped with CTRL-V to
X * prevent them from misinterpreted in DoOneCmd().
X * A space has to be escaped with a backslash to
X * prevent it to be misinterpreted in doset().
X */
X if (*str < ' ' || *str > '~' || (*str == ' ' && !set))
X {
X if (putc(Ctrl('V'), fd) < 0)
X return -1;
X }
X else if ((set && *str == ' ') || *str == '|')
X {
X if (putc('\\', fd) < 0)
X return -1;
X }
X if (putc(*str, fd) < 0)
X return -1;


X }
X return 0;
X}

END_OF_FILE
if test 29561 -ne `wc -c <'vim/src/buffers.c'`; then
echo shar: \"'vim/src/buffers.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/buffers.c'
# end of 'vim/src/buffers.c'
fi
echo shar: End of archive 14 \(of 25\).
cp /dev/null ark14isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:27:38 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 69
Archive-name: vim/part19

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/regexp.c
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:08 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'\" \(38964 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
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#define mkup(c) (reg_ic ? TO_UPPER(c) : (c))
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));
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.
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 regc(chr);
X skipchr();
X len++;
X }
X#ifdef DEBUG


X if (len == 0)

X FAIL("Unexpected magic character; check META.");
X#endif
X /*
X * If there is a following *, \+ or \? we need the character
X * in front of it as a single character operand
X */
X if (len > 1 && ismult(chr))
X {
X unregc(); /* Back off of *+? operand */
X ungetchr(); /* and put it back for next time */
X --len;
X }
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 = (int)(scan - val);
X else
X offset = (int)(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;
Xstatic int nextchr; /* used for ungetchr() */
X
Xstatic void
Xinitchr(str)
Xunsigned char *str;
X{
X regparse = str;
X curchr = prevchr = nextchr = -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
Xstatic void
Xskipchr()
X{
X regparse++;
X prevchr = curchr;
X curchr = nextchr; /* use previously unget char, or -1 */
X nextchr = -1;
X}
X
Xstatic int
Xgetchr()
X{
X int chr;
X
X chr = peekchr();
X skipchr();
X
X return chr;
X}
X
X/*
X * put character back. Works only once!
X */
Xstatic void
Xungetchr()
X{
X nextchr = curchr;
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 = (int)(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 = mkup(*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' || mkup(*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 38964 -ne `wc -c <'vim/src/regexp.c'`; then
echo shar: \"'vim/src/regexp.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/regexp.c'
# end of 'vim/src/regexp.c'
fi
echo shar: End of archive 19 \(of 25\).
cp /dev/null ark19isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:27:55 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 70
Archive-name: vim/part20

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/reference.do4


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:08 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/reference.do4' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/reference.do4'\"
else
echo shar: Extracting \"'vim/doc/reference.do4'\" \(43708 characters\)
sed "s/^X//" >'vim/doc/reference.do4' <<'END_OF_FILE'
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 (or as long as specified with the 'timeoutlen'
Xoption). After that it assumes that the <q> is to be interpreted as such. If
Xtype slowly, or your system is slow, reset the 'timeout' option. Then you
Xmight want to set the 'ttimeout' option. See the "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 losing any builtin function.
X
XIf you include an undo command inside a mapped sequence, this will bring the
Xtext back in the state before executing the macro. This is compatible with
Xthe original vi, as long as there is only one undo command in the mapped
Xsequence (having two undo commands in a mapped sequence did not make sense
Xin the original vi, you would get back the text before the first undo).
X
XThere are two ways to map a function key:
X1. The vi-compatible method: Map the key code. Often this is a sequence that
X starts with <ESC>. To enter a mapping like this you type ":map " and then
X you have to type CTRL-V before hitting the function key.
X2. The second method is to use the internal code for the function key. To
X enter such a mapping just hit the function key, without CTRL-V, or use
X the form "#1", "#2", .. "#9", "#0". Only the first ten function keys can
X be used this way ("#0" refers to function key 10, defined with option
X 't_f10', which may be function key zero on some keyboards).
XThe advantage of the second method is that the mapping will mostly work on
Xdifferent terminals without modification (the function key will be
Xtranslated into the same internal code, no matter what terminal you are
Xusing. The termcap must be correct for this to work, and you must use the
Xsame mappings).
X
XDETAIL: Vim first checks if a sequence from the keyboard is mapped. If it
Xisn't the terminal key codes are tried (see section 20.2). If a terminal
Xcode is found it is replaced by the internal code. Then the check for a
Xmapping is done again (so you can map an internal code to something else).
XWhat is written into the script file (.vim file) depends on what is
Xrecognized. If the terminal key code was recognized as a mapping the key
Xcode itself is written to the script file. If it was recognized as a
Xterminal code the internal code is written to the script file.
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 extension is
Xused, ".vil", ".vik", etc. An existing file will never be overwritten. The
Xautoscript file is deleted as soon as the edited text is successfully
Xwritten 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 autoscript file in
Xanother place than where the edited file is. The advantage is that you will
Xnot pollute the directories with ".vim" files and, when the 'directory' is
Xon another partition, reduce the risc of damaging the file system where the
Xfile is (in a crash). The tradeoff is that you can get name collisions from
Xfiles with the same name but in different directories. You can also use a
Xrecoverable ram disk, but there is no 100% guarantee that this works.
XPutting autoscript files in RAM: makes no sense, you will loose them in a
Xcrash. Put a command resembling the following one 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. Once you are sure the recovery is ok, write out the
Xfile with ":wq" and delete the autoscript ".vim" file. Otherwise, you will
Xcontinue to get warning messages that the ".vim" file already exists.
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 of the window. Do not resize the window 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 does not end 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 from being used for a
Xrecovery.
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 up to the next space will be
Xskipped. Thus following arguments will be processed.
X
XAn environment variable in most string options will be expanded. This
Xhappens only when the string starts with a <$>. If the environment variable
Xexists the <$> and the following environment variable name is replaced by
Xits value. If it does not exist the <$> and the name are not modified. Any
Xnon-id character (not a letter, digit or <_>) may follow the environment
Xvariable name. That character and what follows is appended to the value of
Xthe environemnt variable. Example:
X :set term=$TERM.new
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. If the 'exrc' option is set, the file ".vimrc" in the current directory is
X read for Ex commands. You can include set commands in this file. If this
X file is not found the file ".exrc" is tried.
X6. If you start editing a new file, and the 'modeline' option is set, a
X number of lines at the beginning and end of the file are checked for the
X string "vi:", "vim:" or "ex:". The text after it is considered to be the
X arguments for a ":set" command, separated with colons or spaces. For
X example:
X "vi:noai:sw=3 ts=6"
X The number of lines that are checked can be set with the 'modelines'
X option. If 'modeline' is not set or 'modelines' is 0 no lines are
X checked.
X The string "vi:", "vim:" or "ex:" must be preceded with a blank or begin
X at the start of a line. This minimizes the chance that a normal word like
X "lex:" is caught.
X Note that all of the rest of the line is used, thus a line like:
X "/* vi:ts=4: */"
X will give an error message for the trailing "*/".
X If an error is detected the rest of the line is skipped.
X One other form of modelines is recognized that has the "set" command
X after "vi:", "vim:" or "ex:" (this is compatible with some versions of
X vi). In this case the characters up to the first <:> are executed as an
X ex command. Anything following it is ignored. Thus a line like:
X "/* vi:set ts=4: */"
X is OK. If you want to include a <:> in a set command precede it with a
X <\>.
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 parens. Both forms may be used. In this
Xdocument when an option that can be toggled is "set" that means that ":set
Xoption" is entered. When an option is "reset", ":set nooption" is 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 "Q" command or when you reach 'textwidth' in
X Insert mode) uses the indentation of the first line. The 'autoindent'
X option is reset when the 'paste' option is set.
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, :suspend, :tag, :!, :make, CTRL-]
X and CTRL-^ command; and when a CTRL-O, CTRL-I, '<A-Z>, or `<A-Z>
X command takes one to another file.
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 the file is being
X written, reset this option and set the 'writebackup' option. If you
X do not want a backup file at all reset both options (See the table
X in section 5.4 for another explanation.). {not in Vi}
X
Xbackupdir (bdir) string (default "$HOME")
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. Environment variables are expanded. {not in Vi}
X
Xbinary (bin) toggle (default off)
X This option should be set before editing a binary file. You can also
X use the "-b" command line option. When this option is set the
X 'textwidth' option will set to 0, the 'textmode' and 'textauto'
X options will be reset and 'modelines' will be set to 0. When writing
X a file the end-of-line for the last line is only written if there
X was one in the original file (normally Vim appends an end-of-line to
X the last line if there is none; this would make the file longer).
X
Xbioskey (bk) toggle (default on)
X For MSDOS only: When set the bios is called to obtain a keyboard
X character. This works better to detect CTRL-C, but only works for
X the console. When using a terminal over a serial port reset this
X option. {not in Vi}
X
Xcolumns number (default 80 or terminal width)
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 esckeys off no <ESC>-keys in Insert mode
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 revins off no reverse insert
X ruler off no ruler
X scrolljump 0 no jump scroll
X shiftround off indent not rounded to shiftwidth
X showcmd off command characters not shown
X showmode off current mode not shown
X smartindent off no smart indentation
X textauto off no automatic textmode detection
X textwidth 0 no automatic line wrap
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 Insert 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 may end in an <:> or </>. Environment
X variables are expanded. Carefeful with <\> characters, type two to
X get one in the option, ":set dir=c:\\tmp". {Vi: directory to put
X temp file in, defaults to "/tmp"}
X
Xequalprg (ep) string (default "indent")
X External program to use for "=" command. Environment variables are
X expanded. {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" or "errors")
X Name of the error file for the QuickFix mode (see 5.5). Environment
X variables are expanded. {not in Vi}
X
Xerrorformat (efm) string (default "%f>%l:%c:%t:%n:%m" or
X ""%f",%*[^0-9]%l %m")
X Scanf-like description of the format for the lines in the error file
X (see 5.5). {not in Vi}
X
Xesckeys (ek) toggle (default on)
X Function keys that start with an <ESC> are recognized in Insert
X mode. When this option is off, the cursor and function keys cannot be
X used in Insert mode if they start with an <ESC>. The advantage of this
X is that the single <ESC> is recognized immediately, instead of after
X one second.
X
Xexpandtab (et) toggle (default off)
X In Insert mode: Use the appropriate number of spaces to insert a
X <TAB>. Spaces are used in indents with the '>' and '<' commands and
X when 'autoindent' is set. To insert a real tab when expandtab is
X set, use CTRL-V<TAB>. {not in Vi}
X
Xexrc toggle (default off)
X Enables the reading of .vimrc and .exrc in the current directory. If
X you switch this option on you should also consider setting the
X 'secure' option (see 3.4). {not in Vi}
X
Xformatprg (fp) string (default "")
X The name of an external program that will be used to format the
X lines selected with the "Q" command. The program must take the input
X on stdin and produce the output on stdout. The unix program 'fmt' is
X such a program. If this option is an empty string, the internal
X format function will be used. Environment variables are expanded.
X {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 (Amiga) "vim:vim.hlp"
X (unix) "/usr/local/lib/vim.hlp")
X Name of the help file. It may start with an environment variable.
X For example: "$VIM/doc/vim.hlp". Environment variables are expanded.
X {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. Environment variables are
X expanded. {not in Vi}
X
Xlines number (default 24 or terminal height)
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
Xmakeprg (mp) string (default "make")
X Program to use for the ":make" command. This option may contain
X <%> and <#> characters, which are expanded like when used in a
X command line. Environment variables are expanded. {not in Vi}
X
Xmodeline (ml) toggle (default on)
Xmodelines (mls) number (default 5)
X If 'modeline' is set 'modelines' gives the number of lines that is
X checked for set commands. If 'modeline' is not set or 'modelines' is
X 0 no lines are checked. See 19.1. {not 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 (see section 6.4).
X
Xpaste toggle (default off)
X Put Vim in Paste mode. This is useful if you want to cut or copy
X some text from one window and paste it in Vim. This will avoid
X unexpected effects. When the 'paste' option is set mapping in Insert
X mode is disabled, abbreviations are disabled and some options are
X reset ('textwidth', 'autoindent', 'smartindent', 'revins', 'ruler'
X and 'showmatch'). When the 'paste' option is reset the mentioned
X options are restored to the value before the last time 'paste' was
X set. If you use this often, you could map a function key to the
X command ":set invpaste^V^M". {not in Vi}
X
Xreadonly (ro) toggle (default off)
X If set, writes fail unless you use an !. Protects you from
X accidentally overwriting a file. Also, sets 'updatecount' to zero so
X that no ".vim" autoscript file is created. Default on when vim is
X started in view mode ("vim -v") or when the executable is called
X "view". It is reset if you overwrite the current file (e.g. with
X ":w!"). WARNING: An edit session that starts with 'noreadonly' won't
X be protected with a .vim autoscript file unless 'updatecount' is set
X back to some non-zero number (e.g. 100).
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
Xreport number (default 2)
X Threshold for reporting number of lines changed.
X
Xrevins toggle (default off)
X Inserting characters in Insert mode will work backwards. See "typing
X backwards". Can be toggled with the CTRL-P command in Insert mode.
X This option is reset when 'compatible' or 'paste' is set. {not in Vi}
X
Xruler (ru) toggle (default off)
X Show the line and column number of the cursor position in the status
X line, separated by a comma. If there are characters in the line that
X take two positions on the screen, both the "real" column and the
X screen column are shown, separated with a dash. This option is reset
X when the 'paste' option is set. {not in Vi}
X
Xsecure toggle (default off)
X When on, shell and write commands are not allowed in ".vimrc" and
X ".exrc" in the current directory and map commands are displayed.
X Switch it off only if you know that you will not run into problems,
X or when the 'exrc' option is off.
X
Xscroll number (default 'lines' / 2)
X Number of lines to scroll with CTRL-U and CTRL-D commands. Will be
X set to half the number of lines in the window when the window size
X changes. If you give a count to the CTRL-U or CTRL-D command it will
X be used as the new value for 'scroll'. Reset to 'lines' / 2 with
X ":set scroll=0".
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 slowly. {not in Vi}
X
Xsections (sect) string (default "SHNHH HUnhsh")
X Specifies the nroff macros that separate sections. These are pairs of
X two letters (See section 6.4).
X
Xshell (sh) string (default $SHELL or "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. Environment
X variables are expanded.
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 extension 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 extension (".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, off for unix)
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. This
X option is reset when the 'paste' option is set.
X
Xshowmode (smd) toggle (default on)
X If in Insert or Replace mode, put a message on the last line.
X
Xsidescroll (ss) number (default 0)
X The minimal number of columns to scroll horizontally. Used only when
X the 'wrap' option is on and the cursor is moved off of the screen.
X When set to zero the cursor will be put in the middle of the screen.
X When using a slow terminal set it to a large number or 0. When using
X a fast terminal use a small number or 1. {not in Vi}
X
Xsmartindent (si) toggle (default off)
X Do smart autoindenting for C programs in Insert mode and with the
X "o" and "O" commands. An indent is automatically inserted:
X - After a line ending in <{>.
X - After a line starting with "if", "for", "while", "else" or "do".
X If you type a <{> as the first character in the new line, the
X indent is deleted.
X - Before a line starting with <}> (only with the "O" command).
X One indent is deleted when typing <}> as the first character in a
X new line.
X 'smartindent' is reset when the 'paste' option is set. {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. {not in Vi}
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 up to this number of characters.
X
Xtags string (default "tags")
X Filenames for the tag command, separated by spaces. Environment
X variables are expanded for the first name. {Vi: default is "tags
X /usr/lib/tags"}
X
Xterm string (default $TERM or "amiga" on Amiga, "pcterm"
X on MSDOS)
X Name of the terminal. Used for choosing the terminal control
X characters. Environment variables are expanded.
X
Xterse toggle (default on)
X Ignored. {Vi: shorten the error messages}
X
Xtextauto (ta) toggle (default on)
X When a new file is edited the first line is checked for the line
X separator. If it is a single <LF> 'textmode' is reset. If it is a
X <CR><LF> pair 'textmode' is set.
X
Xtextmode (tx) toggle (MSDOS: default on, others: default off)
X When off, <LF> separates lines. When on, <CR><LF> separates lines.
X Only used when reading and writing files. Set automatically when
X reading a file and 'textauto' is on.
X
Xtextwidth number (default 0)
X Maximum width of text that is being inserted. A longer line will be
X broken after white space to get this width. A zero value disables
X this. 'textwidth' is set to 0 when the 'paste' option is set. If
X 'wrapmargin' is set to non-zero, textwidth is set to
X ('columns' - 'wrapmargin'). {not in Vi}
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. The time can be set with the 'timeoutlen'
X option.
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
Xtimeoutlen (tm) number (default 1000)
X The time in milliseconds that is waited for a key code or mapped key
X sequence to complete. {only in some versions of Vi}
X
Xundolevels (ul) number (default 100)
X Maximum number of changes that can be undone. Set to 0 for Vi
X compatibility: one level of undo and 'u' undoes itself. Set to a
X negative number for no undo at all (saves memory). {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
Xwarn toggle (default on)
X Give a warning message when a shell command is used while the buffer
X has been changed.
X
Xwildchar (wc) number (default <TAB> or CTRL-E)
X Character you have to type to start wildcard expansion in the
X command line. CTRL-E is used when Vim was compiled with COMPATIBLE
X or when the 'compatible' option is set. The character is not
X recognized when used inside a macro. {not in Vi}
X
Xwrap toggle (default on)
X When on, long lines will wrap and continue on the next line. When
X off long lines will not wrap and only part of them will be shown.
X When the cursor is moved to a part that is not shown, the screen
X will scroll horizontally (also see 'sidescroll' option. {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 Allows writing to any file with no need for "!" override.
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
Xdone during 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. Resetting the
X'esckeys' option avoids this problems in Insert mode, but you lose the
Xpossibility to use cursor and function keys in Insert mode.
X
XOn the Amiga the recognition of window resizing is activated only when the
Xterminal name is "amiga" or "builtin_amiga".
X
XSome terminals have confusing codes for the cursor keys. The televideo 925
Xis such a terminal. It sends a CTRL-H for cursor-left. This would make it
Ximpossible to distinguish a backspace and cursor-left. To avoid this problem
XCTRL-H is never recognized as cursor-left.
X
X
X20.2 terminal options
X
XThe terminal options can be set just like normal options. But they are not
Xshown with the ":set all" command. Instead use ":set termcap".
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
X{Vi: no terminal options. You have to exit vi, edit the termcap entry and
Xtry again}
X
XThe options are listed below along with the associated termcap code. Two of
Xthem are required: Cursor positioning and clear screen. The others are used
Xto minimize the screen updating overhead and to recognize special keys.
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 vi cursur invisible
X t_cv ve cursur visible
X t_tp me normal mode
X t_tp se shift-out end (if 'mr' or 'me' not defined)
X t_ti mr reverse mode
X t_ti so shift-out mode (if 'mr' or 'me' not defined)
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
XNote for xterm users: The shifted cursor keys normally don't work. You can
X make them work with the xmodmap command and some mappings in Vim.
X
X Give these commands in the xterm:
X xmodmap -e "keysym Up = Up F16"
X xmodmap -e "keysym Down = Down F17"
X xmodmap -e "keysym Left = Left F18"
X xmodmap -e "keycode Right = Right F19"
X
X And use these mappings in Vim:
X :map CTRL-V 151 CTRL-V 132
X :map! CTRL-V 151 CTRL-V 132
X :map CTRL-V 152 CTRL-V 133
X :map! CTRL-V 152 CTRL-V 133
X :map CTRL-V 153 CTRL-V 134
X :map! CTRL-V 153 CTRL-V 134
X :map CTRL-V 154 CTRL-V 135
X :map! CTRL-V 154 CTRL-V 135
X
XWhere 151-154 are the internal vim decimal codes for function keys F16 to
XF19 and 132-135 are the codes for the shifted arrow keys.
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- an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
X- the environment variables "LINES" and "COLUMNS"
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. If you are using horizontal
Xscrolling ('wrap' option off) consider setting 'sidescroll' to a small
Xnumber.
X
XIf you have a slow terminal you may want to reset the 'showcmd' option.
XThe command characters will not be shown in the status line. If the terminal
Xscrolls very slowly, 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. Another
Xpossibility is to reduce the number of lines that Vim uses with the command
X"z<height><CR>".
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.
XAlso see "difference.doc".
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: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: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. If you try to set them you
Xwon't get an error message, but their value cannot be printed.
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)
Xsourceany toggle (default not documented)
Xttytype string
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:ts=8:sw=8
END_OF_FILE
if test 43708 -ne `wc -c <'vim/doc/reference.do4'`; then
echo shar: \"'vim/doc/reference.do4'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/reference.do4'
# end of 'vim/doc/reference.do4'
fi
echo shar: End of archive 20 \(of 25\).
cp /dev/null ark20isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:31:13 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 75
Archive-name: vim/part25

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25 (of 25)."
# Contents: vim/src/cmdline.c
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:09 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'\" \(60249 characters\)
sed "s/^X//" >'vim/src/cmdline.c' <<'END_OF_FILE'


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

X * VIM - Vi IMproved
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 char *saltfiles[NUMALTFILES]; /* alternate files without path */
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 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;
X
Xstatic int forceit;
Xstatic int regname;
Xstatic int quitmore = 0;
Xstatic int cmd_numfiles = -1; /* number of files found by
X filename completion */
X
Xstatic void putcmdline __ARGS((int, u_char *));
Xstatic void cmdchecklen __ARGS((void));
Xstatic void cursorcmd __ARGS((void));
Xstatic int ccheck_abbr __ARGS((int));
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 *, char *));
Xstatic void doshell __ARGS((char *));
Xstatic void dofilter __ARGS((u_char *, int, int));
Xstatic void domake __ARGS((char *));
Xstatic int doarglist __ARGS((char *));
Xstatic int check_readonly __ARGS((void));
Xstatic int check_changed __ARGS((int));
Xstatic int check_more __ARGS((int));
Xstatic void setaltfname __ARGS((char *, char *, linenr_t, int));
Xstatic void nextwild __ARGS((u_char *, int));
Xstatic void showmatches __ARGS((char *, int));
Xstatic char *addstar __ARGS((char *, int));
Xstatic linenr_t get_address __ARGS((u_char **));
Xstatic void do_align __ARGS((linenr_t, linenr_t, int, int));


X
Xextern char *mktemp __ARGS((char *));

X
Xextern int global_busy, global_wait; /* shared with csearch.c, message.c */
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 char *lookfor = NULL; /* string to match */
X int j = -1;
X int gotesc = FALSE; /* TRUE when last char typed was <ESC> */
X
X/*
X * set some variables for redrawcmd()
X */
X cmdfirstc = firstc;
X cmdbuff = buff;
X cmdlen = cmdpos = 0;
X cmdslen = cmdspos = 1;
X State = CMDLINE;
X gotocmdline(TRUE, firstc);
X
X/*
X * if size of history table changed, reallocate it
X */
X newlen = (int)p_hi;
X if (newlen != hislen) /* history length changed */
X {
X if (newlen)
X temp = (char **)lalloc((u_long)(newlen * sizeof(char *)), TRUE);
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#ifdef DIGRAPHS
X dodigraph(-1); /* init digraph typahead */
X#endif
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 {
X c = vgetc();
X if (c == Ctrl('C') && got_int)
X got_int = FALSE;
X }
X
X if (lookfor && c != K_SDARROW && c != K_SUARROW)
X {
X free(lookfor);
X lookfor = NULL;
X }
X
X if (cmd_numfiles > 0 && !(c == p_wc && KeyTyped) && c != Ctrl('N') &&
X c != Ctrl('P') && c != Ctrl('A') && c != Ctrl('L'))
X (void)ExpandOne(NULL, FALSE, -2); /* may free expanded file names */


X
X#ifdef DIGRAPHS
X c = dodigraph(c);
X#endif

X
X if (c == '\n' || c == '\r' || (c == ESC && !KeyTyped))
X {
X if (ccheck_abbr(c + 0x100))
X continue;
X outchar('\r');
X flushbuf();
X break;
X }
X
X /* hitting <ESC> twice means: abandon command line */
X /* wildcard expansion is only done when the key is really typed, not
X when it comes from a macro */
X if (c == p_wc && !gotesc && KeyTyped)
X {
X if (cmd_numfiles > 0) /* typed p_wc twice */
X nextwild(buff, 3);
X else /* typed p_wc first time */
X nextwild(buff, 0);
X if (c == ESC)
X gotesc = TRUE;
X continue;
X }
X gotesc = FALSE;
X
X if (c == K_ZERO) /* NUL is stored as NL */
X c = '\n';
X
X switch (c)


X {
X case BS:
X case DEL:

X case Ctrl('W'):
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 j = cmdpos;
X if (c == Ctrl('W'))
X {
X while (cmdpos && isspace(buff[cmdpos - 1]))
X --cmdpos;
X i = isidchar(buff[cmdpos - 1]);
X while (cmdpos && !isspace(buff[cmdpos - 1]) && isidchar(buff[cmdpos - 1]) == i)
X --cmdpos;
X }
X else
X --cmdpos;
X cmdlen -= j - cmdpos;
X i = cmdpos;
X while (i < cmdlen)
X buff[i++] = buff[j++];
X redrawcmd();
X }
X else if (cmdlen == 0 && c != Ctrl('W'))


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 redrawcmd();
X continue;
X
X case ESC: /* get here if p_wc != ESC or when ESC typed twice */


X case Ctrl('C'):

X retval = FALSE;
X msg("");
X goto returncmd; /* back to cmd mode */
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 for (i = Rows_max - Rows; i; --i)


X outchar('\n');
X

X redrawcmd();
X continue;
X }
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('B'): /* begin of command line */
X cmdpos = 0;
X cmdspos = 1;
X continue;
X
X case Ctrl('E'): /* end of command line */
X cmdpos = cmdlen;
X buff[cmdlen] = NUL;
X cmdspos = strsize((char *)buff) + 1;
X continue;
X
X case Ctrl('A'): /* all matches */
X nextwild(buff, 4);
X continue;
X
X case Ctrl('L'): /* longest common part */
X nextwild(buff, 5);
X continue;
X
X case Ctrl('N'): /* next match */
X case Ctrl('P'): /* previous match */
X if (cmd_numfiles > 0)
X {
X nextwild(buff, (c == Ctrl('P')) ? 2 : 1);
X continue;
X }
X
X case K_UARROW:
X case K_DARROW:
X case K_SUARROW:
X case K_SDARROW:
X if (hislen == 0) /* no history */
X continue;
X
X i = hiscnt;
X
X /* save current command string */
X if (c == K_SUARROW || c == K_SDARROW)
X {
X buff[cmdpos] = NUL;
X if (lookfor == NULL && (lookfor = strsave((char *)buff)) == NULL)
X continue;
X
X j = strlen(lookfor);
X }
X for (;;)
X {
X /* one step backwards */
X if (c == K_UARROW || c == K_SUARROW || c == Ctrl('P'))
X {
X if (hiscnt == hislen) /* first time */
X hiscnt = hisidx;
X else if (hiscnt == 0 && hisidx != hislen - 1)
X hiscnt = hislen - 1;
X else if (hiscnt != hisidx + 1)
X --hiscnt;
X else /* at top of list */
X break;
X }
X else /* one step forwards */
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 break;
X if (hiscnt == hislen - 1) /* wrap around */
X hiscnt = 0;
X else
X ++hiscnt;
X }
X if (hiscnt < 0 || history[hiscnt] == NULL)
X {
X hiscnt = i;
X break;
X }
X if ((c != K_SUARROW && c != K_SDARROW) || hiscnt == i ||
X strncmp(history[hiscnt], lookfor, (size_t)j) == 0)
X break;
X }
X
X if (hiscnt != i) /* jumped to other entry */
X {
X strcpy((char *)buff, history[hiscnt]);
X cmdpos = cmdlen = strlen((char *)buff);
X redrawcmd();
X }
X continue;
X
X case Ctrl('V'):
X putcmdline('^', buff);
X c = get_literal(&nextc); /* get next (two) character(s) */


X break;
X
X#ifdef DIGRAPHS
X case Ctrl('K'):

X putcmdline('?', buff);
X c = vgetc();
X putcmdline(c, buff);


X c = getdigraph(c, vgetc());

X break;


X#endif /* DIGRAPHS */
X }

X
X /* we come here if we have a normal character */
X
X if (!isidchar(c) && ccheck_abbr(c))
X continue;
X
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 retval = TRUE; /* when we get here we have a valid command line */
X
Xreturncmd:
X buff[cmdlen] = NUL;
X if (hislen != 0 && cmdlen != 0) /* put line in history buffer */
X {
X if (++hisidx == hislen)
X hisidx = 0;
X free(history[hisidx]);
X history[hisidx] = strsave((char *)buff);
X }
X
X /*
X * If the screen was shifted up, redraw the whole screen (later).
X * If the line is too long, clear it, so ruler and shown command do
X * not get printed in the middle of it.
X */
X if (cmdoffset)
X must_redraw = CLEAR;
X else if (cmdslen >= sc_col)
X gotocmdline(TRUE, NUL);


X State = NORMAL;
X script_winsize_pp();

X return retval;
X}
X
X/*
X * put a character on the command line.
X * Used for CTRL-V and CTRL-K


X */
X static void

Xputcmdline(c, buff)
X int c;
X u_char *buff;
X{
X int len;
X char buf[2];
X
X buf[0] = c;
X buf[1] = 0;
X len = outtrans(buf, 1);
X outtrans((char *)(buff + cmdpos), cmdlen - cmdpos);
X cmdslen += len;
X cmdchecklen();
X cmdslen -= len;
X cursorcmd();
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 / (int)Columns > cmdoffset)
X cmdoffset = cmdslen / (int)Columns;
X}
X
X/*
X * this fuction is called when the screen size changes
X */
X void
Xredrawcmdline()
X{
X cmdoffset = 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 - cmdoffset, 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 = (cmdoffset + 1) * (int)Columns - cmdslen; --i > 0; )
X outchar(' ');
X cmdchecklen();


X}
X
X static void

Xcursorcmd()
X{
X windgoto((int)Rows - 1 - cmdoffset + (cmdspos / (int)Columns), cmdspos % (int)Columns);
X}
X
X/*


X * Check the word in front of the cursor for an abbreviation.
X * Called when the non-id character "c" has been entered.

X * When an abbreviation is recognized it is removed from the text with
X * backspaces and the replacement string is inserted, followed by "c".


X */
X static int

Xccheck_abbr(c)
X int c;
X{
X if (p_paste || no_abbr) /* no abbreviations or in paste mode */
X return FALSE;
X
X return check_abbr(c, (char *)cmdbuff, cmdpos, 0);
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 int usefilter = FALSE; /* filter instead of file name */
X u_char *nextcomm;
X
X if (quitmore)
X --quitmore; /* when not editing the last file :q has to be typed twice */
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 {
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 }
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 {
X line1 = line2;
X /* ... but only implicit: really no address given */
X if (lnum == INVLNUM)
X addr_count = 0;
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 = (int)(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 /*
X * for the :make command we insert the 'makeprg' option here,
X * so things like % get expanded
X */
X if (cmdidx == CMD_make)
X {
X if (strlen(p_mp) + strlen((char *)p) + 2 >= (unsigned)CMDBUFFSIZE)
X {
X emsg(e_toolong);
X goto doend;
X }
X strcpy((char *)cmdbuf, p_mp);
X strcat((char *)cmdbuf, " ");
X strcat((char *)cmdbuf, (char *)p);
X strcpy((char *)buff, (char *)cmdbuf);
X p = buff;
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 {
X if (*(p - 1) == '\\') /* remove the backslash */
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 if (!(argt & NOTRLCOM)) /* remove trailing spaces */
X {
X q = (char *)arg + strlen((char *)arg);
X while (--q > (char *)arg && isspace(q[0]) && q[-1] != '\\' && q[-1] != Ctrl('V'))
X *q = NUL;
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 == '.' || *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 n = getdigits((char **)&arg);
X skipspace((char **)&arg);
X if (n <= 0)
X {
X emsg(e_zerocount);
X goto doend;
X }
X line1 = line2;
X line2 += n - 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)
X {
X if (*arg == '>') /* append */
X {
X if (*++arg != '>') /* typed wrong */
X {
X emsg("Use w or w>>");
X goto doend;
X }
X ++arg;
X skipspace((char **)&arg);
X append = TRUE;
X }
X else if (*arg == '!') /* :w !filter */
X {
X ++arg;
X usefilter = TRUE;
X }
X }
X
X if (cmdidx == CMD_read)
X {
X usefilter = forceit; /* :r! filter if forceit */
X if (*arg == '!') /* :r !filter */
X {
X ++arg;
X usefilter = TRUE;
X }
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 == '#' && *(p + 1) == '<')
X { /* "#<": current file name without extension */
X n = 2;
X c = '<';
X }
X if (c == '%' || c == '<')
X {
X if (check_fname())
X goto doend;
X q = xFilename;
X }
X else
X {
X q = (char *)p + 1;
X i = (int)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 if (did_cd)
X q = altfiles[i];
X else
X q = saltfiles[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; /* truncate at the '#' or '%' */
X strcpy((char *)cmdbuf, (char *)arg);/* copy up to there */
X i = p - arg; /* remember the lenght */
X strcat((char *)cmdbuf, q); /* append the file name */
X if (c == '<' && (arg = (u_char *)strrchr(q, '.')) != NULL &&
X arg >= (u_char *)gettail(q)) /* remove extension */
X *((char *)cmdbuf + ((char *)arg - q) + i) = NUL;
X i = strlen((char *)cmdbuf); /* remember the end of the filename */
X strcat((char *)cmdbuf, (char *)p+n);/* append what is after '#' or '%' */
X p = buff + i - 1; /* remember where to continue */
X if (nextcomm) /* append next command */
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);/* copy back to buff[] */
X arg = buff;
X }
X
X /*
X * One file argument: expand wildcards.
X * Don't do this with ":r !command" or ":w !command".
X */
X if (argt & NOSPC)
X {
X if (has_wildcard((char *)arg) && !usefilter)
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 }
X
X/*
X * 6. switch on command name
X */
X switch (cmdidx)
X {
X case CMD_quit:
X if (!check_more(FALSE)) /* if more files we won't exit */
X exiting = TRUE;
X if (check_changed(FALSE) || check_more(TRUE))
X {
X exiting = FALSE;
X settmode(1);
X break;
X }
X getout(0);
X
X case CMD_stop:
X case CMD_suspend:
X if (!forceit && Changed)
X autowrite();
X gotocmdend();
X flushbuf();
X stoptermcap();
X mch_suspend(); /* call machine specific function */
X starttermcap();
X must_redraw = CLEAR;
X break;
X
X case CMD_xit:
X case CMD_wq:
X if (!check_more(FALSE)) /* if more files we won't exit */
X exiting = TRUE;
X if (((cmdidx == CMD_wq || Changed) &&
X (check_readonly() || !dowrite(arg, FALSE))) ||
X check_more(TRUE))
X {
X exiting = FALSE;
X settmode(1);
X break;
X }
X getout(0);
X
X case CMD_args:
X if (numfiles == 0) /* no file name list */
X {
X if (!check_fname()) /* check for no file name at all */
X smsg("[%s]", Filename);
X break;
X }
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 + (int)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], NULL);
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 - (int)line2;
X goto donextfile;
X
X case CMD_rewind:
X i = 0;
X goto donextfile;
X
X case CMD_write:
X if (usefilter) /* input lines to shell command */
X dofilter(arg, 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, NULL);
X break;
X
X case CMD_file:
X if (*arg != NUL)
X {
X setfname((char *)arg, NULL);
X NotEdited = TRUE;
X maketitle();
X }
X fileinfo(did_cd); /* print full filename if :cd used */
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 (usefilter)
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, NULL, line2, FALSE))
X {
X emsg(e_notopen);
X break;
X }
X updateScreen(NOT_VALID);
X break;
X
X case CMD_cd:
X case CMD_chdir:
X#ifdef UNIX
X /*
X * for UNIX ":cd" means: go to home directory
X */
X if (*arg == NUL) /* use IObuff for home directory name */
X {
X expand_env("$HOME", IObuff, IOSIZE);
X arg = (u_char *)IObuff;
X }
X#endif
X if (*arg != NUL)
X {
X if (!did_cd)
X {
X scriptfullpath();


X xFilename = Filename;
X }

X did_cd = TRUE;
X if (chdir((char *)arg))
X emsg(e_failed);
X break;
X }
X /*FALLTHROUGH*/
X
X case CMD_pwd:
X if (dirname(IObuff, IOSIZE))
X msg(IObuff);
X else
X emsg(e_unknown);
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 n += 8;
X }
X n += prt_line(nr2ptr(line1));
X if (++line1 > line2)
X break;


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

X n = Columns; /* call wait_return later */


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

X if (cmdidx == CMD_list)
X p_list = i;
X
X /*
X * if we have one line that runs into the shown command,
X * or more than one line, call wait_return()
X */
X if (n >= sc_col || global_busy)
X {
X outchar('\n');
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_digraphs:
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_abbreviate:
X case CMD_cabbrev:
X case CMD_iabbrev:
X case CMD_cnoreabbrev:
X case CMD_inoreabbrev:
X case CMD_noreabbrev:
X case CMD_unabbreviate:
X case CMD_cunabbrev:
X case CMD_iunabbrev:
X i = ABBREV;
X goto doabbr; /* almost the same as mapping */
X
X case CMD_cmap:
X case CMD_imap:
X case CMD_map:
X case CMD_cnoremap:
X case CMD_inoremap:
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_cunmap:
X case CMD_iunmap:
X case CMD_unmap:
X i = 0;
Xdoabbr:
X if (*cmd == 'c') /* cmap, cunmap, cnoremap, etc. */
X {
X i += CMDLINE;
X ++cmd;
X }
X else if (*cmd == 'i') /* imap, iunmap, inoremap, etc. */
X {
X i += INSERT;
X ++cmd;
X }
X else if (forceit || i) /* map!, unmap!, noremap!, abbrev */
X i += INSERT + CMDLINE;
X else
X i += NORMAL; /* map, unmap, noremap */
X switch (domap((*cmd == 'n') ? 2 : (*cmd == 'u'), (char *)arg, i))
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 outchar('\n');
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:
X case CMD_move:
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 && n < line2 && line2 > line1)
X {
X emsg("Move lines into themselves");
X break;
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 /*

X * there are three situations:
X * 1. destination is above line1
X * 2. destination is between line1 and line2
X * 3. destination is below line2
X *
X * n = destination (when starting)
X * Curpos.lnum = destination (while copying)
X * line1 = start of source (while copying)
X * line2 = end of source (while copying)
X */
X u_save(n, n + 1);
X Curpos.lnum = n;
X lnum = line2 - line1 + 1;
X while (line1 <= line2)
X {
X appendline(Curpos.lnum, save_line(nr2ptr(line1)));
X /* situation 2: skip already copied lines */
X if (line1 == n)
X line1 = Curpos.lnum;
X ++line1;
X if (Curpos.lnum < line1)
X ++line1;
X if (Curpos.lnum < line2)
X ++line2;
X ++Curpos.lnum;
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_redo:
X u_redo(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#ifdef UNIX
X /* with Unix it is possible to open a directory */
X if (isdir((char *)arg) > 0)
X {
X emsg2("\"%s\" is a directory", (char *)arg);
X break;
X }
X#endif
X if (!forceit && (fd = fopen((char *)arg, "r")) != NULL)
X {
X fclose(fd);
X emsg2("\"%s\" exists (use ! to override)", (char *)arg);
X break;
X }
X
X if ((fd = fopen((char *)arg, "w")) == NULL)
X {
X emsg2("Cannot open \"%s\" for writing", (char *)arg);
X break;
X }
X if (makemap(fd) || makeset(fd) || fclose(fd))
X emsg(e_write);
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 {
X /*
X * Great trick: Insert 'ef=' before arg.
X * Always ok, because "cf " must be there.
X */
X arg -= 3;
X arg[0] = 'e';
X arg[1] = 'f';
X arg[2] = '=';
X doset((char *)arg);
X }
X qf_init();
X break;
X
X case CMD_cl:
X qf_list();
X break;
X
X case CMD_cn:
X qf_jump(-1);
X break;
X
X case CMD_cp:
X qf_jump(-2);
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 case CMD_center:
X case CMD_right:
X case CMD_left:
X do_align(line1, line2, atoi((char *)arg),
X cmdidx == CMD_center ? 0 : cmdidx == CMD_right ? 1 : -1);
X break;
X
X case CMD_make:
X domake((char *)arg);


X break;
X
X default:

X emsg(e_invcmd);
X }
X
X
Xdoend:
X forceit = FALSE; /* reset now so it can be used in getfile() */
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 /* echo the command */
X gotocmdline(TRUE, ':');
X if (addr_count) /* :range! */
X {
X outnum((long)line1);
X outchar(',');
X outnum((long)line2);
X }
X outchar('!');
X outtrans(prevcmd, -1);
X
X if (addr_count == 0) /* :! */
X doshell(prevcmd);
X else /* :range! */
X dofilter((u_char *)prevcmd, TRUE, TRUE);


X}
X
X static int

Xautowrite()
X{
X if (!p_aw || check_readonly() || check_fname())
X return FALSE;
X return (writeit(Filename, sFilename, (linenr_t)1, line_count, 0, 0, TRUE));


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), 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 || !other)
X {
X if (check_fname())
X return FALSE;
X return (writeit(Filename, sFilename, line1, line2, append, forceit, TRUE));
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#ifdef UNIX
X /* with UNIX it is possible to open a directory */
X if (isdir((char *)arg) > 0)
X emsg2("\"%s\" is a directory", (char *)arg);
X else
X#endif
X emsg(e_exists);
X return 0;
X }
X return (writeit((char *)arg, NULL, line1, line2, append, forceit, TRUE));


X}
X
X static int

Xdoecmd(arg, sarg)
X char *arg;
X char *sarg;
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 == '+') /* :e +[command] file */
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 if (sarg == NULL)
X sarg = arg;
X
X#ifdef AMIGA
X fname_case(arg); /* set correct case for filename */
X#endif
X
X setalt = (*arg != NUL && otherfile(arg));
X if (check_changed(FALSE))
X {
X if (setalt)
X setaltfname(strsave(arg), strsave(sarg), (linenr_t)1, TRUE);
X return FALSE;
X }
X if (setalt)
X {
X setaltfname(Filename, sFilename, Curpos.lnum, FALSE);


X Filename = NULL;
X sFilename = NULL;

X setfname(arg, sarg);
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 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 startscript(); /* re-start auto script file */

X readfile(Filename, sFilename, (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 UNCHANGED;


X if (command)
X docmdline((u_char *)command);

X RedrawingDisabled = redraw_save; /* cursupdate() will redraw the screen later */
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 stoptermcap();
X outchar('\n'); /* shift screen one line up */
X
X /* warning message before calling the shell */
X if (p_warn && Changed)
X {
X gotocmdline(TRUE, NUL);
X outstr("[No write since last change]\n");
X }
X call_shell(cmd, 0, TRUE);
X
X#ifdef AMIGA
X wait_return(!term_console); /* see below */
X#else
X wait_return(TRUE); /* includes starttermcap() */
X#endif
X
X /*
X * In an Amiga window redrawing is caused by asking the window size.
X * If we got an interrupt this will not work. The chance that the window
X * size is wrong is very small, but we need to redraw the screen.
X */
X#ifdef AMIGA
X if (term_console)
X {
X outstr("\033[0 q"); /* get window size */
X if (got_int)
X must_redraw = CLEAR; /* if got_int is TRUE we have to redraw */
X else
X must_redraw = FALSE; /* no extra redraw needed */
X }
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
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
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/*
X * ! command will be overwritten by next mesages
X * This is a trade off between showing the command and not scrolling the
X * text one line up (problem on slow terminals).
X */
X must_redraw = CLEAR; /* screen has been shifted up one line */
X if (do_in && !writeit(itmp, NULL, line1, line2, FALSE, 0, FALSE))
X {
X outchar('\n'); /* keep message from writeit() */
X emsg(e_notcreate);
X return;
X }
X if (!do_out)


X outchar('\n');
X

X#ifdef UNIX
X/*
X * put braces around the command (for concatenated commands)
X */
X sprintf(IObuff, "(%s)", (char *)buff);
X if (do_in)
X {
X strcat(IObuff, " < ");
X strcat(IObuff, itmp);
X }
X if (do_out)
X {
X strcat(IObuff, " > ");
X strcat(IObuff, otmp);
X }
X#else
X/*
X * for shells that don't understand braces around commands, at least allow
X * the use of commands in a pipe.
X */
X strcpy(IObuff, (char *)buff);
X if (do_in)
X {
X char *p;
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#endif
X
X call_shell(IObuff, 1, FALSE); /* errors are ignored, so you can see the error
X messages from the command; use 'u' to fix the
X text */
X
X if (do_out)
X {
X if (!u_save((linenr_t)(line2), (linenr_t)(line2 + 1)))
X {
X linecount = 0;
X goto error;
X }
X if (readfile(otmp, NULL, 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, TRUE);


X }
X }
X else
X {

Xerror:
X wait_return(FALSE);
X }
X updateScreen(CLEAR); /* do this before messages below */
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 static void

Xdomake(arg)
X char *arg;
X{
X if (*p_ef == NUL)
X {
X emsg("errorfile option not set");
X return;
X }
X if (Changed)
X autowrite();
X remove(p_ef);
X outchar(':');
X outstr(arg); /* show what we are doing */
X#ifdef UNIX
X sprintf(IObuff, "%s |& tee %s", arg, p_ef);
X#else
X sprintf(IObuff, "%s > %s", arg, p_ef);
X#endif
X doshell(IObuff);
X#ifdef AMIGA
X flushbuf();
X vpeekc(); /* read window status report and redraw before message */
X#endif
X qf_init();
X remove(p_ef);
X}
X
X/*
X * Redefine the argument list to 'str'.
X * Return TRUE for failure.


X */
X static int

Xdoarglist(str)
X char *str;
X{
X int new_numfiles = 0;
X char **new_files = NULL;
X int exp_numfiles;
X char **exp_files;
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 **)lalloc((u_long)(sizeof(char *) * (new_numfiles + 1)), TRUE);
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 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 if (files_exp) /* files[] has been allocated, free it */
X FreeWild(numfiles, files);
X else
X files_exp = TRUE;
X files = exp_files;
X numfiles = exp_numfiles;


X
X return FALSE;
X}
X

X void
Xgotocmdline(clr, firstc)
X int clr;
X int firstc;


X{
X int i;
X

X if (clr) /* clear the bottom line(s) */
X {
X for (i = 0; i <= cmdoffset; ++i)
X {
X windgoto((int)Rows - i - 1, 0);
X clear_line();
X }
X redraw_msg = TRUE;
X }
X windgoto((int)Rows - cmdoffset - 1, 0);
X if (firstc)
X outchar(firstc);
X}
X
X void
Xgotocmdend()
X{
X windgoto((int)Rows - 1, 0);
X outchar('\n');
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 emsg(e_nowrtmsg);
X return TRUE;
X }


X return FALSE;
X}
X
X 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(message)
X int message; /* when FALSE check only, no messages */
X{
X if (!forceit && curfile + 1 < numfiles && quitmore == 0)
X {
X if (message)
X {
X emsg(e_more);
X quitmore = 2; /* next try to quit is allowed */
X }
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, sfname, setpm)


X char *fname;
X char *sfname;

X int setpm;
X{
X int other;
X
X other = otherfile(fname);
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, sfname))
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 {
X emsg(e_noalt);
X return 1;
X }
X if (lnum == 0)
X lnum = altlnum[n]; /* altlnum may be changed by getfile() */
X RedrawingDisabled = TRUE;
X if (getfile(altfiles[n], saltfiles[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, sarg, lnum, newfile)
X char *arg;
X char *sarg;
X linenr_t lnum;
X int newfile;


X{
X int i;
X

X free(altfiles[NUMALTFILES - 1]);
X free(saltfiles[NUMALTFILES - 1]);
X for (i = NUMALTFILES - 1; i > 0; --i)
X {
X altfiles[i] = altfiles[i - 1];
X saltfiles[i] = saltfiles[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 saltfiles[0] = sarg;
X altlnum[0] = lnum;


X}
X
X static void

Xnextwild(buff, type)
X u_char *buff;
X int type;
X{
X int i;
X char *p1, *p2;
X int oldlen;
X int difflen;
X
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, type)) != 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}
X
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 * mode = 3: use next match in multiple match and wrap to first
X * mode = 4: return all matches concatenated
X * mode = 5: return longest matched part


X */
X 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 findex;
X int i, found = 0;
X int multmatch = FALSE;
X u_long len;
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 && mode < 4)
X {
X if (cmd_numfiles > 0)
X {
X if (mode == 2)
X --findex;
X else /* mode == 1 || mode == 3 */
X ++findex;
X if (findex < 0)
X findex = 0;
X if (findex > cmd_numfiles - 1)
X {
X if (mode == 3)
X findex = 0;
X else
X findex = cmd_numfiles - 1;
X }
X return strsave(cmd_files[findex]);
X }
X else


X return NULL;
X }
X

X/* free old names */
X if (cmd_numfiles != -1 && mode < 4)
X {
X FreeWild(cmd_numfiles, cmd_files);
X cmd_numfiles = -1;
X }
X findex = 0;
X
X if (mode == -2) /* only release file name */
X return NULL;
X
X if (cmd_numfiles == -1)
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 if (mode < 4)
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 = (int)(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 multmatch = TRUE;
X break;
X }
X found = i;
X }
X }
X if (multmatch || found < 0)
X {
X emsg(e_toomany);
X found = 0; /* return first one */
X multmatch = TRUE; /* for found < 0 */
X }
X if (found >= 0 && !(multmatch && mode == -1))
X ss = strsave(cmd_files[found]);
X }
X }
X
X if (mode == 5 && cmd_numfiles > 0) /* find longest common part */
X {
X for (len = 0; cmd_files[0][len]; ++len)
X {
X for (i = 0; i < cmd_numfiles; ++i)
X {
X#ifdef AMIGA
X if (toupper(cmd_files[i][len]) != toupper(cmd_files[0][len]))
X#else
X if (cmd_files[i][len] != cmd_files[0][len])
X#endif
X break;
X }
X if (i < cmd_numfiles)
X break;
X }
X ss = alloc((unsigned)len + 1);
X if (ss)
X {
X strncpy(ss, cmd_files[0], (size_t)len);
X ss[len] = NUL;
X }
X multmatch = TRUE; /* don't free the names */
X findex = -1; /* next p_wc gets first one */
X }
X
X if (mode == 4 && cmd_numfiles > 0) /* concatenate all file names */
X {
X len = 0;
X for (i = 0; i < cmd_numfiles; ++i)
X len += strlen(cmd_files[i]) + 1;
X ss = lalloc(len, TRUE);
X if (ss)
X {
X *ss = NUL;
X for (i = 0; i < cmd_numfiles; ++i)
X {
X strcat(ss, cmd_files[i]);
X if (i != cmd_numfiles - 1)
X strcat(ss, " ");
X }
X }
X }
X
X if (!multmatch || mode == -1 || mode == 4)
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 = ((int)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 > 0)
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 > 0)
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 for (i = cmdoffset; --i >= 0; ) /* make room for the command */
X outchar('\n');
X must_redraw = CLEAR; /* must redraw later */
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 (strchr(".\\/:", retval[i]))
X break;
X if (i < 0 || 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
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#ifdef MSDOS
X int error = FALSE;
X#endif
X
X expand_env(fname, IObuff, IOSIZE); /* use IObuff for expanded name */
X if ((fp = fopen(IObuff, READBIN)) == NULL)
X return 1;
X
X len = 0;
X while (fgets(IObuff + len, IOSIZE - len, fp) != NULL && !got_int)
X {
X len = strlen(IObuff) - 1;
X if (len >= 0 && IObuff[len] == '\n') /* remove trailing newline */
X {
X /* escaped newline, read more */
X if (len > 0 && len < IOSIZE && IObuff[len - 1] == Ctrl('V'))
X {
X IObuff[len - 1] = '\n'; /* remove CTRL-V */
X continue;
X }
X#ifdef MSDOS
X if (len > 0 && IObuff[len - 1] == '\r') /* trailing CR-LF */
X --len;
X else
X {
X if (!error)
X emsg("Warning: Wrong line separator, ^M may be missing");
X error = TRUE; /* lines like ":map xx yy^M" will fail */
X }
X#endif
X IObuff[len] = NUL;
X }
X breakcheck(); /* check for ^C here, so recursive :so will be broken */
X docmdline((u_char *)IObuff);


X len = 0;
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 {
X if (Curpos.lnum == line_count) /* :/pat on last line */
X Curpos.lnum = 1;
X else
X ++Curpos.lnum;
X }
X searchcmdlen = 0;
X if (dosearch(c, (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}
X
X/*
X * align text:
X * type = -1 left aligned
X * type = 0 centered
X * type = 1 right aligned


X */
X static void

Xdo_align(start, end, width, type)
X linenr_t start;
X linenr_t end;
X int width;
X int type;
X{
X FPOS pos;
X int len;
X int indent = 0;


X
X pos = Curpos;

X if (type == -1) /* left align: width is used for new indent */
X {
X if (width >= 0)
X indent = width;
X }
X else
X {
X if (width <= 0)
X width = p_tw;
X if (width == 0)
X width = 80;
X }
X
X if (!u_save((linenr_t)(line1 - 1), (linenr_t)(line2 + 1)))
X return;
X for (Curpos.lnum = start; Curpos.lnum <= end; ++Curpos.lnum)
X {
X set_indent(indent, TRUE); /* remove existing indent */
X if (type == -1) /* left align */
X continue;
X len = strsize(nr2ptr(Curpos.lnum)); /* get line lenght */
X if (len < width)
X switch (type)
X {
X case 0: set_indent((width - len) / 2, FALSE); /* center */
X break;
X case 1: set_indent(width - len, FALSE); /* right */
X break;
X }
X }
X Curpos = pos;
X beginline(TRUE);
X updateScreen(NOT_VALID);
X}
END_OF_FILE
if test 60249 -ne `wc -c <'vim/src/cmdline.c'`; then
echo shar: \"'vim/src/cmdline.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/cmdline.c'
# end of 'vim/src/cmdline.c'
fi
echo shar: End of archive 25 \(of 25\).
cp /dev/null ark25isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:23:40 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 65
Archive-name: vim/part15

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/ops.c
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:07 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'\" \(31254 characters\)
sed "s/^X//" >'vim/src/ops.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 long 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 {
X /* if (Visual_block)
X shift the block, not the whole line
X else */
X shift_line(op == LSHIFT, p_sr);
X }
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, round)
X int left;
X int round;
X{
X register int count;


X register int i, j;
X

X count = get_indent(); /* get current indent */
X
X if (round) /* round off indent */
X {
X i = count / (int)p_sw; /* compute new indent */
X j = count % (int)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 * (int)p_sw;
X }
X else /* original vi indent */
X {
X if (left)
X {
X count -= (int)p_sw;
X if (count < 0)
X count = 0;
X }
X else
X count += (int)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 && !writing) || yankbuffer == '"') && y_previous != NULL)
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;
X static int bufname;
X
X if (Recording == FALSE) /* start recording */
X {
X if (!isalnum(c) && c != '"') /* registers 0-9, a-z and " are allowed */
X return FALSE;
X Recording = TRUE;
X showmode();
X bufname = c;
X return TRUE;
X }
X else /* stop recording */
X {
X Recording = FALSE;
X msg("");
X /* the trailing 'q' command will not have been put in the buffer */
X p = (char *)get_recorded();


X if (p == NULL)

X return FALSE;
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 == '.' || 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 = lalloc((u_long)(strlen(*pp) + strlen(p) + 1), TRUE);
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 (register): 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) && c != '"') /* registers 0-9, a-z and " 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_typestr("\n", FALSE) < 0)
X return FALSE;
X }
X if (ins_typestr(y_current->y_array[i], FALSE) < 0)
X return FALSE;
X }
X Exec_reg = TRUE; /* disable the 'q' command */


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 (c == '%') /* insert file name */


X {
X if (check_fname())
X return FALSE;

X stuffReadbuff(xFilename);


X return TRUE;
X }
X

X if (!isalnum(c) && c != '"') /* registers 0-9, a-z and " 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 linenr_t old_lcount = line_count;
X
X /*
X * Imitate the strange Vi behaviour: If the delete spans more than one line
X * and mtype == MCHAR and the result is a blank line, make the delete
X * linewise. Don't do this for the change command.
X */
X if (mtype == MCHAR && nlines > 1 && operator == DELETE)
X {
X ptr = nr2ptr(endop.lnum) + endop.col + mincl;
X skipspace(&ptr);
X if (*ptr == NUL && startinmargin())


X mtype = MLINE;
X }

X
X /*
X * Shift number buffers if there is no yankbuffer defined and we do a
X * delete that contains a line break.
X */
X if (yankbuffer == 0 && (mtype == MLINE || nlines > 1))
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 == '.' || yankbuffer == '%') /* read-only buffer */
X {
X beep();
X return;
X }
X else /* yank into specified buffer */
X get_yank_buffer(TRUE);
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 (!doyank(TRUE))
X {
X if (ask_yesno("cannot yank; delete anyway") != 'y')
X {
X emsg(e_abort);


X return;
X }
X }
X

X/*
X * block mode
X */
X if (Visual_block)
X {
X if (!u_save((linenr_t)(startop.lnum - 1), (linenr_t)(endop.lnum + 1)))
X return;
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 if (operator == CHANGE)
X {
X dellines((long)(nlines - 1), TRUE, TRUE);
X if (!u_saveCurpos())
X return;
X while (delchar(TRUE)); /* slow but simple */
X }
X else
X {
X dellines(nlines, TRUE, TRUE);
X }
X u_clearline(); /* "U" command should not be possible after "dd" */
X }
X else if (nlines == 1) /* delete characters within one line */
X {
X if (!u_saveCurpos())
X return;
X n = endop.col - startop.col + 1 - !mincl;
X while (n-- > 0)
X if (!delchar(TRUE))
X break;
X }
X else /* delete characters between lines */
X {
X if (!u_saveCurpos()) /* save first line for undo */
X return;
X n = Curpos.col;
X while (Curpos.col >= n) /* delete from cursor to end of line */
X if (!delchar(TRUE))
X break;
X
X startop = Curpos; /* remember Curpos */
X ++Curpos.lnum;
X dellines((long)(nlines - 2), TRUE, TRUE); /* includes save for undo */
X
X if (!u_saveCurpos()) /* save last line for undo */
X return;
X n = endop.col - !mincl;
X Curpos.col = 0;
X while (n-- >= 0) /* delete from start of line until endop */
X if (!delchar(TRUE))
X break;
X Curpos = startop; /* restore Curpos */
X dojoin(FALSE, TRUE);
X }
X
X if ((mtype == MCHAR && nlines == 1) || operator == CHANGE)
X {


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

X else
X updateScreen(CURSUPD);
X


X msgmore(line_count - old_lcount);
X

X /* correct endop for deleted text (for "']" command) */
X if (Visual_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 (Visual_block) /* block mode */
X {
X for (; pos.lnum <= endop.lnum; ++pos.lnum)
X {
X block_prep(pos.lnum, FALSE);
X pos.col = textcol;
X while (--textlen >= 0)
X {
X swapchar(&pos);
X if (inc(&pos) == -1) /* at end of file */


X break;
X }
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 (!mincl)
X dec(&endop);
X
X while (ltoreq(pos, endop))
X {
X swapchar(&pos);
X if (inc(&pos) == -1) /* at end of file */


X break;
X }
X }
X

X if (mtype == MCHAR && nlines == 1 && !Visual_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 if (!no_op)
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 int yanktype = mtype;
X long yanklines = nlines;
X linenr_t yankendlnum = endop.lnum;
X
X char *pnew;
X
X if (yankbuffer == '.' || 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/*
X * If the cursor was in column 1 before and after the movement, the
X * yank is always linewise.
X */
X if (mtype == MCHAR && startop.col == 0 && endop.col == 0 && nlines > 1)
X {
X yanktype = MLINE;
X if (mincl == FALSE && yankendlnum > startop.lnum)
X {
X --yankendlnum;
X --yanklines;
X }
X }
X
X y_current->y_size = yanklines;
X y_current->y_type = yanktype; /* set the yank buffer type */
X y_current->y_array = (char **)lalloc((u_long)(sizeof(char *) * yanklines), TRUE);
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 (Visual_block)
X {
X/*
X * block mode
X */
X y_current->y_type = MBLOCK; /* set the yank buffer type */
X for ( ; lnum <= yankendlnum; ++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 yanktype != MLINE yank last part of the top line
X * 2. yank the lines between startop and endop, inclusive when yanktype == MLINE
X * 3. if yanktype != MLINE yank first part of the bot line
X */
X if (yanktype != MLINE)
X {
X if (yanklines == 1) /* startop and endop on same line */
X {
X j = endop.col - startop.col + 1 - !mincl;
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 (yanktype == MLINE ? (lnum <= yankendlnum) : (lnum < yankendlnum))
X {
X if ((y_current->y_array[i] = strsave(nr2ptr(lnum++))) == NULL)
X goto fail;
X ++i;
X }
X if (yanktype != MLINE)
X {
X if ((y_current->y_array[i] = strnsave(nr2ptr(yankendlnum), endop.col + 1 - !mincl)) == 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 **)lalloc((u_long)(sizeof(char *) * (curr->y_size + y_current->y_size)), TRUE);
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 (yanktype == 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 **)lalloc((u_long)(strlen(curr->y_array[curr->y_size - 1]) + strlen(y_current->y_array[0]) + 1), TRUE);
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 (yanktype == MCHAR && !Visual_block)
X --yanklines;
X if (yanklines > p_report)
X {
X cursupdate(); /* redisplay now, so message is not deleted */
X smsg("%ld line%s yanked", yanklines, plural(yanklines));
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 int commandchar;


X char temp[2];
X

X startop = Curpos; /* default for "'[" command */
X if (dir == FORWARD)
X startop.col++;
X endop = Curpos; /* default for "']" command */
X commandchar = (dir == FORWARD ? (count == -1 ? 'o' : 'a') : (count == -1 ? 'O' : 'i'));
X if (yankbuffer == '.') /* use inserted text */
X {
X stuff_inserted(commandchar, count, FALSE);
X return;
X }
X else if (yankbuffer == '%') /* use file name */
X {
X if (!check_fname())
X {
X stuffcharReadbuff(commandchar);
X stuffReadbuff(xFilename);
X stuffcharReadbuff(ESC);
X }
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 temp[0] = yankbuffer;


X temp[1] = NUL;

X emsg2("Nothing in register %s", temp);
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 (i)
X {
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 += (colnr_t)(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 }
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("\"\"");
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 = (int)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, insert_space, redraw)
X long count;
X int insert_space;
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(insert_space, redraw))


X {
X beep();
X break;
X }
X

X if (redraw)
X updateScreen(VALID_TO_CURSCHAR);
X}
X
X int
Xdojoin(insert_space, redraw)
X int insert_space;
X int redraw;
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 = 2;
X }
X }
X nextsize = strlen(next);
X if (!canincrease(nextsize + spaces))


X return FALSE;
X
X /*

X * Append the spaces and the next line. Curr has to be obtained again,
X * because canincrease() will have changed the pointer.
X */
X curr = nr2ptr(Curpos.lnum) + currsize;
X while (spaces--)
X *curr++ = ' ';
X strcpy(curr, next);
X
X /*
X * Delete the following line. To do this we move the cursor there
X * briefly, and then move it back. After dellines() the cursor may
X * have moved up (last line deleted), so the current lnum is kept in t.
X */
X t = Curpos.lnum;
X ++Curpos.lnum;
X dellines(1L, FALSE, 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 if (redraw)
X {
X rows_to_del -= plines(Curpos.lnum);
X if (rows_to_del > 0)
X s_del(Cursrow, rows_to_del, TRUE);
X }
X
X /*
X * go to first character of the joined line
X */
X if (currsize == 0)
X Curpos.col = 0;
X else
X {
X Curpos.col = currsize - 1;
X oneright();
X }
X CHANGED;


X
X return TRUE;
X}
X

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


X curs_columns(FALSE); /* 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 ResetRedobuff();
X AppendNumberToRedobuff(count);
X AppendCharToRedobuff(initstr);
X }
X
X if (initstr == 'R')
X State = REPLACE;
X else
X State = INSERT;
X
X if (p_smd)
X showmode();
X
X change_warning(); /* give a warning if readonly */
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 = (int)(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 && (ptr[col] == 'X' || ptr[col] == 'x') &&
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 = TO_UPPER(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}
X

X/*
X * Return TRUE if startop is on or before the first non-blank character in the line
X */
X int
Xstartinmargin()
X{
X int n;
X char *ptr;
X
X n = 0;
X for (ptr = nr2ptr(startop.lnum); *ptr && isspace(*ptr); ++ptr)
X ++n;
X return (n >= startop.col);
X}
END_OF_FILE
if test 31254 -ne `wc -c <'vim/src/ops.c'`; then
echo shar: \"'vim/src/ops.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/ops.c'
# end of 'vim/src/ops.c'
fi
echo shar: End of archive 15 \(of 25\).
cp /dev/null ark15isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:25:39 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 66
Archive-name: vim/part16

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/normal.c


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:07 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'\" \(32142 characters\)
sed "s/^X//" >'vim/src/normal.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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. */
Xint redo_Visual_busy = FALSE; /* TRUE when redo-ing a visual */
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));
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 (q, @)
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, >, <, !, =, Q)
X * 8. Abbreviations (x, X, D, C, s, S, Y, &)
X * 9. Marks (m, ', `, ^O, ^I)
X * 10. Buffer setting (")
X * 11. Visual (v, V, ^V)
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 static int didwarn = FALSE; /* warned for broken inversion */
X
X /* the visual area is remembered for reselection */
X static linenr_t resel_Visual_nlines; /* number of lines */
X static int resel_Visual_type = 0; /* type 'v', 'V' or CTRL-V */
X static colnr_t resel_Visual_col; /* number of columns or end column */
X /* the visual area is remembered for redo */
X static linenr_t redo_Visual_nlines; /* number of lines */
X static int redo_Visual_type = 0; /* type 'v', 'V' or CTRL-V */
X static colnr_t redo_Visual_col; /* number of columns or end column */
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 (p_sc && (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[]m'`\"", c) || (c == 'q' && !Recording && !Exec_reg) ||
X (c == 'r' && !Visual.lnum))
X {
X State = NOMAPPING;
X nchar = vgetc(); /* no macro mapping for this char */
X premsg(c, nchar);
X }
X if (p_sc)
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 'q': /* (stop) recording into a named register */
X CHECKCLEAROP;
X /* command is ignored while executing a register */
X if (!Exec_reg && !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_winheight((int)Prenum);


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 beginline(TRUE);


X break;
X
X default:

X CLEAROPBEEP;


X }
X break;
X
X/*

X * 2: Control commands
X */
X case ':':
X if (Visual.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(did_cd || Prenum); /* print full name if count given or :cd used */
X break;
X
X case K_CCIRCM: /* shorthand command */
X CHECKCLEAROPQ;
X getaltfile((int)Prenum, (linenr_t)0, TRUE);
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 stuffcharReadbuff(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 - emptyrows - 1) / 2;
X else
X n = Prenum;
X mtype = MLINE;
X setpcmark();
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 setpcmark();


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 if (operator == CHANGE && p_ai) /* do not delete the indent */
X {
X beginline(TRUE);
X startop = Curpos;
X mtype = MCHAR;
X mincl = TRUE;
X }
X else
X mtype = MLINE;
X if (!onedown((long)(Prenum1 - 1)))
X CLEAROPBEEP;
X else if (mtype == MCHAR) /* 'c' with autoindent */
X {
X Curpos.col = MAXCOL; /* put cursor on last char in line */
X adjustCurpos();
X }
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 = (colnr_t)(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, operator != NOP);
X else
X n = end_word(Prenum1, type, operator == CHANGE);
X if (n)
X {
X CLEAROPBEEP;
X break;
X }
X#if 0
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, unless the current line is empty.
X */
X if (operator == DELETE && Prenum1 == 1 && startop.lnum != Curpos.lnum &&
X !lineempty(startop.lnum))
X {
X Curpos = startop;
X while (oneright())
X ;


X mincl = TRUE;
X }

X#endif
X break;
X
X case '$':
X mtype = MCHAR;
X mincl = TRUE;
X Curswant = MAXCOL; /* so we stay at the end */
X if (!onedown((long)(Prenum1 - 1)))
X {
X CLEAROPBEEP;


X break;
X }
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, searchbuff, FALSE, Prenum1, TRUE);


X if (n == 0)

X CLEAROP;
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 CLEAROP;
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 CLEAROPBEEP;
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 /* round up, so CTRL-G will give same value */
X Curpos.lnum = (line_count * Prenum + 99) / 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 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 (Visual.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 (Visual.lnum)
X goto dooperator;
X CHECKCLEAROPQ;
X u_undoline();
X set_want_col = TRUE;


X break;
X
X case 'r':

X if (Visual.lnum)
X {
X c = 'c';
X goto dooperator;
X }
X CHECKCLEAROPQ;
X ptr = nr2ptr(Curpos.lnum) + Curpos.col;
X if (strlen(ptr) < (unsigned)Prenum1) /* not enough characters to replace */
X {
X CLEAROPBEEP;
X break;
X }
X /*
X * Replacing with a line break or tab is done by edit(), because it
X * is complicated.
X * Other characters are done below to avoid problems with things like
X * CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC).
X */
X if (nchar == '\r' || nchar == '\n' || nchar == '\t')
X {
X prep_redo(Prenum1, 'r', nchar, NUL);
X stuffnumReadbuff(Prenum1);
X stuffcharReadbuff('R');
X stuffcharReadbuff(nchar);
X stuffcharReadbuff(ESC);
X break;
X }
X
X if (nchar == Ctrl('V')) /* get another character */
X {
X c = Ctrl('V');
X nchar = get_literal(&type);
X if (type) /* typeahead */
X stuffcharReadbuff(type);
X }
X else
X c = NUL;
X prep_redo(Prenum1, 'r', c, nchar);
X if (!u_saveCurpos()) /* save line for undo */
X break;
X Curpos.col += Prenum1 - 1;
X while (Prenum1--) /* replace the characters */
X *ptr++ = nchar;
X set_want_col = TRUE;
X CHANGED;
X updateline();
X break;
X
X case 'J':
X if (Visual.lnum) /* join the visual lines */
X {
X if (Curpos.lnum > Visual.lnum)
X {
X Prenum = Curpos.lnum - Visual.lnum + 1;
X Curpos.lnum = Visual.lnum;
X }
X else
X Prenum = Visual.lnum - Curpos.lnum + 1;
X Visual.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 (Visual.lnum) /* switch start and end of visual */
X {
X Prenum = Visual.lnum;
X Visual.lnum = Curpos.lnum;
X Curpos.lnum = Prenum;
X if (Visual.col != VISUALLINE)
X {
X n = Visual.col;
X Visual.col = Curpos.col;
X Curpos.col = (int)n;


X set_want_col = TRUE;
X }

X break;
X }
X CHECKCLEAROP;
X if (u_save(Curpos.lnum, (linenr_t)(Curpos.lnum + 1)) && Opencmd(FORWARD, TRUE, 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, TRUE))
X {
X startinsert('O', TRUE, Prenum1);
X command_busy = TRUE;
X }
X break;
X
X case 'R':
X if (Visual.lnum)
X {
X c = 'c';
X Visual.col = VISUALLINE;
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 Visual is off: swap case
X * of a single character
X */
X if (!p_to && !Visual.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 'Q':
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 = (int)n;
X break;
X
X/*
X * 8: Abbreviations
X */
X
X /* when Visual 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 (Visual.lnum)
X {
X static char trans[] = "ScYyDdCcxdXdsc";
X
X if (isupper(c) && !Visual_block) /* uppercase means linewise */
X Visual.col = VISUALLINE;
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 == 'Y' && p_ye)
X c = 'Z';
X {
X static char *(ar[9]) = {"dl", "dh", "d$", "c$", "cl", "cc", "yy", "y$", ":s\r"};
X static char *str = "xXDCsSYZ&";
X
X stuffReadbuff(ar[(int)(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 == '.' || nchar == '%' || nchar == '"')
X {
X yankbuffer = nchar;
X opnum = Prenum; /* remember count before '"' */
X }
X else
X CLEAROPBEEP;
X break;
X
X/*
X * 11. Visual
X */
X case 'v':
X case 'V':


X case Ctrl('V'):

X CHECKCLEAROP;
X Visual_block = FALSE;
X
X /* stop Visual */
X if (Visual.lnum)
X {
X Visual.lnum = 0;
X updateScreen(NOT_VALID); /* delete the inversion */
X }
X /* start Visual */
X else
X {
X if (!didwarn && (T_TI == NULL || *T_TI == NUL)) /* cannot invert */
X {
X emsg("Warning: terminal cannot invert");
X didwarn = TRUE;
X }
X if (Prenum) /* use previously selected part */
X {
X if (!resel_Visual_type) /* there is none */
X {
X beep();
X break;


X }
X Visual = Curpos;

X if (resel_Visual_nlines > 1)
X Curpos.lnum += resel_Visual_nlines * Prenum - 1;
X switch (resel_Visual_type)
X {
X case 'V': Visual.col = VISUALLINE;
X break;
X
X case Ctrl('V'):
X Visual_block = TRUE;
X break;
X
X case 'v':
X if (resel_Visual_nlines <= 1)
X Curpos.col += resel_Visual_col * Prenum - 1;
X else
X Curpos.col = resel_Visual_col;
X break;
X }
X if (resel_Visual_col == MAXCOL)
X {
X Curswant = MAXCOL;
X coladvance(MAXCOL);
X }
X else if (Visual_block)
X coladvance((colnr_t)(Cursvcol + resel_Visual_col * Prenum - 1));
X updateScreen(NOT_VALID); /* show the inversion */
X }
X else
X {
X Visual = Curpos;
X if (c == 'V') /* linewise */
X Visual.col = VISUALLINE;
X else if (c == Ctrl('V')) /* blockwise */
X Visual_block = TRUE;
X updateline(); /* start the inversion */


X }
X }
X break;
X

X/*
X * 12. Suspend
X */
X
X case Ctrl('Z'):
X CLEAROP;
X Visual.lnum = 0; /* stop Visual */
X stuffReadbuff(":st\r"); /* with autowrite */
X break;
X
X/*
X * The end
X */
X case ESC:
X if (Visual.lnum)
X {
X Visual.lnum = 0; /* stop Visual */
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 ((Visual.lnum || finish_op) && operator != NOP)
X {
X if (operator != YANK && !Visual.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_Visual_busy)


X {
X startop = Curpos;

X Curpos.lnum += redo_Visual_nlines - 1;
X switch (redo_Visual_type)
X {
X case 'V': Visual.col = VISUALLINE;
X break;
X
X case Ctrl('V'):
X Visual_block = TRUE;
X break;
X
X case 'v':
X if (redo_Visual_nlines <= 1)
X Curpos.col += redo_Visual_col - 1;
X else
X Curpos.col = redo_Visual_col;
X break;
X }
X if (redo_Visual_col == MAXCOL)
X {
X Curswant = MAXCOL;
X coladvance(MAXCOL);
X }
X }
X else if (Visual.lnum)
X startop = Visual;
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 (Visual.lnum || redo_Visual_busy)
X {


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

X startvcol = getvcol(&startop, 2);
X n = getvcol(&endop, 2);
X if (n < startvcol)
X startvcol = (colnr_t)n;
X
X /* if '$' was used, get endvcol from longest line */
X if (Curswant == MAXCOL)
X {
X Curpos.col = MAXCOL;
X endvcol = 0;
X for (Curpos.lnum = startop.lnum; Curpos.lnum <= endop.lnum; ++Curpos.lnum)
X if ((n = getvcol(&Curpos, 3)) > endvcol)
X endvcol = (colnr_t)n;
X Curpos = startop;
X }
X else if (redo_Visual_busy)
X endvcol = startvcol + redo_Visual_col - 1;
X else
X {
X endvcol = getvcol(&startop, 3);
X n = getvcol(&endop, 3);
X if (n > endvcol)
X endvcol = (colnr_t)n;
X }
X coladvance(startvcol);
X }
X
X /*
X * prepare to reselect and redo Visual: this is based on the size
X * of the Visual text


X */
X if (Visual_block)

X resel_Visual_type = Ctrl('V');
X else if (Visual.col == VISUALLINE)
X resel_Visual_type = 'V';
X else
X resel_Visual_type = 'v';
X if (Curswant == MAXCOL)
X resel_Visual_col = MAXCOL;
X else if (Visual_block)
X resel_Visual_col = endvcol - startvcol + 1;
X else if (nlines > 1)
X resel_Visual_col = endop.col;
X else
X resel_Visual_col = endop.col - startop.col + 1;
X resel_Visual_nlines = nlines;
X if (operator != YANK && operator != COLON) /* can't redo yank and : */
X {
X prep_redo(0L, 'v', opchars[operator - 1], NUL);
X redo_Visual_type = resel_Visual_type;
X redo_Visual_col = resel_Visual_col;
X redo_Visual_nlines = resel_Visual_nlines;
X }
X
X mincl = TRUE;
X if (Visual.col == VISUALLINE)
X mtype = MLINE;
X else
X mtype = MCHAR;
X
X redo_Visual_busy = FALSE;
X /*
X * Switch Visual 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 Visual.lnum = 0;
X if (operator == YANK || operator == COLON || operator == FILTER)
X updateScreen(NOT_VALID);
X }
X
X set_want_col = 1;
X
X /* no_op is set when start and end are the same */
X no_op = (mtype == MCHAR && !mincl && equal(startop, endop));
X
X /*
X * If the end of an operator is in column one while mtype is MCHAR and mincl
X * is FALSE, we put endop after the last character in the previous line.
X * If startop is on or before the first non-blank in the line, the operator
X * becomes linewise (strange, but that's the way vi does it).
X */
X if (mtype == MCHAR && mincl == FALSE && endop.col == 0 && nlines > 1)
X {
X --nlines;
X --endop.lnum;
X if (startinmargin())
X mtype = MLINE;
X else
X {


X endop.col = strlen(nr2ptr(endop.lnum));
X if (endop.col)

X {
X --endop.col;
X mincl = TRUE;
X }
X }
X }
X switch (operator)
X {
X case LSHIFT:
X case RSHIFT:
X doshift(operator);
X break;
X
X case DELETE:


X if (!no_op)
X dodelete();

X break;
X
X case YANK:
X if (!no_op)


X doyank(FALSE);
X break;
X

X case CHANGE:
X dochange();
X command_busy = TRUE;
X break;
X
X case FILTER:
X bangredo = TRUE; /* dobang() will put cmd in redo buffer */
X
X case INDENT:
X case COLON:
Xdofilter:
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 else if (operator == FORMAT)
X {
X stuffReadbuff(p_fp);


X stuffReadbuff("\n");
X }

X /* docmdline() does the rest */
X break;
X
X case TILDE:
X case UPPER:
X case LOWER:
X if (!no_op)
X dotilde();
X break;
X
X case FORMAT:
X if (*p_fp != NUL)
X goto dofilter; /* use external command */
X doformat(); /* use internal function */
X break;
X
X default:
X CLEAROPBEEP;
X }
X operator = NOP;
X Visual_block = FALSE;
X yankbuffer = 0;
X }
X
Xnormal_end:
X premsg(-1, NUL);
X if (restart_edit && operator == NOP && Visual.lnum == 0 && !command_busy && stuff_empty() && yankbuffer == 0)
X startinsert(restart_edit, 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 ResetRedobuff();
X if (yankbuffer != 0) /* yank from specified buffer */
X {
X AppendCharToRedobuff('\"');
X AppendCharToRedobuff(yankbuffer);
X }
X if (num)
X AppendNumberToRedobuff(num);
X AppendCharToRedobuff(cmd);


X if (c != NUL)

X AppendCharToRedobuff(c);
X if (nchar != NUL)
X AppendCharToRedobuff(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 Visual active


X */
X static int

Xcheckclearopq()
X{
X if (operator == NOP && Visual.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 'c1' and 'c2'


X */
X static void

Xpremsg(c1, c2)
X int c1, c2;
X{
X char buf[40];
X char *p;
X
X if (!p_sc || !(KeyTyped || c1 == -1 || c1 == ' '))
X return;
X
X cursor_off();
X windgoto((int)Rows - 1, sc_col);
X if (c1 == -1)
X outstrn(" "); /* look in comp_col() for the number of spaces */
X else
X {
X p = buf;
X if (opnum)
X {
X sprintf(p, "%ld", (long)opnum);
X p = p + strlen(buf);
X }
X if (yankbuffer)
X {
X *p++ = '"';
X *p++ = yankbuffer;
X }
X if (operator == 'z')
X *p++ = 'z';
X else if (operator)
X *p++ = opchars[operator - 1];
X if (Prenum)
X {
X sprintf(p, "%ld", (long)Prenum);
X p = p + strlen(p);
X }
X *p = NUL;
X if (c1)
X strcpy(p, transchar(c1));
X if (c2)
X strcat(p, transchar(c2));
X buf[10] = NUL; /* truncate at maximal length */
X outstrn(buf);
X }
X setcursor();
X cursor_on();
X}
END_OF_FILE
if test 32142 -ne `wc -c <'vim/src/normal.c'`; then
echo shar: \"'vim/src/normal.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/normal.c'
# end of 'vim/src/normal.c'
fi
echo shar: End of archive 16 \(of 25\).
cp /dev/null ark16isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:26:01 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 67
Archive-name: vim/part17

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/src/screen.c
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:08 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'\" \(32542 characters\)
sed "s/^X//" >'vim/src/screen.c' <<'END_OF_FILE'


X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved
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 */
Xstatic int Leftcol = 0; /* starting column of the screen */
Xstatic FPOS oldCurpos = {0, 0}; /* last known end of visual part */
Xstatic int oldCurswant = 0; /* last known value of Curswant */
Xstatic int canopt; /* TRUE when cursor goto can be optimized */
X
Xstatic int screenline __ARGS((linenr_t, int, int));
Xstatic void screenchar __ARGS((u_char *, int, int));
Xstatic void screenfill __ARGS((int, int));
Xstatic void screenalloc __ARGS((int));
Xstatic void screenclear2 __ARGS((void));
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 if (must_redraw) /* must redraw whole screen */
X {
X updateScreen(VALID);
X return;
X }
X
X screenalloc(TRUE); /* 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 cursor_off();
X
X row = screenline(Curpos.lnum, Cline_row, (int)Rows - 1);
X
X cursor_on();
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(TRUE); /* allocate screen buffers if size changed */
X
X if (Nextscreen == NULL)
X return;
X
X cmdoffset = 0; /* after redraw command line has no offset */
X if (must_redraw)
X {
X type = must_redraw;
X must_redraw = 0;
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 && Curswant == oldCurswant))
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 cursor_off();
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 + (int)LineSizes[j] >= Rows - 1)
X break;
X LineSizes[idx] = LineSizes[j];
X LineNumbers[idx] = lnum++;
X
X row += LineSizes[idx++];
X if ((int)++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 (Visual.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 (Visual_block && (Curpos.col != oldCurpos.col || Curswant != oldCurswant))
X {
X if (from > Visual.lnum)
X from = Visual.lnum;
X if (to < Visual.lnum)
X to = Visual.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 cursor_on();
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]; /* "%ld" must fit in here */
X char *p_extra;
X int n_extra;
X int n_spaces = 0;
X
X int fromcol, tocol; /* start/end of inverting */
X int noinvcur = FALSE; /* don't invert the cursor */
X int temp;
X FPOS *top, *bot;
X
X row = startrow;
X col = 0;
X vcol = 0;
X invert = FALSE;
X fromcol = -10;
X tocol = MAXCOL;
X ptr = (u_char *)nr2ptr(lnum);
X canopt = TRUE;
X if (Visual.lnum) /* visual active */
X {
X if (ltoreq(Curpos, Visual)) /* Visual is after Curpos */
X {
X top = &Curpos;
X bot = &Visual;
X }
X else /* Visual is before Curpos */
X {
X top = &Visual;
X bot = &Curpos;


X }
X if (Visual_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 != MAXCOL)
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 else if (lnum == top->lnum)
X fromcol = getvcol(top, 2);
X if (lnum == bot->lnum)
X tocol = getvcol(bot, 3) + 1;
X
X if (Visual.col == VISUALLINE) /* linewise */
X {
X if (fromcol > 0)
X fromcol = 0;
X tocol = VISUALLINE;
X }
X }
X /* if the cursor can't be switched off, don't invert the character
X where the cursor is */
X if ((T_CI == NULL || *T_CI == NUL) && lnum == Curpos.lnum)
X noinvcur = TRUE;
X
X /* if inverting in this line, can't optimize cursor positioning */
X if (fromcol >= 0)
X canopt = FALSE;
X }
X if (!p_wrap) /* advance to first character to be displayed */
X {
X while (vcol < Leftcol && *ptr)
X vcol += chartabsize(*ptr++, vcol);
X if (vcol > Leftcol)
X {
X n_spaces = vcol - Leftcol; /* begin with some spaces */
X vcol = Leftcol;
X }
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 else
X {
X p_extra = NULL;
X n_extra = 0;
X }


X for (;;)
X {

X if (!canopt) /* Visual in this line */
X {
X if (((vcol == fromcol && !(noinvcur && vcol == Cursvcol)) ||
X (noinvcur && vcol == Cursvcol + 1 && vcol >= fromcol)) &&
X vcol < tocol) /* start inverting */
X {
X invert = TRUE;
X outstr(T_TI);
X }
X else if (invert && (vcol == tocol || (noinvcur && vcol == Cursvcol)))
X /* stop inverting */
X {
X invert = FALSE;


X outstr(T_TP);
X }
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 (non-printable stuff).
X */
X
X if (n_extra)
X {
X c = (u_char)*p_extra++;
X n_extra--;
X }
X else if (n_spaces)
X {
X c = ' ';
X n_spaces--;
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 /* tab amount depends on current column */
X n_spaces = (int)p_ts - vcol % (int)p_ts - 1;
X c = ' ';
X }
X else if (c == NUL && p_list)
X {
X p_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 (!p_wrap || ++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 int n_extra = 0;
X int n_spaces = 0;
X char *p = NULL; /* init to make SASC shut up */
X int n;
X


X for (;;)
X {

X if (n_extra)
X {
X --n_extra;
X c = *p++;
X }
X else if (n_spaces)
X {
X --n_spaces;
X c = ' ';
X }
X else
X {
X c = s[si++];
X if (c == TAB && !p_list)
X {
X /* tab amount depends on current column */
X n_spaces = p_ts - col % p_ts - 1;
X c = ' ';
X }
X else if (c == NUL && p_list)
X {
X p = "";
X n_extra = 1;
X c = '$';
X }
X else if (c != NUL && (n = charsize(c)) > 1)
X {
X n_extra = n - 1;
X p = transchar(c);
X c = *p++;
X }
X }
X
X if (c == NUL)
X break;
X
X outchar(c);
X col++;
X }
X return col;


X}
X
X static void

Xscreenalloc(clear)
X int clear;
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) || Rows == 0 || Columns == 0)
X return;
X
X comp_col(); /* recompute columns for shown command and ruler */
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 if (clear)
X screenclear2();
X}
X
X void
Xscreenclear()
X{
X screenalloc(FALSE); /* allocate screen buffers if size changed */
X screenclear2();


X}
X
X static void

Xscreenclear2()
X{
X if (starting || Nextscreen == NULL)
X return;
X
X outstr(T_ED); /* clear the display */
X
X /* blank out Nextscreen */
X memset((char *)Nextscreen, ' ', (size_t)(Rows * Columns));
X
X NumLineSizes = 0; /* clear screen info */
X redraw_msg = TRUE; /* refresh cmdline at next screen redraw */
X}
X
X void
Xcursupdate()
X{
X linenr_t p;
X long nlines;
X int i;
X int temp;
X
X screenalloc(TRUE); /* 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 / 2 - 1;
X if (Topline - Curpos.lnum >= temp) /* not very close */
X {
X p = Curpos.lnum;
X i = plines(p);
X temp += i;
X /* count lines for 1/2 screenheight */
X while (i < Rows && i < temp && p > 1)
X i += plines(--p);
X Topline = p;
X if (i >= Rows) /* cursor line won't fit, backup one line */
X ++Topline;
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 if (Topline > Curpos.lnum)


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

X else if (Curpos.lnum >= Botline)
X {
X /* number of lines the cursor is below the bottom of the screen */
X nlines = Curpos.lnum - Botline + 1;
X /*
X * If the cursor is less than a screenheight down
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) /* emptyrows is larger, no need to scroll */
X nlines = 0;
X else if (temp >= Rows) /* more than a screenfull, don't scroll */
X nlines = temp;
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 if (i >= temp) /* it's possible to scroll */
X nlines = p - Topline;
X else /* below Botline, don't scroll */
X nlines = 9999;
X }
X }
X
X /*
X * Scroll up if the cursor is off the bottom of the screen a bit.
X * Otherwise put it at 1/2 of the screen.
X */
X if (nlines >= Rows / 2 && nlines > p_sj)
X {
X p = Curpos.lnum;
X temp = Rows / 2 + 1;
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(!RedrawingDisabled); /* compute Cursvcol and Curscol */
X if (must_redraw)
X updateScreen(VALID);
X }
X
X if (set_want_col)
X {
X Curswant = Cursvcol;
X set_want_col = FALSE;
X }
X}
X
X/*
X * compute Curscol and Cursvcol
X */
X void
Xcurs_columns(scroll)
X int scroll; /* when TRUE, may scroll horizontally */
X{
X int diff;
X
X Cursvcol = getvcol(&Curpos, 1);
X Curscol = Cursvcol;
X if (p_nu)
X Curscol += 8;
X
X Cursrow = Cline_row;
X if (p_wrap) /* long line wrapping, adjust Cursrow */
X while (Curscol >= Columns)
X {
X Curscol -= Columns;
X Cursrow++;
X }
X else if (scroll) /* no line wrapping, compute Leftcol if scrolling is on */
X /* if scrolling is off, Leftcol is assumed to be 0 */
X {
X /* If Cursor is left of the screen, scroll rightwards */
X /* If Cursor is right of the screen, scroll leftwards */
X if (((diff = Leftcol + (p_nu ? 8 : 0) - Curscol) > 0 ||
X (diff = Curscol - (Leftcol + Columns) + 1) > 0))
X {
X if (p_ss == 0 || diff >= Columns / 2)
X Leftcol = Curscol - Columns / 2;
X else
X {
X if (diff < p_ss)
X diff = p_ss;
X if (Curscol < Leftcol + 8)
X Leftcol -= diff;
X else
X Leftcol += diff;
X }
X if (Leftcol < 0)
X Leftcol = 0;
X must_redraw = NOT_VALID; /* screen has to be redrawn with new Leftcol */
X }
X Curscol -= Leftcol;
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 (TAB)
X * type = 3: on the last position of this character (TAB)
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;
X if (p_wrap)
X Cursrow += 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(TRUE); /* 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 if (Rows != Rows_max)

X {
X windgoto((int)Rows - 1, 0); /* delete any garbage that may have */
X clear_line(); /* been shifted to the bottom line */
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((char *)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(TRUE); /* 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 if (Rows != Rows_max)
X windgoto((int)Rows_max - 1, 0);

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((char *)temp, ' ', (size_t)Columns);
X }


X return 1;
X}
X

X void
Xshowmode()
X{
X if ((p_smd && (State == INSERT || State == REPLACE)) || Recording)
X {
X gotocmdline(TRUE, NUL);
X if (p_smd)
X {
X if (State == INSERT || State == REPLACE)
X {
X outstrn("-- ");
X if (p_ri)
X outstrn("REVERSE ");
X if (State == INSERT)
X outstrn("INSERT --");
X else
X outstrn("REPLACE --");
X }
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, ru_col);
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, (int)Curpos.col + 1);
X newlen = strlen(buffer);
X if (Curpos.col != Cursvcol)
X {
X sprintf(buffer + newlen, "-%d", Cursvcol + 1);
X newlen = strlen(buffer);
X }
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}
END_OF_FILE
if test 32542 -ne `wc -c <'vim/src/screen.c'`; then
echo shar: \"'vim/src/screen.c'\" unpacked with wrong size!
fi
chmod +x 'vim/src/screen.c'
# end of 'vim/src/screen.c'
fi
echo shar: End of archive 17 \(of 25\).
cp /dev/null ark17isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:27:19 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 68
Archive-name: vim/part18

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/vim_hlp.uue


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:08 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'\" \(36911 characters\)
sed "s/^X//" >'vim/doc/vim_hlp.uue' <<'END_OF_FILE'
X
Xbegin 644 vim.hlp
XM("`@("`@("`@("`@("`@("`@("`@5DE-(&AE;'`@9FEL92!I;F1E>`H*4D54,
XM55).('%U:70@:&5L<"`@("`@("`@("`@("`@(%9)32!S=&%N9',@9F]R(%9I@
XM($E-<')O=F5D+@I34$%#12`@;VYE('!A9V4@9F]R=V%R9"`@("`@("`@36]SM
XM="!O9B!624T@=V%S(&UA9&4@8GD@0G)A;2!-;V]L96YA87(N"B`@("!A("!GR
XM;R!T;R!T:&ES(&EN9&5X("`@("`@("!624T@:7,@8F%S960@;VX@4W1E=FEE6
XM+"!W;W)K960@;VX@8GDZ(%1I;0H@("`@8B`@;VYE('!A9V4@8F%C:W=A<F0@^
XM("`@("`@5&AO;7!S;VXL(%1O;GD@06YD<F5W<RP@1RY2+B`H1G)E9"D@5V%LY
XM=&5R"@IC("`@;&5F="UR:6=H="!A;F0@=7`M9&]W;B!M;W1I;VYS("`@;B`@,
XM(&ME>2!M87!P:6YG.R!A8F)R979I871I;VYS"F0@("!W;W)D(&%N9"!T97AT[
XM(&]B:F5C="!M;W1I;VYS("`@("!O("`@;W!T:6]N(&-O;6UA;F1S+"!O<'1I"
XM;VYS(&$M90IE("`@<&%T=&5R;B!S96%R8VAE<R`@("`@("`@("`@("`@("`@^
XM<"`@(&]P=&EO;G,@92UP"F8@("!V87)I;W5S(&UO=&EO;G,[('5S:6YG('1AV
XM9W,@("`@("!Q("`@;W!T:6]N<R!R+7,*9R`@('-C<F]L;&EN9R`@("`@("`@'
XM("`@("`@("`@("`@("`@('(@("!O<'1I;VYS('0M>@IH("`@:6YS97)T:6YG^
XM('1E>'0[(&1I9W)A<&AS("`@("`@("`@<R`@('5N9&\[('-H96QL.R!Q=6EC[
XM:V9I>#L@=F%R:6]U<PII("`@:6YS97)T(&UO9&4@("`@("`@("`@("`@("`@#
XM("`@("`@="`@(&-O;6UA;F0@;&EN92!E9&ET:6YG"FH@("!C:&%N9VEN9R!TF
XM97AT("`@("`@("`@("`@("`@("`@("!U("`@17@@<F%N9V5S.R!%>"!S<&5CF
XM:6%L(&-H87)A8W1E<G,*:R`@(&-O;7!L97@@8VAA;F=E<R`@("`@("`@("`@<
XM("`@("`@('8@("!E9&ET:6YG(&9I;&5S.R!U<VEN9R!T:&4@9FEL92!L:7-T+
XM"FP@("!D96QE=&EN9RP@8V]P>6EN9RP@;6]V:6YG('1E>'0@("!W("`@=W)IQ
XM=&EN9R!A;F0@<75I='1I;F<*;2`@(')E<&5A=&EN9R!C;VUM86YD<R`@("`@"
XM("`@("`@("`@('@@("!S=&%R=&EN9R!624T*"E)E860@(G)E9F5R96YC92YDC
XM;V,B(&9O<B!A(&UO<F4@8V]M<&QE=&4@97AP;&%N871I;VXN"@P"3&5F="UR;
XM:6=H="!M;W1I;VYS!0I.("!H("`@("`@("`@("`@;&5F="`H<V%M92!A<R!#*
XM5%),+4@L($)3(&%N9"!C=7)S;W(M;&5F="!K97DI"DX@(&P@("`@("`@("`@'
XM("!R:6=H="`H<V%M92!A<R!34$%#12!A;F0@8W5R<V]R+7)I9VAT(&ME>2D*$
XM("`@,"`@("`@("`@("`@('1O(&9I<G-T(&-H87)A8W1E<B!I;B!T:&4@;&EN#
XM90H@("!>("`@("`@("`@("`@=&\@9FER<W0@;F]N+6)L86YK(&-H87)A8W1E3
XM<B!I;B!T:&4@;&EN90I.("`D("`@("`@("`@("`@=&\@=&AE(&QA<W0@8VAAR
XM<F%C=&5R(&EN('1H92!L:6YE("A.+3$@;&EN97,@;&]W97(I"DX@('P@("`@6
XM("`@("`@("!T;R!C;VQU;6X@3@I.("!F/&-H87(^("`@("`@=&\@=&AE($YT[
XM:"!O8V-U<G)E;F-E(&]F(#QC:&%R/B!T;R!T:&4@<FEG:'0*3B`@1CQC:&%RX
XM/B`@("`@('1O('1H92!.=&@@;V-C=7)R96YC92!O9B`\8VAA<CX@=&\@=&AEF
XM(&QE9G0*3B`@=#QC:&%R/B`@("`@('1I;&P@8F5F;W)E('1H92!.=&@@;V-CW
XM=7)R96YC92!O9B`\8VAA<CX@=&\@=&AE(')I9VAT"DX@(%0\8VAA<CX@("`@'
XM("!T:6QL(&)E9F]R92!T:&4@3G1H(&]C8W5R<F5N8V4@;V8@/&-H87(^('1OL
XM('1H92!L969T"DX@(#L@("`@("`@("`@("!R97!E870@=&AE(&QA<W0@9BP@'
XM1BP@="!O<B!4($X@=&EM97,*3B`@+"`@("`@("`@("`@(')E<&5A="!T:&4@Q
XM;&%S="!F+"!&+"!T(&]R(%0@3B!T:6UE<R!I;B!O<'!O<VET92!D:7)E8W1I_
XM;VX*"@)5<"UD;W=N(&UO=&EO;G,%"DX@(&L@("`@("`@("`@("!U<"`H<V%M\
XM92!A<R!#5%),+5`@86YD(&-U<G-O<BUU<"!K97DI"DX@(&H@("`@("`@("`@B
XM("!D;W=N("AS86UE(&%S($-44DPM2BP@0U123"U.+"!,1B!A;F0@8W5R<V]R1
XM+61O=VX@:V5Y*0I.("`M("`@("`@("`@("`@=7`L(&]N('1H92!F:7)S="!N!
XM;VXM8FQA;FL@8VAA<F%C=&5R"DX@("L@("`@("`@("`@("!D;W=N+"!O;B!T7
XM:&4@9FER<W0@;F]N+6)L86YK(&-H87(N("AS86UE(&%S($-44DPM32!A;F0@%
XM0U(I"DX@(%\@("`@("`@("`@("!.("T@,2!L:6YE<R!D;W=N+"!O;B!T:&4@>
XM9FER<W0@;F]N+6)L86YK(&-H87)A8W1E<@I.("!'("`@("`@("`@("`@9V]T^
XM;R!L:6YE($X@*&1E9F%U;'0@;&%S="!L:6YE*2P@;VX@=&AE(&9I<G-T(&YOF
XM;BUB;&%N:R!C:&%R+@I.("`E("`@("`@("`@("`@9V]T;R!L:6YE($X@<&5RB
XM8V5N=&%G92!D;W=N(&EN('1H92!F:6QE+@H,`E=O<F0@;6]T:6]N<P4*3B`@O
XM=R`@("`@("`@("`@($X@=V]R9',@9F]R=V%R9`I.("!7("`@("`@("`@("`@8
XM3B!B;&%N:RUS97!A<F%T960@=V]R9',@9F]R=V%R9`I.("!E("`@("`@("`@=
XM("`@9F]R=V%R9"!T;R!T:&4@96YD(&]F('1H92!.=&@@=V]R9`I.("!%("`@)
XM("`@("`@("`@9F]R=V%R9"!T;R!T:&4@96YD(&]F('1H92!.=&@@8FQA;FLM%
XM<V5P87)A=&5D('=O<F0*3B`@8B`@("`@("`@("`@($X@=V]R9',@8F%C:W=AU
XM<F0*3B`@0B`@("`@("`@("`@($X@8FQA;FLM<V5P87)A=&5D('=O<F1S(&)A^
XM8VMW87)D"@H"5&5X="!O8FIE8W0@;6]T:6]N<P4*3B`@*2`@("`@("`@("`@=
XM($X@<V5N=&5N8V5S(&9O<G=A<F0*3B`@*"`@("`@("`@("`@($X@<V5N=&5NF
XM8V5S(&)A8VMW87)D"DX@('T@("`@("`@("`@("!.('!A<F%G<F%P:',@9F]RM
XM=V%R9`I.("![("`@("`@("`@("`@3B!P87)A9W)A<&AS(&)A8VMW87)D"DX@O
XM(%U=("`@("`@("`@("!.('-E8W1I;VYS(&9O<G=A<F0*3B`@6UL@("`@("`@3
XM("`@($X@<V5C=&EO;G,@8F%C:W=A<F0*3B`@75L@("`@("`@("`@($X@<V5C.
XM=&EO;G,@*'-T87)T:6YG('=I=&@@82`\?3XI(&9O<G=A<F0*3B`@6UT@("`@C
XM("`@("`@($X@<V5C=&EO;G,@*'-T87)T:6YG('=I=&@@82`\?3XI(&)A8VMWO
XM87)D"@P"4&%T=&5R;B!S96%R8VAE<P4*3B`@+WMP871T97)N?5LO72`@("`@D
XM("`@<V5A<F-H(&9O<G=A<F0@9F]R('1H92!.=&@@;V-C=7)R96YC92!O9B![6
XM<&%T=&5R;GT*3B`@/WMP871T97)N?5L_72`@("`@("`@<V5A<F-H(&)A8VMW=
XM87)D(&9O<B!T:&4@3G1H(&]C8W5R<F5N8V4@;V8@>W!A='1E<FY]"DX@("\@$
XM("`@("`@("`@("`@("`@("`@(')E<&5A="!L87-T('-E87)C:"P@:6X@=&AE/
XM(&9O<G=A<F0@9&ER96-T:6]N"DX@(#\@("`@("`@("`@("`@("`@("`@(')ED
XM<&5A="!L87-T('-E87)C:"P@:6X@=&AE(&)A8VMW87)D(&1I<F5C=&EO;@I.P
XM("!N("`@("`@("`@("`@("`@("`@("!R97!E870@;&%S="!S96%R8V@*3B`@Q
XM3B`@("`@("`@("`@("`@("`@("`@<F5P96%T(&QA<W0@<V5A<F-H+"!I;B!OK
XM<'!O<VET92!D:7)E8W1I;VX*3B`@*B`@("`@("`@("`@("`@("`@("`@<V5A@
XM<F-H(&9O<G=A<F0@9F]R('1H92!I9&5N="!U;F1E<B!T:&4@8W5R<V]R"DX@C
XM(",@("`@("`@("`@("`@("`@("`@('-E87)C:"!B86-K=V%R9"!F;W(@=&AE@
XM(&ED96YT('5N9&5R('1H92!C=7)S;W(*"@)S<&5C:6%L(&-H87)A8W1E<G,@H
XM:6X@<V5A<F-H('!A='1E<FYS!2`@("`@(&UA9VEC("`@("`@;F]M86=I8PH@,
XM("`@("`@("`@(&UA=&-H97,@86YY('-I;F=L92!C:&%R86-T97(@("`@("`NJ
XM("`@("`@("`@("`@7"X*("`@("`@("`@("`@("`@("`@;6%T8VAE<R!S=&%R3
XM="!O9B!L:6YE("`@("`@7B`@("`@("`@("`@(%X*("`@("`@("`@("`@("`@7
XM("`@("!M871C:&5S(&5N9"!O9B!L:6YE("`@("`@)"`@("`@("`@("`@("0*K
XM("`@("`@("`@("`@("`@("`@;6%T8VAE<R!S=&%R="!O9B!W;W)D("`@("`@$
XM7#P@("`@("`@("`@(%P\"B`@("`@("`@("`@("`@("`@("`@;6%T8VAE<R!E$
XM;F0@;V8@=V]R9"`@("`@(%P^("`@("`@("`@("!</@H@("!M871C:&5S(&$@G
XM<VEN9VQE(&-H87(@9G)O;2!T:&4@<F%N9V4@("`@("!;82UZ72`@("`@("`@B
XM7%MA+7I="B!M871C:&5S(&$@<VEN9VQE(&-H87(@;F]T(&EN('1H92!R86YG=
XM92`@("`@(%M>82UZ72`@("`@("!<6UYA+7I="FUA=&-H97,@,"!O<B!M;W)EP
XM(&]F('1H92!P<F5C961I;F<@871O;2`@("`@("H@("`@("`@("`@("!<*@IM?
XM871C:&5S(#$@;W(@;6]R92!O9B!T:&4@<')E8V5D:6YG(&%T;VT@("`@("!<Q
XM*R`@("`@("`@("`@7"L*("`@;6%T8VAE<R`P(&]R(#$@;V8@=&AE('!R96-E(
XM9&EN9R!A=&]M("`@("`@7#\@("`@("`@("`@(%P_"B`@("`@("`@("`@("`@3
XM("`@<V5P87)A=&5S('1W;R!B<F%N8VAE<R`@("`@(%Q\("`@("`@("`@("!<<
XM?`H@("`@("`@("`@(&=R;W5P(&$@<&%T=&5R;B!I;G1O(&%N(&%T;VT@("`@,
XM("!<*%PI("`@("`@("`@7"A<*0H,`E9A<FEO=7,@;6]T:6]N<P4*("`@;3QA5
XM+7I!+5H^("`@(&UA<FL@8W5R<F5N="!P;W-I=&EO;B!W:71H(&UA<FL@/&$MA
XM>D$M6CX*("`@8#QA+7I!+5H^("`@(&=O('1O(&UA<FL@/&$M>D$M6CX*("`@,
XM8&`@("`@("`@("`@(&=O('1O('1H92!P;W-I=&EO;B!B969O<F4@=&AE(&QA0
XM<W0@:G5M<`H@("!@6R!O<B!@72`@("`@9V\@=&\@=&AE('-T87)T(&]R(&5NB
XM9"!O9B!T:&4@<')E=FEO=7-L>2!O<&5R871E9"!O<B!P=70@=&5X=`H@("`G@
XM/&$M>D$M6EM=)SX@<V%M92!A<R!@+"!B=70@;VX@=&AE(&9I<G-T(&YO;BUB:
XM;&%N:R!I;B!T:&4@;&EN90HZ;6%R:W,@("`@("`@("`@<')I;G0@=&AE(&%C:
XM=&EV92!M87)K<PI.("!#5%),+4\@("`@("`@9V\@=&\@3B!O;&1E<B!P;W-IW
XM=&EO;B!I;B!J=6UP(&QI<W0*3B`@0U123"U)("`@("`@(&=O('1O($X@;F5W]
XM97(@<&]S:71I;VX@:6X@:G5M<"!L:7-T"CIJ=6UP<R`@("`@("`@("!P<FEN'
XM="!T:&4@:G5M<"!L:7-T"B`@("4@("`@("`@("`@("!F:6YD('1H92!N97AT]
XM(&)R86-E(&]R(&)R86-K970@:6X@=&AI<R!L:6YE+"!G;R!T;R!I=',@;6%TH
XM8V@*3B`@2"`@("`@("`@("`@(&=O('1O('1H92!.=&@@;&EN92!I;B!T:&4@O
XM=VEN9&]W+"!O;B!T:&4@9FER<W0@;F]N+6)L86YK"B`@($T@("`@("`@("`@!
XM("!G;R!T;R!T:&4@;6ED9&QE(&QI;F4@:6X@=&AE('=I;F1O=RP@;VX@=&AEK
XM(&9I<G-T(&YO;BUB;&%N:PI.("!,("`@("`@("`@("`@9V\@=&\@=&AE($YTH
XM:"!L:6YE(&9R;VT@=&AE(&)O='1O;2P@;VX@=&AE(&9I<G-T(&YO;BUB;&%NA
XM:PH*`E5S:6YG('1A9W,%"CIT85MG72![=&%G?2`@("`@("`@("`@($IU;7`@C
XM=&\@=&%G('MT86=]+"!U;FQE<W,@8VAA;F=E<R!H879E(&)E96X@;6%D90HZK
XM=&%;9UTA('MT86=]("`@("`@("`@("!*=6UP('1O('1A9R![=&%G?2!A;'=A=
XM>7,N($1I<V-A<F0@86YY(&-H86YG97,*("`@0U123"U=("`@("`@("`@("`@^
XM("`@2G5M<"!T;R!T:&4@=&%G('5N9&5R(&-U<G-O<BP@=6YL97-S(&-H86YG_
XM97,@;6%D90I.("!#5%),+50@("`@("`@("`@("`@("!*=6UP('1O($X@;VQDI
XM97(@=&%G(&EN('1A9R!L:7-T"CI;8V]U;G1=<&];<%U;(5T@("`@("`@($IUF
XM;7`@=&\@6V-O=6YT72!O;&1E<B!T86<@:6X@=&%G(&QI<W0*.EMC;W5N=%UT[
XM85MG75LA72`@("`@("`@2G5M<"!T;R!;8V]U;G1=(&YE=V5R('1A9R!I;B!TA
XM86<@;&ES=`HZ=&%G<R`@("`@("`@("`@("`@("`@("!0<FEN="!T86<@;&ES(
XM=`H,`E-C<F]L;&EN9P4*3B`@0U123"U%("`@("`@('=I;F1O=R!.(&QI;F5S>
XM(&1O=VYW87)D<R`H3B!L:6YE<R!%>'1R82D*3B`@0U123"U$("`@("`@('=I5
XM;F1O=R!.(&QI;F5S($1O=VYW87)D<R`H9&5F875L="!H86QF(&$@=VEN9&]W;
XM*0I.("!#5%),+48@("`@("`@=VEN9&]W($X@<&%G97,@1F]R=V%R9',@*&1O"
XM=VYW87)D<RD*3B`@0U123"U9("`@("`@('=I;F1O=R!.(&QI;F5S('5P=V%RR
XM9',*3B`@0U123"U5("`@("`@('=I;F1O=R!.(&QI;F5S(%5P=V%R9',@*&1E>
XM9F%U;'0@:&%L9B!A('=I;F1O=RD*3B`@0U123"U"("`@("`@('=I;F1O=R!.;
XM('!A9V5S($)A8VMW87)D<R`H=7!W87)D<RD*("`@>CQ#4CX@("`@("`@(')EC
XM9')A=RP@8W5R<F5N="!L:6YE(&%T('1O<"!O9B!W:6YD;W<*("`@>BX@("`@L
XM("`@("`@(')E9')A=RP@8W5R<F5N="!L:6YE(&%T(&-E;G1E<B!O9B!W:6YD9
XM;W<*("`@>BT@("`@("`@("`@(')E9')A=RP@8W5R<F5N="!L:6YE(&%T(&)O9
XM='1O;2!O9B!W:6YD;W<*#`));G-E<G1I;F<@=&5X=`4*3B`@82`@("`@("`@?
XM("`@(&%P<&5N9"!T97AT(&%F=&5R('1H92!C=7)S;W(@*$X@=&EM97,I"DX@G
XM($$@("`@("`@("`@("!A<'!E;F0@=&5X="!A="!T:&4@96YD(&]F('1H92!L-
XM:6YE("A.('1I;65S*0I.("!I("`@("`@("`@("`@:6YS97)T('1E>'0@8F5F%
XM;W)E('1H92!C=7)S;W(@*$X@=&EM97,I"DX@($D@("`@("`@("`@("!I;G-EV
XM<G0@=&5X="!B969O<F4@=&AE(&9I<G-T(&YO;BUB;&%N:R!I;B!T:&4@;&ENB
XM92`H3B!T:6UE<RD*3B`@;R`@("`@("`@("`@(&]P96X@82!N97<@;&EN92!B4
XM96QO=R!T:&4@8W5R<F5N="!L:6YE+"!A<'!E;F0@=&5X="`H3B!T:6UE<RD*W
XM3B`@3R`@("`@("`@("`@(&]P96X@82!N97<@;&EN92!A8F]V92!T:&4@8W5RZ
XM<F5N="!L:6YE+"!A<'!E;F0@=&5X="`H3B!T:6UE<RD*"@)3<&5C:6%L(&ENY
XM<V5R=',%"CIR('MF:6QE?2`@("`@("!I;G-E<G0@=&AE(&-O;G1E;G1S(&]F]
XM('MF:6QE?2!B96QO=R!T:&4@8W5R<V]R"CIR(7MC;VUM86YD?2`@("!I;G-EM
XM<G0@=&AE('-T86YD87)D(&]U='!U="!O9B![8V]M;6%N9'T@8F5L;W<@=&AE/
XM(&-U<G-O<@H*`D1I9W)A<&AS!0HZ9&EG6W)A<&AS72`@("`@<VAO=R!C=7)R6
XM96YT(&QI<W0@;V8@9&EG<F%P:',*.F1I9UMR87!H<UT@>V-H87(Q?7MC:&%R8
XM,GT@>VYU;6)E<GT@+BXN"B`@("`@("`@("`@("`@("!A9&0@9&EG<F%P:"AS'
XM*2!T;R!T:&4@;&ES=`H,`F-H87(%("`@("`@("`@("`@("`"86-T:6]N(&EN;
XM(&EN<V5R="!M;V1E!0I#5%),+5L@;W(@/$530SX@("!E;F0@:6YS97)T(&]R)
XM(')E<&QA8V4@;6]D92P@8F%C:R!T;R!C;VUM86YD(&UO9&4*0U123"U!("`@R
XM("`@("`@("`@:6YS97)T('!R979I;W5S;'D@:6YS97)T960@=&5X=`I#5%),9
XM+5(@/#`M.6$M>CX@("!I;G-E<G0@8V]N=&5N=',@;V8@<F5G:7-T97(@/#`MM
XM.6$M>CX*0U123"U`("`@("`@("`@("`@:6YS97)T('!R979I;W5S;'D@:6YSL
XM97)T960@=&5X="!A;F0@<W1O<"!I;G-E<G0*0U123"U*(&]R(#Q,1CX@;W(@K
XM0U123"U-(&]R(#Q#4CX@("!B96=I;B!N97<@;&EN90I#5%),+4L@>V-H87(Q7
XM?2![8VAA<C)]("!E;G1E<B!D:6=R87!H"D-44DPM12`@("`@("`@("`@(&EN*
XM<V5R="!T:&4@8VAA<F%C=&5R('=H:6-H(&ES(&)E;&]W('1H92!C=7)S;W(*]
XM0U123"U9("`@("`@("`@("`@:6YS97)T('1H92!C:&%R86-T97(@=VAI8V@@1
XM:7,@86)O=F4@=&AE(&-U<G-O<@I#5%),+58@("`@("`@("`@("!I;G-E<G0@?
XM8VAA<F%C=&5R(&QI=&5R86QL>2P@;W(@96YT97(@9&5C:6UA;"!B>71E('9A$
XM;'5E"D-44DPM2"!O<B`\0E,^(&]R(#Q$14P^(&1E;&5T92!T:&4@8VAA<F%C0
XM=&5R(&)E9F]R92!T:&4@8W5R<V]R"D-44DPM5R`@("`@("`@("`@(&1E;&5T.
XM92!W;W)D(&)E9F]R92!T:&4@8W5R<V]R"D-44DPM52`@("`@("`@("`@(&1E]
XM;&5T92!A;&P@96YT97)E9"!C:&%R86-T97)S(&EN('1H92!C=7)R96YT(&QIZ
XM;F4*0U123"U4("`@("`@("`@("`@:6YS97)T(&]N92!S:&EF='=I9'1H(&]F=
XM(&EN9&5N="!I;B!T:&4@8W5R<F5N="!L:6YE"D-44DPM1"`@("`@("`@("`@U
XM(&1E;&5T92!O;F4@<VAI9G1W:61T:"!O9B!I;F1E;G0@:6X@=&AE(&-U<G)E#
XM;G0@;&EN90HP($-44DPM1"!O<B!>($-44DPM1"`@("!D96QE=&4@86QL(&ENR
XM9&5N="!I;B!T:&4@8W5R<F5N="!L:6YE"GMC:&%R,7T@/$)3/B![8VAA<C)]6
XM("`@(&5N=&5R(&1I9W)A<&@@:68@)V1G)R!O<'1I;VX@<V5T"D-44DPM4"`@F
XM("`@("`@("`@('1O9V=L92`G<F5V:6YS)R`H<F5V97)S92!I;G-E<G0I(&]PH
XM=&EO;@H@("`@("`@(`)K97ES('1H870@<W1O<"!I;G-E<G0L(&1O('-O;65T5
XM:&EN9R!A;F0@9V5T(&)A8VL@=&\@:6YS97)T.@4*8W5R<V]R(&ME>7,@("`@%
XM("`@;6]V92!C=7)S;W(@;&5F="]R:6=H="]U<"]D;W=N"G-H:69T+75P+V1OD
XM=VX@("`@(&]N92!S8W)E96YF=6QL(&)A8VMW87)D+V9O<G=A<F0*<VAI9G0MR
XM;&5F="]R:6=H="`@;VYE('=O<F0@;&5F="]R:6=H=`I#5%),+4\@>V-O;6UA1
XM;F1]("!E>&5C=71E('MC;VUM86YD?0H,`D-H86YG:6YG('1E>'0%"DX@(%(@D
XM("`@("`@("`@("!E;G1E<B!R97!L86-E(&UO9&4@*')E<&5A="!T:&4@96YT0
XM97)E9"!T97AT($X@=&EM97,I"DX@(&-[;6]T:6]N?2`@("!C:&%N9V4@=&AEN
XM('1E>'0@=&AA="!I<R!M;W9E9"!O=F5R('=I=&@@>VUO=&EO;GT*>W9I<W5A`
XM;'UC("`@("`@(&-H86YG92!T:&4@:&EG:&QI9VAT960@=&5X=`I.("!C8R`@7
XM("`@("`@("`@8VAA;F=E($X@;&EN97,*3B`@0R`@("`@("`@("`@(&-H86YG+
XM92!T;R!E;F0@;V8@;&EN92`H86YD($XM,2!M;W)E(&QI;F5S*0I.("!S("`@E
XM("`@("`@("`@8VAA;F=E($X@8VAA<F%C=&5R<PI.("!3("`@("`@("`@("`@?
XM8VAA;F=E($X@;&EN97,*3B`@<CQC:&%R/B`@("`@(')E<&QA8V4@3B!C:&%RY
XM86-T97)S(&)Y(#QC:&%R/@I.("!^("`@("`@("`@("`@<W=I=&-H(&-A<V4@Y
XM9F]R($X@8VAA<F%C=&5R<R!A;F0@861V86YC92!C=7)S;W(*>W9I<W5A;'U^,
XM("`@("`@('-W:71C:"!C87-E(&9O<B!H:6=H;&EG:'1E9"!T97AT"GMV:7-UG
XM86Q]=2`@("`@("!M86ME(&AI9VAL:6=H=&5D('1E>'0@=7!P97)C87-E"GMVF
XM:7-U86Q]52`@("`@("!M86ME(&AI9VAL:6=H=&5D('1E>'0@;&]W97)C87-E9
XM"DX@($-44DPM02`@("`@("!A9&0@3B!T;R!T:&4@;G5M8F5R(&%T(&]R(&%F<
XM=&5R('1H92!C=7)S;W(*3B`@0U123"U3("`@("`@('-U8G1R86-T($X@9G)O4
XM;2!T:&4@;G5M8F5R(&%T(&]R(&%F=&5R('1H92!C=7)S;W(*3B`@/'MM;W1I&
XM;VY]("`@(&UO=F4@=&AE(&QI;F5S('1H870@87)E(&UO=F5D(&]V97(@;VYE/
XM('-H:69T=VED=&@@;&5F=`I.("`\/"`@("`@("`@("`@;6]V92!.(&QI;F5SY
XM(&]N92!S:&EF='=I9'1H(&QE9G0*3B`@/GMM;W1I;VY]("`@(&UO=F4@=&AE'
XM(&QI;F5S('1H870@87)E(&UO=F5D(&]V97(@;VYE('-H:69T=VED=&@@<FEG=
XM:'0*3B`@/CX@("`@("`@("`@(&UO=F4@3B!L:6YE<R!O;F4@<VAI9G1W:61T(
XM:"!R:6=H=`I.("!1>VUO=&EO;GT@("`@9F]R;6%T('1H92!L:6YE<R!T:&%T3
XM(&%R92!M;W9E9"!O=F5R('1O("=T97AT=VED=&@G(&QE;F=T:`HZ6W)A;F=E3
XM76-E6VYT97)=(%MW:61T:%T@("!C96YT97(@=&AE(&QI;F5S(&EN(%MR86YGE
XM95T*.EMR86YG95UL95MF=%T@6VEN9&5N=%T@("`@;&5F="!A;&EG;B!T:&4@?
XM;&EN97,@:6X@6W)A;F=E72!;=VET:"!I;F1E;G1="CI;<F%N9V5=<FE;9VATO
XM72!;=VED=&A=("`@(')I9VAT(&%L:6=N('1H92!L:6YE<R!I;B!;<F%N9V5=6
XM"@P"0V]M<&QE>"!C:&%N9V5S!0H@("!V("`@("`@("`@("`@<W1A<G0@:&EG4
XM:&QI9VAT:6YG(&-H87)A8W1E<G,@('T@;6]V92!C=7)S;W(@86YD('5S90H@Z
XM("!6("`@("`@("`@("`@<W1A<G0@:&EG:&QI9VAT:6YG(&QI;F5W:7-E("`@Z
XM('T@;W!E<F%T;W(@=&\@869F96-T"B`@($-44DPM5B`@("`@("!S=&%R="!HM
XM:6=H;&EG:'1I;F<@8FQO8VMW:7-E("`@?2!H:6=H;&EG:'1E9"!T97AT"B`@>
XM(&\@("`@("`@("`@("!E>&-H86YG92!C=7)S;W(@<&]S:71I;VX@=VET:"!S4
XM=&%R="!O9B!H:6=H;&EG:'1I;F<*"DX@("%[;6]T:6]N?7MC;VUM86YD?0H@8
XM("`@("`@("`@("`@("`@9FEL=&5R('1H92!L:6YE<R!T:&%T(&%R92!M;W9E"
XM9"!O=F5R('1H<F]U9V@@>V-O;6UA;F1]"DX@("$A>V-O;6UA;F1]"B`@("`@S
XM("`@("`@("`@("!F:6QT97(@3B!L:6YE<R!T:')O=6=H('MC;VUM86YD?0HZK
XM6W)A;F=E72%[8V]M;6%N9'T*("`@("`@("`@("`@("`@(&9I;'1E<B!;<F%N)
XM9V5=(&QI;F5S('1H<F]U9V@@>V-O;6UA;F1]"DX@(#U[;6]T:6]N?7MC;VUM&
XM86YD?0H@("`@("`@("`@("`@("`@9FEL=&5R('1H92!L:6YE<R!T:&%T(&%R@
XM92!M;W9E9"!O=F5R('1H<F]U9V@@(FEN9&5N="(*3B`@/3U[8V]M;6%N9'T*V
XM("`@("`@("`@("`@("`@(&9I;'1E<B!.(&QI;F5S('1H<F]U9V@@(FEN9&5N@
XM="(*.EMR86YG95US6W5B<W1I='5T95TO>W!A='1E<FY]+WMS=')I;F=]+UMG'
XM75MC70H@("`@("`@("`@("`@("`@<W5B<W1I='5T92![<&%T=&5R;GT@8GD@/
XM>W-T<FEN9WT@:6X@6W)A;F=E72!L:6YE<SL@=VET:"!;9UT*("`@("`@("`@F
XM("`@("`@(')E<&QA8V4@86QL(&]C8W5R<F5N8V5S(&]F('MP871T97)N?3L@W
XM=VET:"!;8UT@87-K(&9I<G-T"CI;<F%N9V5=<UMU8G-T:71U=&5=(%MG75MCX
XM70H@("`@("`@("`@("`@("`@<F5P96%T('!R979I;W5S(#IS('=I=&@@;F5W8
XM(')A;F=E(&%N9"!O<'1I;VYS"B`@("8@("`@("`@("`@("!297!E870@<')E$
XM=FEO=7,@.G,@;VX@8W5R<F5N="!L:6YE('=I=&AO=70@;W!T:6]N<PH*#`)$Q
XM96QE=&EN9R!T97AT!0I.("!X("`@("`@("`@("`@9&5L971E($X@8VAA<F%C%
XM=&5R<R!U;F1E<B!A;F0@869T97(@=&AE(&-U<G-O<@I.("!8("`@("`@("`@P
XM("`@9&5L971E($X@8VAA<F%C=&5R<R!B969O<F4@=&AE(&-U<G-O<@I.("!DO
XM>VUO=&EO;GT@("`@9&5L971E('1H92!T97AT('1H870@:7,@;6]V960@;W9EY
XM<B!W:71H('MM;W1I;VY]"GMV:7-U86Q]9"`@("`@("!D96QE=&4@=&AE(&AI;
XM9VAL:6=H=&5D('1E>'0*3B`@9&0@("`@("`@("`@(&1E;&5T92!.(&QI;F5SQ
XM"DX@($0@("`@("`@("`@("!D96QE=&4@=&\@96YD(&]F(&QI;F4@*&%N9"!./
XM+3$@;6]R92!L:6YE<RD*3B`@2B`@("`@("`@("`@(&IO:6X@3BTQ(&QI;F5SN
XM("AD96QE=&4@;F5W;&EN97,I"GMV:7-U86Q]2B`@("`@("!J;VEN('1H92!H"
XM:6=H;&EG:'1E9"!L:6YE<PHZ6W)A;F=E760@6R)X72`@9&5L971E(%MR86YG)
XM95T@;&EN97,@*&EN=&\@<F5G:7-T97(@6R)X72D*"@)#;W!Y:6YG(&%N9"!MN
XM;W9I;F<@=&5X=`4*("`@(CQC:&%R/B`@("`@('5S92!R96=I<W1E<B`\8VAA+
XM<CX@9F]R('1H92!N97AT(&1E;&5T92P@>6%N:R!O<B!P=70*.F1I<R`@("`@'
XM("`@("`@('-H;W<@=&AE(&-U<G)E;G0@<F5G:7-T97(@8V]N=&5N=',*3B`@0
XM>7MM;W1I;VY]("`@('EA;FL@=&AE('1E>'0L(&UO=F5D(&]V97(@=VET:"![Z
XM;6]T:6]N?2P@:6YT;R!A(')E9VES=&5R"GMV:7-U86Q]>2`@("`@("!Y86YK!
XM('1H92!H:6=H;&EG:'1E9"!T97AT(&EN=&\@82!R96=I<W1E<@I.("!Y>2`@1
XM("`@("`@("`@>6%N:R!.(&QI;F5S(&EN=&\@82!R96=I<W1E<@I.("!9("`@M
XM("`@("`@("`@>6%N:R!.(&QI;F5S(&EN=&\@82!R96=I<W1E<@I.("!P("`@$
XM("`@("`@("`@<'5T(&$@<F5G:7-T97(@869T97(@=&AE(&-U<G-O<B!P;W-IK
XM=&EO;B`H3B!T:6UE<RD*3B`@4"`@("`@("`@("`@('!U="!A(')E9VES=&5R"
XM(&)E9F]R92!T:&4@8W5R<V]R('!O<VET:6]N("A.('1I;65S*0H,`E)E<&5A-
XM=&EN9R!C;VUM86YD<P4*3B`@+B`@("`@("`@("`@(')E<&5A="!L87-T(&-HO
XM86YG92`H=VET:"!C;W5N="!R97!L86-E9"!B>2!.*0H@("!Q/&$M>CX@("`@W
XM("`@<F5C;W)D('1Y<&5D(&-H87)A8W1E<G,@:6YT;R!R96=I<W1E<B`\82UZH
XM/@H@("!Q("`@("`@("`@("`@<W1O<"!R96-O<F1I;F<*3B`@0#QA+7H^("`@V
XM("`@(&5X96-U=&4@=&AE(&-O;G1E;G1S(&]F(')E9VES=&5R(#QA+7H^("A.4
XM('1I;65S*0I.("!`0"`@("`@("`@("`@<F5P96%T('!R979I;W5S($`\82UZE
XM/B`H3B!T:6UE<RD*.D`\82UZ/B`@("`@("`@(&5X96-U=&4@=&AE(&-O;G1ER
XM;G1S(&]F(')E9VES=&5R(#QA+7H^(&%S(&%N($5X(&-O;6UA;F0*.D!`("`@4
XM("`@("`@("`@(')E<&5A="!P<F5V:6]U<R`Z0#QA+7H^"CI;<F%N9V5=9UMLQ
XM;V)A;%TO>W!A='1E<FY]+UMC;61="B`@("`@("`@("`@("`@("!%>&5C=71E8
XM($5X(&-O;6UA;F0@6V-M9%T@*&1E9F%U;'0@.G`I(&]N('1H92!L:6YE<R!WX
XM:71H:6X*("`@("`@("`@("`@("`@(%MR86YG95T@=VAE<F4@>W!A='1E<FY]\
XM(&UA=&-H97,N"CI;<F%N9V5=9UML;V)A;%TA+WMP871T97)N?2];8VUD70H@P
XM("`@("`@("`@("`@("`@17AE8W5T92!%>"!C;VUM86YD(%MC;61=("AD969AS
XM=6QT(#IP*2!O;B!T:&4@;&EN97,@=VET:&EN"B`@("`@("`@("`@("`@("!;Y
XM<F%N9V5=('=H97)E('MP871T97)N?2!D;V5S($Y/5"!M871C:"X*.G-O6W5R:
XM8V5=('MF:6QE?0H@("`@("`@("`@("`@("`@4F5A9"!%>"!C;VUM86YD<R!FX
XM<F]M('MF:6QE?2X*.G-O6W5R8V5=(2![9FEL97T*("`@("`@("`@("`@("`@$
XM(%)E860@5DE-(&-O;6UA;F1S(&9R;VT@>V9I;&5]+@H,`DME>2!M87!P:6YGA
XM!0HZ;6%;<%T@>VQH<WT@>W)H<WT@("`@("!-87`@>VQH<WT@=&\@>W)H<WT@(
XM:6X@;F]R;6%L(&UO9&4N"CIM85MP72$@>VQH<WT@>W)H<WT@("`@($UA<"![K
XM;&AS?2!T;R![<FAS?2!I;B!I;G-E<G0@86YD(&-O;6UA;F0@;&EN92!M;V1EW
XM+@HZ;F];<F5M87!=6R%=('ML:'-]('MR:'-]"B`@("`@("`@("`@("`@("`@C
XM("`@("`@(%-A;64@87,@.FUA<"P@;F\@<F5M87!P:6YG(&9O<B!T:&ES('MR*
XM:'-]"CIU;FU;87!=('ML:'-]("`@("`@("`@(%)E;6]V92!T:&4@;6%P<&EN(
XM9R!O9B![;&AS?2!F;W(@;F]R;6%L(&UO9&4N"CIU;FU;87!=(2![;&AS?2`@;
XM("`@("`@(%)E;6]V92!T:&4@;6%P<&EN9R!O9B![;&AS?2!F;W(@:6YS97)TK
XM(&%N9"!C;VUM86YD"B`@("`@("`@("`@("`@("`@("`@("`@(&QI;F4@;6]DD
XM92X*.FUA6W!=(%ML:'-=("`@("`@("`@("`@3&ES="!M87!P:6YG<R`H<W1A7
XM<G1I;F<@=VET:"!;;&AS72D@9F]R(&YO<FUA;"!M;V1E+@HZ;6%;<%TA(%ML-
XM:'-=("`@("`@("`@("!,:7-T(&UA<'!I;F=S("AS=&%R=&EN9R!W:71H(%MLJ
XM:'-=*2!F;W(@:6YS97)T(&%N9`H@("`@("`@("`@("`@("`@("`@("`@("!C]
XM;VUM86YD(&QI;F4@;6]D92X*.F-M87`O.F-U;FUA<"\Z8VYO<F5M87`@;&EKG
XM92!M87`O=6YM87`O;F]R96UA<"!B=70@9F]R(&-O;6UA;F0@;&EN92!M;V1E2
XM(&]N;'D*.FEM87`O.FEU;FUA<"\Z:6YO<F5M87`@;&EK92!M87`O=6YM87`OF
XM;F]R96UA<"!B=70@9F]R(&EN<V5R="!M;V1E(&]N;'D*.FUK6V5X<F-=6R%=_
XM(%MF:6QE72`@("`@=W)I=&4@8W5R<F5N="!M87!P:6YG<RP@86)B<F5V:6%TA
XM:6]N<R!A;F0@<V5T=&EN9W,*("`@("`@("`@("`@("`@("`@("`@("`@=&\@J
XM6V9I;&5=("AD969A=6QT("(N97AR8R([('5S92`A('1O(&]V97)W<FET92D*O
XM.FUK=EMI;7)C75LA72!;9FEL95T@("`@<V%M92!A<R`Z;6ME>')C+"!B=70@Q
XM=VET:"!D969A=6QT("(N=FEM<F,B"@H"06)B<F5V:6%T:6]N<P4*.F%B6V)R.
XM979I871E72![;&AS?2![<FAS?2`@("!A9&0@86)B<F5V:6%T:6]N(&9O<B![@
XM;&AS?2!T;R![<FAS?0HZ86);8G)E=FEA=&5=('ML:'-]("`@("`@("`@('-HW
XM;W<@86)B<F5V:6%T:6]N<R!T:&%T('-T87)T('=I=&@@>VQH<WT*.F%B6V)R_
XM979I871E72`@("`@("`@("`@("`@("!S:&]W(&%L;"!A8F)R979I871I;VYS^
XM"CIU;F%;8F)R979I871E72![;&AS?2`@("`@("`@<F5M;W9E(&%B8G)E=FEA]
XM=&EO;B!F;W(@>VQH<WT*.FEA8B\Z8V%B+SII=6YA8B\Z8W5N86(O.FYO<F5AG
XM8B\Z8VYO<F5A8B\Z:6YO<F5A8B`@("!A;'-O(&%V86EL86)L92$*#`)/<'1IS
XM;VYS!0HZ<V5;=%T@("`@("`@("`@("`@("`@("!3:&]W(&%L;"!M;V1I9FEE4
XM9"!O<'1I;VYS+@HZ<V5;=%T@86QL("`@("`@("`@("`@("!3:&]W(&%L;"!OH
XM<'1I;VYS+@HZ<V5;=%T@>V]P=&EO;GT@("`@("`@("!3970@=&]G9VQE(&]PQ
XM=&EO;B!O;BP@<VAO=R!S=')I;F<@;W(@;G5M8F5R(&]P=&EO;BX*.G-E6W1=4
XM(&YO>V]P=&EO;GT@("`@("`@4V5T('1O9V=L92!O<'1I;VX@;V9F+@HZ<V5;U
XM=%T@:6YV>V]P=&EO;GT@("`@("!I;G9E<G0@=&]G9VQE(&]P=&EO;BX*.G-E,
XM6W1=('MO<'1I;VY]/7MV86QU97T@4V5T('-T<FEN9R!O<B!N=6UB97(@;W!T/
XM:6]N('1O('MV86QU97TN"CIS95MT72![;W!T:6]N?3\@("`@("`@(%-H;W<@E
XM=F%L=64@;V8@>V]P=&EO;GTN"@H";W!T:6]N("AS:&]R=&AA;F0I!2`@(`)TW
XM>7!E!2`@`F1E9F%U;'0%("`@("`@("`"969F96-T!0IA=71O:6YD96YT("AAA
XM:2D@("`@('1O9V=L92`@("!O9F8@("!I;G-E<G0@;6]D93H@8V]P>2!I;F1E^
XM;G0@9G)O;2!P<F5V(&QI;F4*875T;W=R:71E("AA=RD@("`@("!T;V=G;&4@T
XM("`@;V9F("`@=W)I=&4@=&AE(&9I;&4@=VAE;B!S=&%R=&EN9R!A(&YE=R!E5
XM9&ET"F)A8VMS<&%C92`H8G,I("`@("`@;G5M8F5R("`@(#`@("`@(#`@<W1A?
XM;F1A<F0@5FDL(#$@9&5L971E($Y,+"`R(&1E;&5T92!A;&P*8F%C:W5P("AB&
XM:RD@("`@("`@("!T;V=G;&4@("`@;VX@("`@8F%C:W5P(&$@9FEL92!B969O&
XM<F4@;W9E<G=R:71I;F<@:70*8F%C:W5P9&ER("AB9&ER*2`@("!S=')I;F<@\
XM("`@(GXO(B`@56YI>"!O;FQY.B!$:7)E8W1O<GD@9F]R(&)A8VMU<"!F:6QEC
XM<PIB:6YA<GD@*&)I;BD@("`@("`@('1O9V=L92`@("!O9F8@("!B:6YA<GD@N
XM9FEL92!M;V1E"F-O;'5M;G,@*&-O*2`@("`@("`@;G5M8F5R("`@(#@P("`@$
XM(&YU;6)E<B!O9B!C;VQU;6YS(&EN('1H92!D:7-P;&%Y"F-O;7!A=&EB;&4@W
XM*&-P*2`@("`@=&]G9VQE("`@(&]F9B`@('-E="!O<'1I;VYS(&9O<B!M87AI/
XM;75M('9I+6-O;7!A=&EB:6QI='D*9&EG<F%P:"`H9&<I("`@("`@("!T;V=G+
XM;&4@("`@;V9F("`@96YA8FQE(#Q"4SX@9&EG<F%P:',@:6X@:6YS97)T(&UO<
XM9&4*9&ER96-T;W)Y("AD:7(I("`@("!S=')I;F<@("`@(B(@("`@9&ER96-T.
XM;W)Y('1O('!U="!A=71O<V-R:7!T(&9I;&4*97%U86QP<F<@*&5P*2`@("`@5
XM("!S=')I;F<@("`@(FEN9&5N="(@('!R;V=R86T@=7-E9"!F;W(@)STG(&-OJ
XM;6UA;F0*97)R;W)B96QL<R`H96(I("`@("!T;V=G;&4@("`@;V9F("`@<FEN1
XM9R!T:&4@8F5L;"!F;W(@97)R;W(@;65S<V%G97,*97)R;W)F:6QE("AE9BD@@
XM("`@("!S=')I;F<@("`@(D%Z=&5C0RY%<G(B(&9I;&4@9F]R(%%U:6-K1FEXW
XM(&]P=&EO;@H,`F]P=&EO;B`H<VAO<G1H86YD*04@("`"='EP904@(`)D969AF
XM=6QT!2`@("`@("`@`F5F9F5C=`4*97)R;W)F;W)M870@*&5F;2D@("!S=')I6
XM;F<@("`@("`@("`@9F]R;6%T(&]F(&5R<F]R(&UE<W-A9V5S(&9R;VT@8V]M(
XM<&EL97(*97-C:V5Y<R`H96LI("`@("`@("!T;V=G;&4@("`@;VX@("`@9G5N&
XM8RX@:V5Y<R!W:71H(#Q%4T,^('=O<FL@:6X@:6YS97)T(&UO9&4*97AP86YD<
XM=&%B("AE="D@("`@("!T;V=G;&4@("`@;V9F("`@:6YS97)T(&UO9&4Z('5SZ
XM92!S<&%C97,@=&\@96YT97(@82!T86(*97AR8R`@("`@("`@("`@("`@("!T-
XM;V=G;&4@("`@;V9F("`@<F5A9"`N97AR8R\N=FEM<F,@9G)O;2!C=7)R96YTZ
XM(&1I<F5C=&]R>0IF;W)M871P<F<@*&9P*2`@("`@('-T<FEN9R`@("`B(B`@S
XM("!E>'1E<FYA;"!P<F]G<F%M(&9O<B`G42<@8V]M;6%N9`IG<F%P:&EC("AGW
XM<BD@("`@("`@('1O9V=L92`@("!O9F8@("!D:7-P;&%Y(&-H87)S(#!X.#`M\
XM,'@Y9B!D:7)E8W1L>0IH96QP9FEL92`H:&8I("`@("`@('-T<FEN9R`@("`BR
XM=FEM.G9I;2YH;'`B("`@("!N86UE(&]F(&AE;'`@9FEL90IH:7-T;W)Y("AHQ
XM:2D@("`@("`@(&YU;6)E<B`@("`R,"`@("!N=6UB97(@;V8@<F5M96UB97)E/
XM9"!C;VUM86YD(&QI;F5S"FEG;F]R96-A<V4@*&EC*2`@("`@=&]G9VQE("`@'
XM(&]F9B`@(&EG;F]R92!C87-E(&EN('-E87)C:"!P871T97)N<PII;G-E<G1ME
XM;V1E("AI;2D@("`@('1O9V=L92`@("!O9F8@("!S=&%R="!E9&ET:6YG(&ENE
XM(&EN<V5R="!M;V1E"FIO:6YS<&%C97,@*&IS*2`@("`@=&]G9VQE("`@(&]N`
XM("`@(&EN<V5R="!T=V\@<W!A8V5S(&%F=&5R(&$@)RXG('=I=&@@:F]I;@IK>
XM97EW;W)D<')G("AK<"D@("`@('-T<FEN9R`@("`B<F5F(B!N86UE(&]F('!R?
XM;V=R86T@9F]R("=+)R!C;VUM86YD"FQI;F5S("`@("`@("`@("`@("`@;G5M*
XM8F5R("`@(#(U("`@(&YU;6)E<B!O9B!L:6YE<R!I;B!T:&4@9&ES<&QA>0IL]
XM:7-T("`@("`@("`@("`@("`@('1O9V=L92`@("!O9F8@("!D:7-P;&%Y(&QI8
XM;F5S(&EN(&QI<W0@;6]D90IM86=I8R`@("`@("`@("`@("`@('1O9V=L92`@+
XM("!O;B`@("!D:69F97)E;G0@<&%T=&5R;B!M871C:&EN9R!C:&%R86-T97)S=
XM"FUA:V5P<F<@*&UP*2`@("`@("`@<W1R:6YG("`@(")M86ME(B!N86UE(&]FN
XM('!R;V=R86T@9F]R("<Z;6%K92<@8V]M;6%N9`IM;V1E;&EN92`H;6PI("`@%
XM("`@('1O9V=L92`@("!O;B`@("!L:6YE<R!A<F4@8VAE8VME9"!F;W(@<V5T,
XM(&-O;6UA;F1S"FUO9&5L:6YE<R`H;6QS*2`@("`@;G5M8F5R("`@(#4@("`@7
XM(&YU;6)E<B!O9B!L:6YE<R!C:&5C:V5D(&9O<B!S970@8V]M;6%N9',*;G5M?
XM8F5R("AN=2D@("`@("`@("!T;V=G;&4@("`@;V9F("`@9&ES<&QA>2!L:6YE(
XM(&YU;6)E<G,*<&%R86=R87!H<R`H<&%R82D@("!S=')I;F<@("`@(DE03%!0"
XM4%%04"!,27!P;'!I<&)P(@H@("`@("`@("`@("`@("`@("`@("`@("`@("`@)
XM("`@("`@("!N<F]F9B!M86-R;W,@=&AA="!S97!A<F%T92!P87)A9W)A<&AS/
XM"G!A<W1E("`@("`@("`@("`@("`@=&]G9VQE("`@(&]F9B`@('!A<W1E(&UO]
XM9&4Z(&EN<V5R="!L:71E<F%L;'D*#`)O<'1I;VX@*'-H;W)T:&%N9"D%("`@\
XM`G1Y<&4%("`"9&5F875L=`4@("`@("`@(`)E9F9E8W0%"G)E861O;FQY("AR+
XM;RD@("`@("`@=&]G9VQE("`@(&]F9B`@(&]V97)W<FET:6YG('1H92!F:6QEV
XM(&YO="!A;&QO=V5D"G)E;6%P("`@("`@("`@("`@("`@=&]G9VQE("`@(&]N7
XM("`@(#IM87`@8V]M;6%N9"!W;W)K<R!R96-U<G-I=F5L>0IR97!O<G0@("`@0
XM("`@("`@("`@(&YU;6)E<B`@("`R("`@("!M:6YI;6%L(&YU;6)E<B!O9B!LL
XM:6YE<R!F;W(@<F5P;W)T:6YG"G)E=FEN<R`H<FDI("`@("`@("`@=&]G9VQE?
XM("`@(&]F9B`@(&EN<V5R="!C:&%R86-T97)S(')I9VAT('1O(&QE9G0*<G5L9
XM97(@*')U*2`@("`@("`@("!T;V=G;&4@("`@;V9F("`@<VAO=R!C=7)S;W(@K
XM<&]S:71I;VX@:6X@<W1A='5S(&QI;F4*<V-R;VQL("`@("`@("`@("`@("!N_
XM=6UB97(@("`@,3(@("`@<V-R;VQL('-I>F4@9F]R($-44DPM52!A;F0@0U12"
XM3"U$"G-C<F]L;&IU;7`@*'-J*2`@("`@;G5M8F5R("`@(#$@("`@(&UI;FEMT
XM86P@;G5M8F5R(&]F(&QI;F5S(&9O<B!S8W)O;&QI;F<*<V5C=&EO;G,@*'-E,
XM8W0I("`@("!S=')I;F<@("`@(E-(3DA(($A5;FAS:"(@("`@("!M86-R;W,@'
XM<V5P87)A=&EN9R!S96-T:6]N<PIS96-U<F4@("`@("`@("`@("`@('1O9V=LD
XM92`@("!O9F8@("!S96-U<FET>2!C:&5C:W,@9F]R("YV:6UR8R!A;F0@+F5X=
XM<F,*<VAE;&P@*'-H*2`@("`@("`@("!S=')I;F<@("`@(G-H(B`@<VAE;&P@Q
XM=&\@=7-E(&9O<B`A(&%N9"`Z(2!C;VUM86YD<PIS:&5L;'1Y<&4@*'-T*2`@T
XM("`@(&YU;6)E<B`@("`P("`@("!H;W<@=&\@=7-E('1H92!S:&5L;`IS:&EFD
XM=')O=6YD("AS<BD@("`@('1O9V=L92`@("!O9F8@("!R;W5N9"!I;F1E;G0@9
XM=&\@<VAI9G1W:61T:"!W:71H(#X@86YD(#P*<VAI9G1W:61T:"`H<W<I("`@M
XM("!N=6UB97(@("`@."`@("`@;G5M8F5R(&]F('-P86-E<R!T;R!U<V4@9F]R5
XM("AA=71O*6EN9&5N=`IS:&]W8VUD("AS8RD@("`@("`@('1O9V=L92`@("!OC
XM;B`@("!S:&]W(&-O;6UA;F0@:6X@<W1A='5S(&QI;F4*<VAO=VUA=&-H("AS$
XM;2D@("`@("!T;V=G;&4@("`@;V9F("`@<VAO=R!M871C:&EN9R!B<F%C:V5T;
XM(&EF(&]N92!I<R!I;G-E<G1E9"`*<VAO<G1N86UE("AS;BD@("`@("!T;V=G)
XM;&4@("`@;V9F("`@35-$3U,M;&EK92!F:6QE<WES=&5M(&)E:6YG('5S960*I
XM<VAO=VUO9&4@*'-M9"D@("`@("!T;V=G;&4@("`@;VX@("`@<VAO=R!I;G-E*
XM<G0O<F5P;&%C92!M;V1E(&UE<W-A9V4*<VED97-C<F]L;"`H<W,I("`@("!N>
XM=6UB97(@("`@,"`@("`@;6EN:6UA;"!N<B!O9B!C;VQU;6YS(&9O<B!H;W)IA
XM>BX@<V-R;VQL"G-M87)T:6YD96YT("AS:2D@("`@=&]G9VQE("`@(&]F9B`@4
XM(&1O('-M87)T(&%U=&]I;F1E;G1I;F<*<W5F9FEX97,@*'-U*2`@("`@("!SV
XM=')I;F<@("`@(BYB86LN;RYH+FEN9F\N=FEM(B!S=69F:7AE<R!T:&%T(&%R<
XM92!I9VYO<F5D"B`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@7
XM('=H96X@;75L=&EP;&4@9FEL97,@;6%T8V@@82!W:6QD8V%R9`H,`F]P=&EOL
XM;B`H<VAO<G1H86YD*04@("`"='EP904@(`)D969A=6QT!2`@("`@("`@`F5F1
XM9F5C=`4*=&%B<W1O<"`H=',I("`@("`@("!N=6UB97(@("`@."`@("`@;G5MW
XM8F5R(&]F('-P86-E<R!T:&%T(&$@5$%"(&-O=6YT<R!F;W(*=&%G;&5N9W1H!
XM("AT;"D@("`@("!N=6UB97(@("`@,"`@("`@:68@;F]N+7IE<F\L('1A9W,@L
XM87)E('-I9VYI9FEC86YT('5P=&\*("`@("`@("`@("`@("`@("`@("`@("`@9
XM("`@("`@("`@("`@("`@('1H:7,@;G5M8F5R(&]F(&-H87)A8W1E<G,*=&%G<
XM<R`@("`@("`@("`@("`@("!S=')I;F<@("`@(G1A9W,B("`@;F%M97,@;V8@&
XM=&%G(&9I;&5S"G1E<FT@("`@("`@("`@("`@("`@<W1R:6YG("`@(")A;6EG(
XM82(@("!N86UE(&]F('1E<FUI;F%L"G1E>'1A=71O("AT82D@("`@("`@=&]GM
XM9VQE("`@(&]N("`@(&1E=&5C="!L:6YE('-E<&%R871O<BP@*')E*7-E="`G.
XM=&5X=&UO9&4G"G1E>'1M;V1E("AT>"D@("`@("`@=&]G9VQE("`@(&]F9B`@_
XM('5S92`\0U(^/$Q&/B!F;W(@;&EN92!S97!A<F%T;W(*=&5X='=I9'1H("ATS
XM=RD@("`@("!N=6UB97(@("`@,"`@("`@;6%X:6UU;2!W:61T:"!O9B!A(&QIB
XM;F4@:6X@:6YS97)T(&UO9&4*=&EL9&5O<"`H=&\I("`@("`@("!T;V=G;&4@U
XM("`@;V9F("`@=&EL9&4@8F5H879E<R!L:6ME(&%N(&]P97)A=&]R"G1I;65OS
XM=70@("`@("`@("`@("`@=&]G9VQE("`@(&]N("`@('=A:70@;VYL>2`G=&TG.
XM(&US96,@9F]R(&UA<'!I;F=S)FME>2!C;V1E<R`*='1I;65O=70@("`@("`@0
XM("`@("!T;V=G;&4@("`@;V9F("`@=V%I="!O;FQY("=T;2<@;7-E8R!F;W(@R
XM:V5Y(&-O9&5S(`IT:6UE;W5T;&5N("AT;2D@("`@(&YU;6)E<B`@("`Q,#`PC
XM("!M:6QL:7-E8V]N9',@=&\@=V%I="!F;W(@;6%P<&EN9W,F:V5Y(&-O9&5SA
XM"G5N9&]L979E;',@*'5L*2`@("`@;G5M8F5R("`@(#$P,"`@(&YU;6)E<B!O/
XM9B!C:&%N9V5S('1H870@8V%N(&)E('5N9&]N90H@("`@("`@("`@("`@("`@<
XM("`@("`@("`@("`@("`@("`@("`@("`@*#`@9F]R(%9I(&-O;7!A=&EB:6QI+
XM='DI"G9I<W5A;&)E;&P@*'9B*2`@("`@=&]G9VQE("`@(&]F9B`@('5S92!V\
XM:7-U86P@:6YS=&5A9"!O9B!A=61I8FQE(&)E97`*=VEL9&-H87(@*'=C*2`@P
XM("`@("!N=6UB97(@("`@5$%"("`@8VAA<B!U<V5D('1O('-T87)T(&9I;&5N.
XM86UE(&-O;7!L971I;VX*=W)A<"`@("`@("`@("`@("`@("!T;V=G;&4@("`@3
XM;VX@("`@=VAE;B!O9F8Z(&AO<FEZ;VYT86P@<V-R;VQL:6YG"G=R87!M87)GF
XM:6X@*'=M*2`@("`@;G5M8F5R("`@(#`@("`@('-E="!T97AT=VED=&@@=&\@9
XM*&-O;'5M;G,@+2!W<F%P;6%R9VEN*0IW<F%P<V-A;B`H=W,I("`@("`@('1O^
XM9V=L92`@("!O;B`@("!S96%R8VAE<R!W<F%P(&%R;W5N9"!T:&4@96YD(&]FZ
XM('1H92!F:6QE"G=R:71E86YY("AW82D@("`@("`@=&]G9VQE("`@(&]F9B`@$
XM(&%L=V%Y<R!W<FET92!F:6QE('=I=&AO=70@87-K:6YG"G=R:71E8F%C:W5PX
XM("AW8BD@("`@=&]G9VQE("`@(&]N("`@(&)A8VMU<"!A(&9I;&4@5TA)3$4@9
XM;W9E<G=R:71I;F<@:70*>6%N:V5N9&]F;&EN92`H>64I("!T;V=G;&4@("`@_
XM;V9F("`@)UDG('EA;FMS(&9R;VT@8W5R<V]R('1O(&5N9"!O9B!L:6YE"@P")
XM56YD;R]2961O(&-O;6UA;F1S!0I.("!U("`@("`@("`@("`@=6YD;R!.(&QAD
XM<W0@8VAA;F=E<PI.("!#5%),+5(@("`@("`@<F5D;R!.(&QA<W0@=6YD;VYEA
XM(&-H86YG97,*("`@52`@("`@("`@("`@(')E<W1O<F4@;&%S="!C:&%N9V5DZ
XM(&QI;F4*`D5X=&5R;F%L(&-O;6UA;F1S!0HZ<V@@("`@("`@("`@("`@<W1A5
XM<G0@82!S:&5L;`HZ(7MC;VUM86YD?2`@("`@97AE8W5T92![8V]M;6%N9'T@%
XM=VET:"!A('-H96QL"B`@($L@("`@("`@("`@("!L;V]K=7`@:V5Y=V]R9"!U^
XM;F1E<B!T:&4@8W5R<V]R('=I=&@@97AT97)N86P@<')O9W)A;0H"475I8VMFN
XM:7@@8V]M;6%N9',%"CIC8R!;;G)=("`@("`@("!D:7-P;&%Y(&5R<F]R(%MN#
XM<ET@*&1E9F%U;'0@:7,@=&AE('-A;64@86=A:6XI"CIC;B`@("`@("`@("`@=
XM("!D:7-P;&%Y('1H92!N97AT(&5R<F]R"CIC<"`@("`@("`@("`@("!D:7-PG
XM;&%Y('1H92!P<F5V:6]U<R!E<G)O<@HZ8VP@("`@("`@("`@("`@;&ES="!A^
XM;&P@97)R;W)S"CIC9B`@("`@("`@("`@("!R96%D(&5R<F]R<R!F<F]M('1HK
XM92!E<G)O<B!F:6QE"CIC<2`@("`@("`@("`@("!Q=6ET('=I=&AO=70@=W)I0
XM=&EN9R!A;F0@<F5T=7)N(&5R<F]R(&-O9&4@*'1O('1H92!C;VUP:6QE<BD*$
XM.FUA:V4@6V%R9W-=("`@('-T87)T(&UA:V4L(')E860@97)R;W)S(&%N9"!J+
XM=6UP('1O(&9I<G-T(&5R<F]R"@)687)I;W5S(&-O;6UA;F1S!0H@("!#5%),R
XM+4P@("`@("`@0VQE87(@86YD(')E9')A=R!T:&4@<V-R965N+@H@("!#5%),&
XM+4<@("`@("`@<VAO=R!C=7)R96YT(&9I;&4@;F%M92`H=VET:"!P871H*2!AT
XM;F0@8W5R<V]R('!O<VET:6]N"B`@($-44DPM0R`@("`@("!D=7)I;F<@<V5AV
XM<F-H97,Z(&EN=&5R<G5P="!T:&4@<V5A<F-H"B`@(#Q$14P^("`@("`@("!W#
XM:&EL92!E;G1E<FEN9R!A(&-O=6YT.B!D96QE=&4@;&%S="!C:&%R86-T97(*@
XM.G9E<G,@("`@("`@("`@('-H;W<@97AA8W0@=F5R<VEO;B!N=6UB97(@;V8@T
XM=&AI<R!624T*#`)#;VUM86YD(&QI;F4@961I=&EN9P4*0U123"U6("`@("`@N
XM("`@("`@(&EN<V5R="!C:&%R86-T97(@;&ET97)A;&QY+"!O<B!E;G1E<B!DC
XM96-I;6%L(&)Y=&4@=F%L=64*/$-?3$5&5#XO/$-?4DE'2%0^("`@(&-U<G-O"
XM<B!L969T+W)I9VAT"CQ30U],1494/B\\4T-?4DE'2%0^("!C=7)S;W(@;VYE*
XM('=O<F0@;&5F="]R:6=H=`I#5%),+4(O0U123"U%("`@("`@8W5R<V]R('1O9
XM(&)E9VEN+V5N9"!O9B!C;VUM86YD(&QI;F4*/$)3/B`@("`@("`@("`@("`@@
XM(&1E;&5T92!T:&4@8VAA<F%C=&5R(&EN(&9R;VYT(&]F('1H92!C=7)S;W(*?
XM/$1%3#X@("`@("`@("`@("`@(&1E;&5T92!T:&4@8VAA<F%C=&5R('5N9&5RN
XM('1H92!C=7)S;W(*0U123"U7("`@("`@("`@("`@(&1E;&5T92!T:&4@=V]R.
XM9"!I;B!F<F]N="!O9B!T:&4@8W5R<V]R"D-44DPM52`@("`@("`@("`@("!R+
XM96UO=F4@86QL(&-H87)A8W1E<G,*/$-?55`^+SQ#7T1/5TX^("`@(')E8V%L*
XM;"!O;&1E<B]N97=E<B!C;VUM86YD(&QI;F4@9G)O;2!H:7-T;W)Y"CQ30U]5/
XM4#XO/%-#7T1/5TX^("!R96-A;&P@;VQD97(O;F5W97(@8V]M;6%N9"!T:&%TM
XM('-T87)T<R!W:71H(&-U<G)E;G0@8V]M;6%N9`I#5%),+40@("`@("`@("`@O
XM("`@;&ES="!F:6QE;F%M97,@=&AA="!M871C:"!T:&4@<&%T=&5R;B!I;B!FJ
XM<F]N="!O9B!T:&4@8W5R<V]R"D-44DPM02`@("`@("`@("`@("!I;G-E<G0@9
XM86QL(&9I;&5N86UE<R!T:&%T(&UA=&-H('!A='1E<FX@:6X@9G)O;G0@;V8@^
XM8W5R<V]R"D-44DPM3"`@("`@("`@("`@("!I;G-E<G0@;&]N9V5S="!C;VUMS
XM;VX@<&%R="!O9B!F:6QE;F%M97,@=&AA="!M871C:"!P871T97)N+BX*)W=I&
XM;&1C:&%R)R`@("`@("`@(&1O(&9I;&5N86UE(&-O;7!L971I;VX@;VX@=&AEA
XM('!A='1E<FX@:6X@9G)O;G0@;V8@=&AE(&-U<G-O<@I#5%),+4X@("`@("`@,
XM("`@("`@869T97(@)W=I;&1C:&%R)R!W:71H(&UU;'1I<&QE(&UA=&-H97,ZU
XM(&=O('1O(&YE>'0@;6%T8V@*0U123"U0("`@("`@("`@("`@(&%F=&5R("=WQ
XM:6QD8VAA<B<@=VET:"!M=6QT:7!L92!M871C:&5S.B!G;R!T;R!P<F5V:6]U(
XM<R!M871C:`H\15-#/B`@("`@("`@("`@("`@86)A;F1O;B!C;VUM86YD(&QI&
XM;F4@*&EF("=W:6QD8VAA<B<@:7,@/$530SX@='EP92!I="!T=VEC92D*#`)%X
XM>"!R86YG97,%"BP@("`@("`@("`@("`@("!S97!A<F%T97,@='=O(&QI;F4@=
XM;G5M8F5R<PH[("`@("`@("`@("`@("`@:61E;2P@<V5T(&-U<G-O<B!T;R!TM
XM:&4@9FER<W0@;&EN92!N=6UB97(*"GMN=6UB97)]("`@("`@("!A;B!A8G-OO
XM;'5T92!L:6YE(&YU;6)E<@HN("`@("`@("`@("`@("`@=&AE(&-U<G)E;G0@'
XM;&EN90HD("`@("`@("`@("`@("`@=&AE(&QA<W0@;&EN92!I;B!T:&4@9FEL&
XM90HE("`@("`@("`@("`@("`@97%U86P@=&\@,2PD("AT:&4@96YT:7)E(&9I/
XM;&4I"B=T("`@("`@("`@("`@("!P;W-I=&EO;B!O9B!M87)K('0*+WMP871T5
XM97)N?2`@("`@('1H92!N97AT(&QI;F4@=VAE<F4@>W!A='1E<FY](&UA=&-HH
XM97,*/WMP871T97)N?2`@("`@('1H92!P<F5V:6]U<R!L:6YE('=H97)E('MP#
XM871T97)N?2!M871C:&5S"@HK6VYU;5T@("`@("`@("`@861D(%MN=6U=('1OK
XM('1H92!P<F5C961I;F<@;&EN92!N=6UB97(@*&1E9F%U;'0@,2D*+5MN=6U=)
XM("`@("`@("`@('-U8G1R86-T(%MN=6U=(&9R;VT@=&AE('!R96-E9&EN9R!LB
XM:6YE(&YU;6)E<B`H9&5F875L="`Q*0H*`E-P96-I86P@17@@8VAA<F%C=&5R-
XM<P4*("`@('P@("`@("`@("`@('-E<&%R871E<R!T=V\@8V]M;6%N9',@*&YOW
XM="!F;W(@(CIG;&]B86PB(&%N9"`B.B$B*0H@("`@(B`@("`@("`@("`@8F5G?
XM:6YS(&-O;6UE;G0*("`@(",@("`@("`@("`@(&EN(&9I<G-T(&-O;'5M;CH@1
XM8F5G:6YS(&-O;6UE;G0*("`@("-;;G5M8F5R72`@(&%L=&5R;F%T92!F:6QE9
XM;F%M92!;;G5M8F5R72`H;VYL>2!W:&5R92!F:6QE;F%M92!I<R!E>'!E8W1ER
XM9"D*("`@("4@("`@("`@("`@(&-U<G)E;G0@9FEL96YA;64@*&]N;'D@=VAEN
XM<F4@9FEL96YA;64@:7,@97AP96-T960I"B`@("`C+B`@("`@("`@("!I9&5M)
XM+"!B=70@=VET:&]U="!E>'1E;G-I;VX*#`)%9&ET:6YG(&$@9FEL904*.F4@S
XM("`@("`@("`@("`@("`@("`@("`@161I="!T:&4@8W5R<F5N="!F:6QE+"!UK
XM;FQE<W,@8VAA;F=E<R!H879E(&)E96X@;6%D92X*.F4A("`@("`@("`@("`@+
XM("`@("`@("`@161I="!T:&4@8W5R<F5N="!F:6QE(&%L=V%Y<RX@1&ES8V%R_
XM9"!A;GD@8VAA;F=E<RX*.F5;9&ET72![9FEL97T@("`@("`@("`@161I="![N
XM9FEL97TL('5N;&5S<R!C:&%N9V5S(&AA=F4@8F5E;B!M861E+@HZ95MD:71=!
XM(2![9FEL97T@("`@("`@("!%9&ET('MF:6QE?2!A;'=A>7,N($1I<V-A<F0@0
XM86YY(&-H86YG97,N"DX@("!#5%),+5X@("`@("`@("`@("`@($5D:70@86QT.
XM97)N871E(&9I;&4@3B`H97%U:79A;&5N="!T;R`B.F4@(TXB*2X*.G!W9"`@P
XM("`@("`@("`@("`@("`@("`@4')I;G0@=&AE(&-U<G)E;G0@9&ER96-T;W)Y&
XM(&YA;64N"CIC9"!;<&%T:%T@("`@("`@("`@("`@($-H86YG92!T:&4@8W5R0
XM<F5N="!D:7)E8W1O<GD@=&\@6W!A=&A=+@HZ9EMI;&5=("`@("`@("`@("`@`
XM("`@("!0<FEN="!T:&4@8W5R<F5N="!F:6QE;F%M92!A;F0@=&AE(&-U<G-O2
XM<B!P;W-I=&EO;BX*.F9;:6QE72![;F%M97T@("`@("`@("`@4V5T('1H92!C:
XM=7)R96YT(&9I;&5N86UE('1O('MN86UE?2X*.F9I;&5S("`@("`@("`@("`@"
XM("`@("`@4VAO=R!A;'1E<FYA=&4@9FEL92!N86UE<PH*`E5S:6YG('1H92!FX
XM:6QE(&QI<W0%"CIA<EMG<UT@("`@("`@("`@("`@("`@(%!R:6YT('1H92!F8
XM:6QE(&QI<W0L('=I=&@@=&AE(&-U<G)E;G0@9FEL92!I;B`B6UTB+@HZ;EME5
XM>'1=("`@("`@("`@("`@("`@("!%9&ET(&YE>'0@9FEL92P@=6YL97-S(&-H?
XM86YG97,@:&%V92!B965N(&UA9&4N"CIN6V5X=%TA("`@("`@("`@("`@("`@M
XM($5D:70@;F5X="!F:6QE+"!D:7-C87)D(&%N>2!C:&%N9V5S('1O('1H92!BR
XM=69F97(N"CIN6V5X=%U;(5T@>V9I;&5L:7-T?2`@($1E9FEN92![9FEL96QI)
XM<W1](&%S('1H92!N97<@;&ES="!O9B!F:6QE<R!A;F0@961I=`H@("`@("`@J
XM("`@("`@("`@("`@("`@("!T:&4@9FER<W0@;VYE("AS964@.FYE>'0@9F]R0
XM(%LA72DN"CI.6V5X=%U;(5T@("`@("`@("`@("`@($5D:70@<')E=FEO=7,@'
XM9FEL92`H<V5E(#IN97AT(&9O<B!;(5TI+@HZ<F5W6VEN9%U;(5T@("`@("`@S
XM("`@("!%9&ET(&9I<G-T(&9I;&4@*'-E92`Z;F5X="!F;W(@6R%=*2X*.G=NL
XM6V5X=%U;(5T@("`@("`@("`@("`@5W)I=&4@9FEL92!A;F0@961I="!N97AT%
XM(&9I;&4N(`HZ=VY;97AT75LA72![9FEL97T@("`@("!7<FET92!T;R![9FELU
XM97T@86YD(&5D:70@;F5X="!F:6QE+"!U;FQE<W,@>V9I;&5]"B`@("`@("`@"
XM("`@("`@("`@("`@("`@(&5X:7-T<RX@5VET:"`A(&]V97)W<FET92!E>&ESK
XM=&EN9R!F:6QE<RX*#`)7<FET:6YG(&%N9"!Q=6ET=&EN9P4*.EMR86YG95UW\
XM6W)I=&5=6R%=("`@("`@5W)I=&4@=&\@=&AE(&-U<G)E;G0@9FEL92X*.EMR6
XM86YG95UW6W)I=&5=('MF:6QE?2`@5W)I=&4@=&\@>V9I;&5]+"!U;FQE<W,@?
XM:70@86QR96%D>2!E>&ES=',N"CI;<F%N9V5==UMR:71E72$@>V9I;&5](%=R[
XM:71E('1O('MF:6QE?2X@3W9E<G=R:71E(&%N(&5X:7-T:6YG(&9I;&4N"CI;9
XM<F%N9V5==UMR:71E75LA72`^/B`@($%P<&5N9"!T;R!T:&4@8W5R<F5N="!F'
XM:6QE+@HZ6W)A;F=E77=;<FET95U;(5T@/CX@>V9I;&5]"B`@("`@("`@("`@K
XM("`@("`@("`@("`@($%P<&5N9"!T;R![9FEL97TN"CI;<F%N9V5==UMR:71EP
XM72`A>V-M9'T@($5X96-U=&4@>V-M9'T@=VET:"!;<F%N9V5=(&QI;F5S(&%S9
XM('-T86YD87)D(&EN<'5T+@H*.G%;=6ET72`@("`@("`@("`@("`@("`@475I'
XM="P@=6YL97-S(&-H86YG97,@:&%V92!B965N(&UA9&4N"CIQ6W5I=%TA("`@V
XM("`@("`@("`@("`@(%%U:70@86QW87ES+"!D:7-C87)D(&%N>2!C:&%N9V5S[
XM+@HZ8W$@("`@("`@("`@("`@("`@("`@("!1=6ET('=I=&AO=70@=W)I=&ENZ
XM9R!A;F0@<F5T=7)N(&5R<F]R(&-O9&4*.G=Q6R%=("`@("`@("`@("`@("`@D
XM("`@5W)I=&4@=&AE(&-U<G)E;G0@9FEL92!A;F0@97AI="X*.G=Q6R%=('MF0
XM:6QE?2`@("`@("`@("`@5W)I=&4@=&\@>V9I;&5](&%N9"!E>&ET+@HZ>%MIX
XM=%U;(5T@6V9I;&5=("`@("`@("!,:6ME("(Z=W$B(&)U="!W<FET92!O;FQY%
XM('=H96X@8VAA;F=E<R!H879E(&)E96X@;6%D90H@("!:6B`@("`@("`@("`@^
XM("`@("`@("!386UE(&%S("(Z>"(N"@HZ<W1;;W!=6R%=("`@("`@("`@("`@C
XM("!S=7-P96YD(%9)32!O<B!S=&%R="!N97<@<VAE;&PN($EF("=A=R<@;W!TU
XM:6]N(&ES('-E="`*("`@("`@("`@("`@("`@("`@("`@("`@86YD(%LA72!N2
XM;W0@9VEV96X@=W)I=&4@=&AE(&)U9F9E<BX*0U123"U:("`@("`@("`@("`@6
XM("`@("`@<V%M92!A<R`B.G-T;W`A(@H,`E-T87)T:6YG(%9)304*=FEM(%MO4
XM<'1I;VYS72`@("`@("`@("`@<W1A<G0@961I=&EN9R!W:71H(&%N(&5M<'1YF
XM(&)U9F9E<@IV:6T@6V]P=&EO;G-=('MF:6QE("XN?2!S=&%R="!E9&ET:6YG:
XM(&]N92!O<B!M;W)E(&9I;&5S"G9I;2!;;W!T:6]N<UT@*UMN=6U=('MF:6QEQ
XM("XN?0H@("`@("`@("`@("`@("`@("`@("`@("!I9&5M+"!P=70@=&AE(&-U@
XM<G-O<B!A="!L:6YE(%MN=6U=("AD969A=6QT(&QA<W0@;&EN92D*=FEM(%MO=
XM<'1I;VYS72`K+WMP871]('MF:6QE("XN?0H@("`@("`@("`@("`@("`@("`@/
XM("`@("!I9&5M+"!P=70@=&AE(&-U<G-O<B!A="!T:&4@9FER<W0@;V-C=7)R/
XM96YC92!O9B![<&%T?0IV:6T@6V]P=&EO;G-=("UT('MT86=]("!E9&ET('1H>
XM92!F:6QE(&%S<V]C:6%T960@=VET:"![=&%G?0IV:6T@6V]P=&EO;G-=("UE!
XM(%MF;F%M95T@<W1A<G0@961I=&EN9R!I;B!1=6EC:T9I>"!M;V1E+"!D:7-PM
XM;&%Y('1H92!F:7)S="!E<G)O<@H";W!T:6]N<P4*+78@("`@("`@("`@("`@C
XM("`@("`@("`@<F5A9"UO;FQY(&UO9&4@*%9I97<I+"!I;7!L:65S("UN"BUB/
XM("`@("`@("`@("`@("`@("`@("`@(&)I;F%R>2!M;V1E"BUR("`@("`@("`@3
XM("`@("`@("`@("`@(')E8V]V97(@86)O<G1E9"!E9&ET+"!U<VEN9R!C;VUM;
XM86YD<R!F<F]M("(N=FEM(B!F:6QE"BUN("`@("`@("`@("`@("`@("`@("`@=
XM(&1O(&YO="!C<F5A=&4@(BYV:6TB(&9I;&4*+7@@("`@("`@("`@("`@("`@%
XM("`@("`@9&\@;F]T(')E<W1A<G0@5DE-('1O(&]P96X@82!W:6YD;W<@*&9O@
XM<B!E+F<N(&UA:6PI"BUS('MS8W)I<'1I;GT@("`@("`@("`@(&9I<G-T(')E3
XM860@=&AE(&-O;6UA;F1S(&EN('1H92!F:6QE('MS8W)I<'1I;GT*+7<@>W-C3
XM<FEP=&]U='T@("`@("`@("`@=W)I=&4@86QL('1Y<&5D(&-H87)A8W1E<G,@^
XM=&\@=&AE(&9I;&4@>W-C<FEP=&]U='T*+50@>W1E<FUI;F%L?2`@("`@("`@(
XM("`@<V5T('1E<FUI;F%L('1Y<&4*+60@>V1E=FEC97T@("`@("`@("`@("`@-
XM;W!E;B![9&5V:6-E?2!T;R!B92!U<V5D(&%S(&$@8V]N<V]L90H*`F%U=&]MY
XM871I8R!O<'1I;VX@<V5T=&EN9R!W:&5N(&5D:71I;F<@82!F:6QE!0IV:6TZD
XM>W-E="UA<F=].B`N+B`@("`@("!);B!T:&4@9FER<W0@86YD(&QA<W0@;&ENK
XM97,@;V8@=&AE(&9I;&4@*'-E92`G;6PG"B`@("`@("`@("`@("`@("`@("`@$
XM("`@(&]P=&EO;BDL('MS970M87)G?2!I<R!G:79E;B!A<R!A;B!A<F=U;65N@
X*="!T;R`Z<V5T"BDL\
X``
Xend
Xsize 26335
END_OF_FILE
if test 36911 -ne `wc -c <'vim/doc/vim_hlp.uue'`; then
echo shar: \"'vim/doc/vim_hlp.uue'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/vim_hlp.uue'
# end of 'vim/doc/vim_hlp.uue'
fi
echo shar: End of archive 18 \(of 25\).
cp /dev/null ark18isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:28:17 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 71
Archive-name: vim/part21

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/reference.do3


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:08 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/reference.do3' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/reference.do3'\"
else
echo shar: Extracting \"'vim/doc/reference.do3'\" \(44166 characters\)
sed "s/^X//" >'vim/doc/reference.do3' <<'END_OF_FILE'
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 to lose
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} one or more <TAB> or space characters
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 abandoning 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 up to 20 entries),
Xthe oldest entry is deleted and the older entries shift one position up
X(their index number is decremented by one). If the last used entry was not
Xat the bottom, the entries below the last used one are moved to the top.
XThis means that an old branch in the call graph is not lost, but moved to
Xanother place on 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
XThe following commands can be used to insert new text into the buffer. They
Xcan all be undone. The non-Ex commands can be repeated with the "." command.
X
Xa Append text after the cursor [count] times.
X
XA Append text at the end of the line [count] times.
X
Xi Insert text before the cursor [count] times.
X
XI Insert text before the first CHAR on the line
X [count] times.
X
Xo Begin a new line below the cursor and insert text,
X repeat [count] times. {Vi: blank [count] screen
X lines}
X
XO Begin a new line above the cursor and insert text,
X repeat [count] times. {Vi: blank [count] screen
X 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[count] 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
XThe <LF> character is recognized as end-of-line marker. If the 'textmode'
Xoption is set, a <CR> in front of an <LF> is ignored. The 'textmode' option
Xis default on for MSDOS.
X
XIf the 'textauto' option is set Vim tries to recognize the type of
Xend-of-line marker (see 5.2 how this is done). However, the 'textmode'
Xoption will not be changed. Only while reading one file the text mode is
Xused or not.
X
XOn non-MSDOS systems the message "[textmode]" is shown if a file is read in
Xtext mode, to remind you that something unusual is done. On MSDOS the
Xmessage "[notextmode]" is shown if a file is read without text mode.
X
X
X 10. Deleting text
X
X["x]x Delete [count] characters under and after the cursor
X [into register x] (not linewise).
X
X["x]X Delete [count] 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 See below for exception.
X
X["x]dd Delete [count] lines [into register x] (linewise).
X
X["x]D Delete the characters under the cursor until the end
X of the line and [count]-1 more lines [into register
X x]; synonym for d$ (not linewise).
X
X{visual}["x]x or
X{visual}["x]d Delete the highlighted text [into register x] (see
X the chapter on Visual mode). {not in Vi}
X
X{visual}["x]X or
X{visual}["x]D Delete the highlighted lines [into register x] (see
X the chapter on Visual mode). {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]
X (default: current line, see 4.4.3) [into register
X x].
X
XThese commands delete text. They can be repeated with the "." command
X(except ":d") and undone. Use Visual mode to delete blocks of text. See
X"copying" for an explanation of registers.
X
XAn exception for the d{motion} command: If the motion is not linewise, the
Xstart and end of the motion are not in the same line and before the start
Xand after the end are only blanks, the delete becomes linewise. This means
Xthat the blank line that would remain is also deleted.
X
X
XJ Join [count] lines, with a minimum of two lines.
X
X{visual}J Join the highlighted lines, with a minimum of two
X lines. {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 <LF>, unless the line ended with a
Xspace, <TAB> or the next line started with a <)>. If the next line has
Xleading white 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 [count]-1
X times.
X
X["x]c{motion} Delete {motion} text [into register x] and start
X insert.
X
X["x]cc Delete [count] lines [into register x] and start
X insert (linewise).
X
X["x]C Delete from the cursor position to the end of the
X line and [count]-1 more lines [into register x], and
X start insert. Synonym for c$ (not linewise).
X
X["x]s Delete [count] characters [into register x] and start
X insert (s stands for Substitute). Synonym for "cl"
X (not linewise).
X
X["x]S Delete [count] lines [into register x] and start
X insert. Synonym for "^cc" with 'autoindent' option
X or "0cc" with 'noautoindent' option (not linewise).
X
X{visual}["x]c or
X{visual}["x]r or
X{visual}["x]s Delete the highlighted text [into register x] and
X start insert (see the chapter on Visual mode). {not
X in Vi}
X
X{visual}["x]C or
X{visual}["x]R or
X{visual}["x]S Delete the highlighted lines [into register x] and
X start insert (see the chapter on Visual mode). {not
X 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[count] 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 and moving text" 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 restores the original text (if there was any) (see section
X"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 white 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 the character under the cursor by <char>. If
X <char> is a <CR> or <LF> the character will be
X replaced by a line break. If a [count] is given that
X many characters will be replaced by [count] <char>s
X or line breaks {Vi: "5r<CR>" replaces five
X characters with a single line break}
X
X~ 'notildeop' option: switch case of the character
X under the cursor and move the cursor to the right.
X If a [count] is given do that many characters {Vi:
X no count}
X
X~{motion} 'tildeop' option: switch case of {motion} text. {Vi:
X tilde cannot be used as an operator}
X
X{visual}~ switch case of highlighted text (see the chapter on
X Visual mode). {not in Vi}
X
X{visual}U Make highlighted text uppercase (see the chapter on
X Visual mode). {not in Vi}
X
X{visual}u Make highlighted text lowercase (see the chapter on
X Visual mode). {not in Vi}
X
XCTRL-A Add [count] to the number at or after the cursor.
X {not in Vi}
X
XCTRL-S Subtract [count] from the number at or after the
X cursor. If your terminal has problems with CTRL-S
X read unix.doc. {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. Create the first entry. The entry should start with a number.
X2. qa - start recording into buffer <a>
X3. Y - yank the entry
X4. p - put a copy of the entry below the first one
X5. CTRL-A - increment the number
X6. q - stop recording
X7. <count>@a - repeat the yank, put and increment <count> times
X
X
X<{motion} Shift the {motion} lines one shiftwidth leftwards.
X
X<< Shift [count] lines one shiftwidth leftwards.
X
X{visual}< Shift the highlighted lines one shiftwidth leftwards
X (see the chapter on Visual mode). {not in Vi}
X
X>{motion} Shift {motion} lines one shiftwidth rightwards.
X
X>> Shift [count] lines one shiftwidth rightwards.
X
X{visual}> Shift the highlighted lines one shiftwidth
X rightwards (see the chapter on Visual mode). {not in
X 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]le[ft] [indent] left align lines in [range]. Sets the indent in the

X lines to [indent] (default 0). {not in Vi}
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 white 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.
X
XIf the 'shiftround' option is set, the indent is rounded to a multiple of
X'shiftwidth'.
X
XWhen the 'expandtab' option if off (this is the default) <TAB>s are used as
Xmuch as possible to make the indent. You can use ">><<" to replace an indent
Xmade out of spaces with the same indent made out of <TAB>s (and a few
Xspaces if neccessary). If the 'expandtab' option is on, only spaces are
Xused. Then you can use ">><<" to replace <TAB>s in the indent by spaces.
X
XQ{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 the 'textwidth' option is
X 0, all lines will be joined together. If the
X 'autoindent' option is set, the indent of the first
X line is used for the following lines. The
X 'formatprg' option can be set to the name of an
X external program, which will be used instead of the
X internal function. The 'textwidth' option will then
X not be used. {not in Vi}
X
X:[range]ce[nter] [width]
X Center lines in [range] between [width] columns
X (default 'textwidth' or 80 when 'textwidth' is 0).


X {not in Vi}
X

X:[range]ri[ght] [width]
X right align lines in [range] at [width] columns
X (default 'textwidth' or 80 when 'textwidth' is 0).


X {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 [count] lines through the external program
X {filter}.
X
X{visual}!{filter} Filter the highlighted lines through the external
X program {filter} (see the chapter on Visual mode).


X {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 [count] lines through the external program
X given with the 'equalprg' option (default: indent).


X {not in Vi}
X

X{visual}= Filter the highlighted lines through the external
X program given with the 'equalprg' option (default:
X indent) (see the chapter on Visual mode). {not in
X 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, <n> to skip). With
X [count] that many lines are are searched, starting
X with the last line number in [range] (default
X 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 <CR> split line in two at this point
X CTRL-V <CR> insert a carriage-return (CTRL-M)
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:s/abcde/abc^Mde/ modifies "abcde" in "abc", "de" (two lines)
X:s/$/^V^M/ modifies "abcde" in "abcde^M"
X
XNote: To insert a ^M you have to type CTRL-V <CR>. To insert a ^V you have
Xto type CTRL-V CTRL-V. So to insert the ^V^M in the last example you have to
Xtype CTRL-V CTRL-V CTRL-V <CR>.
X
XBecause CTRL-V <CR> inserts a <CR>, it is impossible to insert a CTRL-V just
Xin front of a line break. You will have to split it up in two parts:
X :s/foo/^Vxxxx/
X :s/xxxx/^M/
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
X put (use uppercase character to append with delete
X and yank) (<.> 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 [count] lines [into register x] (linewise).
X
X["x]Y With 'noyankendofline' option: yank [count] 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{visual}["x]y Yank the highlighed text [into register x] (see the
X chapter on Visual mode). {not in Vi}
X
X{visual}["x]Y Yank the highlighted lines [into register x] (see the
X chapter on Visual mode). {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
X[count]
X times. {Vi: no count}
X
X["x]P Put the text [from register x] before the cursor
X [count] 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 with "." (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 ("p") or above ("P") the line where the cursor
Xis. Otherwise the text will be inserted after ("p") or before ("P") the
Xcursor. With the ":put" command the text will always be inserted in the next
Xline. You can exchange two characters with the command sequence "xp". You
Xcan exchange two lines with the command sequence "ddp". You can exchange
Xtwo words with the command sequence "deep" (start with the cursor in the
Xblank space before the first word). The "']" or "`]" command can be used
Xafter the put command to move the cursor to the end of the inserted text,
X"'[" or "`[" to move the cursor to the start.
X
XIf the command that was used to get the text into the register used
Xblockwise Visual mode, the block of text will be inserted before ("P") or
Xafter ("p") the cursor column, in the current and next lines. Vim will make
Xthe whole block of text start in the same column. Thus the inserted text
Xlooks the same as when it was yanked or deleted. Some <TAB> characters may
Xbe replaced by spaces to make this happen. However, if the width of the
Xblock is not a multiple of a <TAB> width and the text after the inserted
Xblock contains <TAB>s, that text may be misaligned.
X
XThere are four types of registers: The unnamed regster, 10 numbered
Xregisters, 26 named registers and two read-only registers.
X The unnamed register is the register where all text deleted with
Xthe "d", "c", "s", "x" commands or copied with the yank "y" command is
Xplaced, regardless of whether or not a specific register was used (e.g.
X"xdd). The contents of this register are used by any put command (p or P)
Xwhich does not specify a register. Additionally it can be accessed by the
Xname <">. This means you have to type two double quotes. {Vi: register
Xcontents lost when changing files, no <">}
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 or the text is less than one line (text deleted with
X"x" or "dw" will not be put in a numbered register). The contents of
Xregister <1> are put in <2>, <2> in <3>, and so forth. The contents of
Xregister <9> are lost. {Vi: numbered register contents are lost when
Xchanging 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 are lost.
X The read-only registers are <%> and <.>. They can only be used with the
Xcommands "p", "P" and ":put". <.> contains the last inserted text (the same
Xas what is inserted with the insert mode commands CTRL-A and CTRL-@). <%>
Xcontains the name of the current file.
X
XIf you use a put command without specifying a register, the register that
Xwas last written to is used (this is also the contents of the unnamed
Xregister). If you are confused, use the ":dis" command to find out what will
Xbe put (all named and numbered registers are displayed; the unnamed register
Xis labelled <">).
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. Visual mode
X
XVisual mode 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
Xv start/stop Visual mode per character. {not in Vi}
X
XV start/stop Visual mode linewise. {not in Vi}
X
XCTRL-V start/stop Visual mode blockwise. {not in Vi}
X
Xo go to Other end of highlighted text: The current
X cursor position becomes the start of the highlighted
X text and the cursor is moved to the Other end of the
X highlighted text. {not in Vi}
X
XTo apply an operator on a piece of text:
X 1. mark the start of the text with "v", "V" or CTRL-V
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 Visual mode up to and
X including the character under the cursor is highlighted.
X 3. hit an operator
X The highlighted characters will be operated upon.
X
XThe highlighted text includes the character under the cursor. On terminals
Xwhere it is possible to make the cursor invisible the cursor position is
Xalso highlighted. On terminals where this is not possible the cursor is
Xdisplayed normally.
X
XWith "v" the text before the start position 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-V (blockwise Visual mode) the highlighted text will be a rectangle
Xbetween start position and the cursor. However, some operators work on whole
Xlines anyway (see the list below). The change and substitute operators will
Xdelete the highlighted text and then start insertion at the top left
Xposition.
X
XWhen the "$" command is used with blockwise Visual mode, the right end of the
Xhighlighted text will be determined by the longest highlighted line. This
Xstops when a motion command is used that does not move straight up or down.
X
XIf "v", "V", CTRL-V or ESC is typed while in Visual mode, the highlighting
Xstops and no text is affected. If you hit CTRL-Z the highlighting stops and
Xthe editor is suspended 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 cause a beep and Visual mode continues.
X
XIf the "v", "V" or CTRL-V is preceded with a count, the previously
Xhighlighted area is used for a start. You can then move the end of the
Xhighlighted area and give an operator. The type of the old area is used
X(character, line or blockwise).
X- Linewise Visual mode: The number of lines is multiplied with the count.
X- Blockwise Visual mode: The number of lines and columns is multiplied with
X the count.
X- Normal Visual mode within one line: The number of characters is multipled
X with the count.
X- Normal Visual mode with several lines: The number of lines is multipled
X with the count, in the last line the same number of characters is used as
X in the last line in the previously highlighted area.
XThe start of the text is the Cursor position. If the "$" command was used as
Xone of the last commands to extend the highlighted text, the area will be
Xextended to the rightmost column of the longest line.
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 Q format lines to 'textwidth' length (1)
X
XAdditionally the following commands can be used:
X : start ex command for highlighted 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-V
X(*): in a future a blockwise shift will move the block only, not whole
X lines.
X
XIf you want to give a register name using the """ command, do this just before
Xtyping the operator character: "v{move around}"xd".
X
XWhen repeating a Visual mode operator, the operator will be applied to the
Xsame amount of text as the last time:
X- Linewise Visual mode: The same number of lines.
X- Blockwise Visual mode: The same number of lines and columns.
X- Normal Visual mode within one line: The same number of characters.
X- Normal Visual mode with several lines: The same number of lines, in the
X last 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 highlighted text, the repeating will
Xbe applied up to 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. Type an index
X character to go directly to a page. Type <SPACE> or
X CTRL-F (with MSDOS: page-down) to go one page
X forward. Type <b> or CTRL-B (with MSDOS: page-up) to
X go one page back. Type <a> to go back to the index.
X Type <CR> to get out of the help screen. {Vi: no
X 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:[range]l[ist] [count]
X Same as :print, but display unprintable characters
X with <^>.
X
X:[range]nu[mber] [count]
X Same as :print, but precede each line with its line
X number.
X
X:= Print the line number.
X
X:sh[ell] Escape to a shell (name from 'shell' option).
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 [count].
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
Xq<0-9a-zA-Z"> Record typed characters into register <0-9a-zA-Z">
X (uppercase to append). The 'q' that stops recording
X is also stored in the register. The 'q' command is
X disabled while executing a register. (Implementation
X note: This was done because the 'q' command can be
X the result of mapping). {Vi: no recording}
X
Xq Stops recording. {Vi: no recording}
X
X@<0-9a-z"> Execute the contents of register <0-9a-z"> [count]
X times. {Vi: only named registers}
X
X@@ Repeat the previous @<0-9a-z"> [count] times.
X
X:@<0-9a-z"> Execute the contents of register <0-9a-z"> as
X an Ex command. {Vi: only in some versions}
X
X:@@ Repeat the previous :@<0-9a-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 "q". 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 function 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. In the MSDOS version the values
Xare 48 (0x30) higher. Any of these codes can be entered with CTRL-V followed
Xby the three digit decimal code.
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 special-function key follows (MSDOS)
X 159 0x9f CTRL-@
X
X
X 16. Undo and redo
X
X<UNDO> or
Xu Undo [count] changes. {Vi: only one level}
X
X:u[ndo] Undo one change. {Vi: only one level}
X
XCTRL-R Redo [count] changes which were undone. {Vi: redraw
X screen}
X
X:red[o] Redo one change which was unodone. {Vi: no redo}
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. If it is negative no undo is
Xpossible. Use this if you are running out of memory.
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 are
Xshifted to "2, etc. The contents of register "9 are lost. You can now get
Xback the most recent deleted text with the put command: '"1P'. (also, if the
Xdeleted text was the result of the last delete or copy operation, 'P' or 'p'
Xalso works as this puts the contents of the unnamed register). 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 being 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 remove the contents of the
Xfirst put, and repeat the put command for the second register. Repeat the
X'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 Command 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 Command 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 Command mode.
X
X:unm[ap]! {lhs} Remove the mapping of {lhs} for Insert and
X Command_line mode.
X
X:map List all key mappings for Command 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 Command mode. {not in Vi}
X
X:map! {lhs} List the key mappings for the key sequences starting
X with {lhs} in insert and Command_line mode. {not in Vi}
X
X:cm[ap] Same as :map, but for Command_line mode only. {not
X in Vi}
X
X:cu[nmap] Same as :unmap, but for Command_line mode only.


X {not in Vi}
X

X:cno[remap] Same as :noremap, but for Command_line mode only.


X {not in Vi}
X

X:im[ap] Same as :map, but for Insert mode only. {not in Vi}
X
X:iu[nmap] Same as :unmap, but for Insert mode only. {not in
X Vi}
X
X:ino[remap] Same as :noremap, but for Insert mode only. {not in
X Vi}
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
XThere are three sets of mappings
X- For Insert mode. These are also used in Replace mode.
X- For Command_line mode: When entering a ":" or "/" command.
X- For Command mode: When typing commands.
X
XThe original vi did not have separate mappings for Insert mode and
XCommand_line mode. Therefore the ":map!" command enters and displays
Xmappings for both. In Vim you can use the ":cmap" and ":imap" commands to
Xenter mappings for each mode separately. When listing mappings with ":map!",
X":cmap" or ":imap" the character in column 1 is <!> for mappings in both
XInsert and Command_line mode, <i> for Insert mode only and <c> for
XCommand_line mode only.
X
XEverything from the first non-blank after {lhs} up to the end of the line
X(or <|>) is considered to be part of {rhs}. This allows the {rhs} to end
Xwith a space.
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 Command_line mode,
Xtype a CTRL-V first. The mapping in Insert mode is disabled if the 'paste'
Xoption is set.
X
XNote that the second character (argument) of the commands @zZtTfF[]rm'`"v is
Xnot mapped. This was done to be able to use all the named registers and
Xmarks, 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
END_OF_FILE
if test 44166 -ne `wc -c <'vim/doc/reference.do3'`; then
echo shar: \"'vim/doc/reference.do3'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/reference.do3'
# end of 'vim/doc/reference.do3'
fi
echo shar: End of archive 21 \(of 25\).
cp /dev/null ark21isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:28:42 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 72
Archive-name: vim/part22

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/reference.do2


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:08 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH

if test -f 'vim/doc/reference.do2' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/reference.do2'\"
else
echo shar: Extracting \"'vim/doc/reference.do2'\" \(45369 characters\)
sed "s/^X//" >'vim/doc/reference.do2' <<'END_OF_FILE'
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 in this case.
X
XVim remembers whether you have changed the buffer. You are protected from
Xlosing 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[dit] [+pat] Edit the current file, unless changes have been made.
X
X:e[dit]! [+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:e[dit] #[count] Edit the [count]th alternate filename (as shown by
X :files). Omitting [count] is equivalent to CTRL-^.
X
X:ex [+pat] [file] Same as :edit. {Vi: go from visual to Ex mode}
X
X:vi[sual] [+pat] [file] Same as :edit. {Vi: go from Ex to Visual mode}
X
X[count]CTRL-^ Edit [count]th alternate file (equivalent to ":e
X #[count]"). Without count this gets you to the
X previously edited file. This is a quick way to
X toggle between two (or more) files. If the
X 'autowrite' option is set and the buffer was
X changed, write it.


X
X:cd On non-Unix systems: Print the current directory

X name. On Unix systems: Change the current directory
X to the home directory.
X
X:cd {path} Change the current directory to {path}. Does not
X change the meaning of an already entered file name,
X because its full path name is remembered.
X
X:chd[ir] [path] Same as :cd.
X
X:pwd Print the current directory name. {Vi: no pwd}
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. One warning: After using ":cd" the
Xfull path name will be used for reading and writing files. On some networked
Xfile systems this may cause problems. The result of using the full path name
Xis that the file names currently in use will remain refering to the same
Xfile. Example: If you have a file a:test and a directory a:vim the commands
X":e test" ":cd vim" ":w" will overwrite the file a:test and not write
Xa:vim/test. But if you do ":w test" the file a:vim/test will be written,
Xbecause you gave a new file name and did not refer to a file name before the
X":cd".
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
XWhen reading a file when the 'textmode' option is off (default for
Xnon-MSDOS) the <LF> character is interpreted as end-of-line. If 'textmode'
Xis on (default for MSDOS), <CR><LF> is also interpreted as end-of-line.
X
XWhen writeing a file when the 'textmode' option is off a <LF> character is
Xused to separate lines. When the 'textmode' option is on <CR><LF> is used.
X
XYou can read a file with 'textmode' set and write it with 'textmode' reset.
XThis will replace all <CR><LF> pairs by <LF>. If you read a file with
X'textmode' reset and write with 'textmode' set, all <LF> characters will be
Xreplaced by <CR><LF>.
X
XIf you start editing a new file and the 'textauto' option is set, Vim will
Xtry to detect whether the lines in the file are separated by a single <LF>
X(as used on Unix and Amiga) or by a <CR><LF> pair (MSDOS). It reads up to
Xthe first <LF> and checks if there is a <CR> in front of it. If there is the
X'textmode' option is set, otherwise it is reset. If the 'textmode' option is
Xset on non-MSDOS systems the message "[textmode]" is shown to remind you
Xthat something unusual is happening. On MSDOS systems you get the message
X"[notextmode]" if the 'textmode' option is not set.
X
XBefore editing binary, executable or Vim script files you should set the
X'textmode' and 'textauto' options off. With 'textmode' on you risc that
Xsingle <LF> characters are unexpectedly replaced with <CR><LF>. A simple way
Xto do this is by starting Vim with the "-b" option.
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: only in some versions}
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 lose 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}. <!> forces the
X write even if file does not exist.
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 mode (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 Write 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 (default)
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
XIf the 'textmode' option is set <CR><LF> is used for end-of-line. This is
Xdefault for MSDOS. On other systems the message "[textmode]" is shown to
Xremind you that an usual end-of-line marker was used. If the 'textmode' is
Xnot set LF is used for end-of-line. On MSDOS the message "[notextmode]" is
Xshown. See also the 'textmode' and 'textauto' options.
X
X
X5.5 Using the QuickFix mode
X
XVim has a special mode to speedup the edit-compile-edit cycle. This is
Xinspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.
XThe idea is to save the error messages from the compiler in a file and use
XVim to jump to the errors one by one. You can then examine each problem and
Xfix it, without having to remember all the error messages.
X
XIf you are using Manx's Aztec C compiler on the Amiga you should do the
Xfollowing:
X- Set the CCEDIT environment variable with the command
X mset "CCEDIT=vim -e"
X- Compile with the -qf option. If the compiler finds any errors, Vim is
X started and the cursor is positioned on the first error. The error message
X will be displayed on the last line. You can go to other errors with the
X commands mentioned below. You can fix the errors and write the file(s).
X- If you exit Vim normally the compiler will re-compile the same file. If you
X exit with the :cq command, the compiler will terminate. Do this if you
X cannot fix the error, or if another file needs to be compiled first.
X
XIf you are using another compiler you should save the error messages in a
Xfile and start Vim with "vim -e filename". An easy way to do this is with
Xthe ":make" command (see below). The 'errorformat' option should be set to
Xmatch the error messages from your compiler (see below).
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. {not in Vi}
X
X:cn Display the next error in the list that includes a
X file name. If there are no file names at all, go the
X the next error. {not in Vi}
X
X:cp Display the previous error in the list that includes
X a file name. If there are no file names at all, go
X the the previous error. {not in Vi}
X
X:cq Quit Vim with an error code, so that the compiler
X will not compile the same file again. {not in Vi}
X
X:cf [errorfile] Read the error file and jump to the first error.
X This is done automatically when Vim is started with
X the -e option. You can use this command when you
X keep Vim running while compiling. If you give the
X name of the errorfile, the 'errorfile' option will
X be set to [errorfile] {not in Vi}
X
X:cl List all errors. {not in Vi}
X
X:make [arguments] 1. If the 'autowrite' option is set and the buffer
X was changed, write it.
X 2. Any existing 'errorfile' is deleted.
X 3. The program given with the 'makeprg' option is
X started (default "make") with the optional
X [arguments] and the output is saved in
X 'errorfile' (for Unix it is also echoed on the
X screen).
X 4. The 'errorfile' is then read and the first error
X is jumped to.
X 5. The 'errorfile' is deleted.


X {not in Vi}
X

XThe name of the file can be set with the 'errorfile' option. The default is
X"AztecC.Err" for the Amiga and "errors" for other systems. The format of the
Xfile from the Aztec compiler 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> or <W>
X errornumber number of the error (for lookup in the manual)
X errormessage description of the error
X
XAnother compiler is likely to use a different format. You should set the
X'errorformat' option to a scanf-like string that describes the format. First
Xyou need to know how scanf works. Look in the documentation of your C
Xcompiler. Vim will understand eight conversion characters. Others are invalid.
X %f file name (finds a string)
X %l line number (finds a number)
X %c column number (finds a number)
X %t error type (finds a single character)
X %n error number (finds a number)
X %m error message (finds a string)
X %*<conv> any scanf non-assignable conversion
X %% the single <%> character
X
XExamples:
X"%f>%l:%c:%t:%n:%m" for the AztecC.Err file
X"%f:%l:\ %t%*[^0123456789]%n:\ %m" for Aztec C error messages
X"%f\ %l\ %t%*[^0123456789]%n:\ %m" for SAS C
X"\"%f\",%*[^0123456789]%l:\ %m" default for generic C compilers
X
XNote the backslash in front of a space and double quote. It is required for
Xthe :set command.
X
XThe "%f" and "%m" conversions have to detect the end of the string. They
Xshould be followed by a character that cannot be in the string. Everything
Xup to that character is included in the string. Be careful: "%f%l" will
Xinclude everything up to the first <%> in the file name. If the "%f" or "%m"
Xis at the end, everything up to the end of the line is included.
X
XIf a line is detected that does not completely match the 'errorformat', the
Xwhole line is put in the error message and the entry is marked "not valid"
XThese lines are skipped with the ":cn" and ":cp" commands (unless there is
Xno valid line at all). You can use ":cl" to display all the error messages.
X
XIf the error format does not contain a file name Vim cannot switch to the
Xcorrect file. You will have to do this by hand.
X
XIf you have a compiler that produces error messages that do not fit in the
Xformat string, you could write a program that translates the error messages
Xinto this format. You can use this program with the ":make" command by
Xchanging the 'makeprg' option. For example:
X ":set mp=make\ \\\|&\ error_filter".
XThe backslashes before the pipe character are required to avoid it to be
Xrecognized as a command separator. The backslash before each space is
Xrequired for the set command.
X
XThe ":make" command executes the command given with the 'makeprg' option.
XThis is done by passing the command to the shell given with the 'shell'
Xoption. This works almost like typing
X
X ":!{makeprg} >{errorfile} [arguments]".
X
X{makeprg} is the string given with the 'makeprg' option. Any command can be
Xused, not just "make". Characters <%> and <#> are expanded as usual on a
Xcommand line. You can use "#<" to insert the current filename without
Xextension, for example ":set makeprg=make\ #<.o".
X
X{errorfile} is the 'errorfile' option.
X
X[arguments] is anything that is typed after ":make".
X
XThere are some restrictions to the Quickfix mode on the Amiga. The
Xcompiler only writes the first 25 errors to the errorfile (Manx's
Xdocumentation does not say how to get more). If you want to find the others,
Xyou will have to fix a few errors and exit the editor. After recompiling,
Xup to 25 remaining errors will be found.
X
XOn the Amiga, if Vim was started from the compiler, the :sh and :! commands
Xwill not work, because Vim is then running in the same process as the
Xcompiler and these two 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
X5.6 Editing binary files
X
XAlthough Vim was made to edit text files, it is possible to edit binary
Xfiles. The "-b" command line option (b for binary) sets some options for
Xediting binary files ('binary' on, 'textwidth' to 0, 'textmode' and
X'textauto' off, 'modelines' to 0, 'expandtab' off). Setting the 'binary'
Xoption has the same effect. Don't forget to do this before reading the file.
X
XThere are a few things to remember when editing binary files:
X- When editing executable files the number of characters must not change.
X Use only the "R" or "r" command to change text. Do not delete characters
X with "x" or by backspacing.
X- Set the 'textwidth' option to 0. Otherwise lines will unexpectedly be
X split in two.
X- When there are not many end-of-line characters, the lines will become very
X long. If you want to edit a line that does not fit on the screen reset the
X 'wrap' option. Horizontal scrolling is used then. If a line becomes too
X long (more than about 32767 characters on the Amiga, much more on 32-bit
X systems) you cannot edit that line. It is also possible that you get an
X "out of memory" error when reading the file.
X- Make sure the 'textmode' and 'textauto' options are off before loading the
X file. In 'textmode' both <CR><LF> and <LF> are considered to end a line
X and when the file is written the <LF> will be replaced by <CR><LF>. The
X 'modelines' option should also be off, because there may be a string like
X ":vi:" in the file that would give unpredictable results.
X- <NUL> characters are shown on the screen as ^@. You can enter them with
X "CTRL-V CTRL-@" or "CTRL-V 000" {vi cannot handle <NUL> characters in the
X file}
X- To insert a <LF> character in the file split up a line. When writing the
X buffer to a file a <LF> will be written for the end of line.
X- Vim normally appends an end-of-line character at the end of the file if
X there is none. Setting the 'binary' option prevents this. If you want to
X add the final end-of-line, append an empty line at the end.
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 start and end position. Generally, motions that move between lines
Xaffect lines (are linewise), and motions that move within a line affect
Xcharacters. However, there are some exceptions.
X A character motion is either inclusive or exclusive. When inclusive,
Xthe start and end position of the motion are included in the operation.
XWhen exclusive, the last character towards the end of the buffer is not
Xincluded. Linewise motions always include the start and end position.
X Which motions are linewise, inclusive or exclusive is mentioned
Xbelow. There are however, two general exceptions:
X1. If the motion is exclusive and the end of the motion is in column 1, the
X end of the motion is moved to the end of the previous line and the motion
X becomes inclusive. Example: "}" ends at the first line after a paragraph,
X but "V}" will not include that line.
X2. If the motion is exclusive, the end of the motion is in column 1 and the
X start of the motion was at or before the first non-blank in the line, the
X motion becomes linewise. Example: If a paragraph begins with some blanks
X and you do "d}" while standing on the first non-blank, all the lines of
X the paragraph are deleted, including the blanks. If you do a put now, the
X deleted lines will be inserted below the cursor position.
X
XInstead of first giving the operator and then a motion you can use Visual
Xmode: mark the start of the text with <v>, move the cursor to the end of the
Xtext that is to be affected and then hit the operator. The text between the
Xstart and the cursor position is highlighted, so you can see what text will
Xbe operated upon. This allows much more freedom, but requires more key
Xstrokes and has limited redo functionality. See the chapter on Visual mode.
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, because they
Xdo not know what the hjkl keys do. The mnemonic value of hjkl is clear from
Xlooking at the keyboard. Think of j as an arrow pointing downwards.
X
X6.1 Left-right motions
X
Xh or
X<C_LEFT> or
XCTRL-H or
X<BS> [count] characters to the left (exclusive).
X
Xl or
X<C_RIGHT> or
X<SPACE> [count] 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 [count] from the cursor
X (inclusive).
X
X| To column [count] (inclusive).
X
Xf<char> To [count]'th occurrence of <char> to the right. The
X cursor is placed on <char> (inclusive).
X
XF<char> To the [count]'th occurrence of <char> to the left.
X The cursor is placed on <char> (inclusive).
X
Xt<char> Till before [count]'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 [count]'th occurrence of <char> to the
X left. The cursor is placed on the character right of
X <char> (inclusive).
X
X; Repeat latest f, t, F or T [count] times.
X
X, Repeat latest f, t, F or T in opposite direction
X [count] 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 [count] lines upward (linewise).
X
Xj or
X<C_DOWN> or
XCTRL-J or
X<LF> or
XCTRL-N [count] lines downward (linewise).
X
X- <minus> [count] lines upward, on the first non-blank
X character (linewise).
X
X+ or
XCTRL-M or
X<CR> [count] lines downward, on the first non-blank
X character (linewise).
X
X_ <underscore> [count] - 1 lines downward, on the first non-blank
X character (linewise).
X
XG Goto line [count], 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{count}% Go to {count} percentage in the file, column 1
X (linewise). To compute the new line number this
X formula is used: {count} * number-of-lines / 100.


X {not 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 [count] words forward (exclusive).
X
XW [count] WORDS forward (exclusive).
X
Xe Forward to the end of word [count] (inclusive).
X
XE Forward to the end of WORD [count] (inclusive).
X
X<SC_LEFT> or
Xb [count] words backward (exclusive).
X
XB [count] 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 white space (spaces, tabs, end of line). A WORD
Xconsists of a sequence of non-blank characters, separated with white space.
XAn empty line is also considered to be a word and 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 white 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

XAnother special case: When using the "w" motion in combination with an
Xoperator and the last word moved over is at the end of a line, the end of
Xthat word becomes the end of the operated text, not the first word in the
Xnext line.
X
XThe original vi implementation of "e" is buggy. For example, the "e" command
Xwill stop on the first character of a line if the previous line was empty.
XBut when you use "2e" this does not happen. In Vim "ee" and "2e" are the
Xsame, which is more logical. However, this causes a small incompatibility
Xbetween vi and Vim.
X
X
X6.4 Text object motions
X
X( [count] sentences backward (exclusive).
X
X) [count] sentences forward (exclusive).
X
X{ [count] paragraphs backward (exclusive).
X
X} [count] paragraphs forward (exclusive).
X
X]] [count] sections forward or to the next <{> in the
X first column. When used after an operator, then the
X <}> in the first column. (linewise).
X
X][ [count] sections forward or to the next <}> in the
X first column (linewise).
X
X[[ [count] sections backward or to the previous <{> in
X the first column (linewise).
X
X[] [count] sections backward or to the previous <}> in
X the first column (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. Note that
Xthis does not include a <{> or <}> in the first column.
X
XA section begins after a form-feed in the first column and at each of a set
Xof section macros, specified by the pairs of characters in the 'sections'
Xoption. The default is "SHNHH HUnhsh".
X
XThe "]" and "[" commands stop at the <{> or <}" in the first column. This is
Xuseful to find the start or end of a function in a C program. Note that the
Xfirst character of the command determines the search direction and the
Xsecond character the type of brace found.
X
X
X6.5 Pattern searches
X
X/{pattern}[/] Search forward for the [count]'th occurrence of
X {pattern} (exclusive).
X
X/{pattern}/{offset} Search forward for the [count]'th occurrence of
X {pattern} and go {offset} lines up or down (see
X below). (linewise).
X
X/ Search forward for the [count]'th latest used
X pattern with latest used {offset}.
X
X//{offset} Search forward for the [count]'th latest used
X pattern with new {offset}. If {offset} is empty no
X offset is used.
X
X* Search forward for the [count]'th occurrence of the
X ident after or under the cursor (exclusive). {not in
X Vi}
X
X# Search backward for the [count]'th occurrence of the
X ident after or under the cursor (exclusive). {not in
X Vi}
X
X?{pattern}[?] Search backward for the [count]'th previous
X occurrence of {pattern} (exclusive).
X
X?{pattern}?{offset} Search backward for the [count]'th previous
X occurrence of {pattern} and go {offset} lines up or
X down (see below) (linewise).
X
X? Search backward for the [count]'th latest used
X pattern with latest used {offset}.
X
X??{offset} Search backward for the [count]'th latest used
X pattern with new {offset}. If {offset} is empty no
X offset is used.
X
Xn Repeat the latest "/" or "?" [count] times. {Vi: no
X count}
X
XN Repeat the latest "/" or "?" [count] times in
X opposite 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 internally for the :tags command)
X
XIf a <-> or <+> is given but [num] is omitted, a count of one will be used.
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 (search to the
Xleft and up) and the "*" is under your right hand middle finger (search to
Xthe right and down).
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. Example: "foo\|bar" matches "foo" and
X "bar.
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. Example: "foo[0-9]bar",
X first match "foo", then a digit and then "bar".
X
X3. A piece is an atom, possibly followed by:
X 'magic' 'nomagic'
X option option
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 Examples:
X .* .\* match anything, also empty string
X .\+ .\+ match any non-empty string
X foo\? foo\? match "fo" and "foo"
X
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
XIt is impossible to have a pattern that contains a line break.
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
XTechnical detail:
X<NUL> characters in the file are stored as <LF> in memory. In the display
Xthey are shown as "^@". The translation is done when reading and writing
Xfiles. To match a <NUL> with a search pattern you can just enter CTRL-@ or
X"CTRL-V 000". This is probably just what you expect. Internally the
Xcharacter is replaced by a <LF> in the search pattern. What is unusual is
Xthat typing CTRL_V CTRL_J also inserts a <LF>, thus also searches for a
X<NUL> in the file. {vi cannot handle <NUL> characters in the file at all}
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 <t>. 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 Visual mode. These commands do not work when no
Xoperator or put command has been used yet in the current file. The position
Xmay be incorrect 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", "L", "M", "H" and
Xthe commands that start editing a new file. If you make the cursor "jump"
Xwith one of these commands, the position of the cursor before the jump is
Xremembered. You can return to that position with the "''" and "``" command,
Xunless the line containing that position was changed or deleted.
X
XCTRL-O Go to [count] Older cursor position in jump list
X (not a motion command). {not in Vi}
X
XCTRL-I Go to [count] 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). Parens
X and braces preceded with a backslash are ignored.
X Parens and braces inside quotes are ignored, unless
X the number of parens/braces in a line is uneven and
X this line and the previous one does not end in a
X backslash. No count is allowed ({count}% jumps to a
X line {count} percentage down the file).
X
XH To line [count] 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 [count] 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
XMove edit window downwards (this means that more lines downwards in the text
Xbuffer are seen):
X
XCTRL-E Window [count] lines downwards in the buffer
X
XCTRL-D Window Downwards in the buffer. The number of lines
X comes from the 'scroll' option (default: half a
X screen). If [count] given, first set 'scroll' option
X to [count].
X
X<SC_DOWN> or
XCTRL-F Window [count] pages Forwards (downwards) in the
X buffer.
X
XMove edit window upwards (this means that more lines upwards in the text
Xbuffer are seen):
X
XCTRL-Y Window [count] lines upwards in the buffer.
X
XCTRL-U Window Upwards in the buffer. The number of lines
X comes from the 'scroll' option (default: half a
X screen). If [count] given, first set 'scroll' option
X to [count].
X
X<SC_UP> or
XCTRL-B Window [count] pages Backwards (upwards) in the
X buffer.
X
XWindow repositioning:
X
Xz<CR> Redraw, line [count] at top of window (default
X cursor line).
X
Xz{height}<CR> Redraw, make window {height} lines tall. This is
X useful to make the number of lines small when screen
X updating is very slow. Cannot make the height more
X than the physical screen height.
X
Xz. Redraw, line [count] at center of window (default
X cursor line).
X
Xz- Redraw, line [count] 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 [count] older entry in the tag stack
X (default 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-----------------------------------------------------------------------------
END_OF_FILE
if test 45369 -ne `wc -c <'vim/doc/reference.do2'`; then
echo shar: \"'vim/doc/reference.do2'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/reference.do2'
# end of 'vim/doc/reference.do2'
fi
echo shar: End of archive 22 \(of 25\).
cp /dev/null ark22isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:30:42 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 73
Archive-name: vim/part23

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 25)."
# Contents: vim/doc/reference.do1
# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:09 1993


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

if test -f 'vim/doc/reference.do1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/reference.do1'\"
else
echo shar: Extracting \"'vim/doc/reference.do1'\" \(47200 characters\)
sed "s/^X//" >'vim/doc/reference.do1' <<'END_OF_FILE'
X
X
X
X Vim reference manual
X
X By Bram Moolenaar
X
X version 2.0
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. Visual mode
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 IMproved. It used to be Vi IMitation, but that does not
Xreally cover it anymore. Vim is a text editor which includes almost all the
Xcommands from the Unix program "Vi". It is very useful for editing programs
Xand other ASCII text. All commands are given with the keyboard. There is no
Xmouse support and there are no menus. This gives the advantage that you can
Xkeep 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[count] 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 [count] is not mentioned in the description of the
X command, but only in the explanation. This was done to make
X the commands easier to lookup. If the "sc" option is on, the
X (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 register designation where text can be stored.
X The x is a single character between <a> and <z> or <A> and
X <Z> or <">, 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" or with """" the stored text is
X put into the unnamed register. See also "Copying and moving
X text".
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{visual} A piece of text that is started with the "v", "V" or CTRL-V
X command and ended by the cursor position. This is used
X before an "operator" to highlight the text that is to be
X operated upon. See the chapter on Visual mode.
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'option' An option, or parameter, that can be set to a value is
X enclosed in single quotes. See chapter 19.
X
X"command" In examples the commands you can type are enclosed in double
X quotes.
X
X
Xnotation meaning equivalent decimal value
X-----------------------------------------------------------------------
X<NUL> zero CTRL_@ 000 (internally 010)
X<BELL> bell CTRL-G 007
X<BS> backspace CTRL-H 008
X<TAB> tab CTRL-I 009
X<LF> linefeed CTRL-J 010
X<FF> formfeed CTRL-L 012
X<CR> carriage return CTRL-M 013
X<ESC> escape CTRL-[ 027
X<SPACE> space 032
X<DEL> delete 127
X<C_UP> cursor-up 128 (msdos: 176)
X<C_DOWN> cursor-down 129 (msdos: 177)
X<C_LEFT> cursor-left 130 (msdos: 178)
X<C_RIGHT> cursor-right 131 (msdos: 179)
X<SC_UP> shift-cursor-up 132 (msdos: 180)
X<SC_DOWN> shift-cursor-down 133 (msdos: 181)
X<SC_LEFT> shift-cursor-left 134 (msdos: 182)
X<SC_RIGHT> shift-cursor-right 135 (msdos: 183)
X<F1> - <F10> function keys 1 to 10 136 - 145 (msdos: 184 - 193)
X<SF1> - <SF10> shift-function keys 1 to 10 146 - 155 (msdos: 194 - 203)
XHELP> help key 156 (msdos: 204)
X<UNDO> undo key 157 (msdos: 205)
X-----------------------------------------------------------------------
XNote: The shifted cursor keys, the help key and the undo key are only
Xavailable on a few terminals. On some terminals the function keys 11 to 20
Xare used instead of the shifted function keys. On the Amiga shifted function
Xkey 10 produces a code (CSI) that is also used by key sequences. It will be
Xrecognized only after typing another key.
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 [errorfile] QuickFix mode. The file with the name [errorfile] is read
X and the first error is displayed. If [errorfile] is not
X given, the 'errorfile' option is used for the file name
X (default "AztecC.Err" for the Amiga, "errors" for other
X systems). See section 5.5: "using the QuickFix mode".
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). Calling the executable "view"
X has the same effect as the -v option. If your system does
X not support links and you do not want to have the executable
X twice you could make an alias: "alias view vim -v".
X
X-b Binary mode. The 'textauto', 'textmode' and 'expandtab'
X options will be reset. The 'textwidth' option is set to 0.
X 'modelines' is set to 0. The 'binary' option is set. This is
X done after reading the .vimrc/.exrc files but before reading
X a file. See also 5.6: "Editing binary files".
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-x Do not restart Vim to open a new window. This option should
X be used when Vim is started by a program that will wait for
X the edit session to finish (e.g. mail or readnews). See
X section 3.3.
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
XIf the executable is called "view" Vim will start in Readonly mode. This is
Xuseful if you can make a hard or symbolic link from "view" to "vim".
XStarting in Readonly mode can also be done with "vim -v".
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 (Amiga only)
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) or with
X the -x option, this method is not used. The reason for this is that
X when a compiler starts Vim with the -e option it will wait for a
X return code. With the script trick the compiler cannot get the
X return code. The -x option can be used when Vim is started by a mail
X program which also waits for the edit session to finish. As a
X consequence the ":sh" and ":!" commands are not available when the
X -e or -x 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 the following order. If
Xan environment variable is used, it is executed as a single Ex command line.
XMultiple commands must be separated with <|>. If a file is used, each line
Xis executed as an Ex command line.
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. If the 'exrc' option is set (default is 'noexrc'), the current directory
X is searched for two files. The first that exists is used, the other is
X ignored.
X 1. The file ".vimrc"
X 2. The file ".exrc"
X
X3. The environment variable SHELL, if it exists, is used to set the
X 'shell' option. With MSDOS the COMPSPEC variable is used if SHELL does
X not exist.
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 (note that the
X'exrc' option is default off). See the section "Saving settings" for how to
Xcreate a file with commands to recreate the 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
XOn MS-DOS systems Vim assumes that all the "_vimrc" and "_exrc" files have
X<CR><LF> pairs as line separators. This will give problems if you have a
Xfile with only <LF>s and have a line like ":map xx yy^M". The trailing ^M
Xwill be ignored.
X
XWhile reading the ".vimrc" or the ".exrc" file in the current directory some
Xcommands can be disabled for security reasons by setting the 'secure'
Xoption. Otherwise it would be possible to create a .exrc that contains nasty
Xcommands, which another user may automatically execute when he starts Vim it
Xthat directory. The disabled commands are the ones that start a shell and
Xthe ones that write to a file. The ":map" commands are echoed, so you can
Xsee which keys are being mapped.
X
XYou can reset the 'secure' option in the EXINIT or VIMINIT environment
Xvariable or in the global ".exrc" or ".vimrc" file. This is not possible in
X".vimrc" or ".exrc" in the current directory, for obvious reasons.
X
XOn unix systems this only happens if you are not the owner of the ".vimrc"
Xor ".exrc" file. Warning: If you unpack an archive that contains a .exrc
Xfile, it will be owned by you. You won't have the security protection. Check
Xthe .exrc file before you start Vim in that directory, or reset the 'exrc'
Xoption.
X
X
X3.5 Suspending
X
XCTRL-Z Suspend the editor. Same as ":stop".
X
X:sus[pend][!] or
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 many UNIX systems it is possible to suspend Vim with CTRL-Z. This is only
Xpossible in Command mode (see next chapter). Vim will continue 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 continue 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
X the filter 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 by:
X - hitting <CR> or <LF>, which causes the entered command to be executed
X - deleting the complete line (e.g. with CTRL-U) and giving a final <BS>
X - hitting CTRL-C or <ESC>, which quits the command line without executing
X the command.
X In the last case <ESC> may be the character defined with the 'wildchar'
X option, and start filename completion. You can ignore that and type <ESC>
X again. {vi: when hitting <ESC> the command line is executed. This is
X unexpected for most people, therefore it was changed in Vim. But when the
X <ESC> is part of a mapping the command line is executed. If you want the
X vi behaviour also when typing <ESC> use ":cmap ^V<ESC> ^V^M"}
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-@" or "CTRL-V 000". On some systems you have to
Xuse "CTRL-V 003" to insert a CTRL-C.
X
Xchar action
X-----------------------------------------------------------------------
XCTRL-@ Insert previously inserted text and stop insert. {Vi: only
X when typed as first char, only up to 128 chars}
XCTRL-A Insert previously inserted text. {not in Vi}
XCTRL-C Quit insert mode, back to command mode.
XCTRL-D Delete one shiftwidth of indent at the start of the current
X line. See also 'shiftround' option. When preceded with <^>
X or <0> delete all indent in the current line. With <^> the
X indent is restored in the next line. This is useful when
X inserting a label. {Vi: CTRL-D works only when used after
X autoindent}
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-I <TAB> Insert a tab. If the 'expandtab' option is on, the
X equivalent number of spaces is inserted (use CTRL-V <TAB> to
X avoid the expansion).
XCTRL-J <LF> Begin new line.
XCTRL-K {char1} {char2}
X Enter digraph (see 4.7). {not in Vi}
XCTRL-M <CR> Begin new line.
XCTRL-O Execute one Command mode command. See below. {not in Vi}
XCTRL-P Toggle the 'revins' option. {not in Vi}
XCTRL-R <0-9a-z"%>
X Insert the contents of a numbered or named register. The
X text is inserted as if you typed it, but mappings and
X abbreviations are not used. If you have options like
X 'textwidht' or 'autoindent' set, this will influence what
X will be inserted. Use <"> for the unnamed register,
X containing the text of the last delete or yank. Use <%> for
X the current file name. See the chapter on copying and
X moving text about registers. {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. The non-digit and the three
X digits are not considered for mapping. {Vi: no decimal byte
X entry}
XCTRL-W Delete the word before the cursor (see below). See the
X section "word motions" for the definition of a word.
XCTRL-Y Insert the character which is above the cursor. {not in Vi}
XCTRL-[ or <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 (unless 'revins' is set):
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. If you enter a value of 10, it will end up in the file as a 0.
XThe 10 is a <LF>, which is used internally to represent the <NUL> character.
XWhen writing the buffer to a file the <LF> character is translated into
X<NUL>. The <LF> character is written at the end of each line. Thus if you
Xwant to insert a <LF> character in a file you will have to make a line
Xbreak.
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 use CTRL-O if you want to map a function key to a command.
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.
XThe shifted cursor keys are not available on all terminals.
X
X
X'textwidth' option
X
XThe 'textwidth' option can be used to automatically break a line before it
Xgets too long. Set the 'textwidth' option to the desired maximum line
Xlength. If you then type more characters (not spaces or tabs), the
Xlast word will be put on a new line (unless it is the only word on the
Xline). If you set 'textwidth' to 0, this feature is disabled. Vi has the
X'wrapmargin' option, but it does not do what you want. For compatibility, if
Xyou set the 'wrapmargin' option, 'textwidth' will be set to (columns -
X'wrapmargin'), where columns is the width of the display.
X
XIf you want to format a block of text you can use the "Q" operator. Type "Q"
Xand a movement command to move the cursor to the end of the block. In many
Xcases the command "Q}" will do what you want (format until the end of
Xparagraph). Or you can use visual mode: hit "v", move to the end of the
Xblock and hit "Q".
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> type CTRL-V first.
XThe 'expandtab' option is default off. Note that in Replace mode a single
Xcharacter is replaced by several spaces. The result of this is that the
Xnumber of characters in the line increases. Backspacing will delete one
Xspace at a time. The original text will be put back in a place where you
Xwould not expect it.
X
X
Xtyping backwards
X
XIf the 'revins' (reverse insert) option is set, inserting happens backwards.
XThis can be used to type Hebrew. When inserting characters the cursor is not
Xmoved and the text moves rightwards. A <BS> deletes the character under the
Xcursor. CTRL-W and CTRL-U also work in the opposite direction. <BS>, CTRL-W
Xand CTRL-U do not stop at the start of insert or end of line, no matter how
Xthe 'backspace' option is set.
X
XIn Replace mode the cursor is moved leftwards. <BS> will restore the
Xcharacter right of the cursor.
X
XIn insert or Replace mode the 'revins' option can be toggled with CTRL-P.
X
XIf the 'showmode' option is set, "-- REVERSE INSERT --" or
X"-- REVERSE REPLACE --" will be shown in the status line.
X
X
XReplace mode
X
XIn Replace mode one character in the line is deleted for every character you
Xtype. If there is no character 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
XIf you delete characters in Replace mode (with <BS>, <DEL>, CTRL-W or
XCTRL-U), you really delete your changes. The characters that were replaced
Xare restored. If you had typed past the existing text, the characters you
Xadded are deleted.
X All this only works in the current line. If you have started a new line
X(replaced a character with a <CR>) Vim no longer remembers what happened in
Xthe previous line. If you backspace over the newline (only possible if the
X'backspace' option is non-zero), the two lines will be joined again, but
Xtyping further backspaces will not restore the original text. Only the
Xcursor is moved.
X If the 'expandtab' option is set, a <TAB> will replace one character
Xwith several spaces. When backspacing over these spaces, the original text
Xwill appear in a position where you would not expect it.
X
X
X4.4 Command_line mode
X
XCommand_line mode is used to enter Ex commands <:>, search patterns </><?>
Xand filter commands <!>.
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. The non-digit and the three
X digits are not considered for mapping. This works the same
X way as in Insert mode (see above).


X<C_LEFT> cursor left
X<C_RIGHT> cursor right
X<SC_LEFT> cursor one word left
X<SC_RIGHT> cursor one word right

XCTRL-B cursor to begin of command line
XCTRL-E cursor to end of command line
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-W delete the word in front of the cursor
XCTRL-U remove all characters
X
X Note: if the command line becomes empty with one of the
X delete commands, command line mode is quit.
X
X{char1} <BS> {char2} or
XCTRL-K {char1} {char2}
X enter digraph (see 4.7). {not in Vi}
X
X<CR> or <LF> start entered command
X<ESC> when typed: quit command line without executing
X in macros: start entered command
XCTRL-C quit command line without executing
X
X<C_UP> recall older command line from history
X<C_DOWN> recall more recent command line from history
X
X<SC_UP> recall older command line from history, which begin matches
X the current command line.
X<SC_DOWN> recall more recent command line from history, which begin
X matches the current command line.
X
XCTRL-D list filenames that match the pattern in front of the cursor
X'wildchar' option
X do filename completion on the pattern in front of the cursor
X (Note: does not work inside a macro)
XCTRL-K {char1} {char2}
X enter digraph (see 4.7). {not in Vi}
XCTRL-N after 'wildchar' with multiple matches: go to next match;
X otherwise: recall more recent command line from history
XCTRL-P after 'wildchar' with multiple matches: go to previous match;
X otherwise: recall older command line from history
XCTRL-A do filename completion on the pattern in front of the cursor
X and insert all matches
XCTRL-L do filename completion on the pattern in front of the cursor
X and insert the longest common part
X
XThe 'wildchar' option defaults to <TAB> (CTRL-E when compiled with
XCOMPATIBLE; in a previous version <ESC> was used). In the pattern for
XCTRL-D and 'wildchar' standard Amiga wildcards are accepted, plus the <*>
Xand <?> 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 an extension that is in the 'suffixes' option are ignored.
XThe 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
XIf there is more than one matching file (after ignoring the ones matching
Xthe 'suffixes' option) the message "Too many file names" is given. The first
Xfile name is inserted. You can get to the others by entering 'wildchar',
XCTRL-N or CTRL-P. All files are included then, also the ones with extensions
Xmatching the 'suffixes' option.
X
XThe <SC_UP> and <SC_DOWN> keys take the current command line as search
Xstring. The beginning of the next/previous command lines are compared against
Xthis string. The fist line that matches is the new command line. When typing
Xthese two keys repeatedly, the same string is used again. For example this
Xcan be used to find the previous substitute command: Type ":s" and then
X<SC_UP>. The same could be done by typing <C_UP> a number of times until the
Xdesired command line is shown. (Note: the shifted arrow keys do not work on
Xall terminals)
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. If you want
X<|> to be included in a command, precede it with <\>. Note that this is
Xconfusing (inherited from vi). If you give a command with ":!" you don't
Xhave to use a backslash, with ":r !" you have to. And with ":g" the <|> is
Xincluded in the command, with ":s" it is not. Examples:
X :!ls | wc view the output of two commands
X :r !ls \| wc insert the same output in the text
X :%g/foo/p|> moves all matching lines one shiftwidth
X :%s/foo/bar/|> moves one line one shiftwidth
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 spaces in filenames are allowed if one filename is expected as
Xargument. Trailing spaces will be ignored, unless escaped with a backslash
Xor CTRL-V. Note that the ":next" command uses spaces to separate file names.
XEscape the spaces to include them in a file name. Example:
X :next foo\ bar goes\ to school\
Xstarts editing the three files "foo bar", "goes to" and "school ".
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 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,
Xunless the 'wrap' option is off (see below). The bottom lines in the window
Xmay 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
XIf the 'wrap' option is off, long lines will not wrap. Only the part that
Xfits on the screen is shown. If the cursor is moved to a part of the line
Xthat is not shown, the screen is scrolled horizontally. The advantage of
Xthis method is that columns are shown as they are and lines that cannot fit
Xon the screen can be edited. The disadvantage is that you cannot see all the
Xcharacters of a line at once. The 'sidescroll' option can be set to the
Xminimal number of columns to scroll. {Vi: has no 'wrap' option}
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 <LF> 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 unix default
Xcurrent mode 'showmode' on on
Xcommand characters 'showcmd' on off
Xcursor position 'ruler' off 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
Xshow the characters you typed 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
XOn most Unix systems window resize works ok. {Vi: not ok}
X
X
X4.6 Abbreviations
X
XAbbreviations are used in insert mode, Replace mode and Command_line mode.
XIf you enter a word that is an abbreviation, it is replaced by the word it
Xstands for. Only whole words are recognized. A word is made up of letters,
Xdigits and <_>. You have to type a character other than a letter, digit, or
X<_> in front of the word and after the word before the abbreviation is
Xrecognized. The word may also begin at the start of a line and at the
Xposition where the insertion started. You may also type a <CR> or <LF> after
Xthe word.
X
XExample: ":ab foo four old otters". Note that spaces in the <rhs> are
Xallowed and included in the replacement string. If you now insert the word
X"foo" with a space before and after it, it will be replaced by "four old
Xotters". If you would type "foobar" or "barfoo" nothing happens.
X
XTo avoid the abbreviation in insert mode type part of the abbreviation, exit
Xinsert mode with <ESC>, re-enter insert mode with "a" and type the rest. In
XCommand_line mode you can type CTRL-V twice somewhere in the abbreviation to
Xavoid it to be replaced. A CTRL-V in front of a normal character is mostly
Xignored otherwise.
X
XThere are no default abbreviations.
X
XAbbreviations are disabled if the 'paste' option is set.
X
X:ab[breviate] list all abbreviations. The character in the first
X column indicates the mode where the abbreviation is
X used: 'i' for insert mode, 'c' for Command_line
X mode, '!' for both.
X
X:ab[breviate] <lhs> list the abbreviations that start with <lhs>
X


X:ab[breviate] <lhs> <rhs>

X add abbreviation for <lhs> to <rhs>. If <lhs> already
X existed it is replaced with the new <rhs>. <rhs> may
X contain spaces.
X
X:una[bbreviate] <lhs> remove abbreviation for <lhs> from the list
X
X:norea[bbrev] [lhs] [rhs]
X same as ":ab", but no remapping for this <rhs> {not
X in Vi}
X
X:ca[bbrev] [lhs] [rhs] same as ":ab", but for Command_line mode only. {not
X in Vi}
X
X:cuna[bbrev] <lhs> same as ":una", but for Command_line mode only. {not
X in Vi}
X


X:cnorea[bbrev] [lhs] [rhs]

X same as ":ab", but for Command_line mode only and no
X remapping for this <rhs> {not in Vi}
X
X:ia[bbrev] [lhs] [rhs] same as ":ab", but for insert mode only. {not in Vi}
X
X:iuna[bbrev] <lhs> same as ":una", but for insert mode only. {not in
X Vi}
X


X:inorea[bbrev] [lhs] [rhs]

X same as ":ab", but for insert mode only and no
X remapping for this <rhs> {not in Vi}
X
X
X4.7 Digraphs
X
X:dig[raphs] show currently defined digraphs. {not in Vi}
X


X:dig[raphs] {char1}{char2} {number} ...

X Add digraph {char1}{char2} to the list. {number} is
X the decimal representation of the 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 easier to remember than the decimal number
Xthat 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 what you want. To avoid this,
Xuse <DEL> instead of <BS>.
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) <%> is replaced by the
Xcurrent filename and <#> is replaced by the alternate filename. The older
Xalternate filenames are "#1", "#2", ..., "#9". "#0" is the same as "#". "#<"
Xis replaced by the current filename with the extension deleted (everything
Xafter and including the last '.' in the file name).
X
XCTRL-G or
X:f[ile] Prints the current filename (as typed) and the
X cursor position.
X
X{count}CTRL-G Prints the current filename with full path and the
X cursor position.
X
X:f[ile] {name} Sets the current filename to {name}.
X
X:files Lists the alternate filenames.
X
XVim will remember the full path name of a file name that you enter. In most
Xcases when the file name is displayed only the name you typed is shown, but
Xthe full path name is being used if you used the ":cd" command.
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
END_OF_FILE
if test 47200 -ne `wc -c <'vim/doc/reference.do1'`; then
echo shar: \"'vim/doc/reference.do1'\" unpacked with wrong size!
fi
chmod +x 'vim/doc/reference.do1'
# end of 'vim/doc/reference.do1'
fi
echo shar: End of archive 23 \(of 25\).
cp /dev/null ark23isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

Bram Moolenaar

unread,
Dec 21, 1993, 12:30:57 PM12/21/93
to
Submitted-by: mo...@oce.nl (Bram Moolenaar)
Posting-number: Volume 41, Issue 74
Archive-name: vim/part24

Environment: UNIX, AMIGA, MS-DOS
Supersedes: vim: Volume 37, Issue 1-24

#! /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 24 (of 25)."
# Contents: vim/src/arpbase.h


# Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:09 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
chmod +x 'vim/src/arpbase.h'
# end of 'vim/src/arpbase.h'
fi
echo shar: End of archive 24 \(of 25\).
cp /dev/null ark24isdone


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 24 25 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 25 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

===============================================================================

0 new messages