home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume37
/
vim
/
part07
< prev
next >
Wrap
Text File
|
1993-04-23
|
48KB
|
1,338 lines
Newsgroups: comp.sources.misc
From: mool@oce.nl (Bram Moolenaar)
Subject: v37i007: vim - Vi IMitation editor v1.27, Part07/24
Message-ID: <1993Apr23.173105.16608@sparky.imd.sterling.com>
X-Md4-Signature: 5b3f5fe05d837b4336df7ca77f3fd784
Date: Fri, 23 Apr 1993 17:31:05 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: mool@oce.nl (Bram Moolenaar)
Posting-number: Volume 37, Issue 7
Archive-name: vim/part07
Environment: UNIX, AMIGA, MS-DOS
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 7 (of 23)."
# Contents: vim/doc/difference.doc vim/src/termlib.c vim/src/version.c
# Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:08 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'vim/doc/difference.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/doc/difference.doc'\"
else
echo shar: Extracting \"'vim/doc/difference.doc'\" \(14014 characters\)
sed "s/^X//" >'vim/doc/difference.doc' <<'END_OF_FILE'
XThis is a summary of the differences between VIM and vi.
X
X
XThe most interesting additions:
X
XMulti level undo.
X'u' goes backward in time, 'ctrl-R' goes forward again. Set option
X'undolines' to the number of changes to be remembered (default 100). Set
X'undolines' to 0 for vi-compatible one level undo.
X
X
XRepeat a series of commands.
X'v'<c> starts recording typed characters into named buffer <c> (append to the
Xbuffer if buffer name is upper case). A subsequent 'v' stops recording. The
Xbuffer can then be executed with the '@'<c> command. This is very useful to
Xrepeat a complex action.
X
X
XFlexible insert mode.
XThe arrow keys can be used in insert mode to move around in the file. This
Xbreaks the insert in two parts as far as undo and redo is concerned.
X
XCTRL-O can be used to execute a single command-mode command. This is almost
Xthe same as hitting ESC, typing the command and hitting 'a'. For undo/redo
Xonly those inserts are remembered where something was actually inserted.
X
X
XQuoting.
XQuoting can be used to first choose a piece of text and then give a command
Xto do something with it. This is an (easy to use) alternative to first giving
Xthe operator and then moving to the end of the text to be operated upon. 'q'
Xand 'Q' are used to start quoting a piece of text. 'q' works on characters
Xand 'Q' on lines. Move the cursor to extend the quoted part. It is shown
Xhighlighted on the screen. By typing 'o' the other end of the quoted text can
Xbe moved. The quoted text can be affected by an operator:
X d delete
X c change
X y yank
X > or < insert or delete indent
X ! filter through external program
X = filter through indent
X : start ":" command for the quoted lines.
X V format text to 'textwidth' columns
X J join lines
X ~ swap case
X u make uppercase
X U make lowercase
X
X
XBlock operators.
XWith quoting a rectangular block of text can be selected. Start quoting with
XCTRL-Q. The block can be deleted ('d'), yanked ('d') or its case can be
Xswapped ('~'). A deleted or yanked block can be put into the text with the
X'p' and 'P' commands.
X
X
XOnline help.
X':help' command and help key (F1 for MSDOS) display several pages of concise
Xhelp. The name of the help file can be set with the "helpfile" option.
X
X
XCommand line editing.
XYou can insert or delete at any place in the command line using the cursor
Xkeys. The right/left cursor keys can be used to move forward/backward one
Xcharacter. The shifted right/left cursor keys can be used to move
Xforward/backward one word.
X
XThe command lines are remembered. The up/down cursor keys can be used to
Xrecall previous command lines. The 'history' option can be set to the number
Xof lines that will be remembered.
X
X
XFilename completion.
XWhile entering a command line (on the bottom line of the screen) <ESC> can be
Xtyped after an (incomplete) file name wildcard; the wildcard will be
Xexpanded. If there are multiple matches, CTRL-N (next) and CTRL-P (previous)
Xwill walk through the matches. CTRL-D can be typed after an (incomplete) file
Xname wildcard; all matching files will be listed.
X
X
XText formatting.
XThe 'textwidth' (tw) option can be used to automatically limit the line
Xlength. This replaces the 'wrapmargin' option of Vi, which was not very
Xuseful. The 'V' operator can be used to format a piece of text ("V}" formats
Xa paragraph).
X
X
XCommand line options:
X
XWhen Vim is started with "-v" (View) then readonly mode is used (includes
X"-n").
X
XWhen Vim is started with "-s scriptfile", the characters read from
X"scriptfile" are treated as if you typed them. If end of file is reached
Xbefore the editor exits, further characters are read from the console.
X
XThe "-w" option can be used to record all typed characters in a script file.
XThis file can then be used to redo the editing, possibly on another file or
Xafter changing some commands in the script file.
X
XThe "-n" option disables the writing of a ".vim" file (see below).
X
XThe "-c command" option does the same as the the "+command" option.
X
XThe "-T terminal" option sets the terminal type.
X
X
XIn command mode:
X
XMissing command: 'Q' (go to Ex mode).
XMissing Ex commands: append, change, insert, open, preserve, recover,
X(un)abbreviate, visual, z and ~.
X
XThe command characters are shown in the last line of the screen. They are
Xremoved when the command is finished. If you do not want this (on a slow
Xterminal) reset the 'showcmd' option.
X
XIf the 'ruler' option is set, the current cursor position is shown in the
Xlast line of the screen.
X
X'u' and CTRL-R accept a count for the number of undos/redos.
X
X'U' still works after having moved off of the last changed line and after
X'u'.
X
XNulls in the file are replaced by newlines internally. This allows editing of
Xbinary files (more or less). When searching for nulls, use a newline in the
Xsearch pattern.
X
XCharacters with the 8th bit set are displayed. The characters between '~' and
X0xa0 are displayed as "~?", "~@", "~A", etc., unless the "graphic' option is
Xset.
X
X'=' is an operator to filter lines through an external command (vi: lisp
Xstuff). The name of the command can be set with the 'equalprg' option. The
Xdefault is "indent".
X
X'][' goes to the next ending of a C function ('}' in column 1).
X'[]' goes to the previous ending of a C function ('}' in column 1).
X
X'*' searches forward for the identifier under the cursor, '#' backward.
X'K' runs the program defined by the "keywordprg" option, with the identifier
Xunder the cursor as argument.
X
X'%' can be preceded with a count. The cursor jumps to the line that
Xpercentage down in the file.
X
XWith the CTRL-] command, the cursor may be in the middle of the identifier.
X
XThe used tags are remembered. Commands that can be used with the tag stack
Xare CTRL-T, ':pop' and ':tag'. ':tags' lists the tag stack.
X
XThe 'tags' option can be set to a list of tag file names. Thus multiple
Xtag files can be used.
X
XPreviously used file names are remembered in the alternate file name list.
XCTRL-^ accepts a count, which is an index in this list.
X
XSearch patterns have more features.
X
XSearches can find the end of a match and may include a character offset.
X
XCount added to '~', ':next', ':Next', 'n' and 'N'.
X
XAdded :wnext command. Same as ":write" followed by ":next".
X
XIf option "tildeop" has been set, '~' is an operator (must be followed by a
Xmovement command).
X
XWith the 'J' (join) command you can reset the 'joinspaces' (js) option to
Xhave only one space after a period (Vi inserts two spaces).
X
X'cw' can be used to change white space formed by several characters (Vi is
Xconfusing: 'cw' only changes one space, while 'dw' deletes all white space).
X
X'o' and 'O' accept a count for repeating the insert (Vi clears a part of
Xdisplay).
X
X':dis' command shows the contents of the yank buffers.
X
XPreviously used file names are remembered in the alternate file name list.
X':files' command shows the list of alternate filenames.
X'#'<N> means <N>th alternate filename in the list.
X
XFlags after command not supported (no plans to include it).
X
XQuickFix commands included, almost the same as with Manx's Z editor.
XThe 'errorfile' option has the name of the file with error messages.
X
X":cd" command shows current directory instead of going to the home directory.
X":cd ~" goes to home directory.
X
X':source!' command reads Vi commands from a file.
X
X':mkexrc' command writes current modified options and mappings to a ".exrc"
Xfile. ':mkvimrc' writes to a ".vimrc" file.
X
XThe :put! command inserts the contents of a register above the current line.
X
XThe named register '.' can be used with commands p, P and :put. The contents
Xof the register is the last inserted text.
X
X':noremap' command can be used to enter a mapping that will not be remapped.
XThis is useful to exchange the meaning of two keys.
X
X':@r' command executes buffer r (is in some versions of vi).
X
XCTRL-O/CTRL-I can be used to jump to older/newer positions. These are the
Xsame positions as used with the '' command, but may be in another file. The
X':jumps' command lists the older positions.
X
XIf the 'shiftround' option is set, an indent is rounded to a multiple of
X'shiftwidth' with '>' and '<' commands.
X
XThe 'scrolljump' option can be set to the minimal number of lines to scroll
Xwhen the cursor gets off the screen. Use this when scrolling is slow.
X
XUppercase marks can be used to jump between files. The ':marks' command lists
Xall currently set marks. The commands "']" and "`]" jump to the end of the
Xprevious operator or end of the text inserted with the put command. "'[" and
X"`[" do jump to the start.
X
XThe 'shelltype' option can be set to reflect the type of shell used.
X
XThe CTRL-A (add) and CTRL-S (subtract) commands are new. The count to the
Xcommand (default 1) is added to/subtracted from the number at or after the
Xcursor. That number may be decimal, octal (starts with a '0') or hexadecimal
X(starts with '0x'). Very useful in macros.
X
XWith the :set command the prefix "inv" can be used to invert toggle options.
X
X
XIn insert mode:
X
XThe backspace key can be used just like CTRL-D to remove auto-indents.
X
XYou can backspace, ctrl-U and CTRL-W over newlines if the 'backspace' (bs)
Xoption is set to non-zero. You can backspace over the start of insert if the
X'backspace' option is set to 2.
X
XIf the 'repdel' option is reset, a <BS> in replace mode will not delete a
Xcharacter.
X
XCTRL-T/CTRL-D always insert/delete an indent in the current line, no matter
Xwhat column the cursor is in. '0' and '^' before CTRL-D are ignored.
X
XCTRL-@ (insert previously inserted text) works always (Vi: only when typed as
Xfirst character).
X
XCTRL-A works like CTRL-@ but does not leave insert mode.
X
XCTRL-B <0-9a-z> can be used to insert the contents of a register.
X
XWhen the 'smartindent' (si) option is set, C programs will be better
Xauto-indented.
X
XCTRL-R and CTRL-E can be used to copy a character from above/below the
Xcurrent cursor position.
X
XAfter CTRL-V you can enter a three digit decimal number. This byte value is
Xinserted in the text as a single character. Useful for international
Xcharacters that are not on your keyboard.
X
XWhen the 'expandtab' (et) option is set, a <TAB> is expanded to the
Xappropriate number of spaces.
X
XThe window always reflects the contents of the buffer (Vi does not do this
Xwhen changing text and in some other cases).
X
XIf Vim is compiled with DIGRAPHS defined, digraphs are supported. A set of
Xnormal Amiga digraphs is included. They are shown with the :digraph" command.
XMore can be added with ":digraph {char1}{char2} {number}". A digraph is
Xentered with "CTRL-K {char1} {char2}" or "{char1} BS {char2}" (only when
X'digraph' option is set).
X
X
Xgeneral:
X
XMissing options: autoprint (ap), beautify (bf), edcompatible, hardtabs (ht),
Xlisp, mesg, open, optimize (op), prompt, redraw, slowopen (slow),
Xwarn, window, w300, w1200 and w9600. Terse option ignored.
X
XWhen the 'compatible' option is set, all options are set for maximum
Xvi-compatibility
X
XThe 'ttimeout' option is like 'timeout', but only works for cursor and
Xfunction keys, not for ordinary mapped characters.
X
XThere is an option for each terminal string. Can be used when termcap is not
Xsupported or to change individual strings.
X
XOn systems that have no job control (most systems but BSD-UNIX) the CTRL-Z
Xand ":stop" command starts a new shell.
X
XIf Vim is started on the Amiga without an interactive window for output, a
Xwindow is opened (and :sh still works). You can give a device to use for
Xediting with the '-d' argument, e.g. "-d con:20/20/600/150".
X
XOn startup the VIMINIT or EXINIT environment variables, the file s:.vimrc or
Xs:.exrc and .vimrc or .exrc are read for initialization commands. When
Xreading .vimrc and .exrc some commands are not allowed because of security
Xreasons (shell commands and writing to a file, :map commands are echoed).
X
XLine lenght can be upto 32767 characters, file length upto 2147483646 lines.
XIf a line is larger than the screen, the last line is filled with <@>s and
Xonly the part of the line before that is shown.
X
XThe 'columns' option is used to set or get the width of the display.
X
XThe name of the current file name is shown in the title bar of the window.
X
XWildcards in file names are expanded.
X
XOption settings are read from the first and last few lines of the file.
XOption 'modelines' determines how many lines are tried (default is 5). Note
Xthat this is different from the Vi versions that can execute any Ex command
Xin a modeline (a major security problem).
X
XIf the 'insertmode' option is set (e.g. in .exrc), Vim starts in insert mode.
X
XAll text is kept in memory. Available memory limits the file size (and other
Xthings such as undo). This may be a problem with MSDOS, is hardly a problem
Xont the Amiga and almost never with Unix.
X
XIf the "backup" or "writebackup" option is set: Before a file is overwritten,
Xa backup file (.bak) is made. If the "backup" option is set it is left
Xbehind.
X
XAll entered commands and text is written into a script file, ending in
X".vim". This can be used to recover your work if the machine crashes during
Xan edit session. This can be switched off by setting the 'updatecount' option
Xto 0 or starting Vim with the "-n" option. Use the 'directory' option for
Xplacing the .vim file somewhere else.
X
XThe 'shortname' (sn) option, when set, tells Vim that ".bak" and ".vim"
Xfilenames are to be MSDOS-like: 8 characters plus 3 for extention. This
Xshould be used on messydos or crossdos filesystems on the Amiga. If this
Xoption is off, Vim tries to guess if MSDOS filename restrictions are
Xeffective.
X
XRecovery after a crash has a smaller chance for success, because there is no
Xtemporary file.
X
XError messages are shown at least one second (Vi overwrites error messages).
X
XIf Vim asks to "Hit RETURN to continue", you can hit any key. Characters
Xother than <CR>, <NL> and <SPACE> are interpreted as the (start of) a
Xcommand. (Vi only accepts a command starting with ':').
X
XThe contents of the numbered registers is remembered when changing files.
X
XThe AUX: device of the Amiga is supported.
X
Xvi:tw=77:
END_OF_FILE
if test 14014 -ne `wc -c <'vim/doc/difference.doc'`; then
echo shar: \"'vim/doc/difference.doc'\" unpacked with wrong size!
fi
# end of 'vim/doc/difference.doc'
fi
if test -f 'vim/src/termlib.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/termlib.c'\"
else
echo shar: Extracting \"'vim/src/termlib.c'\" \(15527 characters\)
sed "s/^X//" >'vim/src/termlib.c' <<'END_OF_FILE'
X/* vi:sw=4:ts=4:
X The following software is (C) 1984 Peter da Silva,
X the Mad Australian, in the public domain. It may
X be re-distributed for any purpose with the inclusion
X of this notice. */
X/* modified by Bram Moolenaar */
X
X/* TERMLIB: Terminal independant database. */
X
X#include "vim.h"
X#include "proto.h"
X#include "proto/termlib.pro"
X
X#ifndef AMIGA
X# include <sgtty.h>
X#endif
X
Xstatic int getent __PARMS((char *, char *, FILE *, int));
Xstatic int nextent __PARMS((char *, FILE *, int));
Xstatic int _match __PARMS((char *, char *));
Xstatic char *_addfmt __PARMS((char *, char *, int));
Xstatic char *_find __PARMS((char *, char *));
X
X/*
X * Global variables for termlib
X */
X
Xchar *tent; /* Pointer to terminal entry, set by tgetent */
Xchar PC = 0; /* Pad character, default NULL */
Xchar *UP = 0, *BC = 0; /* Pointers to UP and BC strings from database */
Xshort ospeed; /* Baud rate (1-16, 1=300, 16=19200), as in stty */
X
X/*
X * Module: tgetent
X *
X * Purpose: Get termcap entry for <term> into buffer at <tbuf>.
X *
X * Calling conventions: char tbuf[TBUFSZ+], term=canonical name for
X * terminal.
X *
X * Returned values: 1 = success, -1 = can't open file,
X * 0 = can't find terminal.
X *
X * Notes
X * Should probably supply static buffer.
X *
X * Uses environment variables "TERM" and
X * "TERMCAP". If TERM = term (that is, if the argument
X * matches the environment) then it looks at TERMCAP.
X * If TERMCAP begins with a slash, then it assumes
X * this is the file to search rather than /etc/termcap.
X * If TERMCAP does not begin with a slash, and it
X * matches TERM, then this is used as the entry.
X *
X * This could be simplified considerably for non-UNIX
X * systems.
X */
X
X#ifdef AMIGA
X# define TERMCAPFILE "s:termcap"
X#else
X# define TERMCAPFILE "/etc/termcap"
X#endif
X
Xtgetent(tbuf, term)
X char *tbuf; /* Buffer to hold termcap entry, TBUFSZ bytes max */
X char *term; /* Name of terminal */
X{
X char tcbuf[32]; /* Temp buffer to handle */
X char *tcptr = tcbuf; /* extended entries */
X char *tcap = TERMCAPFILE; /* Default termcap file */
X char *tmp;
X FILE *termcap;
X int retval = 0;
X int len;
X
X if ((tmp = (char *)vimgetenv("TERMCAP")) != NULL)
X {
X if (*tmp == '/') /* TERMCAP = name of termcap file */
X tcap = tmp ;
X else /* TERMCAP = termcap entry itself */
X {
X int tlen = strlen(term);
X
X while (*tmp && *tmp != ':') /* Check if TERM matches */
X {
X while (*tmp == '|')
X tmp++;
X if (_match(tmp, term) == tlen)
X {
X strcpy(tbuf, tmp);
X tent = tbuf;
X return 1;
X }
X else
X tmp = _find(tmp, ":|");
X }
X }
X }
X if (!(termcap = fopen(tcap, "r")))
X {
X strcpy(tbuf, tcap);
X return -1;
X }
X
X len = 0;
X while (getent(tbuf + len, term, termcap, TBUFSZ - len))
X {
X if ((term = tgetstr("tc", &tcptr))) /* extended entry */
X {
X rewind(termcap);
X len = strlen(tbuf);
X }
X else
X {
X retval = 1;
X tent = tbuf;
X break;
X }
X }
X fclose(termcap);
X return retval;
X}
X
X static int
Xgetent(tbuf, term, termcap, buflen)
X char *tbuf, *term;
X FILE *termcap;
X int buflen;
X{
X char *tptr;
X int tlen = strlen(term);
X
X while (nextent(tbuf, termcap, buflen)) /* For each possible entry */
X {
X tptr = tbuf;
X while (*tptr && *tptr != ':') /* : terminates name field */
X {
X while (*tptr == '|') /* | seperates names */
X tptr++;
X if (_match(tptr, term) == tlen) /* FOUND! */
X {
X tent = tbuf;
X return 1;
X }
X else /* Look for next name */
X tptr = _find(tptr, ":|");
X }
X }
X return 0;
X}
X
X static int
Xnextent(tbuf, termcap, buflen) /* Read 1 entry from TERMCAP file */
X char *tbuf;
X FILE *termcap;
X int buflen;
X{
X char *lbuf = tbuf; /* lbuf=line buffer */
X /* read lines straight into buffer */
X
X while (lbuf < tbuf+buflen && /* There's room and */
X fgets(lbuf, (int)(tbuf+buflen-lbuf), termcap)) /* another line */
X {
X int llen = strlen(lbuf);
X
X if (*lbuf == '#') /* eat comments */
X continue;
X if (lbuf[-1] == ':' && /* and whitespace */
X lbuf[0] == '\t' &&
X lbuf[1] == ':')
X {
X strcpy(lbuf, lbuf+2);
X llen -= 2;
X }
X if (lbuf[llen-2] == '\\') /* and continuations */
X lbuf += llen-2;
X else
X {
X lbuf[llen-1]=0; /* no continuation, return */
X return 1;
X }
X }
X
X return 0; /* ran into end of file */
X}
X
X/*
X * Module: tgetflag
X *
X * Purpose: returns flag true or false as to the existence of a given
X * entry. used with 'bs', 'am', etc...
X *
X * Calling conventions: id is the 2 character capability id.
X *
X * Returned values: 1 for success, 0 for failure.
X */
X
Xtgetflag(id)
X char *id;
X{
X char buf[256], *ptr = buf;
X
X return tgetstr(id, &ptr) ? 1 : 0;
X}
X
X/*
X * Module: tgetnum
X *
X * Purpose: get numeric value such as 'li' or 'co' from termcap.
X *
X * Calling conventions: id = 2 character id.
X *
X * Returned values: -1 for failure, else numerical value.
X */
X
Xtgetnum(id)
Xchar *id;
X{
X char *ptr, buf[256];
X ptr = buf;
X
X if (tgetstr(id, &ptr))
X return atoi(buf);
X else
X return 0;
X}
X
X/*
X * Module: tgetstr
X *
X * Purpose: get terminal capability string from database.
X *
X * Calling conventions: id is the two character capability id.
X * (*buf) points into a hold buffer for the
X * id. the capability is copied into the buffer
X * and (*buf) is advanced to point to the next
X * free byte in the buffer.
X *
X * Returned values: 0 = no such entry, otherwise returns original
X * (*buf) (now a pointer to the string).
X *
X * Notes
X * It also decodes certain escape sequences in the buffer.
X * they should be obvious from the code:
X * \E = escape.
X * \n, \r, \t, \f, \b match the 'c' escapes.
X * ^x matches control-x (^@...^_).
X * \nnn matches nnn octal.
X * \x, where x is anything else, matches x. I differ
X * from the standard library here, in that I allow ^: to match
X * :.
X *
X */
X
Xchar *
Xtgetstr(id, buf)
Xchar *id, **buf;
X{
X int len = strlen(id);
X char *tmp=tent;
X char *hold;
X int i;
X
X do {
X tmp = _find(tmp, ":"); /* For each field */
X while (*tmp == ':') /* skip empty fields */
X tmp++;
X if (!*tmp)
X break;
X
X if (_match(id, tmp) == len) {
X tmp += len; /* find '=' '@' or '#' */
X if (*tmp == '@') /* :xx@: entry for tc */
X return 0; /* deleted entry */
X hold= *buf;
X while (*++tmp && *tmp != ':') {/* not at end of field */
X switch(*tmp) {
X case '\\': /* Expand escapes here */
X switch(*++tmp) {
X case 0: /* ignore backslashes */
X tmp--; /* at end of entry */
X break; /* shouldn't happen */
X case 'e':
X case 'E': /* ESC */
X *(*buf)++ = '\033';
X break;
X case 'n': /* \n */
X *(*buf)++ = '\n';
X break;
X case 'r': /* \r */
X *(*buf)++ = '\r';
X break;
X case 't': /* \t */
X *(*buf)++ = '\t';
X break;
X case 'b': /* \b */
X *(*buf)++ = '\b';
X break;
X case 'f': /* \f */
X *(*buf)++ = '\f';
X break;
X case '0': /* \nnn */
X case '1':
X case '2':
X case '3':
X case '4':
X case '5':
X case '6':
X case '7':
X case '8':
X case '9':
X **buf = 0;
X /* get up to three digits */
X for (i = 0; i < 3 && isdigit(*tmp); ++i)
X **buf = **buf * 8 + *tmp++ - '0';
X (*buf)++;
X tmp--;
X break;
X default: /* \x, for all other x */
X *(*buf)++= *tmp;
X }
X break;
X case '^': /* control characters */
X *(*buf)++ = *++tmp - '@';
X break;
X default:
X *(*buf)++ = *tmp;
X }
X }
X *(*buf)++ = 0;
X return hold;
X }
X } while (*tmp);
X
X return 0;
X}
X
X/*
X * Module: tgoto
X *
X * Purpose: decode cm cursor motion string.
X *
X * Calling conventions: cm is cursor motion string.
X * line, col, are the desired destination.
X *
X * Returned values: a string pointing to the decoded string, or
X * "OOPS" if it cannot be decoded.
X *
X * Notes
X * The accepted escapes are:
X * %d as in printf, 0 origin.
X * %2, %3 like %02d, %03d in printf.
X * %. like %c
X * %+x adds <x> to value, then %.
X * %>xy if value>x, adds y. No output.
X * %i increments line& col, no output.
X * %r reverses order of line&col. No output.
X * %% prints as a single %.
X * %n exclusive or row & col with 0140.
X * %B BCD, no output.
X * %D reverse coding (x-2*(x%16)), no output.
X */
X
Xchar *
Xtgoto(cm, col, line)
Xchar *cm; /* cm string, from termcap */
Xint col, /* column, x position */
X line; /* line, y position */
X{
X char gx, gy, /* x, y */
X *ptr, /* pointer in 'cm' */
X reverse = 0, /* reverse flag */
X *bufp, /* pointer in returned string */
X addup = 0, /* add upline */
X addbak = 0, /* add backup */
X c;
X static char buffer[32];
X
X if (!cm)
X return "OOPS"; /* Kludge, but standard */
X
X bufp = buffer;
X ptr = cm;
X
X while (*ptr) {
X if ((c = *ptr++) != '%') { /* normal char */
X *bufp++ = c;
X } else { /* % escape */
X switch(c = *ptr++) {
X case 'd': /* decimal */
X bufp = _addfmt(bufp, "%d", line);
X line = col;
X break;
X case '2': /* 2 digit decimal */
X bufp = _addfmt(bufp, "%02d", line);
X line = col;
X break;
X case '3': /* 3 digit decimal */
X bufp = _addfmt(bufp, "%03d", line);
X line = col;
X break;
X case '>': /* %>xy: if >x, add y */
X gx = *ptr++;
X gy = *ptr++;
X if (col>gx) col += gy;
X if (line>gx) line += gy;
X break;
X case '+': /* %+c: add c */
X line += *ptr++;
X case '.': /* print x/y */
X if (line == '\t' || /* these are */
X line == '\n' || /* chars that */
X line == '\004' || /* UNIX hates */
X line == '\0') {
X line++; /* so go to next pos */
X if (reverse == (line == col))
X addup=1; /* and mark UP */
X else
X addbak=1; /* or BC */
X }
X *bufp++=line;
X line = col;
X break;
X case 'r': /* r: reverse */
X gx = line;
X line = col;
X col = gx;
X reverse = 1;
X break;
X case 'i': /* increment (1-origin screen) */
X col++;
X line++;
X break;
X case '%': /* %%=% literally */
X *bufp++='%';
X break;
X case 'n': /* magic DM2500 code */
X line ^= 0140;
X col ^= 0140;
X break;
X case 'B': /* bcd encoding */
X line = line/10<<4+line%10;
X col = col/10<<4+col%10;
X break;
X case 'D': /* magic Delta Data code */
X line = line-2*(line&15);
X col = col-2*(col&15);
X break;
X default: /* Unknown escape */
X return "OOPS";
X }
X }
X }
X
X if (addup) /* add upline */
X if (UP) {
X ptr=UP;
X while (isdigit(*ptr) || *ptr == '.')
X ptr++;
X if (*ptr == '*')
X ptr++;
X while (*ptr)
X *bufp++ = *ptr++;
X }
X
X if (addbak) /* add backspace */
X if (BC) {
X ptr=BC;
X while (isdigit(*ptr) || *ptr == '.')
X ptr++;
X if (*ptr == '*')
X ptr++;
X while (*ptr)
X *bufp++ = *ptr++;
X }
X else
X *bufp++='\b';
X
X *bufp = 0;
X
X return(buffer);
X}
X
X/*
X * Module: tinit
X *
X * Purpose: simplified terminal initialisation.
X *
X * Calling conventions: name is name of terminal.
X *
X * Returned values: none.
X *
X * Notes
X * tinit calls tgetent, then sets up the global
X * variables PC, UP, BC, ospeed appropriately.
X *
X */
X
X#if 0 /* already included in term.c */
X
Xchar tbuf[TBUFSZ]; /* Buffer for termcap entry */
Xchar junkbuf[TBUFSZ]; /* Big buffer for junk */
Xchar *junkptr;
X
Xtinit(name)
Xchar *name;
X{
X#ifndef AMIGA
X struct sgttyb sgbuf;
X#endif
X char *ps;
X
X junkptr = junkbuf;
X
X tgetent(tbuf, name);
X
X ps = tgetstr("pc", &junkptr);
X if (ps) PC = *ps;
X UP = tgetstr("up", &junkptr);
X BC = tgetstr("bc", &junkptr);
X
X#ifdef AMIGA
X ospeed=0;
X#else
X gtty(1, &sgbuf);
X ospeed=sgbuf.sg_ospeed;
X#endif
X return 0;
X}
X#endif
X
X/*
X * Module: tputs
X *
X * Purpose: decode padding information
X *
X * Calling conventions: cp = string to be padded, affcnt = # of items
X * affected (lines, characters, whatever),
X * outc = routine to output 1 character.
X *
X * Returned values: none
X *
X * Notes
X * cp has padding information ahead of it, in the form
X * nnnTEXT or nnn*TEXT. nnn is the number of milliseconds to delay,
X * and may be a decimal (nnn.mmm). If the asterisk is given, then
X * the delay is multiplied by afcnt. The delay is produced by outputting
X * a number of nulls (or other padding char) after printing the
X * TEXT.
X *
X */
X
Xlong _bauds[16]={
X 0, 50, 75, 110,
X 134, 150, 200, 300,
X 600, 1200, 1800, 2400,
X 4800, 9600, 19200, 19200 };
X
Xtputs(cp, affcnt, outc)
Xchar *cp; /* string to print */
Xint affcnt; /* Number of lines affected */
Xvoid (*outc) __ARGS((unsigned int)); /* routine to output 1 character */
X{
X long frac, /* 10^(#digits after decimal point) */
X counter, /* digits */
X atol();
X
X if (isdigit(*cp)) {
X counter = 0;
X frac = 1000;
X while (isdigit(*cp))
X counter = counter * 10L + (long)(*cp++ - '0');
X if (*cp == '.')
X while (isdigit(*++cp)) {
X counter = counter * 10L + (long)(*cp++ - '0');
X frac = frac * 10;
X }
X if (*cp!='*') { /* multiply by affected lines */
X if (affcnt>1) affcnt = 1;
X }
X else
X cp++;
X
X /* Calculate number of characters for padding counter/frac ms delay */
X if (ospeed)
X counter = (counter * _bauds[ospeed] * (long)affcnt) / frac;
X
X while (*cp) /* output string */
X (*outc)(*cp++);
X if (ospeed)
X while (counter--) /* followed by pad characters */
X (*outc)(PC);
X }
X else
X while (*cp)
X (*outc)(*cp++);
X return 0;
X}
X
X/*
X * Module: tutil.c
X *
X * Purpose: Utility routines for TERMLIB functions.
X *
X */
X
X static int
X_match(s1, s2) /* returns length of text common to s1 and s2 */
Xchar *s1, *s2;
X{
X int i = 0;
X
X while (s1[i] && s1[i] == s2[i])
X i++;
X
X return i;
X}
X
X static char *
X_find(s, set) /* finds next c in s that's a member of set, returns pointer */
Xchar *s, *set;
X{
X for(; *s; s++) {
X char *ptr = set;
X
X while (*ptr && *s != *ptr)
X ptr++;
X
X if (*ptr)
X return s;
X }
X
X return s;
X}
X
X static char *
X_addfmt(buf, fmt, val) /* add val to buf according to format fmt */
Xchar *buf, *fmt;
Xint val;
X{
X sprintf(buf, fmt, val);
X while (*buf)
X buf++;
X return buf;
X}
END_OF_FILE
if test 15527 -ne `wc -c <'vim/src/termlib.c'`; then
echo shar: \"'vim/src/termlib.c'\" unpacked with wrong size!
fi
# end of 'vim/src/termlib.c'
fi
if test -f 'vim/src/version.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/version.c'\"
else
echo shar: Extracting \"'vim/src/version.c'\" \(14258 characters\)
sed "s/^X//" >'vim/src/version.c' <<'END_OF_FILE'
X/* vi:ts=4:sw=4:tw=77
X *
X *
X * VIM - Vi IMitation
X *
X * Code Contributions By: Bram Moolenaar mool@oce.nl
X * Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*
X Started with Stevie version 3.6 (Fish disk 217) - GRWalter (Fred)
X
X VIM 1.0 - Changed so many things that I felt that a new name was required
X (I didn't like the name Stevie that much: I don't have an ST).
X - VIM stands for "Vi IMitation".
X - New storage structure, MULTI-LEVEL undo and redo,
X improved screen output, removed an awful number of bugs,
X removed fixed size buffers, added counts to a lot of commands,
X added new commands, added new options, added 'smart indent',
X added recording mode, added script files, moved help to a file,
X etc. etc. etc.
X - Compiles under Manx/Aztec C 5.0. You can use "rez" to make VIM
X resident.
X - Bram Moolenaar (Mool)
X
X VIM 1.09 - spaces can be used in tags file instead of tabs (compatible with
X Manx ctags).
X
X VIM 1.10 - Csh not required anymore for CTRL-D. Search options /e and /s added.
X Shell option implemented. BS in replace mode does not delete
X character. Backspace, wrapmargin and tags options added.
X Added support for Manx's QuickFix mode (just like "Z").
X The ENV: environment variables instead of the Old Manx environment
X variables are now used, because Vim was compiled with version 5.0d
X of the compiler. "mool" library not used anymore. Added index to
X help screens.
X
X VIM 1.11 - removed bug that caused :e of same file, but with name in upper case,
X to re-edit that file.
X
X VIM 1.12 - The second character of several commands (e.g. 'r', 't', 'm') not
X :mapped anymore (UNIX vi does it like this, don't know why); Some
X operators did not work when doing a 'l' on the last character in
X a line (e.g. 'yl'); Added :mapping when executing registers;
X Removed vi incompatibility from 't' and 'T' commands; :mapping! also
X works for command line editing; Changed a few details to have Vim
X run the macros for solving a maze and Towers of Hanoi! It now also
X runs the Turing machine macros!
X
X VIM 1.13 - Removed a bug for !! on empty line. "$" no longer puts cursor at
X the end of the line when combined with an operator. Added
X automatic creation of a script file for recovery after a crash.
X Added "-r" option. Solved bug for not detecting end of script file.
X ".bak" is now appended, thus "main.c" and "main.h" will have
X separate backup files.
X
X VIM 1.14 - Removed a few minor bugs. Added "-n" option to skip autoscript.
X Made options more Vi compatible. Improved ^C handling. On serious
X errors typahead and scripts are discarded. 'U' is now correctly
X undone with 'u'. Fixed showmatch() handling of 'x' and '\x'.
X Solved window size dependency for scripts by adding ":winsize"
X commands to scripts. This version released on Fish disk 591.
X
X VIM 1.15 - No extra return in recording mode (MCHAR instead of MLINE buffer).
X plural() argument is now a long. Search patterns shared between
X :g, :s and /. After recovery a message is given. Overflow of mapbuf
X is detected. Line number possible with :read. Error message when
X characters follow a '$' in a search pattern. Cause for crash
X removed: ":s/pat/repl/g" allocated not enough memory. Option
X "directory" added. Option "expandtab" added. Solved showmode non-
X functioning. Solved bug with window resizing. Removed some *NULL
X references. CTRL-], * and # commands now skips non-identifier
X characters. Added tag list, CTRL-T, :pop and :tags commands.
X Added jump list, CTRL-O and CTRL-I commands. Added "shiftround"
X option. Applied AUX and Lattice mods from Juergen Weigert.
X Finally made linenr_t a long, files can be > 65000 lines!
X :win command could be written to script file halfway a command.
X Option shelltype added. With ^V no mapping anymore.
X Added :move, :copy, :t, :mark and :k. Improved Ex address parsing.
X Many delimiters possible with :s.
X
X VIM 1.16 - Solved bug with zero line number in Ex range. Added file-number to
X jump list. Solved bug when scrolling downwards. Made tagstack vi
X compatible. Cmdline editing: CTRL-U instead of '@'. Made Vim DICE
X compatible. Included regexp improvements from Olaf Seibert,
X mapstring() removed. Removed bug with CTRL-U in insert mode.
X Count allowed before ". Added uppercase (file) marks. Added
X :marks command. Added joinspaces option. Added :jumps command. Made
X jumplist compatible with tag list. Added count to :next and :Next.
X
X VIM 1.17 - Removed '"' for Ex register name. Repaired stupid bug in tag code.
X Now compiled with Aztec 5.2a. Changed Arpbase.h for use with 2.04
X includes. Added repdel option. Improved :set listing. Added count
X to 'u' and CTRL-R commands. "vi:" and "ex:" in modelines must now
X be preceded with a blank. Option "+command" for command line and
X :edit command added.
X
X VIM 1.18 - Screen was not updated when all lines deleted. Readfile() now
X puts cursor on first new line. Catch strange disk label.
X Endless "undo line missing" loop removed. With empty file 'O' would
X cause this. Added window size reset in windexit(). Flush .vim file
X only when buffer has been changed. Added the nice things from
X Elvis 1.5: Added "equalprg" and "ruler" option. Added quoting.
X Added third meaning to 'backspace' option: backspacing over start
X of insert. Added "-c {command}" command line option. Made generating
X of prototypes automatically. Added insert mode command CTRL-O and
X arrow keys. CTRL-T/CTRL-D now always insert/delete indent. When
X starting an edit on specified lnum there was redraw of first lines.
X Added 'inputmode' option. Added CTRL-A and CTRL-S commands. '`' is
X now exclusive (as it should be). Added digraphs as an option.
X Changed implementation of parameters. Added :wnext command.
X Added ':@r' command. Changed handling of CTRL-V in command line.
X Block macros now work. Added keyword lookup command 'K'. Added
X CTRL-N and CTRL-P to command line editing. For DOS 2.0x the Flush
X function is used for the autoscript file; this should solve the
X lockup bug. Added wait_return to msg() for long messages.
X
X VIM 1.19 - Changes from Juergen Weigert:
X Terminal type no longer restricted to machine console. New
X option -T terminal. New set option "term". Builtin termcap
X entries for "amiga", "ansi", "atari", "nansi", "pcterm".
X Ported to MSDOS. New set option "textmode" ("tx") to control
X CR-LF translation. CTRL-U and CTRL-D scroll half a screen full,
X rather than 12 lines. New set option "writebackup" ("wb") to
X disable even the 'backup when writing' feature.
X Ported to SunOS. Full termcap support. Does resize on SIGWINCH.
X
X Made storage.c portable. Added reading of ".vimrc". Added
X 'helpfile' option. With quoting the first char of an empty line
X is inverted. Optimized screen updating a bit. Startup code
X looks for VIMINIT variable and .vimrc file first. Added option
X helpfile. Solved bug of inserting deletes: redefined ISSPECIAL.
X Changed inchar() to use key codes from termcap. Added parameters
X for terminal codes. Replaced aux device handling by amiga window
X handling. Added optional termcap code. Added 'V', format
X operator.
X
X VIM 1.20 - wait_return only ignores CR, LF and space. 'V' also works for
X single line. No redrawing while formatting text. Added CTRL-Z.
X Added usage of termcap "ks" and "ke". Fixed showmatch().
X Added timeout option. Added newfile argument to readfile().
X
X VIM 1.21 - Added block mode. Added 'o' command for quoting. Added :set inv.
X Added pos2ptr(). Added repeating and '$' to Quoting.
X
X VIM 1.22 - Fixed a bug in doput() with count > 1.
X Port to linux by Juergen Weigert included.
X More unix semantics in writeit(), forceit flag ignores errors while
X preparing backup file. For UNIX, backup is now copied, not moved.
X When the current directory is not writable, vim now tries a backup
X in the directory given with the backupdir option. For UNIX, raw mode
X has now ICRNL turned off, that allowes ^V^M. Makefiles for BSD,
X SYSV, and linux unified in makefile.unix. For MSDOS
X mch_get_winsize() implemented. Reimplemented builtin termcaps in
X term.c and term.h. set_term() now handles all cases. Even builtins
X when TERMCAP is defined. Show "..." while doing filename completion.
X
X VIM 1.23 - Improved MSDOS version: Added function and cursor keys to builtin
X pcterm. Replaced setmode by settmode, delay by vim_delay and
X delline by dellines to avoid name conflicts. Made F1 help key.
X Renamed makecmdtab to mkcmdtab and cmdsearch to csearch for
X 8 char name limit. Wildcard expansion adds *.* to names without a
X dot. Added shell execution.
X For unix: writeit() overwrites readonly files when forced write,
X more safety checks. Termcap buffer for linux now 2048 bytes.
X Expandone() no longer appends "*" to file name. Added "graphic"
X option. Added ':' command to quoting.
X
X VIM 1.24 Adjusted number of spaces inserted by dojoin(). MSDOS version uses
X searchpath() to find helpfile. Fixed a few small problems. Fixed
X nasty bug in getperm() for SAS 6.0. Removed second argument from
X wait_return(). Script files accessed in binary mode with MSDOS.
X Added 'u' and 'U' commands to quoting (make upper or lower case).
X Added "CTRL-V [0-9]*" to enter any byte value. Fixed doput().
X Dodis() displays register 0. Added CTRL-B to insert mode. Attempt
X to fix the lockup bug by adding Delay() to startscript(). -v
X option now implies -n option. doformat() added to improve 'V'
X command. Replace bool_t with int. Fixed handling of \& and ~ in
X regsub(). Added interrupt handling in msdos.c for ctrl-break and
X critical errors. Added scrolljump option. Added :stop. Added -d
X argument. Fixed bug in quickfix startup from cli. Fixed enforcer
X hit with aux:. Added CTRL-C handling to unix.c. Fixed "O<BS><CR>"
X bug with autoindent. Worked around :cq not working by adding a
X printf()!? Added default mapping for MSDOS PageUp etc. Fixed
X cursor position after 'Y'. Added shift-cursor commands. Changed
X ExpandFile() to keep names with errors. Added CLEAR and CURSUPD
X arguments to updateScreen(). Fixed CTRL-@ after a change command.
X modname() changes '.' into '_'. Added emptyrows to screen.c.
X Fixed redo of search with offset. Added count to 'z' command.
X Made :so! work with :global. Added writing of cursor postition to
X startscript(). Minimized terminal requirements. Fixed problem
X with line in tags file with mixed spaces and tabs. Fixed problem
X with pattern "\\" in :s and :g. This version posted on Usenet.
X
X VIM 1.25 Improved error messages for :set. Open helpfile in binary mode
X for MSDOS. Fixed ignorecase for Unix in cstrncmp(). Fixed read
X from NULL with :tags after vim -t. Repaired 'z' command. Changed
X outnum() for >32767. In msdos.c flushbuf did write(1, .. instead
X of write(0, .. Added secure to fix security. Fixed pointer
X use after free() bug in regsub() (made :s fail under MSDOS).
X Added nofreeNULL(), needed for some UNIXes. Improved window
X resizing for Unix. Fixed messages for report == 0. Added
X bsdmemset(). Changed a few small things for portability. Added
X :list. Made '0' and '^' exclusive. Fixed regexp for /pattern*
X (did /(pattern)* instead of /pattern(n)*). Added "']" and "'[".
X Changed Delay(2L) into Delay(10L). Made 'timeout' option
X vi-compatible, added 'ttimeout' option. Changed TIOCSETP to
X TIOCSETN in unix.c. Added "ti" and "te" termcap entries, makes
X sun cmdtool work. Added stop- and starttermcap(). Use cooked
X output for listings on Amiga only. Added "starting" flag, no ~s
X anymore with every startup. Modname made portable; Added
X 'shortname' option, Fixed problems with .vim file on messydos.
X Global .exrc/.vimrc for Unix added. Added patches for SCO Xenix.
X Add :w argument to list of alternate file names. Applied a few
X changes for HPUX. Added Flock in writeit() for safety. Command
X ":'a,'bm." moved to 'b instead of current line. Argument in
X 'shell' option allowed. Re-implemented :copy and :move. Fixed
X BS-CR-BS on empty line bug in edit.c. -t option was ignored if
X there is a file ".vim". Changed amiga.c to work without
X arp.library for dos 2.0. Fixed "\$" and "\^" in regexp. Fixed
X pipe in filter command. Fixed CTRL-U and CTRL-D. With '}' indent
X in front of the cursor is included in the operated text. Fixed
X tag with '[' in search pattern. Added CTRL-V to 'r'. Fixed "tc"
X entry in termlib.c. term_console now default off. Added :noremap
X and ^V in :map argument. Replaced CTRL by Ctrl because some
X unixes have this already. Fixed "Empty file" message disappearing
X when there is no .exrc file. Added CTRL-K for entering digraphs.
X Removed escape codes from vim.hlp, added handling of inversion to
X help().
X
X VIM 1.26 For Unix: Removed global .exrc; renamed global .vimrc to vimrc.
X Moved names of *rc and help files to makefile. Added various
X little changes for different kinds of Unix. Changed CR-LF
X handling in dosource() for MSDOS. Added :mkvimrc. Fixed
X WildExpand in unix.c for empty file. Fixed incompatibility with
X msdos share program (removed setperm(fname, 0) from fileio.c).
X Added ":set compatible". Fixed 'history=0'.
X
X VIM 1.27 Added USE_LOCALE. Changed swapchar() to use toupper() and
X tolower(). Changed init order: .vimrc before EXINIT. Half-fixed
X lines that do not fit on screen. A few minor bug fixes. Fixed
X typehead bug in Read() in unix.c. Added :number. Reset IXON flag
X in unix.c for CTRL-Q. In tags file any Ex command can be used. Ex
X search command accepts same flags as normal search command. Fixed
X '?' in tag search pattern. 'New file' message was wrong when 'bk'
X and 'wb' options were both off.
X*/
X
Xchar *Version = "VIM 1.27";
X#if !defined(linux) && defined(BSD) || defined(SYSV)
Xchar *longVersion = "Vi IMitation 1.27 (1993 April 6) by Bram Moolenaar";
X#else
Xchar *longVersion = "Vi IMitation 1.27 (" __DATE__ " " __TIME__ ") by Bram Moolenaar";
X#endif
END_OF_FILE
if test 14258 -ne `wc -c <'vim/src/version.c'`; then
echo shar: \"'vim/src/version.c'\" unpacked with wrong size!
fi
# end of 'vim/src/version.c'
fi
echo shar: End of archive 7 \(of 23\).
cp /dev/null ark7isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 23 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
-------------8<----------------8<----------------8<---------------8<--------
Bram Moolenaar | DISCLAIMER: This note does not
Oce Nederland B.V., Research & Development | necessarily represent the position
p.o. box 101, 5900 MA Venlo | of Oce-Nederland B.V. Therefore
The Netherlands phone +31 77 594077 | no liability or responsibility for
UUCP: mool@oce.nl fax +31 77 595450 | whatever will be accepted.
exit 0 # Just in case...