summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2006-03-19 22:15:26 +0000
committerBram Moolenaar <Bram@vim.org>2006-03-19 22:15:26 +0000
commit39f05630adc017f00ea551b827fd1d5ef21a0a3a (patch)
tree72e84a7bf71a46889d89f8ae8b6f5075b5784e65 /src
parentc15ef30c08fa1f2c52053c6345ded69d6f2bc701 (diff)
downloadvim-git-39f05630adc017f00ea551b827fd1d5ef21a0a3a.tar.gz
updated for version 7.0229
Diffstat (limited to 'src')
-rw-r--r--src/edit.c151
-rw-r--r--src/gui_w32.c2
-rw-r--r--src/option.c2
-rw-r--r--src/structs.h8
-rw-r--r--src/version.h4
5 files changed, 97 insertions, 70 deletions
diff --git a/src/edit.c b/src/edit.c
index 0cac94531..898f9235e 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -69,9 +69,7 @@ struct compl_S
compl_T *cp_prev;
char_u *cp_str; /* matched text */
char cp_icase; /* TRUE or FALSE: ignore case */
- char_u *cp_kind; /* kind menu text (allocated, can be NULL) */
- char_u *cp_extra; /* extra menu text (allocated, can be NULL) */
- char_u *cp_info; /* verbose info (can be NULL) */
+ char_u *(cp_text[CPT_COUNT]); /* text for the menu */
char_u *cp_fname; /* file containing the match, allocated when
* cp_flags has FREE_FNAME */
int cp_flags; /* ORIGINAL_TEXT, CONT_S_IPOS or FREE_FNAME */
@@ -2060,10 +2058,9 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
/* Copy the original case of the part we typed */
STRNCPY(IObuff, compl_orig_text, compl_length);
- return ins_compl_add(IObuff, len, icase, fname, NULL, NULL, NULL,
- dir, flags);
+ return ins_compl_add(IObuff, len, icase, fname, NULL, dir, flags);
}
- return ins_compl_add(str, len, icase, fname, NULL, NULL, NULL, dir, flags);
+ return ins_compl_add(str, len, icase, fname, NULL, dir, flags);
}
/*
@@ -2073,14 +2070,12 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
* maybe because alloc() returns NULL, then FAIL is returned.
*/
int
-ins_compl_add(str, len, icase, fname, kind, extra, info, cdir, flags)
+ins_compl_add(str, len, icase, fname, cptext, cdir, flags)
char_u *str;
int len;
int icase;
char_u *fname;
- char_u *kind; /* extra text for popup menu or NULL */
- char_u *extra; /* extra text for popup menu or NULL */
- char_u *info; /* extra text for popup menu or NULL */
+ char_u **cptext; /* extra text for popup menu or NULL */
int cdir;
int flags;
{
@@ -2146,12 +2141,15 @@ ins_compl_add(str, len, icase, fname, kind, extra, info, cdir, flags)
else
match->cp_fname = NULL;
match->cp_flags = flags;
- if (kind != NULL && *kind != NUL)
- match->cp_kind = vim_strsave(kind);
- if (extra != NULL && *extra != NUL)
- match->cp_extra = vim_strsave(extra);
- if (info != NULL && *info != NUL)
- match->cp_info = vim_strsave(info);
+
+ if (cptext != NULL)
+ {
+ int i;
+
+ for (i = 0; i < CPT_COUNT; ++i)
+ if (cptext[i] != NULL && *cptext[i] != NUL)
+ match->cp_text[i] = vim_strsave(cptext[i]);
+ }
/*
* Link the new match structure in the list of matches.
@@ -2285,7 +2283,7 @@ ins_compl_add_matches(num_matches, matches, icase)
for (i = 0; i < num_matches && add_r != FAIL; i++)
if ((add_r = ins_compl_add(matches[i], -1, icase,
- NULL, NULL, NULL, NULL, dir, 0)) == OK)
+ NULL, NULL, dir, 0)) == OK)
/* if dir was BACKWARD then honor it just once */
dir = FORWARD;
FreeWild(num_matches, matches);
@@ -2343,7 +2341,7 @@ set_completion(startcol, list)
/* compl_pattern doesn't need to be set */
compl_orig_text = vim_strnsave(ml_get_curline() + compl_col, compl_length);
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
- -1, FALSE, NULL, NULL, NULL, NULL, 0, ORIGINAL_TEXT) != OK)
+ -1, FALSE, NULL, NULL, 0, ORIGINAL_TEXT) != OK)
return;
/* Handle like dictionary completion. */
@@ -2511,13 +2509,17 @@ ins_compl_show_pum()
shown_compl = compl;
cur = i;
}
- compl_match_array[i].pum_text = compl->cp_str;
- if (compl->cp_kind != NULL)
- compl_match_array[i].pum_kind = compl->cp_kind;
- if (compl->cp_info != NULL)
- compl_match_array[i].pum_info = compl->cp_info;
- if (compl->cp_extra != NULL)
- compl_match_array[i++].pum_extra = compl->cp_extra;
+
+ if (compl->cp_text[CPT_ABBR] != NULL)
+ compl_match_array[i].pum_text =
+ compl->cp_text[CPT_ABBR];
+ else
+ compl_match_array[i].pum_text = compl->cp_str;
+ compl_match_array[i].pum_kind = compl->cp_text[CPT_KIND];
+ compl_match_array[i].pum_info = compl->cp_text[CPT_INFO];
+ if (compl->cp_text[CPT_MENU] != NULL)
+ compl_match_array[i++].pum_extra =
+ compl->cp_text[CPT_MENU];
else
compl_match_array[i++].pum_extra = compl->cp_fname;
}
@@ -2550,7 +2552,9 @@ ins_compl_show_pum()
{
/* popup menu already exists, only need to find the current item.*/
for (i = 0; i < compl_match_arraysize; ++i)
- if (compl_match_array[i].pum_text == compl_shown_match->cp_str)
+ if (compl_match_array[i].pum_text == compl_shown_match->cp_str
+ || compl_match_array[i].pum_text
+ == compl_shown_match->cp_text[CPT_ABBR])
break;
cur = i;
}
@@ -2859,6 +2863,7 @@ find_line_end(ptr)
ins_compl_free()
{
compl_T *match;
+ int i;
vim_free(compl_pattern);
compl_pattern = NULL;
@@ -2880,9 +2885,8 @@ ins_compl_free()
/* several entries may use the same fname, free it just once. */
if (match->cp_flags & FREE_FNAME)
vim_free(match->cp_fname);
- vim_free(match->cp_kind);
- vim_free(match->cp_extra);
- vim_free(match->cp_info);
+ for (i = 0; i < CPT_COUNT; ++i)
+ vim_free(match->cp_text[i]);
vim_free(match);
} while (compl_curr_match != NULL && compl_curr_match != compl_first_match);
compl_first_match = compl_curr_match = NULL;
@@ -3377,56 +3381,66 @@ expand_by_function(type, base)
}
#endif /* FEAT_COMPL_FUNC */
-#if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL)
+#if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) || defined(PROTO)
/*
* Add completions from a list.
- * Unreferences the list.
*/
static void
ins_compl_add_list(list)
list_T *list;
{
listitem_T *li;
- int icase;
- char_u *p;
- char_u *x;
- char_u *k;
- char_u *info;
int dir = compl_direction;
/* Go through the List with matches and add each of them. */
for (li = list->lv_first; li != NULL; li = li->li_next)
{
- icase = p_ic;
- if (li->li_tv.v_type == VAR_DICT && li->li_tv.vval.v_dict != NULL)
- {
- p = get_dict_string(li->li_tv.vval.v_dict, (char_u *)"word", FALSE);
- x = get_dict_string(li->li_tv.vval.v_dict, (char_u *)"menu", FALSE);
- k = get_dict_string(li->li_tv.vval.v_dict, (char_u *)"kind", FALSE);
- info = get_dict_string(li->li_tv.vval.v_dict,
- (char_u *)"info", FALSE);
- if (get_dict_string(li->li_tv.vval.v_dict,
- (char_u *)"icase", FALSE) != NULL)
- icase = get_dict_number(li->li_tv.vval.v_dict,
- (char_u *)"icase");
- }
- else
- {
- p = get_tv_string_chk(&li->li_tv);
- x = NULL;
- k = NULL;
- info = NULL;
- }
- if (p != NULL && *p != NUL)
- {
- if (ins_compl_add(p, -1, icase, NULL, k, x, info, dir, 0) == OK)
- /* if dir was BACKWARD then honor it just once */
- dir = FORWARD;
- }
+ if (ins_compl_add_tv(&li->li_tv, dir) == OK)
+ /* if dir was BACKWARD then honor it just once */
+ dir = FORWARD;
else if (did_emsg)
break;
}
}
+
+/*
+ * Add a match to the list of matches from a typeval_T.
+ * If the given string is already in the list of completions, then return
+ * NOTDONE, otherwise add it to the list and return OK. If there is an error,
+ * maybe because alloc() returns NULL, then FAIL is returned.
+ */
+ int
+ins_compl_add_tv(tv, dir)
+ typval_T *tv;
+ int dir;
+{
+ char_u *word;
+ int icase = p_ic;
+ char_u *(cptext[CPT_COUNT]);
+
+ if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
+ {
+ word = get_dict_string(tv->vval.v_dict, (char_u *)"word", FALSE);
+ cptext[CPT_ABBR] = get_dict_string(tv->vval.v_dict,
+ (char_u *)"abbr", FALSE);
+ cptext[CPT_MENU] = get_dict_string(tv->vval.v_dict,
+ (char_u *)"menu", FALSE);
+ cptext[CPT_KIND] = get_dict_string(tv->vval.v_dict,
+ (char_u *)"kind", FALSE);
+ cptext[CPT_INFO] = get_dict_string(tv->vval.v_dict,
+ (char_u *)"info", FALSE);
+ if (get_dict_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL)
+ icase = get_dict_number(tv->vval.v_dict, (char_u *)"icase");
+ }
+ else
+ {
+ word = get_tv_string_chk(tv);
+ vim_memset(cptext, 0, sizeof(cptext));
+ }
+ if (word == NULL || *word == NUL)
+ return FAIL;
+ return ins_compl_add(word, -1, icase, NULL, cptext, dir, 0);
+}
#endif
/*
@@ -4509,7 +4523,7 @@ ins_complete(c)
vim_free(compl_orig_text);
compl_orig_text = vim_strnsave(line + compl_col, compl_length);
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
- -1, FALSE, NULL, NULL, NULL, NULL, 0, ORIGINAL_TEXT) != OK)
+ -1, FALSE, NULL, NULL, 0, ORIGINAL_TEXT) != OK)
{
vim_free(compl_pattern);
compl_pattern = NULL;
@@ -5887,10 +5901,15 @@ stop_insert(end_insert_pos, esc)
pos_T tpos = curwin->w_cursor;
curwin->w_cursor = *end_insert_pos;
- if (gchar_cursor() == NUL && curwin->w_cursor.col > 0)
- --curwin->w_cursor.col;
- while (cc = gchar_cursor(), vim_iswhite(cc))
+ for (;;)
+ {
+ if (gchar_cursor() == NUL && curwin->w_cursor.col > 0)
+ --curwin->w_cursor.col;
+ cc = gchar_cursor();
+ if (!vim_iswhite(cc))
+ break;
(void)del_char(TRUE);
+ }
if (curwin->w_cursor.lnum != tpos.lnum)
curwin->w_cursor = tpos;
else if (cc != NUL)
diff --git a/src/gui_w32.c b/src/gui_w32.c
index 3c3d9949b..12d607146 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -1813,7 +1813,7 @@ im_get_status()
#ifdef FEAT_MBYTE
/*
- * Convert latin9 text to ucs-2.
+ * Convert latin9 text "text[len]" to ucs-2 in "unicodebuf".
*/
static void
latin9_to_ucs(char_u *text, int len, WCHAR *unicodebuf)
diff --git a/src/option.c b/src/option.c
index 8b3d8c660..8bfeb98f8 100644
--- a/src/option.c
+++ b/src/option.c
@@ -580,7 +580,7 @@ static struct vimoption
(char_u *)&p_beval, PV_NONE,
{(char_u *)FALSE, (char_u *)0L}},
# ifdef FEAT_EVAL
- {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
+ {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
(char_u *)&p_bexpr, PV_NONE,
{(char_u *)"", (char_u *)0L}},
# endif
diff --git a/src/structs.h b/src/structs.h
index 6abdc4149..907b1cc27 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -2283,3 +2283,11 @@ typedef struct
void *tn_search_ctx;
} tagname_T;
+/*
+ * Array indexes used for cptext argument of ins_compl_add().
+ */
+#define CPT_ABBR 0 /* "abbr" */
+#define CPT_MENU 1 /* "menu" */
+#define CPT_KIND 2 /* "kind" */
+#define CPT_INFO 3 /* "info" */
+#define CPT_COUNT 4 /* Number of entries */
diff --git a/src/version.h b/src/version.h
index 6e8bfdcb7..365d28868 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 (2006 Mar 18)"
-#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 18, compiled "
+#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 19)"
+#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 19, compiled "