📄 vi.h
字号:
/* vi.h *//* Author: * Steve Kirkendall * 14407 SW Teal Blvd. #C * Beaverton, OR 97005 * kirkenda@cs.pdx.edu */#define VERSION "ELVIS 1.5, by Steve Kirkendall (23 March 1992)"#define COPYING "This version of ELVIS is freely redistributable."#include <errno.h>extern int errno;#if TOS && !defined(__GNUC__)#define ENOENT (-AEFILNF)#endif#if TOS || VMS# include <types.h># define O_RDONLY 0# define O_WRONLY 1# define O_RDWR 2# ifdef __GNUC__# define S_IJDIR S_IFDIR# endif#else# if OSK# include <modes.h># define O_RDONLY S_IREAD# define O_WRONLY S_IWRITE# define O_RDWR (S_IREAD | S_IWRITE)# define ENOENT E_PNNF# define sprintf Sprintf# else# include <sys/types.h># if COHERENT# include <sys/fcntl.h># else# include <fcntl.h># endif# endif#endif#ifndef O_BINARY# define O_BINARY 0#endif#include "curses.h"#include <signal.h>/*------------------------------------------------------------------------*//* Miscellaneous constants. */#define INFINITY 2000000001L /* a very large integer */#define LONGKEY 10 /* longest possible raw :map key */#ifndef MAXRCLEN# define MAXRCLEN 1000 /* longest possible :@ command */#endif/*------------------------------------------------------------------------*//* These describe how temporary files are divided into blocks */#define MAXBLKS (BLKSIZE / sizeof(unsigned short))typedef union{ char c[BLKSIZE]; /* for text blocks */ unsigned short n[MAXBLKS]; /* for the header block */} BLK;/*------------------------------------------------------------------------*//* These are used manipulate BLK buffers. */extern BLK hdr; /* buffer for the header block */extern BLK *blkget(); /* given index into hdr.c[], reads block */extern BLK *blkadd(); /* inserts a new block into hdr.c[] *//*------------------------------------------------------------------------*//* These are used to keep track of various flags */extern struct _viflags{ short file; /* file flags */} viflags;/* file flags */#define NEWFILE 0x0001 /* the file was just created */#define READONLY 0x0002 /* the file is read-only */#define HADNUL 0x0004 /* the file contained NUL characters */#define MODIFIED 0x0008 /* the file has been modified, but not saved */#define NOFILE 0x0010 /* no name is known for the current text */#define ADDEDNL 0x0020 /* newlines were added to the file */#define HADBS 0x0040 /* backspace chars were lost from the file */#define UNDOABLE 0x0080 /* file has been modified */#define NOTEDITED 0x0100 /* the :file command has been used *//* macros used to set/clear/test flags */#define setflag(x,y) viflags.x |= y#define clrflag(x,y) viflags.x &= ~y#define tstflag(x,y) (viflags.x & y)#define initflags() viflags.file = 0;/* The options */extern char o_autoindent[1];extern char o_autoprint[1];extern char o_autotab[1];extern char o_autowrite[1];extern char o_columns[3];extern char o_directory[30];extern char o_edcompatible[1];extern char o_equalprg[80];extern char o_errorbells[1];extern char o_exrefresh[1];extern char o_ignorecase[1];extern char o_keytime[3];extern char o_keywordprg[80];extern char o_lines[3];extern char o_list[1];extern char o_number[1];extern char o_readonly[1];extern char o_remap[1];extern char o_report[3];extern char o_scroll[3];extern char o_shell[60];extern char o_shiftwidth[3];extern char o_sidescroll[3];extern char o_sync[1];extern char o_tabstop[3];extern char o_term[30];extern char o_flash[1];extern char o_warn[1];extern char o_wrapscan[1];#ifndef CRUNCHextern char o_beautify[1];extern char o_exrc[1];extern char o_mesg[1];extern char o_more[1];extern char o_novice[1];extern char o_prompt[1];extern char o_taglength[3];extern char o_terse[1];extern char o_window[3];extern char o_wrapmargin[3];extern char o_writeany[1];#endif#ifndef NO_ERRLISTextern char o_cc[30];extern char o_make[30];#endif#ifndef NO_CHARATTRextern char o_charattr[1];#endif#ifndef NO_DIGRAPHextern char o_digraph[1];extern char o_flipcase[80];#endif#ifndef NO_SENTENCEextern char o_hideformat[1];#endif#ifndef NO_EXTENSIONSextern char o_inputmode[1];extern char o_ruler[1];#endif#ifndef NO_MAGICextern char o_magic[1];#endif#ifndef NO_MODELINESextern char o_modelines[1];#endif#ifndef NO_SENTENCEextern char o_paragraphs[30];extern char o_sections[30];#endif#if MSDOSextern char o_pcbios[1];#endif#ifndef NO_SHOWMATCHextern char o_showmatch[1];#endif#ifndef NO_SHOWMODEextern char o_smd[1];#endif/*------------------------------------------------------------------------*//* These help support the single-line multi-change "undo" -- shift-U */extern char U_text[BLKSIZE];extern long U_line;/*------------------------------------------------------------------------*//* These are used to refer to places in the text */typedef long MARK;#define markline(x) (long)((x) / BLKSIZE)#define markidx(x) (int)((x) & (BLKSIZE - 1))#define MARK_UNSET ((MARK)0)#define MARK_FIRST ((MARK)BLKSIZE)#define MARK_LAST ((MARK)(nlines * BLKSIZE))#define MARK_AT_LINE(x) ((MARK)(x) * BLKSIZE)#define NMARKS 29extern MARK mark[NMARKS]; /* marks a-z, plus mark ' and two temps */extern MARK cursor; /* mark where line is *//*------------------------------------------------------------------------*//* These are used to keep track of the current & previous files. */extern long origtime; /* modification date&time of the current file */extern char origname[256]; /* name of the current file */extern char prevorig[256]; /* name of the preceding file */extern long prevline; /* line number from preceding file *//*------------------------------------------------------------------------*//* misc housekeeping variables & functions */extern int tmpfd; /* fd used to access the tmp file */extern int tmpnum; /* counter used to generate unique filenames */extern long lnum[MAXBLKS]; /* last line# of each block */extern long nlines; /* number of lines in the file */extern char args[BLKSIZE]; /* file names given on the command line */extern int argno; /* the current element of args[] */extern int nargs; /* number of filenames in args */extern long changes; /* counts changes, to prohibit short-cuts */extern int significant; /* boolean: was a *REAL* change made? */extern BLK tmpblk; /* a block used to accumulate changes */extern long topline; /* file line number of top line */extern int leftcol; /* column number of left col */#define botline (topline + LINES - 2)#define rightcol (leftcol + COLS - (*o_number ? 9 : 1))extern int physcol; /* physical column number that cursor is on */extern int physrow; /* physical row number that cursor is on */extern int exwrote; /* used to detect verbose ex commands */extern int doingdot; /* boolean: are we doing the "." command? */extern int doingglobal; /* boolean: are doing a ":g" command? */extern long rptlines; /* number of lines affected by a command */extern char *rptlabel; /* description of how lines were affected */extern char *fetchline(); /* read a given line from tmp file */extern char *parseptrn(); /* isolate a regexp in a line */extern MARK paste(); /* paste from cut buffer to a given point */extern char *wildcard(); /* expand wildcards in filenames */extern MARK input(); /* inserts characters from keyboard */extern char *linespec(); /* finds the end of a /regexp/ string */#define ctrl(ch) ((ch)&037)#ifndef NO_RECYCLEextern long allocate(); /* allocate a free block of the tmp file */#endifextern int trapint(); /* trap handler for SIGINT */extern int deathtrap(); /* trap handler for deadly signals */extern void blkdirty(); /* marks a block as being "dirty" */extern void blkflush(); /* writes a single dirty block to the disk */extern void blksync(); /* forces all "dirty" blocks to disk */extern void blkinit(); /* resets the block cache to "empty" state */extern void beep(); /* rings the terminal's bell */extern void exrefresh(); /* writes text to the screen */extern void msg(); /* writes a printf-style message to the screen */extern void endmsgs(); /* if "manymsgs" is set, then scroll up 1 line */extern void garbage(); /* reclaims any garbage blocks */extern void redraw(); /* updates the screen after a change */extern void resume_curses();/* puts the terminal in "cbreak" mode */extern void beforedo(); /* saves current revision before a new change */extern void afterdo(); /* marks end of a beforedo() change */extern void abortdo(); /* like "afterdo()" followed by "undo()" */extern int undo(); /* restores file to previous undo() */extern void dumpkey(); /* lists key mappings to the screen */extern void mapkey(); /* defines a new key mapping */extern void savekeys(); /* lists key mappings to a file */extern void redrawrange(); /* records clues from modify.c */extern void cut(); /* saves text in a cut buffer */extern void delete(); /* deletes text */extern void add(); /* adds text */extern void change(); /* deletes text, and then adds other text */extern void cutswitch(); /* updates cut buffers when we switch files */extern void do_abbr(); /* defines or lists abbreviations */extern void do_digraph(); /* defines or lists digraphs */extern void exstring(); /* execute a string as EX commands */extern void dumpopts();extern void setopts();extern void saveopts();extern void savedigs();extern void saveabbr();extern void savecolor();extern void cutname();extern void cutname();extern void initopts();extern void cutend();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -