comparison src/edit.c @ 644:e4fa26ce8769 v7.0187

updated for version 7.0187
author vimboss
date Wed, 25 Jan 2006 22:10:52 +0000
parents 1c586ee8dd45
children 9032e4668296
comparison
equal deleted inserted replaced
643:d3c978b4c7ce 644:e4fa26ce8769
87 static compl_T *compl_curr_match = NULL; 87 static compl_T *compl_curr_match = NULL;
88 static compl_T *compl_shown_match = NULL; 88 static compl_T *compl_shown_match = NULL;
89 89
90 /* When the first completion is done "compl_started" is set. When it's 90 /* When the first completion is done "compl_started" is set. When it's
91 * FALSE the word to be completed must be located. */ 91 * FALSE the word to be completed must be located. */
92 static int compl_started = FALSE; 92 static int compl_started = FALSE;
93 93
94 static int compl_matches = 0; 94 static int compl_matches = 0;
95 static char_u *compl_pattern = NULL; 95 static char_u *compl_pattern = NULL;
96 static int compl_direction = FORWARD; 96 static int compl_direction = FORWARD;
97 static int compl_shows_dir = FORWARD; 97 static int compl_shows_dir = FORWARD;
121 static int ins_compl_get_exp __ARGS((pos_T *ini, int dir)); 121 static int ins_compl_get_exp __ARGS((pos_T *ini, int dir));
122 static void ins_compl_delete __ARGS((void)); 122 static void ins_compl_delete __ARGS((void));
123 static void ins_compl_insert __ARGS((void)); 123 static void ins_compl_insert __ARGS((void));
124 static int ins_compl_next __ARGS((int allow_get_expansion, int count)); 124 static int ins_compl_next __ARGS((int allow_get_expansion, int count));
125 static int ins_compl_key2dir __ARGS((int c)); 125 static int ins_compl_key2dir __ARGS((int c));
126 static int ins_compl_pum_key __ARGS((int c));
126 static int ins_compl_key2count __ARGS((int c)); 127 static int ins_compl_key2count __ARGS((int c));
127 static int ins_complete __ARGS((int c)); 128 static int ins_complete __ARGS((int c));
128 static int quote_meta __ARGS((char_u *dest, char_u *str, int len)); 129 static int quote_meta __ARGS((char_u *dest, char_u *str, int len));
129 #endif /* FEAT_INS_EXPAND */ 130 #endif /* FEAT_INS_EXPAND */
130 131
493 * If 'showmode' is set, show the current (insert/replace/..) mode. 494 * If 'showmode' is set, show the current (insert/replace/..) mode.
494 * A warning message for changing a readonly file is given here, before 495 * A warning message for changing a readonly file is given here, before
495 * actually changing anything. It's put after the mode, if any. 496 * actually changing anything. It's put after the mode, if any.
496 */ 497 */
497 i = 0; 498 i = 0;
498 if (p_smd) 499 if (p_smd && msg_silent == 0)
499 i = showmode(); 500 i = showmode();
500 501
501 if (!p_im && did_restart_edit == 0) 502 if (!p_im && did_restart_edit == 0)
502 change_warning(i + 1); 503 change_warning(i + 1);
503 504
1114 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 1115 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1115 /* In a quickfix window a <CR> jumps to the error under the 1116 /* In a quickfix window a <CR> jumps to the error under the
1116 * cursor. */ 1117 * cursor. */
1117 if (bt_quickfix(curbuf) && c == CAR) 1118 if (bt_quickfix(curbuf) && c == CAR)
1118 { 1119 {
1119 do_cmdline_cmd((char_u *)".cc"); 1120 if (curwin->w_llist_ref == NULL) /* quickfix window */
1121 do_cmdline_cmd((char_u *)".cc");
1122 else /* location list window */
1123 do_cmdline_cmd((char_u *)".ll");
1120 break; 1124 break;
1121 } 1125 }
1122 #endif 1126 #endif
1123 #ifdef FEAT_CMDWIN 1127 #ifdef FEAT_CMDWIN
1124 if (cmdwin_type != 0) 1128 if (cmdwin_type != 0)
1844 /* Always allow ^R - let it's results then be checked */ 1848 /* Always allow ^R - let it's results then be checked */
1845 if (c == Ctrl_R) 1849 if (c == Ctrl_R)
1846 return TRUE; 1850 return TRUE;
1847 1851
1848 /* Accept <PageUp> and <PageDown> if the popup menu is visible. */ 1852 /* Accept <PageUp> and <PageDown> if the popup menu is visible. */
1849 if (pum_visible() && (c == K_PAGEUP || c == K_KPAGEUP || c == K_S_UP 1853 if (ins_compl_pum_key(c))
1850 || c == K_PAGEDOWN || c == K_KPAGEDOWN || c == K_S_DOWN))
1851 return TRUE; 1854 return TRUE;
1852 1855
1853 switch (ctrl_x_mode) 1856 switch (ctrl_x_mode)
1854 { 1857 {
1855 case 0: /* Not in any CTRL-X mode */ 1858 case 0: /* Not in any CTRL-X mode */
2646 { 2649 {
2647 /* Show error message from attempted keyword completion (probably 2650 /* Show error message from attempted keyword completion (probably
2648 * 'Pattern not found') until another key is hit, then go back to 2651 * 'Pattern not found') until another key is hit, then go back to
2649 * showing what mode we are in. */ 2652 * showing what mode we are in. */
2650 showmode(); 2653 showmode();
2651 if ((ctrl_x_mode == 0 && c != Ctrl_N && c != Ctrl_P && c != Ctrl_R) 2654 if ((ctrl_x_mode == 0 && c != Ctrl_N && c != Ctrl_P && c != Ctrl_R
2655 && !ins_compl_pum_key(c))
2652 || ctrl_x_mode == CTRL_X_FINISHED) 2656 || ctrl_x_mode == CTRL_X_FINISHED)
2653 { 2657 {
2654 /* Get here when we have finished typing a sequence of ^N and 2658 /* Get here when we have finished typing a sequence of ^N and
2655 * ^P or other completion characters in CTRL-X mode. Free up 2659 * ^P or other completion characters in CTRL-X mode. Free up
2656 * memory that was used, and make sure we can redo the insert. */ 2660 * memory that was used, and make sure we can redo the insert. */
3450 return BACKWARD; 3454 return BACKWARD;
3451 return FORWARD; 3455 return FORWARD;
3452 } 3456 }
3453 3457
3454 /* 3458 /*
3459 * Return TRUE for keys that are used for completion only when the popup menu
3460 * is visible.
3461 */
3462 static int
3463 ins_compl_pum_key(c)
3464 int c;
3465 {
3466 return pum_visible() && (c == K_PAGEUP || c == K_KPAGEUP || c == K_S_UP
3467 || c == K_PAGEDOWN || c == K_KPAGEDOWN || c == K_S_DOWN);
3468 }
3469
3470 /*
3455 * Decide the number of completions to move forward. 3471 * Decide the number of completions to move forward.
3456 * Returns 1 for most keys, height of the popup menu for page-up/down keys. 3472 * Returns 1 for most keys, height of the popup menu for page-up/down keys.
3457 */ 3473 */
3458 static int 3474 static int
3459 ins_compl_key2count(c) 3475 ins_compl_key2count(c)
3460 int c; 3476 int c;
3461 { 3477 {
3462 int h; 3478 int h;
3463 3479
3464 if (pum_visible() && (c == K_PAGEUP || c == K_KPAGEUP || c == K_S_UP 3480 if (ins_compl_pum_key(c))
3465 || c == K_PAGEDOWN || c == K_KPAGEDOWN || c == K_S_DOWN))
3466 { 3481 {
3467 h = pum_get_height(); 3482 h = pum_get_height();
3468 if (h > 3) 3483 if (h > 3)
3469 h -= 2; /* keep some context */ 3484 h -= 2; /* keep some context */
3470 return h; 3485 return h;