comparison src/edit.c @ 523:a7ae7e043e43

updated for version 7.0146
author vimboss
date Tue, 13 Sep 2005 21:20:47 +0000
parents 52e76e2b5b65
children 7052f11a3dc9
comparison
equal deleted inserted replaced
522:530b30703db6 523:a7ae7e043e43
29 #define CTRL_X_FINISHED 8 29 #define CTRL_X_FINISHED 8
30 #define CTRL_X_DICTIONARY (9 + CTRL_X_WANT_IDENT) 30 #define CTRL_X_DICTIONARY (9 + CTRL_X_WANT_IDENT)
31 #define CTRL_X_THESAURUS (10 + CTRL_X_WANT_IDENT) 31 #define CTRL_X_THESAURUS (10 + CTRL_X_WANT_IDENT)
32 #define CTRL_X_CMDLINE 11 32 #define CTRL_X_CMDLINE 11
33 #define CTRL_X_FUNCTION 12 33 #define CTRL_X_FUNCTION 12
34 #define CTRL_X_OCCULT 13 34 #define CTRL_X_OMNI 13
35 #define CTRL_X_SPELL 14 35 #define CTRL_X_SPELL 14
36 #define CTRL_X_LOCAL_MSG 15 /* only used in "ctrl_x_msgs" */ 36 #define CTRL_X_LOCAL_MSG 15 /* only used in "ctrl_x_msgs" */
37 37
38 #define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT] 38 #define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT]
39 39
50 NULL, 50 NULL,
51 N_(" Dictionary completion (^K^N^P)"), 51 N_(" Dictionary completion (^K^N^P)"),
52 N_(" Thesaurus completion (^T^N^P)"), 52 N_(" Thesaurus completion (^T^N^P)"),
53 N_(" Command-line completion (^V^N^P)"), 53 N_(" Command-line completion (^V^N^P)"),
54 N_(" User defined completion (^U^N^P)"), 54 N_(" User defined completion (^U^N^P)"),
55 N_(" Occult completion (^O^N^P)"), 55 N_(" Omni completion (^O^N^P)"),
56 N_(" Spelling suggestion (^S^N^P)"), 56 N_(" Spelling suggestion (^S^N^P)"),
57 N_(" Keyword Local completion (^N^P)"), 57 N_(" Keyword Local completion (^N^P)"),
58 }; 58 };
59 59
60 static char_u e_hitend[] = N_("Hit end of paragraph"); 60 static char_u e_hitend[] = N_("Hit end of paragraph");
818 c = Ctrl_O; 818 c = Ctrl_O;
819 /*FALLTHROUGH*/ 819 /*FALLTHROUGH*/
820 820
821 case Ctrl_O: /* execute one command */ 821 case Ctrl_O: /* execute one command */
822 #ifdef FEAT_COMPL_FUNC 822 #ifdef FEAT_COMPL_FUNC
823 if (ctrl_x_mode == CTRL_X_OCCULT) 823 if (ctrl_x_mode == CTRL_X_OMNI)
824 goto docomplete; 824 goto docomplete;
825 #endif 825 #endif
826 if (echeck_abbr(Ctrl_O + ABBR_OFF)) 826 if (echeck_abbr(Ctrl_O + ABBR_OFF))
827 break; 827 break;
828 ins_ctrl_o(); 828 ins_ctrl_o();
1842 return (c == Ctrl_V || c == Ctrl_Q || c == Ctrl_P || c == Ctrl_N 1842 return (c == Ctrl_V || c == Ctrl_Q || c == Ctrl_P || c == Ctrl_N
1843 || c == Ctrl_X); 1843 || c == Ctrl_X);
1844 #ifdef FEAT_COMPL_FUNC 1844 #ifdef FEAT_COMPL_FUNC
1845 case CTRL_X_FUNCTION: 1845 case CTRL_X_FUNCTION:
1846 return (c == Ctrl_U || c == Ctrl_P || c == Ctrl_N); 1846 return (c == Ctrl_U || c == Ctrl_P || c == Ctrl_N);
1847 case CTRL_X_OCCULT: 1847 case CTRL_X_OMNI:
1848 return (c == Ctrl_O || c == Ctrl_P || c == Ctrl_N); 1848 return (c == Ctrl_O || c == Ctrl_P || c == Ctrl_N);
1849 #endif 1849 #endif
1850 case CTRL_X_SPELL: 1850 case CTRL_X_SPELL:
1851 return (c == Ctrl_S || c == Ctrl_P || c == Ctrl_N); 1851 return (c == Ctrl_S || c == Ctrl_P || c == Ctrl_N);
1852 } 1852 }
2359 #ifdef FEAT_COMPL_FUNC 2359 #ifdef FEAT_COMPL_FUNC
2360 case Ctrl_U: 2360 case Ctrl_U:
2361 ctrl_x_mode = CTRL_X_FUNCTION; 2361 ctrl_x_mode = CTRL_X_FUNCTION;
2362 break; 2362 break;
2363 case Ctrl_O: 2363 case Ctrl_O:
2364 ctrl_x_mode = CTRL_X_OCCULT; 2364 ctrl_x_mode = CTRL_X_OMNI;
2365 break; 2365 break;
2366 #endif 2366 #endif
2367 case 's': 2367 case 's':
2368 case Ctrl_S: 2368 case Ctrl_S:
2369 ctrl_x_mode = CTRL_X_SPELL; 2369 ctrl_x_mode = CTRL_X_SPELL;
2582 2582
2583 #ifdef FEAT_COMPL_FUNC 2583 #ifdef FEAT_COMPL_FUNC
2584 static int expand_by_function __ARGS((int type, char_u *base, char_u ***matches)); 2584 static int expand_by_function __ARGS((int type, char_u *base, char_u ***matches));
2585 2585
2586 /* 2586 /*
2587 * Execute user defined complete function 'completefunc' or 'occultfunc', and 2587 * Execute user defined complete function 'completefunc' or 'omnifunc', and
2588 * get matches in "matches". 2588 * get matches in "matches".
2589 * Return value is number of matches. 2589 * Return value is number of matches.
2590 */ 2590 */
2591 static int 2591 static int
2592 expand_by_function(type, base, matches) 2592 expand_by_function(type, base, matches)
2593 int type; /* CTRL_X_OCCULT or CTRL_X_FUNCTION */ 2593 int type; /* CTRL_X_OMNI or CTRL_X_FUNCTION */
2594 char_u *base; 2594 char_u *base;
2595 char_u ***matches; 2595 char_u ***matches;
2596 { 2596 {
2597 list_T *matchlist; 2597 list_T *matchlist;
2598 char_u *args[2]; 2598 char_u *args[2];
2846 ins_compl_add_matches(num_matches, matches, dir); 2846 ins_compl_add_matches(num_matches, matches, dir);
2847 break; 2847 break;
2848 2848
2849 #ifdef FEAT_COMPL_FUNC 2849 #ifdef FEAT_COMPL_FUNC
2850 case CTRL_X_FUNCTION: 2850 case CTRL_X_FUNCTION:
2851 case CTRL_X_OCCULT: 2851 case CTRL_X_OMNI:
2852 num_matches = expand_by_function(type, compl_pattern, &matches); 2852 if (*compl_pattern == NUL)
2853 num_matches = 0;
2854 else
2855 num_matches = expand_by_function(type, compl_pattern, &matches);
2853 if (num_matches > 0) 2856 if (num_matches > 0)
2854 ins_compl_add_matches(num_matches, matches, dir); 2857 ins_compl_add_matches(num_matches, matches, dir);
2855 break; 2858 break;
2856 #endif 2859 #endif
2857 2860
3455 return FAIL; 3458 return FAIL;
3456 startcol = (int)(compl_xp.xp_pattern - compl_pattern); 3459 startcol = (int)(compl_xp.xp_pattern - compl_pattern);
3457 compl_col = startcol; 3460 compl_col = startcol;
3458 compl_length = curs_col - startcol; 3461 compl_length = curs_col - startcol;
3459 } 3462 }
3460 else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OCCULT) 3463 else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI)
3461 { 3464 {
3462 #ifdef FEAT_COMPL_FUNC 3465 #ifdef FEAT_COMPL_FUNC
3463 /* 3466 /*
3464 * Call user defined function 'completefunc' with "a:findstart" 3467 * Call user defined function 'completefunc' with "a:findstart"
3465 * set to 1 to obtain the length of text to use for completion. 3468 * set to 1 to obtain the length of text to use for completion.
3467 char_u *args[2]; 3470 char_u *args[2];
3468 int col; 3471 int col;
3469 char_u *funcname; 3472 char_u *funcname;
3470 pos_T pos; 3473 pos_T pos;
3471 3474
3472 /* Call 'completefunc' or 'occultfunc' and get pattern length as a 3475 /* Call 'completefunc' or 'omnifunc' and get pattern length as a
3473 * string */ 3476 * string */
3474 funcname = ctrl_x_mode == CTRL_X_FUNCTION 3477 funcname = ctrl_x_mode == CTRL_X_FUNCTION
3475 ? curbuf->b_p_cfu : curbuf->b_p_ofu; 3478 ? curbuf->b_p_cfu : curbuf->b_p_ofu;
3476 if (*funcname == NUL) 3479 if (*funcname == NUL)
3480 {
3481 EMSG2(_(e_notset), ctrl_x_mode == CTRL_X_FUNCTION
3482 ? "completefunc" : "omnifunc");
3477 return FAIL; 3483 return FAIL;
3484 }
3478 3485
3479 args[0] = (char_u *)"1"; 3486 args[0] = (char_u *)"1";
3480 args[1] = NULL; 3487 args[1] = NULL;
3481 pos = curwin->w_cursor; 3488 pos = curwin->w_cursor;
3482 col = call_func_retnr(funcname, 2, args, FALSE); 3489 col = call_func_retnr(funcname, 2, args, FALSE);
3483 curwin->w_cursor = pos; /* restore the cursor position */ 3490 curwin->w_cursor = pos; /* restore the cursor position */
3484 3491
3485 if (col < 0) 3492 if (col < 0)
3486 return FAIL; 3493 col = curs_col;
3487 compl_col = col; 3494 compl_col = col;
3488 if ((colnr_T)compl_col > curs_col) 3495 if ((colnr_T)compl_col > curs_col)
3489 compl_col = curs_col; 3496 compl_col = curs_col;
3490 3497
3491 /* Setup variables for completion. Need to obtain "line" again, 3498 /* Setup variables for completion. Need to obtain "line" again,