Mercurial > vim
comparison src/edit.c @ 716:8ae24f338cab v7.0217
updated for version 7.0217
author | vimboss |
---|---|
date | Tue, 07 Mar 2006 22:38:47 +0000 |
parents | 0f9f4761ad9c |
children | a35dce0cabc5 |
comparison
equal
deleted
inserted
replaced
715:b526e10493b1 | 716:8ae24f338cab |
---|---|
109 | 109 |
110 static int compl_matches = 0; | 110 static int compl_matches = 0; |
111 static char_u *compl_pattern = NULL; | 111 static char_u *compl_pattern = NULL; |
112 static int compl_direction = FORWARD; | 112 static int compl_direction = FORWARD; |
113 static int compl_shows_dir = FORWARD; | 113 static int compl_shows_dir = FORWARD; |
114 static int compl_pending = FALSE; | 114 static int compl_pending = 0; /* > 1 for postponed CTRL-N */ |
115 static pos_T compl_startpos; | 115 static pos_T compl_startpos; |
116 static colnr_T compl_col = 0; /* column where the text starts | 116 static colnr_T compl_col = 0; /* column where the text starts |
117 * that is being completed */ | 117 * that is being completed */ |
118 static char_u *compl_orig_text = NULL; /* text as it was before | 118 static char_u *compl_orig_text = NULL; /* text as it was before |
119 * completion started */ | 119 * completion started */ |
2464 } | 2464 } |
2465 | 2465 |
2466 if (compl == compl_shown_match) | 2466 if (compl == compl_shown_match) |
2467 { | 2467 { |
2468 did_find_shown_match = TRUE; | 2468 did_find_shown_match = TRUE; |
2469 | |
2470 /* When the original text is the shown match don't set | |
2471 * compl_shown_match. */ | |
2472 if (compl->cp_flags & ORIGINAL_TEXT) | |
2473 shown_match_ok = TRUE; | |
2474 | |
2469 if (!shown_match_ok && shown_compl != NULL) | 2475 if (!shown_match_ok && shown_compl != NULL) |
2470 { | 2476 { |
2471 /* The shown match isn't displayed, set it to the | 2477 /* The shown match isn't displayed, set it to the |
2472 * previously displayed match. */ | 2478 * previously displayed match. */ |
2473 compl_shown_match = shown_compl; | 2479 compl_shown_match = shown_compl; |
3835 if (allow_get_expansion && insert_match | 3841 if (allow_get_expansion && insert_match |
3836 && (!compl_get_longest || compl_used_match)) | 3842 && (!compl_get_longest || compl_used_match)) |
3837 /* Delete old text to be replaced */ | 3843 /* Delete old text to be replaced */ |
3838 ins_compl_delete(); | 3844 ins_compl_delete(); |
3839 | 3845 |
3840 compl_pending = FALSE; | |
3841 | |
3842 /* Repeat this for when <PageUp> or <PageDown> is typed. But don't wrap | 3846 /* Repeat this for when <PageUp> or <PageDown> is typed. But don't wrap |
3843 * around. */ | 3847 * around. */ |
3844 while (--todo >= 0) | 3848 while (--todo >= 0) |
3845 { | 3849 { |
3846 if (compl_shows_dir == FORWARD && compl_shown_match->cp_next != NULL) | 3850 if (compl_shows_dir == FORWARD && compl_shown_match->cp_next != NULL) |
3847 { | 3851 { |
3852 if (compl_pending != 0) | |
3853 --compl_pending; | |
3848 compl_shown_match = compl_shown_match->cp_next; | 3854 compl_shown_match = compl_shown_match->cp_next; |
3849 found_end = (compl_first_match != NULL | 3855 found_end = (compl_first_match != NULL |
3850 && (compl_shown_match->cp_next == compl_first_match | 3856 && (compl_shown_match->cp_next == compl_first_match |
3851 || compl_shown_match == compl_first_match)); | 3857 || compl_shown_match == compl_first_match)); |
3852 } | 3858 } |
3853 else if (compl_shows_dir == BACKWARD | 3859 else if (compl_shows_dir == BACKWARD |
3854 && compl_shown_match->cp_prev != NULL) | 3860 && compl_shown_match->cp_prev != NULL) |
3855 { | 3861 { |
3862 if (compl_pending != 0) | |
3863 ++compl_pending; | |
3856 found_end = (compl_shown_match == compl_first_match); | 3864 found_end = (compl_shown_match == compl_first_match); |
3857 compl_shown_match = compl_shown_match->cp_prev; | 3865 compl_shown_match = compl_shown_match->cp_prev; |
3858 found_end |= (compl_shown_match == compl_first_match); | 3866 found_end |= (compl_shown_match == compl_first_match); |
3859 } | 3867 } |
3860 else | 3868 else |
3861 { | 3869 { |
3862 compl_pending = TRUE; | 3870 if (compl_shows_dir == BACKWARD) |
3871 --compl_pending; | |
3872 else | |
3873 ++compl_pending; | |
3863 if (!allow_get_expansion) | 3874 if (!allow_get_expansion) |
3864 return -1; | 3875 return -1; |
3865 | 3876 |
3866 num_matches = ins_compl_get_exp(&compl_startpos); | 3877 num_matches = ins_compl_get_exp(&compl_startpos); |
3867 if (compl_pending && compl_direction == compl_shows_dir) | 3878 if (compl_pending != 0 && compl_direction == compl_shows_dir) |
3868 compl_shown_match = compl_curr_match; | 3879 compl_shown_match = compl_curr_match; |
3869 found_end = FALSE; | 3880 found_end = FALSE; |
3870 } | 3881 } |
3871 if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0 | 3882 if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0 |
3872 && compl_leader != NULL | 3883 && compl_leader != NULL |
3937 } | 3948 } |
3938 | 3949 |
3939 /* | 3950 /* |
3940 * Call this while finding completions, to check whether the user has hit a key | 3951 * Call this while finding completions, to check whether the user has hit a key |
3941 * that should change the currently displayed completion, or exit completion | 3952 * that should change the currently displayed completion, or exit completion |
3942 * mode. Also, when compl_pending is TRUE, show a completion as soon as | 3953 * mode. Also, when compl_pending is not zero, show a completion as soon as |
3943 * possible. -- webb | 3954 * possible. -- webb |
3944 * "frequency" specifies out of how many calls we actually check. | 3955 * "frequency" specifies out of how many calls we actually check. |
3945 */ | 3956 */ |
3946 void | 3957 void |
3947 ins_compl_check_keys(frequency) | 3958 ins_compl_check_keys(frequency) |
3974 c != K_UP && c != K_DOWN); | 3985 c != K_UP && c != K_DOWN); |
3975 } | 3986 } |
3976 else if (c != Ctrl_R) | 3987 else if (c != Ctrl_R) |
3977 compl_interrupted = TRUE; | 3988 compl_interrupted = TRUE; |
3978 } | 3989 } |
3979 if (compl_pending && !got_int) | 3990 if (compl_pending != 0 && !got_int) |
3980 (void)ins_compl_next(FALSE, 1, TRUE); | 3991 (void)ins_compl_next(FALSE, compl_pending > 0 |
3992 ? compl_pending : -compl_pending, TRUE); | |
3981 } | 3993 } |
3982 | 3994 |
3983 /* | 3995 /* |
3984 * Decide the direction of Insert mode complete from the key typed. | 3996 * Decide the direction of Insert mode complete from the key typed. |
3985 * Returns BACKWARD or FORWARD. | 3997 * Returns BACKWARD or FORWARD. |
4079 if (stop_arrow() == FAIL) | 4091 if (stop_arrow() == FAIL) |
4080 return FAIL; | 4092 return FAIL; |
4081 | 4093 |
4082 line = ml_get(curwin->w_cursor.lnum); | 4094 line = ml_get(curwin->w_cursor.lnum); |
4083 curs_col = curwin->w_cursor.col; | 4095 curs_col = curwin->w_cursor.col; |
4096 compl_pending = 0; | |
4084 | 4097 |
4085 /* if this same ctrl_x_mode has been interrupted use the text from | 4098 /* if this same ctrl_x_mode has been interrupted use the text from |
4086 * "compl_startpos" to the cursor as a pattern to add a new word | 4099 * "compl_startpos" to the cursor as a pattern to add a new word |
4087 * instead of expand the one before the cursor, in word-wise if | 4100 * instead of expand the one before the cursor, in word-wise if |
4088 * "compl_startpos" | 4101 * "compl_startpos" |