📄 vim.h
字号:
/*
* flags for find_tags().
*/
#define TAG_HELP 1 /* only search for help tags */
#define TAG_NAMES 2 /* only return name of tag */
#define TAG_REGEXP 4 /* use tag pattern as regexp */
#define TAG_NOIC 8 /* don't always ignore case */
#ifdef USE_CSCOPE
# define TAG_CSCOPE 16 /* cscope tag */
#endif
#define TAG_VERBOSE 32 /* message verbosity */
/*
* Types of dialogs passed to do_vim_dialog().
*/
#define VIM_GENERIC 0
#define VIM_ERROR 1
#define VIM_WARNING 2
#define VIM_INFO 3
#define VIM_QUESTION 4
#define VIM_LAST_TYPE 4 /* sentinel value */
/*
* Return values for functions like gui_yesnocancel()
*/
#define VIM_OK 1
#define VIM_YES 2
#define VIM_NO 3
#define VIM_CANCEL 4
#define VIM_ALL 5
#define VIM_DISCARDALL 6
/* Magic chars used in confirm dialog strings */
#define DLG_BUTTON_SEP '\n'
#define DLG_HOTKEY_CHAR '&'
/*
* Events for autocommands.
*/
enum auto_event
{
EVENT_BUFDELETE = 0, /* just before deleting a buffer */
EVENT_BUFENTER, /* after entering a buffer */
EVENT_BUFFILEPOST, /* after renaming a buffer */
EVENT_BUFFILEPRE, /* before renaming a buffer */
EVENT_BUFLEAVE, /* before leaving a buffer */
EVENT_BUFNEWFILE, /* when creating a buffer for a new file */
EVENT_BUFREADPOST, /* after reading a buffer */
EVENT_BUFREADPRE, /* before reading a buffer */
EVENT_BUFUNLOAD, /* just before unloading a buffer */
EVENT_BUFWRITEPOST, /* after writing a buffer */
EVENT_BUFWRITEPRE, /* before writing a buffer */
EVENT_FILEAPPENDPOST, /* after appending to a file */
EVENT_FILEAPPENDPRE, /* before appending to a file */
EVENT_FILECHANGEDSHELL, /* after shell command that changed file */
EVENT_FILEREADPOST, /* after reading a file */
EVENT_FILEREADPRE, /* before reading a file */
EVENT_FILEWRITEPOST, /* after writing a file */
EVENT_FILEWRITEPRE, /* before writing a file */
EVENT_FILTERREADPOST, /* after reading from a filter */
EVENT_FILTERREADPRE, /* before reading from a filter */
EVENT_FILTERWRITEPOST, /* after writing to a filter */
EVENT_FILTERWRITEPRE, /* before writing to a filter */
EVENT_STDINREADPOST, /* after reading from stdin */
EVENT_STDINREADPRE, /* before reading from stdin */
EVENT_TERMCHANGED, /* after changing 'term' */
EVENT_USER, /* user defined autocommand */
EVENT_VIMENTER, /* after starting Vim */
EVENT_VIMLEAVE, /* before exiting Vim */
EVENT_VIMLEAVEPRE, /* before exiting Vim and writing .viminfo */
EVENT_WINENTER, /* after entering a window */
EVENT_WINLEAVE, /* before leaving a window */
EVENT_FILEENCODING, /* after changing the file-encoding (set fe=) */
NUM_EVENTS /* MUST be the last one */
};
typedef enum auto_event EVENT_T;
/*
* Values for index in highlight_attr[].
* When making changes, also update the table in highlight_changed()!
*/
enum hlf_value
{
HLF_8 = 0, /* Meta & special keys listed with ":map" */
HLF_AT, /* @ and ~ characters at end of screen */
HLF_D, /* directories in CTRL-D listing */
HLF_E, /* error messages */
HLF_H, /* obsolete, ignored */
HLF_I, /* incremental search */
HLF_L, /* last search string */
HLF_M, /* "--More--" message */
HLF_CM, /* Mode (e.g., "-- INSERT --") */
HLF_N, /* line number for ":number" and ":#" commands */
HLF_R, /* return to continue message and yes/no questions */
HLF_S, /* status lines */
HLF_SNC, /* status lines of not-current windows */
HLF_T, /* Titles for output from ":set all", ":autocmd" etc. */
HLF_V, /* Visual mode */
HLF_W, /* warning messages */
HLF_COUNT /* MUST be the last one */
};
/*
* Boolean constants
*/
#ifndef TRUE
# define FALSE 0 /* note: this is an int, not a long! */
# define TRUE 1
#endif
#define MAYBE 2 /* sometimes used for a variant on TRUE */
/* May be returned by add_new_completion(): */
#define RET_ERROR (-1)
/*
* Operator IDs; The order must correspond to op_chars[] in normal.c!
*/
#define OP_NOP 0 /* no pending operation */
#define OP_DELETE 1 /* "d" delete operator */
#define OP_YANK 2 /* "y" yank operator */
#define OP_CHANGE 3 /* "c" change operator */
#define OP_LSHIFT 4 /* "<" left shift operator */
#define OP_RSHIFT 5 /* ">" right shift operator */
#define OP_FILTER 6 /* "!" filter operator */
#define OP_TILDE 7 /* "g~" switch case operator */
#define OP_INDENT 8 /* "=" indent operator */
#define OP_FORMAT 9 /* "gq" format operator */
#define OP_COLON 10 /* ":" colon operator */
#define OP_UPPER 11 /* "gU" make upper case operator */
#define OP_LOWER 12 /* "gu" make lower case operator */
#define DO_JOIN 13 /* "J" join operator, only for visual mode */
/*
* Motion types, used for operators and for yank/delete registers.
*/
#define MCHAR 0 /* character-wise movement/register */
#define MLINE 1 /* line-wise movement/register */
#define MBLOCK 2 /* block-wise register */
/*
* Minimum screen size
*/
#define MIN_COLUMNS 12 /* minimal columns for screen */
#define MIN_LINES 2 /* minimal lines for screen */
#define STATUS_HEIGHT 1 /* height of a status line under a window */
/*
* Buffer sizes
*/
#ifndef CMDBUFFSIZE
# define CMDBUFFSIZE 256 /* size of the command processing buffer */
#endif
#define LSIZE 512 /* max. size of a line in the tags file */
#define IOSIZE (1024+1) /* file i/o and sprintf buffer size */
#define MSG_BUF_LEN 80 /* length of buffer for small messages */
#if defined(AMIGA) || defined(__linux__) || defined(__QNX__) || defined(__CYGWIN32__) || defined(_AIX)
# define TBUFSZ 2048 /* buffer size for termcap entry */
#else
# define TBUFSZ 1024 /* buffer size for termcap entry */
#endif
/*
* Maximum length of key sequence to be mapped.
* Must be able to hold an Amiga resize report.
*/
#define MAXMAPLEN 50
#ifdef BINARY_FILE_IO
# define WRITEBIN "wb" /* no CR-LF translation */
# define READBIN "rb"
# define APPENDBIN "ab"
#else
# define WRITEBIN "w"
# define READBIN "r"
# define APPENDBIN "a"
#endif
/*
* EMX doesn't have a global way of making open() use binary I/O.
* Use O_BINARY for all open() calls.
*/
#if defined(__EMX__) || defined(__CYGWIN32__)
# define O_EXTRA O_BINARY
#else
# define O_EXTRA 0
#endif
/*
* defines to avoid typecasts from (char_u *) to (char *) and back
* (vim_strchr() and vim_strrchr() are now in alloc.c)
*/
#define STRLEN(s) strlen((char *)(s))
#define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
#define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n))
#define STRCMP(d, s) strcmp((char *)(d), (char *)(s))
#define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n))
#ifdef HAVE_STRCASECMP
# define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s))
#else
# ifdef HAVE_STRICMP
# define STRICMP(d, s) stricmp((char *)(d), (char *)(s))
# else
# define STRICMP(d, s) vim_stricmp((char *)(d), (char *)(s))
# endif
#endif
#ifdef HAVE_STRNCASECMP
# define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n))
#else
# ifdef HAVE_STRNICMP
# define STRNICMP(d, s, n) strnicmp((char *)(d), (char *)(s), (size_t)(n))
# else
# define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n))
# endif
#endif
#define STRCAT(d, s) strcat((char *)(d), (char *)(s))
#define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
#ifdef HAVE_STRPBRK
# define vim_strpbrk(s, cs) (char_u *)strpbrk((char *)(s), (char *)(cs))
#endif
#define MSG(s) msg((char_u *)(s))
#define MSG_ATTR(s, attr) msg_attr((char_u *)(s), (attr))
#define EMSG(s) emsg((char_u *)(s))
#define EMSG2(s, p) emsg2((char_u *)(s), (char_u *)(p))
#define EMSGN(s, n) emsgn((char_u *)(s), (long)(n))
#define OUT_STR(s) out_str((char_u *)(s))
#define OUT_STR_NF(s) out_str_nf((char_u *)(s))
#define MSG_PUTS(s) msg_puts((char_u *)(s))
#define MSG_PUTS_ATTR(s, a) msg_puts_attr((char_u *)(s), (a))
#define MSG_PUTS_TITLE(s) msg_puts_title((char_u *)(s))
#define MSG_PUTS_LONG(s) msg_puts_long((char_u *)(s))
#define MSG_PUTS_LONG_ATTR(s, a) msg_puts_long_attr((char_u *)(s), (a))
typedef long linenr_t; /* line number type */
typedef unsigned colnr_t; /* column number type */
#define MAXLNUM (0x7fffffff) /* maximum (invalid) line number */
#if SIZEOF_INT >= 4
# define MAXCOL (0x7fffffff) /* maximum column number, 31 bits */
#else
# define MAXCOL (0x7fff) /* maximum column number, 15 bits */
#endif
#define SHOWCMD_COLS 10 /* columns needed by shown command */
/*
* Include a prototype for mch_memmove(), it may not be in alloc.pro.
*/
#ifdef VIM_MEMMOVE
void mch_memmove __ARGS((void *, void *, size_t));
#else
# ifndef mch_memmove
# define mch_memmove(to, from, len) memmove(to, from, len)
# endif
#endif
/*
* fnamecmp() is used to compare file names.
* On some systems case in a file name does not matter, on others it does.
* (this does not account for maximum name lengths and things like "../dir",
* thus it is not 100% accurate!)
*/
#ifdef CASE_INSENSITIVE_FILENAME
# define fnamecmp(x, y) STRICMP((x), (y))
# define fnamencmp(x, y, n) STRNICMP((x), (y), (n))
#else
# define fnamecmp(x, y) strcmp((char *)(x), (char *)(y))
# define fnamencmp(x, y, n) strncmp((char *)(x), (char *)(y), (size_t)(n))
#endif
#ifdef HAVE_MEMSET
# define vim_memset(ptr, c, size) memset((ptr), (c), (size))
#else
void *vim_memset __ARGS((void *, int, size_t));
#endif
#ifdef HAVE_MEMCMP
# define vim_memcmp(p1, p2, len) memcmp((p1), (p2), (len))
#else
# ifdef HAVE_BCMP
# define vim_memcmp(p1, p2, len) bcmp((p1), (p2), (len))
# else
int vim_memcmp __ARGS((void *, void *, size_t));
# define VIM_MEMCMP
# endif
#endif
/*
* Enums need a typecast to be used as array index (for Ultrix).
*/
#define hl_attr(n) highlight_attr[(int)(n)]
#define term_str(n) term_strings[(int)(n)]
/*
* vim_iswhite() is used for "^" and the like. It differs from isspace()
* because it doesn't include <CR> and <LF> and the like.
*/
#define vim_iswhite(x) ((x) == ' ' || (x) == '\t')
/* GUI and MSDOS can change the shape of the cursor */
#if defined(USE_GUI) || defined(MSDOS) || (defined(WIN32) && !defined(USE_GUI_WIN32))
# define CURSOR_SHAPE
#endif
/* Note that gui.h is included by structs.h */
#include "regexp.h" /* for struct regexp */
#include "structs.h" /* file that defines many structures */
#ifdef USE_MOUSE
/* Codes for mouse event */
# define MOUSE_LEFT 0x00
# define MOUSE_MIDDLE 0x01
# define MOUSE_RIGHT 0x02
# define MOUSE_RELEASE 0x03
# define MOUSE_SHIFT 0x04
# define MOUSE_ALT 0x08
# define MOUSE_CTRL 0x10
/* 0x20 is reserved by xterm */
# define MOUSE_DRAG (0x40 | MOUSE_RELEASE)
# define MOUSE_CLICK_MASK 0x03
# define NUM_MOUSE_CLICKS(code) \
(((unsigned)((code) & 0xC0) >> 6) + 1)
# define SET_NUM_MOUSE_CLICKS(code, num) \
(code) = ((code) & 0x3f) | ((((num) - 1) & 3) << 6)
/*
* jump_to_mouse() returns one of these values, possibly with
* CURSOR_MOVED added
*/
# define IN_UNKNOWN 1
# define IN_BUFFER 2
# define IN_STATUS_LINE 3 /* Or in command line */
# define CURSOR_MOVED 0x100
/* flags for jump_to_mouse() */
# define MOUSE_FOCUS 0x01 /* need to stay in this window */
# define MOUSE_MAY_VIS 0x02 /* may start Visual mode */
# define MOUSE_DID_MOVE 0x04 /* only act when mouse has moved */
# define MOUSE_SETPOS 0x08 /* only set current mouse position */
# define MOUSE_MAY_STOP_VIS 0x10 /* may stop Visual mode */
#endif /* USE_MOUSE */
/* defines for eval_vars() */
#define VALID_PATH 1
#define VALID_HEAD 2
#ifdef USE_CLIPBOARD
/* Selection states for modeless selection */
# define SELECT_CLEARED 0
# define SELECT_IN_PROGRESS 1
# define SELECT_DONE 2
# define SELECT_MODE_CHAR 0
# define SELECT_MODE_WORD 1
# define SELECT_MODE_LINE 2
# ifdef USE_GUI_WIN32
# ifdef HAVE_OLE
# define WM_OLE (WM_APP+0)
# endif
# endif
/* Info about selected text */
typedef struct VimClipboard
{
int available; /* Is clipboard available? */
int owned; /* Flag: do we own the selection? */
FPOS start; /* Start of selected area */
FPOS end; /* End of selected area */
int vmode; /* Visual mode character */
/* Fields for selection that doesn't use Visual mode */
short_u origin_row;
short_u origin_start_col;
short_u origin_end_col;
short_u word_start_col;
short_u word_end_col;
FPOS prev; /* Previous position */
short_u state; /* Current selection state */
short_u mode; /* Select by char, word, or line. */
# ifdef USE_GUI_X11
Atom atom; /* Vim's own special selection format */
# endif
# ifdef WIN32
int_u format; /* Vim's own special clipboard format */
# endif
# ifdef USE_GUI_BEOS
/* no clipboard at the moment */
# endif
} VimClipboard;
#endif /* USE_CLIPBOARD */
#ifdef __BORLANDC__
/* work around a bug in the Borland 'stat' function: */
# include <io.h> /* for access() */
# define stat(a,b) (access(a,0) ? -1 : stat(a,b))
#endif
#include "globals.h" /* global variables and messages */
#include "option.h" /* option variables and defines */
#include "ex_cmds.h" /* Ex command defines */
#include "proto.h" /* function prototypes */
#ifdef USE_SNIFF
# include "if_sniff.h"
#endif
/* This has to go after the include of proto.h, as proto/os_win32.pro declares
* functions of these names. The declarations would break if the defines had
* been seen at that stage.
*/
#if !defined(USE_GUI_WIN32) && !defined(macintosh)
# define mch_errmsg(str) fprintf(stderr, (str))
# define mch_display_error() fflush(stderr)
# define mch_msg(str) printf((str))
#else
# define mch_msg(str) mch_errmsg((str))
#endif
/*
* If console dialog not supported, but GUI dialog is, use the GUI one.
*/
#if defined(GUI_DIALOG) && !defined(CON_DIALOG)
# define do_dialog gui_mch_dialog
#endif
/*
* The filters used in file browsers are too machine specific to
* be defined usefully in a generic fashion.
* So instead the filter strings are defined here for each architecture
* that supports gui_mch_browse()
*/
#ifdef USE_BROWSE
# ifdef USE_GUI_WIN32
# define BROWSE_FILTER_MACROS \
(char_u *)"Vim macro files (*.vim)\0*.vim\0All Files (*.*)\0*.*\0\0"
# define BROWSE_FILTER_ALL_FILES (char_u *)"All Files (*.*)\0*.*\0\0"
# else
# define BROWSE_FILTER_MACROS \
(char_u *)"Vim macro files (*.vim)\0*.vim\0All Files (*)\0*\0\0"
# define BROWSE_FILTER_ALL_FILES (char_u *)"All Files (*)\0*\0\0"
# endif
#endif
/* stop using fastcall for Borland */
#if defined(__BORLANDC__) && defined(WIN32) && !defined(DEBUG)
# pragma option -p.
#endif
#if !defined(MEM_PROFILE) && !defined(PROTO)
# define vim_realloc(ptr, size) realloc((ptr), (size))
#endif
#endif /* VIM__H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -