10647 lines · 268.2 KB · C
RawDownload
/* vi:set ts=8 sts=4 sw=4: * * VIM - Vi IMproved	by Bram Moolenaar * * Do ":help uganda"  in Vim to read copying and usage conditions. * Do ":help credits" in Vim to see a list of people who contributed. * See README.txt for an overview of the Vim source code. */ /* * Code to handle user-settable options. This is all pretty much table- * driven. Checklist for adding a new option: * - Put it in the options array below (copy an existing entry). * - For a global option: Add a variable for it in option.h. * - For a buffer or window local option: *   - Add a PV_XX entry to the enum below. *   - Add a variable to the window or buffer struct in structs.h. *   - For a window option, add some code to copy_winopt(). *   - For a buffer option, add some code to buf_copy_options(). *   - For a buffer string option, add code to check_buf_options(). * - If it's a numeric option, add any necessary bounds checks to do_set(). * - If it's a list of flags, add some code in do_set(), search for WW_ALL. * - When adding an option with expansion (P_EXPAND), but with a different *   default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP. * - Add documentation!  One line in doc/help.txt, full description in *   options.txt, and any other related places. * - Add an entry in runtime/optwin.vim. * When making changes: * - Adjust the help for the option in doc/option.txt. * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a *   comment at the help for the 'compatible' option. */ #define IN_OPTION_C#include "vim.h" /* * The options that are local to a window or buffer have "indir" set to one of * these values.  Special values: * PV_NONE: global option. * PV_WIN is added: window-local option * PV_BUF is added: buffer-local option * PV_BOTH is added: global option which also has a local value. */#define PV_BOTH 0x1000#define PV_WIN  0x2000#define PV_BUF  0x4000#define PV_MASK 0x0fff#define OPT_WIN(x)  (idopt_T)(PV_WIN + (int)(x))#define OPT_BUF(x)  (idopt_T)(PV_BUF + (int)(x))#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x)) /* * Definition of the PV_ values for buffer-local options. * The BV_ values are defined in option.h. */#define PV_AI		OPT_BUF(BV_AI)#define PV_AR		OPT_BOTH(OPT_BUF(BV_AR))#ifdef FEAT_QUICKFIX# define PV_BH		OPT_BUF(BV_BH)# define PV_BT		OPT_BUF(BV_BT)# define PV_EFM		OPT_BOTH(OPT_BUF(BV_EFM))# define PV_GP		OPT_BOTH(OPT_BUF(BV_GP))# define PV_MP		OPT_BOTH(OPT_BUF(BV_MP))#endif#define PV_BIN		OPT_BUF(BV_BIN)#define PV_BL		OPT_BUF(BV_BL)#ifdef FEAT_MBYTE# define PV_BOMB	OPT_BUF(BV_BOMB)#endif#define PV_CI		OPT_BUF(BV_CI)#ifdef FEAT_CINDENT# define PV_CIN		OPT_BUF(BV_CIN)# define PV_CINK	OPT_BUF(BV_CINK)# define PV_CINO	OPT_BUF(BV_CINO)#endif#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)# define PV_CINW	OPT_BUF(BV_CINW)#endif#ifdef FEAT_FOLDING# define PV_CMS		OPT_BUF(BV_CMS)#endif#ifdef FEAT_COMMENTS# define PV_COM		OPT_BUF(BV_COM)#endif#ifdef FEAT_INS_EXPAND# define PV_CPT		OPT_BUF(BV_CPT)# define PV_DICT	OPT_BOTH(OPT_BUF(BV_DICT))# define PV_TSR		OPT_BOTH(OPT_BUF(BV_TSR))#endif#ifdef FEAT_COMPL_FUNC# define PV_CFU		OPT_BUF(BV_CFU)#endif#ifdef FEAT_FIND_ID# define PV_DEF		OPT_BOTH(OPT_BUF(BV_DEF))# define PV_INC		OPT_BOTH(OPT_BUF(BV_INC))#endif#define PV_EOL		OPT_BUF(BV_EOL)#define PV_EP		OPT_BOTH(OPT_BUF(BV_EP))#define PV_ET		OPT_BUF(BV_ET)#ifdef FEAT_MBYTE# define PV_FENC	OPT_BUF(BV_FENC)#endif#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)# define PV_BEXPR	OPT_BOTH(OPT_BUF(BV_BEXPR))#endif#ifdef FEAT_EVAL# define PV_FEX		OPT_BUF(BV_FEX)#endif#define PV_FF		OPT_BUF(BV_FF)#define PV_FLP		OPT_BUF(BV_FLP)#define PV_FO		OPT_BUF(BV_FO)#ifdef FEAT_AUTOCMD# define PV_FT		OPT_BUF(BV_FT)#endif#define PV_IMI		OPT_BUF(BV_IMI)#define PV_IMS		OPT_BUF(BV_IMS)#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)# define PV_INDE	OPT_BUF(BV_INDE)# define PV_INDK	OPT_BUF(BV_INDK)#endif#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)# define PV_INEX	OPT_BUF(BV_INEX)#endif#define PV_INF		OPT_BUF(BV_INF)#define PV_ISK		OPT_BUF(BV_ISK)#ifdef FEAT_CRYPT# define PV_KEY		OPT_BUF(BV_KEY)#endif#ifdef FEAT_KEYMAP# define PV_KMAP	OPT_BUF(BV_KMAP)#endif#define PV_KP		OPT_BOTH(OPT_BUF(BV_KP))#ifdef FEAT_LISP# define PV_LISP	OPT_BUF(BV_LISP)#endif#define PV_MA		OPT_BUF(BV_MA)#define PV_ML		OPT_BUF(BV_ML)#define PV_MOD		OPT_BUF(BV_MOD)#define PV_MPS		OPT_BUF(BV_MPS)#define PV_NF		OPT_BUF(BV_NF)#ifdef FEAT_OSFILETYPE# define PV_OFT		OPT_BUF(BV_OFT)#endif#ifdef FEAT_COMPL_FUNC# define PV_OFU		OPT_BUF(BV_OFU)#endif#define PV_PATH		OPT_BOTH(OPT_BUF(BV_PATH))#define PV_PI		OPT_BUF(BV_PI)#ifdef FEAT_TEXTOBJ# define PV_QE		OPT_BUF(BV_QE)#endif#define PV_RO		OPT_BUF(BV_RO)#ifdef FEAT_SMARTINDENT# define PV_SI		OPT_BUF(BV_SI)#endif#ifndef SHORT_FNAME# define PV_SN		OPT_BUF(BV_SN)#endif#ifdef FEAT_SYN_HL# define PV_SMC		OPT_BUF(BV_SMC)# define PV_SYN		OPT_BUF(BV_SYN)#endif#ifdef FEAT_SPELL# define PV_SPC		OPT_BUF(BV_SPC)# define PV_SPF		OPT_BUF(BV_SPF)# define PV_SPL		OPT_BUF(BV_SPL)#endif#define PV_STS		OPT_BUF(BV_STS)#ifdef FEAT_SEARCHPATH# define PV_SUA		OPT_BUF(BV_SUA)#endif#define PV_SW		OPT_BUF(BV_SW)#define PV_SWF		OPT_BUF(BV_SWF)#define PV_TAGS		OPT_BOTH(OPT_BUF(BV_TAGS))#define PV_TS		OPT_BUF(BV_TS)#define PV_TW		OPT_BUF(BV_TW)#define PV_TX		OPT_BUF(BV_TX)#define PV_WM		OPT_BUF(BV_WM) /* * Definition of the PV_ values for window-local options. * The WV_ values are defined in option.h. */#define PV_LIST		OPT_WIN(WV_LIST)#ifdef FEAT_ARABIC# define PV_ARAB	OPT_WIN(WV_ARAB)#endif#ifdef FEAT_DIFF# define PV_DIFF	OPT_WIN(WV_DIFF)#endif#ifdef FEAT_FOLDING# define PV_FDC		OPT_WIN(WV_FDC)# define PV_FEN		OPT_WIN(WV_FEN)# define PV_FDI		OPT_WIN(WV_FDI)# define PV_FDL		OPT_WIN(WV_FDL)# define PV_FDM		OPT_WIN(WV_FDM)# define PV_FML		OPT_WIN(WV_FML)# define PV_FDN		OPT_WIN(WV_FDN)# ifdef FEAT_EVAL#  define PV_FDE	OPT_WIN(WV_FDE)#  define PV_FDT	OPT_WIN(WV_FDT)# endif# define PV_FMR		OPT_WIN(WV_FMR)#endif#ifdef FEAT_LINEBREAK# define PV_LBR		OPT_WIN(WV_LBR)#endif#define PV_NU		OPT_WIN(WV_NU)#ifdef FEAT_LINEBREAK# define PV_NUW		OPT_WIN(WV_NUW)#endif#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)# define PV_PVW		OPT_WIN(WV_PVW)#endif#ifdef FEAT_RIGHTLEFT# define PV_RL		OPT_WIN(WV_RL)# define PV_RLC		OPT_WIN(WV_RLC)#endif#ifdef FEAT_SCROLLBIND# define PV_SCBIND	OPT_WIN(WV_SCBIND)#endif#define PV_SCROLL	OPT_WIN(WV_SCROLL)#ifdef FEAT_SPELL# define PV_SPELL	OPT_WIN(WV_SPELL)#endif#ifdef FEAT_SYN_HL# define PV_CUC		OPT_WIN(WV_CUC)# define PV_CUL		OPT_WIN(WV_CUL)#endif#ifdef FEAT_STL_OPT# define PV_STL		OPT_BOTH(OPT_WIN(WV_STL))#endif#ifdef FEAT_WINDOWS# define PV_WFH		OPT_WIN(WV_WFH)#endif#ifdef FEAT_VERTSPLIT# define PV_WFW		OPT_WIN(WV_WFW)#endif#define PV_WRAP		OPT_WIN(WV_WRAP)  /* WV_ and BV_ values get typecasted to this for the "indir" field */typedef enum{    PV_NONE = 0} idopt_T; /* * Options local to a window have a value local to a buffer and global to all * buffers.  Indicate this by setting "var" to VAR_WIN. */#define VAR_WIN ((char_u *)-1) /* * These are the global values for options which are also local to a buffer. * Only to be used in option.c! */static int	p_ai;static int	p_bin;#ifdef FEAT_MBYTEstatic int	p_bomb;#endif#if defined(FEAT_QUICKFIX)static char_u	*p_bh;static char_u	*p_bt;#endifstatic int	p_bl;static int	p_ci;#ifdef FEAT_CINDENTstatic int	p_cin;static char_u	*p_cink;static char_u	*p_cino;#endif#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)static char_u	*p_cinw;#endif#ifdef FEAT_COMMENTSstatic char_u	*p_com;#endif#ifdef FEAT_FOLDINGstatic char_u	*p_cms;#endif#ifdef FEAT_INS_EXPANDstatic char_u	*p_cpt;#endif#ifdef FEAT_COMPL_FUNCstatic char_u	*p_cfu;static char_u	*p_ofu;#endifstatic int	p_eol;static int	p_et;#ifdef FEAT_MBYTEstatic char_u	*p_fenc;#endifstatic char_u	*p_ff;static char_u	*p_fo;static char_u	*p_flp;#ifdef FEAT_AUTOCMDstatic char_u	*p_ft;#endifstatic long	p_iminsert;static long	p_imsearch;#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)static char_u	*p_inex;#endif#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)static char_u	*p_inde;static char_u	*p_indk;#endif#if defined(FEAT_EVAL)static char_u	*p_fex;#endifstatic int	p_inf;static char_u	*p_isk;#ifdef FEAT_CRYPTstatic char_u	*p_key;#endif#ifdef FEAT_LISPstatic int	p_lisp;#endifstatic int	p_ml;static int	p_ma;static int	p_mod;static char_u	*p_mps;static char_u	*p_nf;#ifdef FEAT_OSFILETYPEstatic char_u	*p_oft;#endifstatic int	p_pi;#ifdef FEAT_TEXTOBJstatic char_u	*p_qe;#endifstatic int	p_ro;#ifdef FEAT_SMARTINDENTstatic int	p_si;#endif#ifndef SHORT_FNAMEstatic int	p_sn;#endifstatic long	p_sts;#if defined(FEAT_SEARCHPATH)static char_u	*p_sua;#endifstatic long	p_sw;static int	p_swf;#ifdef FEAT_SYN_HLstatic long	p_smc;static char_u	*p_syn;#endif#ifdef FEAT_SPELLstatic char_u	*p_spc;static char_u	*p_spf;static char_u	*p_spl;#endifstatic long	p_ts;static long	p_tw;static int	p_tx;static long	p_wm;#ifdef FEAT_KEYMAPstatic char_u	*p_keymap;#endif /* Saved values for when 'bin' is set. */static int	p_et_nobin;static int	p_ml_nobin;static long	p_tw_nobin;static long	p_wm_nobin; /* Saved values for when 'paste' is set */static long	p_tw_nopaste;static long	p_wm_nopaste;static long	p_sts_nopaste;static int	p_ai_nopaste; struct vimoption{    char	*fullname;	/* full option name */    char	*shortname;	/* permissible abbreviation */    long_u	flags;		/* see below */    char_u	*var;		/* global option: pointer to variable;				 * window-local option: VAR_WIN;				 * buffer-local option: global value */    idopt_T	indir;		/* global option: PV_NONE;				 * local option: indirect option index */    char_u	*def_val[2];	/* default values for variable (vi and vim) */#ifdef FEAT_EVAL    scid_T	scriptID;	/* script in which the option was last set */#endif}; #define VI_DEFAULT  0	    /* def_val[VI_DEFAULT] is Vi default value */#define VIM_DEFAULT 1	    /* def_val[VIM_DEFAULT] is Vim default value */ /* * Flags */#define P_BOOL		0x01	/* the option is boolean */#define P_NUM		0x02	/* the option is numeric */#define P_STRING	0x04	/* the option is a string */#define P_ALLOCED	0x08	/* the string option is in allocated memory,				    must use vim_free() when assigning new				    value. Not set if default is the same. */#define P_EXPAND	0x10	/* environment expansion.  NOTE: P_EXPAND can				   never be used for local or hidden options! */#define P_NODEFAULT	0x40	/* don't set to default value */#define P_DEF_ALLOCED	0x80	/* default value is in allocated memory, must				    use vim_free() when assigning new value */#define P_WAS_SET	0x100	/* option has been set/reset */#define P_NO_MKRC	0x200	/* don't include in :mkvimrc output */#define P_VI_DEF	0x400	/* Use Vi default for Vim */#define P_VIM		0x800	/* Vim option, reset when 'cp' set */ 				/* when option changed, what to display: */#define P_RSTAT		0x1000	/* redraw status lines */#define P_RWIN		0x2000	/* redraw current window */#define P_RBUF		0x4000	/* redraw current buffer */#define P_RALL		0x6000	/* redraw all windows */#define P_RCLR		0x7000	/* clear and redraw all */ #define P_COMMA		0x8000	/* comma separated list */#define P_NODUP		0x10000L/* don't allow duplicate strings */#define P_FLAGLIST	0x20000L/* list of single-char flags */ #define P_SECURE	0x40000L/* cannot change in modeline or secure mode */#define P_GETTEXT	0x80000L/* expand default value with _() */#define P_NOGLOB       0x100000L/* do not use local value for global vimrc */#define P_NFNAME       0x200000L/* only normal file name chars allowed */#define P_INSECURE     0x400000L/* option was set from a modeline */ #define ISK_LATIN1  (char_u *)"@,48-57,_,192-255" /* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used * for the currency sign. */#if defined(MSDOS) || defined(MSWIN) || defined(OS2)# define ISP_LATIN1 (char_u *)"@,~-255"#else# define ISP_LATIN1 (char_u *)"@,161-255"#endif /* The 16 bit MS-DOS version is low on space, make the string as short as * possible when compiling with few features. */#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \	|| defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \	|| defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL)# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine"#else# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"#endif /* * options[] is initialized here. * The order of the options MUST be alphabetic for ":set all" and findoption(). * All option names MUST start with a lowercase letter (for findoption()). * Exception: "t_" options are at the end. * The options with a NULL variable are 'hidden': a set command for them is * ignored and they are not printed. */static struct vimoption#ifdef FEAT_GUI_W16	_far#endif	options[] ={    {"aleph",	    "al",   P_NUM|P_VI_DEF,#ifdef FEAT_RIGHTLEFT			    (char_u *)&p_aleph, PV_NONE,#else			    (char_u *)NULL, PV_NONE,#endif			    {#if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)			    (char_u *)128L,#else			    (char_u *)224L,#endif					    (char_u *)0L}},    {"antialias",   "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,#if defined(FEAT_GUI) && defined(MACOS_X)			    (char_u *)&p_antialias, PV_NONE,			    {(char_u *)FALSE, (char_u *)FALSE}#else			    (char_u *)NULL, PV_NONE,			    {(char_u *)FALSE, (char_u *)FALSE}#endif			    },    {"arabic",	    "arab", P_BOOL|P_VI_DEF|P_VIM,#ifdef FEAT_ARABIC			    (char_u *)VAR_WIN, PV_ARAB,#else			    (char_u *)NULL, PV_NONE,#endif			    {(char_u *)FALSE, (char_u *)0L}},    {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,#ifdef FEAT_ARABIC			    (char_u *)&p_arshape, PV_NONE,#else			    (char_u *)NULL, PV_NONE,#endif			    {(char_u *)TRUE, (char_u *)0L}},

Lines 1–500 of 10647.