diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 91 | ||||
-rw-r--r-- | src/ex_cmds.h | 2 | ||||
-rw-r--r-- | src/memline.c | 2 | ||||
-rw-r--r-- | src/misc1.c | 54 | ||||
-rw-r--r-- | src/option.c | 25 | ||||
-rw-r--r-- | src/option.h | 7 | ||||
-rw-r--r-- | src/proto/eval.pro | 3 | ||||
-rw-r--r-- | src/proto/misc1.pro | 6 | ||||
-rw-r--r-- | src/proto/spell.pro | 3 | ||||
-rw-r--r-- | src/version.h | 4 |
10 files changed, 163 insertions, 34 deletions
diff --git a/src/eval.c b/src/eval.c index 0e9a2ba17..66aed74e2 100644 --- a/src/eval.c +++ b/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)); @@ -13358,6 +13422,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 */ /* ARGSUSED */ diff --git a/src/ex_cmds.h b/src/ex_cmds.h index 6a06be5a4..48ef24b05 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -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, diff --git a/src/memline.c b/src/memline.c index 9f9e3074f..47dc00d84 100644 --- a/src/memline.c +++ b/src/memline.c @@ -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; } diff --git a/src/misc1.c b/src/misc1.c index 87c0f1a0a..73d0ef250 100644 --- a/src/misc1.c +++ b/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; diff --git a/src/option.c b/src/option.c index 389ab6ea3..8553771ae 100644 --- a/src/option.c +++ b/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; diff --git a/src/option.h b/src/option.h index 0be4ac308..2b7e80d7e 100644 --- a/src/option.h +++ b/src/option.h @@ -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' */ diff --git a/src/proto/eval.pro b/src/proto/eval.pro index f03b28be9..9505ed027 100644 --- a/src/proto/eval.pro +++ b/src/proto/eval.pro @@ -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)); diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro index 94d04554c..be4c9df43 100644 --- a/src/proto/misc1.pro +++ b/src/proto/misc1.pro @@ -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)); diff --git a/src/proto/spell.pro b/src/proto/spell.pro index 37830ca6e..91483b022 100644 --- a/src/proto/spell.pro +++ b/src/proto/spell.pro @@ -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 : */ diff --git a/src/version.h b/src/version.h index 4dbd342ed..1b12b0ca2 100644 --- a/src/version.h +++ b/src/version.h @@ -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 " |