comparison src/edit.c @ 1430:342cf2a9f5cc v7.1.145

updated for version 7.1-145
author vimboss
date Fri, 19 Oct 2007 18:40:51 +0000
parents bdcfe793d49f
children 40aa7ae37901
comparison
equal deleted inserted replaced
1429:3372616fe1f1 1430:342cf2a9f5cc
127 static int compl_cont_mode = 0; 127 static int compl_cont_mode = 0;
128 static expand_T compl_xp; 128 static expand_T compl_xp;
129 129
130 static void ins_ctrl_x __ARGS((void)); 130 static void ins_ctrl_x __ARGS((void));
131 static int has_compl_option __ARGS((int dict_opt)); 131 static int has_compl_option __ARGS((int dict_opt));
132 static int ins_compl_accept_char __ARGS((int c));
132 static int ins_compl_add __ARGS((char_u *str, int len, int icase, char_u *fname, char_u **cptext, int cdir, int flags, int adup)); 133 static int ins_compl_add __ARGS((char_u *str, int len, int icase, char_u *fname, char_u **cptext, int cdir, int flags, int adup));
133 static int ins_compl_equal __ARGS((compl_T *match, char_u *str, int len)); 134 static int ins_compl_equal __ARGS((compl_T *match, char_u *str, int len));
134 static void ins_compl_longest_match __ARGS((compl_T *match)); 135 static void ins_compl_longest_match __ARGS((compl_T *match));
135 static void ins_compl_add_matches __ARGS((int num_matches, char_u **matches, int icase)); 136 static void ins_compl_add_matches __ARGS((int num_matches, char_u **matches, int icase));
136 static int ins_compl_make_cyclic __ARGS((void)); 137 static int ins_compl_make_cyclic __ARGS((void));
752 { 753 {
753 ins_compl_addfrommatch(); 754 ins_compl_addfrommatch();
754 continue; 755 continue;
755 } 756 }
756 757
757 /* A printable, non-white character: Add to "compl_leader". */ 758 /* A non-white character that fits in with the current
758 if (vim_isprintc(c) && !vim_iswhite(c)) 759 * completion: Add to "compl_leader". */
760 if (ins_compl_accept_char(c))
759 { 761 {
760 ins_compl_addleader(c); 762 ins_compl_addleader(c);
761 continue; 763 continue;
762 } 764 }
763 765
2051 EMSG(_(e_internal)); 2053 EMSG(_(e_internal));
2052 return FALSE; 2054 return FALSE;
2053 } 2055 }
2054 2056
2055 /* 2057 /*
2058 * Return TRUE when character "c" is part of the item currently being
2059 * completed. Used to decide whether to abandon complete mode when the menu
2060 * is visible.
2061 */
2062 static int
2063 ins_compl_accept_char(c)
2064 int c;
2065 {
2066 if (ctrl_x_mode & CTRL_X_WANT_IDENT)
2067 /* When expanding an identifier only accept identifier chars. */
2068 return vim_isIDc(c);
2069
2070 switch (ctrl_x_mode)
2071 {
2072 case CTRL_X_FILES:
2073 /* When expanding file name only accept file name chars. But not
2074 * path separators, so that "proto/<Tab>" expands files in
2075 * "proto", not "proto/" as a whole */
2076 return vim_isfilec(c) && !vim_ispathsep(c);
2077
2078 case CTRL_X_CMDLINE:
2079 case CTRL_X_OMNI:
2080 /* Command line and Omni completion can work with just about any
2081 * printable character, but do stop at white space. */
2082 return vim_isprintc(c) && !vim_iswhite(c);
2083
2084 case CTRL_X_WHOLE_LINE:
2085 /* For while line completion a space can be part of the line. */
2086 return vim_isprintc(c);
2087 }
2088 return vim_iswordc(c);
2089 }
2090
2091 /*
2056 * This is like ins_compl_add(), but if 'ic' and 'inf' are set, then the 2092 * This is like ins_compl_add(), but if 'ic' and 'inf' are set, then the
2057 * case of the originally typed text is used, and the case of the completed 2093 * case of the originally typed text is used, and the case of the completed
2058 * text is inferred, ie this tries to work out what case you probably wanted 2094 * text is inferred, ie this tries to work out what case you probably wanted
2059 * the rest of the word to be in -- webb 2095 * the rest of the word to be in -- webb
2060 */ 2096 */
3126 3162
3127 line = ml_get_curline(); 3163 line = ml_get_curline();
3128 p = line + curwin->w_cursor.col; 3164 p = line + curwin->w_cursor.col;
3129 mb_ptr_back(line, p); 3165 mb_ptr_back(line, p);
3130 3166
3131 /* Stop completion when the whole word was deleted. */ 3167 /* Stop completion when the whole word was deleted. For Omni completion
3132 if ((int)(p - line) - (int)compl_col <= 0) 3168 * allow the word to be deleted, we won't match everything. */
3169 if ((int)(p - line) - (int)compl_col < 0
3170 || ((int)(p - line) - (int)compl_col == 0
3171 && (ctrl_x_mode & CTRL_X_OMNI) == 0))
3133 return K_BS; 3172 return K_BS;
3134 3173
3135 /* Deleted more than what was used to find matches or didn't finish 3174 /* Deleted more than what was used to find matches or didn't finish
3136 * finding all matches: need to look for matches all over again. */ 3175 * finding all matches: need to look for matches all over again. */
3137 if (curwin->w_cursor.col <= compl_col + compl_length 3176 if (curwin->w_cursor.col <= compl_col + compl_length
4589 4628
4590 line = ml_get(curwin->w_cursor.lnum); 4629 line = ml_get(curwin->w_cursor.lnum);
4591 curs_col = curwin->w_cursor.col; 4630 curs_col = curwin->w_cursor.col;
4592 compl_pending = 0; 4631 compl_pending = 0;
4593 4632
4594 /* if this same ctrl_x_mode has been interrupted use the text from 4633 /* If this same ctrl_x_mode has been interrupted use the text from
4595 * "compl_startpos" to the cursor as a pattern to add a new word 4634 * "compl_startpos" to the cursor as a pattern to add a new word
4596 * instead of expand the one before the cursor, in word-wise if 4635 * instead of expand the one before the cursor, in word-wise if
4597 * "compl_startpos" 4636 * "compl_startpos" is not in the same line as the cursor then fix it
4598 * is not in the same line as the cursor then fix it (the line has 4637 * (the line has been split because it was longer than 'tw'). if SOL
4599 * been split because it was longer than 'tw'). if SOL is set then 4638 * is set then skip the previous pattern, a word at the beginning of
4600 * skip the previous pattern, a word at the beginning of the line has 4639 * the line has been inserted, we'll look for that -- Acevedo. */
4601 * been inserted, we'll look for that -- Acevedo. */
4602 if ((compl_cont_status & CONT_INTRPT) == CONT_INTRPT 4640 if ((compl_cont_status & CONT_INTRPT) == CONT_INTRPT
4603 && compl_cont_mode == ctrl_x_mode) 4641 && compl_cont_mode == ctrl_x_mode)
4604 { 4642 {
4605 /* 4643 /*
4606 * it is a continued search 4644 * it is a continued search