Mercurial > vim
comparison src/edit.c @ 825:6675076019ae v7.0d
updated for version 7.0d
author | vimboss |
---|---|
date | Mon, 10 Apr 2006 14:55:34 +0000 |
parents | 23f82b5d2814 |
children | 1cdd2661f34c |
comparison
equal
deleted
inserted
replaced
824:8dd456c1e283 | 825:6675076019ae |
---|---|
87 * ins_compl_get_exp(). | 87 * ins_compl_get_exp(). |
88 */ | 88 */ |
89 static compl_T *compl_first_match = NULL; | 89 static compl_T *compl_first_match = NULL; |
90 static compl_T *compl_curr_match = NULL; | 90 static compl_T *compl_curr_match = NULL; |
91 static compl_T *compl_shown_match = NULL; | 91 static compl_T *compl_shown_match = NULL; |
92 | |
93 /* After using a cursor key <Enter> selects a match in the popup menu, | |
94 * otherwise it inserts a line break. */ | |
95 static int compl_enter_selects = FALSE; | |
92 | 96 |
93 /* When "compl_leader" is not NULL only matches that start with this string | 97 /* When "compl_leader" is not NULL only matches that start with this string |
94 * are used. */ | 98 * are used. */ |
95 static char_u *compl_leader = NULL; | 99 static char_u *compl_leader = NULL; |
96 | 100 |
724 { | 728 { |
725 ins_compl_addleader(c); | 729 ins_compl_addleader(c); |
726 continue; | 730 continue; |
727 } | 731 } |
728 | 732 |
729 /* Pressing CTRL-Y selects the current match. */ | 733 /* Pressing CTRL-Y selects the current match. Shen |
730 if (c == Ctrl_Y) | 734 * compl_enter_selects is set the Enter key does the same. */ |
735 if (c == Ctrl_Y || (compl_enter_selects | |
736 && (c == CAR || c == K_KENTER || c == NL))) | |
731 { | 737 { |
732 ins_compl_delete(); | 738 ins_compl_delete(); |
733 ins_compl_insert(); | 739 ins_compl_insert(); |
734 } | 740 } |
735 } | 741 } |
2913 vim_free(compl_leader); | 2919 vim_free(compl_leader); |
2914 compl_leader = NULL; | 2920 compl_leader = NULL; |
2915 edit_submode_extra = NULL; | 2921 edit_submode_extra = NULL; |
2916 vim_free(compl_orig_text); | 2922 vim_free(compl_orig_text); |
2917 compl_orig_text = NULL; | 2923 compl_orig_text = NULL; |
2924 compl_enter_selects = FALSE; | |
2918 } | 2925 } |
2919 | 2926 |
2920 /* | 2927 /* |
2921 * Return TRUE when Insert completion is active. | 2928 * Return TRUE when Insert completion is active. |
2922 */ | 2929 */ |
2974 } | 2981 } |
2975 | 2982 |
2976 /* Show the popup menu with a different set of matches. */ | 2983 /* Show the popup menu with a different set of matches. */ |
2977 ins_compl_show_pum(); | 2984 ins_compl_show_pum(); |
2978 compl_used_match = FALSE; | 2985 compl_used_match = FALSE; |
2986 compl_enter_selects = FALSE; | |
2979 | 2987 |
2980 return TRUE; | 2988 return TRUE; |
2981 } | 2989 } |
2982 return FALSE; | 2990 return FALSE; |
2983 } | 2991 } |
3012 { | 3020 { |
3013 /* Show the popup menu with a different set of matches. */ | 3021 /* Show the popup menu with a different set of matches. */ |
3014 ins_compl_del_pum(); | 3022 ins_compl_del_pum(); |
3015 ins_compl_show_pum(); | 3023 ins_compl_show_pum(); |
3016 compl_used_match = FALSE; | 3024 compl_used_match = FALSE; |
3025 compl_enter_selects = FALSE; | |
3017 ins_compl_set_original_text(compl_leader); | 3026 ins_compl_set_original_text(compl_leader); |
3018 } | 3027 } |
3019 } | 3028 } |
3020 | 3029 |
3021 /* | 3030 /* |
3275 } | 3284 } |
3276 | 3285 |
3277 auto_format(FALSE, TRUE); | 3286 auto_format(FALSE, TRUE); |
3278 | 3287 |
3279 /* If the popup menu is displayed pressing CTRL-Y means accepting | 3288 /* If the popup menu is displayed pressing CTRL-Y means accepting |
3280 * the selection without inserting anything. */ | 3289 * the selection without inserting anything. When |
3281 if (c == Ctrl_Y && pum_visible()) | 3290 * compl_enter_selects is set the Enter key does the same. */ |
3291 if ((c == Ctrl_Y || (compl_enter_selects | |
3292 && (c == CAR || c == K_KENTER || c == NL))) | |
3293 && pum_visible()) | |
3282 retval = TRUE; | 3294 retval = TRUE; |
3283 | 3295 |
3284 /* CTRL-E means completion is Ended, go back to the typed text. */ | 3296 /* CTRL-E means completion is Ended, go back to the typed text. */ |
3285 if (c == Ctrl_E) | 3297 if (c == Ctrl_E) |
3286 { | 3298 { |
3296 ins_compl_free(); | 3308 ins_compl_free(); |
3297 compl_started = FALSE; | 3309 compl_started = FALSE; |
3298 compl_matches = 0; | 3310 compl_matches = 0; |
3299 msg_clr_cmdline(); /* necessary for "noshowmode" */ | 3311 msg_clr_cmdline(); /* necessary for "noshowmode" */ |
3300 ctrl_x_mode = 0; | 3312 ctrl_x_mode = 0; |
3313 compl_enter_selects = FALSE; | |
3301 if (edit_submode != NULL) | 3314 if (edit_submode != NULL) |
3302 { | 3315 { |
3303 edit_submode = NULL; | 3316 edit_submode = NULL; |
3304 showmode(); | 3317 showmode(); |
3305 } | 3318 } |
4047 /* Delete old text to be replaced, since we're still searching and | 4060 /* Delete old text to be replaced, since we're still searching and |
4048 * don't want to match ourselves! */ | 4061 * don't want to match ourselves! */ |
4049 ins_compl_delete(); | 4062 ins_compl_delete(); |
4050 } | 4063 } |
4051 | 4064 |
4065 /* Enter will select a match when the match wasn't inserted and the popup | |
4066 * menu is visislbe. */ | |
4067 compl_enter_selects = !insert_match && compl_match_array != NULL; | |
4068 | |
4052 /* | 4069 /* |
4053 * Show the file name for the match (if any) | 4070 * Show the file name for the match (if any) |
4054 * Truncate the file name to avoid a wait for return. | 4071 * Truncate the file name to avoid a wait for return. |
4055 */ | 4072 */ |
4056 if (compl_shown_match->cp_fname != NULL) | 4073 if (compl_shown_match->cp_fname != NULL) |
7275 case Ctrl_J: | 7292 case Ctrl_J: |
7276 case 'j': ins_down(TRUE); | 7293 case 'j': ins_down(TRUE); |
7277 break; | 7294 break; |
7278 | 7295 |
7279 /* CTRL-G u: start new undoable edit */ | 7296 /* CTRL-G u: start new undoable edit */ |
7280 case 'u': u_sync(); | 7297 case 'u': u_sync(TRUE); |
7281 ins_need_undo = TRUE; | 7298 ins_need_undo = TRUE; |
7282 | 7299 |
7283 /* Need to reset Insstart, esp. because a BS that joins | 7300 /* Need to reset Insstart, esp. because a BS that joins |
7284 * aline to the previous one must save for undo. */ | 7301 * aline to the previous one must save for undo. */ |
7285 Insstart = curwin->w_cursor; | 7302 Insstart = curwin->w_cursor; |