forked from aniani/vim
updated for version 7.0096
This commit is contained in:
91
src/eval.c
91
src/eval.c
@@ -367,7 +367,6 @@ static int get_string_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate));
|
||||
static int get_lit_string_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate));
|
||||
static int get_list_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate));
|
||||
static list_T *list_alloc __ARGS((void));
|
||||
static void list_unref __ARGS((list_T *l));
|
||||
static void list_free __ARGS((list_T *l));
|
||||
static listitem_T *listitem_alloc __ARGS((void));
|
||||
static void listitem_free __ARGS((listitem_T *item));
|
||||
@@ -560,6 +559,7 @@ static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_sort __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_soundfold __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_spellbadword __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_spellsuggest __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_split __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
@@ -596,6 +596,8 @@ static void f_winrestcmd __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
|
||||
static void prepare_vimvar __ARGS((int idx, typval_T *save_tv));
|
||||
static void restore_vimvar __ARGS((int idx, typval_T *save_tv));
|
||||
static win_T *find_win_by_nr __ARGS((typval_T *vp));
|
||||
static pos_T *var2fpos __ARGS((typval_T *varp, int lnum));
|
||||
static int get_env_len __ARGS((char_u **arg));
|
||||
@@ -1206,6 +1208,69 @@ eval_to_number(expr)
|
||||
return retval;
|
||||
}
|
||||
|
||||
#if defined(FEAT_SYN_HL) || defined(PROTO)
|
||||
/*
|
||||
* Evaluate an expression to a list with suggestions.
|
||||
* For the "expr:" part of 'spellsuggest'.
|
||||
*/
|
||||
list_T *
|
||||
eval_spell_expr(badword, expr)
|
||||
char_u *badword;
|
||||
char_u *expr;
|
||||
{
|
||||
typval_T save_val;
|
||||
typval_T rettv;
|
||||
list_T *list = NULL;
|
||||
char_u *p = skipwhite(expr);
|
||||
|
||||
/* Set "v:val" to the bad word. */
|
||||
prepare_vimvar(VV_VAL, &save_val);
|
||||
vimvars[VV_VAL].vv_type = VAR_STRING;
|
||||
vimvars[VV_VAL].vv_str = badword;
|
||||
if (p_verbose == 0)
|
||||
++emsg_off;
|
||||
|
||||
if (eval1(&p, &rettv, TRUE) == OK)
|
||||
{
|
||||
if (rettv.v_type != VAR_LIST)
|
||||
clear_tv(&rettv);
|
||||
else
|
||||
list = rettv.vval.v_list;
|
||||
}
|
||||
|
||||
if (p_verbose == 0)
|
||||
--emsg_off;
|
||||
vimvars[VV_VAL].vv_str = NULL;
|
||||
restore_vimvar(VV_VAL, &save_val);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
* "list" is supposed to contain two items: a word and a number. Return the
|
||||
* word in "pp" and the number as the return value.
|
||||
* Return -1 if anything isn't right.
|
||||
* Used to get the good word and score from the eval_spell_expr() result.
|
||||
*/
|
||||
int
|
||||
get_spellword(list, pp)
|
||||
list_T *list;
|
||||
char_u **pp;
|
||||
{
|
||||
listitem_T *li;
|
||||
|
||||
li = list->lv_first;
|
||||
if (li == NULL)
|
||||
return -1;
|
||||
*pp = get_tv_string(&li->li_tv);
|
||||
|
||||
li = li->li_next;
|
||||
if (li == NULL)
|
||||
return -1;
|
||||
return get_tv_number(&li->li_tv);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
|
||||
/*
|
||||
* Call some vimL function and return the result as a string
|
||||
@@ -4976,7 +5041,7 @@ list_alloc()
|
||||
* Unreference a list: decrement the reference count and free it when it
|
||||
* becomes zero.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
list_unref(l)
|
||||
list_T *l;
|
||||
{
|
||||
@@ -6627,6 +6692,7 @@ static struct fst
|
||||
{"setwinvar", 3, 3, f_setwinvar},
|
||||
{"simplify", 1, 1, f_simplify},
|
||||
{"sort", 1, 2, f_sort},
|
||||
{"soundfold", 1, 1, f_soundfold},
|
||||
{"spellbadword", 0, 0, f_spellbadword},
|
||||
{"spellsuggest", 1, 2, f_spellsuggest},
|
||||
{"split", 1, 3, f_split},
|
||||
@@ -8442,8 +8508,6 @@ findfilendir(argvars, rettv, dir)
|
||||
rettv->v_type = VAR_STRING;
|
||||
}
|
||||
|
||||
static void prepare_vimvar __ARGS((int idx, typval_T *save_tv));
|
||||
static void restore_vimvar __ARGS((int idx, typval_T *save_tv));
|
||||
static void filter_map __ARGS((typval_T *argvars, typval_T *rettv, int map));
|
||||
static int filter_map_one __ARGS((typval_T *tv, char_u *expr, int map, int *remp));
|
||||
|
||||
@@ -13357,6 +13421,25 @@ f_sort(argvars, rettv)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "soundfold({word})" function
|
||||
*/
|
||||
static void
|
||||
f_soundfold(argvars, rettv)
|
||||
typval_T *argvars;
|
||||
typval_T *rettv;
|
||||
{
|
||||
char_u *s;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
s = get_tv_string(&argvars[0]);
|
||||
#ifdef FEAT_SYN_HL
|
||||
rettv->vval.v_string = eval_soundfold(s);
|
||||
#else
|
||||
rettv->vval.v_string = vim_strsave(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* "spellbadword()" function
|
||||
*/
|
||||
|
||||
@@ -765,6 +765,8 @@ EX(CMD_spellwrong, "spellwrong", ex_spell,
|
||||
NEEDARG|EXTRA|TRLBAR),
|
||||
EX(CMD_spelldump, "spelldump", ex_spelldump,
|
||||
TRLBAR),
|
||||
EX(CMD_spellrepall, "spellrepall", ex_spellrepall,
|
||||
TRLBAR),
|
||||
EX(CMD_sprevious, "sprevious", ex_previous,
|
||||
EXTRA|RANGE|NOTADR|COUNT|BANG|EDITCMD|ARGOPT|TRLBAR),
|
||||
EX(CMD_srewind, "srewind", ex_rewind,
|
||||
|
||||
@@ -880,7 +880,7 @@ ml_recover()
|
||||
(void)recover_names(&fname, TRUE, 0);
|
||||
msg_putchar('\n');
|
||||
MSG_PUTS(_("Enter number of swap file to use (0 to quit): "));
|
||||
i = get_number(FALSE);
|
||||
i = get_number(FALSE, NULL);
|
||||
if (i < 1 || i > len)
|
||||
goto theend;
|
||||
}
|
||||
|
||||
54
src/misc1.c
54
src/misc1.c
@@ -3085,15 +3085,20 @@ get_keystroke()
|
||||
}
|
||||
|
||||
/*
|
||||
* get a number from the user
|
||||
* Get a number from the user.
|
||||
* When "mouse_used" is not NULL allow using the mouse.
|
||||
*/
|
||||
int
|
||||
get_number(colon)
|
||||
int colon; /* allow colon to abort */
|
||||
get_number(colon, mouse_used)
|
||||
int colon; /* allow colon to abort */
|
||||
int *mouse_used;
|
||||
{
|
||||
int n = 0;
|
||||
int c;
|
||||
|
||||
if (mouse_used != NULL)
|
||||
*mouse_used = FALSE;
|
||||
|
||||
/* When not printing messages, the user won't know what to type, return a
|
||||
* zero (as if CR was hit). */
|
||||
if (msg_silent != 0)
|
||||
@@ -3118,6 +3123,14 @@ get_number(colon)
|
||||
n /= 10;
|
||||
MSG_PUTS("\b \b");
|
||||
}
|
||||
#ifdef FEAT_MOUSE
|
||||
else if (mouse_used != NULL && c == K_LEFTMOUSE)
|
||||
{
|
||||
*mouse_used = TRUE;
|
||||
n = mouse_row + 1;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
else if (n == 0 && c == ':' && colon)
|
||||
{
|
||||
stuffcharReadbuff(':');
|
||||
@@ -3137,9 +3150,12 @@ get_number(colon)
|
||||
|
||||
/*
|
||||
* Ask the user to enter a number.
|
||||
* When "mouse_used" is not NULL allow using the mouse and in that case return
|
||||
* the line number.
|
||||
*/
|
||||
int
|
||||
prompt_for_number()
|
||||
prompt_for_number(mouse_used)
|
||||
int *mouse_used;
|
||||
{
|
||||
int i;
|
||||
int save_cmdline_row;
|
||||
@@ -3152,12 +3168,16 @@ prompt_for_number()
|
||||
save_cmdline_row = cmdline_row;
|
||||
cmdline_row = Rows - 1;
|
||||
save_State = State;
|
||||
State = CMDLINE;
|
||||
if (mouse_used == NULL)
|
||||
State = CMDLINE;
|
||||
else
|
||||
State = NORMAL;
|
||||
|
||||
i = get_number(TRUE);
|
||||
if (KeyTyped) /* don't call wait_return() now */
|
||||
i = get_number(TRUE, mouse_used);
|
||||
if (KeyTyped)
|
||||
{
|
||||
msg_putchar('\n');
|
||||
/* don't call wait_return() now */
|
||||
/* msg_putchar('\n'); */
|
||||
cmdline_row = msg_row - 1;
|
||||
need_wait_return = FALSE;
|
||||
msg_didany = FALSE;
|
||||
@@ -3426,24 +3446,30 @@ expand_env(src, dst, dstlen)
|
||||
char_u *dst; /* where to put the result */
|
||||
int dstlen; /* maximum length of the result */
|
||||
{
|
||||
expand_env_esc(src, dst, dstlen, FALSE);
|
||||
expand_env_esc(src, dst, dstlen, FALSE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
expand_env_esc(src, dst, dstlen, esc)
|
||||
char_u *src; /* input string e.g. "$HOME/vim.hlp" */
|
||||
expand_env_esc(srcp, dst, dstlen, esc, startstr)
|
||||
char_u *srcp; /* input string e.g. "$HOME/vim.hlp" */
|
||||
char_u *dst; /* where to put the result */
|
||||
int dstlen; /* maximum length of the result */
|
||||
int esc; /* escape spaces in expanded variables */
|
||||
char_u *startstr; /* start again after this (can be NULL) */
|
||||
{
|
||||
char_u *src;
|
||||
char_u *tail;
|
||||
int c;
|
||||
char_u *var;
|
||||
int copy_char;
|
||||
int mustfree; /* var was allocated, need to free it later */
|
||||
int at_start = TRUE; /* at start of a name */
|
||||
int startstr_len = 0;
|
||||
|
||||
src = skipwhite(src);
|
||||
if (startstr != NULL)
|
||||
startstr_len = STRLEN(startstr);
|
||||
|
||||
src = skipwhite(srcp);
|
||||
--dstlen; /* leave one char space for "\," */
|
||||
while (*src && dstlen > 0)
|
||||
{
|
||||
@@ -3679,6 +3705,10 @@ expand_env_esc(src, dst, dstlen, esc)
|
||||
at_start = TRUE;
|
||||
*dst++ = *src++;
|
||||
--dstlen;
|
||||
|
||||
if (startstr != NULL && src - startstr_len >= srcp
|
||||
&& STRNCMP(src - startstr_len, startstr, startstr_len) == 0)
|
||||
at_start = TRUE;
|
||||
}
|
||||
}
|
||||
*dst = NUL;
|
||||
|
||||
25
src/option.c
25
src/option.c
@@ -2040,7 +2040,7 @@ static struct vimoption
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
},
|
||||
{"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF,
|
||||
{"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND,
|
||||
#ifdef FEAT_SYN_HL
|
||||
(char_u *)&p_spl, PV_SPL,
|
||||
{(char_u *)"en", (char_u *)0L}
|
||||
@@ -2049,7 +2049,7 @@ static struct vimoption
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
},
|
||||
{"spellsuggest", "sps", P_STRING|P_VI_DEF,
|
||||
{"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
|
||||
#ifdef FEAT_SYN_HL
|
||||
(char_u *)&p_sps, PV_NONE,
|
||||
{(char_u *)"best", (char_u *)0L}
|
||||
@@ -4554,9 +4554,14 @@ option_expand(opt_idx, val)
|
||||
* Expanding this with NameBuff, expand_env() must not be passed IObuff.
|
||||
* Escape spaces when expanding 'tags', they are used to separate file
|
||||
* names.
|
||||
* For 'spellsuggest' expand after "file:".
|
||||
*/
|
||||
expand_env_esc(val, NameBuff, MAXPATHL,
|
||||
(char_u **)options[opt_idx].var == &p_tags);
|
||||
(char_u **)options[opt_idx].var == &p_tags,
|
||||
#ifdef FEAT_SYN_HL
|
||||
(char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
|
||||
#endif
|
||||
NULL);
|
||||
if (STRCMP(NameBuff, val) == 0) /* they are the same */
|
||||
return NULL;
|
||||
|
||||
@@ -4590,7 +4595,7 @@ didset_options()
|
||||
(void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
|
||||
#endif
|
||||
#ifdef FEAT_SYN_HL
|
||||
(void)opt_strings_flags(p_sps, p_sps_values, &sps_flags, FALSE);
|
||||
(void)spell_check_sps();
|
||||
#endif
|
||||
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
|
||||
(void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
|
||||
@@ -5753,7 +5758,7 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
|
||||
/* 'spellsuggest' */
|
||||
else if (varp == &p_sps)
|
||||
{
|
||||
if (opt_strings_flags(p_sps, p_sps_values, &sps_flags, FALSE) != OK)
|
||||
if (spell_check_sps() != OK)
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
#endif
|
||||
@@ -9013,6 +9018,16 @@ set_context_in_set_cmd(xp, arg, opt_flags)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_SYN_HL
|
||||
/* for 'spellsuggest' start at "file:" */
|
||||
if (options[opt_idx].var == (char_u *)&p_sps
|
||||
&& STRNCMP(p, "file:", 5) == 0)
|
||||
{
|
||||
xp->xp_pattern = p + 5;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -708,13 +708,6 @@ EXTERN int p_sb; /* 'splitbelow' */
|
||||
#endif
|
||||
#ifdef FEAT_SYN_HL
|
||||
EXTERN char_u *p_sps; /* 'spellsuggest' */
|
||||
EXTERN unsigned sps_flags;
|
||||
# ifdef IN_OPTION_C
|
||||
static char *(p_sps_values[]) = {"best", "fast", "double", NULL};
|
||||
# endif
|
||||
# define SPS_BEST 0x01
|
||||
# define SPS_FAST 0x02
|
||||
# define SPS_DOUBLE 0x04
|
||||
#endif
|
||||
#ifdef FEAT_VERTSPLIT
|
||||
EXTERN int p_spr; /* 'splitright' */
|
||||
|
||||
@@ -20,6 +20,8 @@ int skip_expr __ARGS((char_u **pp));
|
||||
char_u *eval_to_string __ARGS((char_u *arg, char_u **nextcmd));
|
||||
char_u *eval_to_string_safe __ARGS((char_u *arg, char_u **nextcmd));
|
||||
int eval_to_number __ARGS((char_u *expr));
|
||||
list_T *eval_spell_expr __ARGS((char_u *badword, char_u *expr));
|
||||
int get_spellword __ARGS((list_T *list, char_u **pp));
|
||||
char_u *call_vim_function __ARGS((char_u *func, int argc, char_u **argv, int safe));
|
||||
void *save_funccal __ARGS((void));
|
||||
void restore_funccal __ARGS((void *vfc));
|
||||
@@ -37,6 +39,7 @@ void ex_lockvar __ARGS((exarg_T *eap));
|
||||
int do_unlet __ARGS((char_u *name, int forceit));
|
||||
void del_menutrans_vars __ARGS((void));
|
||||
char_u *get_user_var_name __ARGS((expand_T *xp, int idx));
|
||||
void list_unref __ARGS((list_T *l));
|
||||
int list_append_dict __ARGS((list_T *list, dict_T *dict));
|
||||
int garbage_collect __ARGS((void));
|
||||
dict_T *dict_alloc __ARGS((void));
|
||||
|
||||
@@ -41,15 +41,15 @@ void check_status __ARGS((buf_T *buf));
|
||||
void change_warning __ARGS((int col));
|
||||
int ask_yesno __ARGS((char_u *str, int direct));
|
||||
int get_keystroke __ARGS((void));
|
||||
int get_number __ARGS((int colon));
|
||||
int prompt_for_number __ARGS((void));
|
||||
int get_number __ARGS((int colon, int *mouse_used));
|
||||
int prompt_for_number __ARGS((int *mouse_used));
|
||||
void msgmore __ARGS((long n));
|
||||
void beep_flush __ARGS((void));
|
||||
void vim_beep __ARGS((void));
|
||||
void init_homedir __ARGS((void));
|
||||
void free_homedir __ARGS((void));
|
||||
void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
|
||||
void expand_env_esc __ARGS((char_u *src, char_u *dst, int dstlen, int esc));
|
||||
void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
|
||||
char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
|
||||
char_u *expand_env_save __ARGS((char_u *src));
|
||||
void vim_setenv __ARGS((char_u *name, char_u *val));
|
||||
|
||||
@@ -10,7 +10,10 @@ void ex_mkspell __ARGS((exarg_T *eap));
|
||||
void ex_spell __ARGS((exarg_T *eap));
|
||||
void spell_add_word __ARGS((char_u *word, int len, int bad));
|
||||
void init_spell_chartab __ARGS((void));
|
||||
int spell_check_sps __ARGS((void));
|
||||
void spell_suggest __ARGS((void));
|
||||
void ex_spellrepall __ARGS((exarg_T *eap));
|
||||
void spell_suggest_list __ARGS((garray_T *gap, char_u *word, int maxcount));
|
||||
char_u *eval_soundfold __ARGS((char_u *word));
|
||||
void ex_spelldump __ARGS((exarg_T *eap));
|
||||
/* vim: set ft=c : */
|
||||
|
||||
@@ -36,5 +36,5 @@
|
||||
#define VIM_VERSION_NODOT "vim70aa"
|
||||
#define VIM_VERSION_SHORT "7.0aa"
|
||||
#define VIM_VERSION_MEDIUM "7.0aa ALPHA"
|
||||
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jun 27)"
|
||||
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jun 27, compiled "
|
||||
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jun 28)"
|
||||
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jun 28, compiled "
|
||||
|
||||
Reference in New Issue
Block a user