comparison src/cmdexpand.c @ 29881:0cc9a3001717 v9.0.0279

patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu' Commit: https://github.com/vim/vim/commit/5416232707349d5f24294178f47544f2024b73ed Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 26 16:58:51 2022 +0100 patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu' Problem: The tiny version has the popup menu but not 'wildmenu'. Solution: Graduate the wildmenu feature.
author Bram Moolenaar <Bram@vim.org>
date Fri, 26 Aug 2022 18:00:05 +0200
parents 5b46eb13e3bb
children 3ef1fe06690d
comparison
equal deleted inserted replaced
29880:bd3aac5d1d9e 29881:0cc9a3001717
24 #if defined(FEAT_EVAL) 24 #if defined(FEAT_EVAL)
25 static int ExpandUserDefined(char_u *pat, expand_T *xp, regmatch_T *regmatch, char_u ***matches, int *numMatches); 25 static int ExpandUserDefined(char_u *pat, expand_T *xp, regmatch_T *regmatch, char_u ***matches, int *numMatches);
26 static int ExpandUserList(expand_T *xp, char_u ***matches, int *numMatches); 26 static int ExpandUserList(expand_T *xp, char_u ***matches, int *numMatches);
27 #endif 27 #endif
28 28
29 #ifdef FEAT_WILDMENU
30 // "compl_match_array" points the currently displayed list of entries in the 29 // "compl_match_array" points the currently displayed list of entries in the
31 // popup menu. It is NULL when there is no popup menu. 30 // popup menu. It is NULL when there is no popup menu.
32 static pumitem_T *compl_match_array = NULL; 31 static pumitem_T *compl_match_array = NULL;
33 static int compl_match_arraysize; 32 static int compl_match_arraysize;
34 // First column in cmdline of the matched item for completion. 33 // First column in cmdline of the matched item for completion.
35 static int compl_startcol; 34 static int compl_startcol;
36 static int compl_selected; 35 static int compl_selected;
37 #endif
38 36
39 #define SHOW_FILE_TEXT(m) (showtail ? sm_gettail(matches[m]) : matches[m]) 37 #define SHOW_FILE_TEXT(m) (showtail ? sm_gettail(matches[m]) : matches[m])
40 38
41 /* 39 /*
42 * Returns TRUE if fuzzy completion is supported for a given cmdline completion 40 * Returns TRUE if fuzzy completion is supported for a given cmdline completion
303 (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE); 301 (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE);
304 302
305 return OK; 303 return OK;
306 } 304 }
307 305
308 #if defined(FEAT_WILDMENU) || defined(PROTO)
309
310 /* 306 /*
311 * Create and display a cmdline completion popup menu with items from 307 * Create and display a cmdline completion popup menu with items from
312 * 'matches'. 308 * 'matches'.
313 */ 309 */
314 static int 310 static int
403 */ 399 */
404 int cmdline_compl_startcol(void) 400 int cmdline_compl_startcol(void)
405 { 401 {
406 return compl_startcol; 402 return compl_startcol;
407 } 403 }
408 #endif
409 404
410 /* 405 /*
411 * Get the next or prev cmdline completion match. The index of the match is set 406 * Get the next or prev cmdline completion match. The index of the match is set
412 * in "p_findex" 407 * in "p_findex"
413 */ 408 */
486 if (orig_save == NULL) 481 if (orig_save == NULL)
487 findex = 0; 482 findex = 0;
488 else 483 else
489 findex = -1; 484 findex = -1;
490 } 485 }
491 #ifdef FEAT_WILDMENU
492 if (compl_match_array) 486 if (compl_match_array)
493 { 487 {
494 compl_selected = findex; 488 compl_selected = findex;
495 cmdline_pum_display(); 489 cmdline_pum_display();
496 } 490 }
497 else if (p_wmnu) 491 else if (p_wmnu)
498 win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files, 492 win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files,
499 findex, cmd_showtail); 493 findex, cmd_showtail);
500 #endif
501 *p_findex = findex; 494 *p_findex = findex;
502 495
503 if (findex == -1) 496 if (findex == -1)
504 return vim_strsave(orig_save); 497 return vim_strsave(orig_save);
505 498
900 numMatches = xp->xp_numfiles; 893 numMatches = xp->xp_numfiles;
901 matches = xp->xp_files; 894 matches = xp->xp_files;
902 showtail = cmd_showtail; 895 showtail = cmd_showtail;
903 } 896 }
904 897
905 #ifdef FEAT_WILDMENU
906 if (wildmenu && vim_strchr(p_wop, WOP_PUM) != NULL) 898 if (wildmenu && vim_strchr(p_wop, WOP_PUM) != NULL)
907 // cmdline completion popup menu (with wildoptions=pum) 899 // cmdline completion popup menu (with wildoptions=pum)
908 return cmdline_pum_create(ccline, xp, matches, numMatches, showtail); 900 return cmdline_pum_create(ccline, xp, matches, numMatches, showtail);
909 #endif 901
910
911 #ifdef FEAT_WILDMENU
912 if (!wildmenu) 902 if (!wildmenu)
913 { 903 {
914 #endif
915 msg_didany = FALSE; // lines_left will be set 904 msg_didany = FALSE; // lines_left will be set
916 msg_start(); // prepare for paging 905 msg_start(); // prepare for paging
917 msg_putchar('\n'); 906 msg_putchar('\n');
918 out_flush(); 907 out_flush();
919 cmdline_row = msg_row; 908 cmdline_row = msg_row;
920 msg_didany = FALSE; // lines_left will be set again 909 msg_didany = FALSE; // lines_left will be set again
921 msg_start(); // prepare for paging 910 msg_start(); // prepare for paging
922 #ifdef FEAT_WILDMENU 911 }
923 }
924 #endif
925 912
926 if (got_int) 913 if (got_int)
927 got_int = FALSE; // only int. the completion, not the cmd line 914 got_int = FALSE; // only int. the completion, not the cmd line
928 #ifdef FEAT_WILDMENU
929 else if (wildmenu) 915 else if (wildmenu)
930 win_redr_status_matches(xp, numMatches, matches, -1, showtail); 916 win_redr_status_matches(xp, numMatches, matches, -1, showtail);
931 #endif
932 else 917 else
933 { 918 {
934 // find the length of the longest file name 919 // find the length of the longest file name
935 maxlen = 0; 920 maxlen = 0;
936 for (i = 0; i < numMatches; ++i) 921 for (i = 0; i < numMatches; ++i)
3376 } 3361 }
3377 3362
3378 vim_free(buf); 3363 vim_free(buf);
3379 } 3364 }
3380 3365
3381 #ifdef FEAT_WILDMENU
3382
3383 /* 3366 /*
3384 * Translate some keys pressed when 'wildmenu' is used. 3367 * Translate some keys pressed when 'wildmenu' is used.
3385 */ 3368 */
3386 int 3369 int
3387 wildmenu_translate_key( 3370 wildmenu_translate_key(
3390 expand_T *xp, 3373 expand_T *xp,
3391 int did_wild_list) 3374 int did_wild_list)
3392 { 3375 {
3393 int c = key; 3376 int c = key;
3394 3377
3395 #ifdef FEAT_WILDMENU
3396 if (cmdline_pum_active()) 3378 if (cmdline_pum_active())
3397 { 3379 {
3398 // When the popup menu is used for cmdline completion: 3380 // When the popup menu is used for cmdline completion:
3399 // Up : go to the previous item in the menu 3381 // Up : go to the previous item in the menu
3400 // Down : go to the next item in the menu 3382 // Down : go to the next item in the menu
3407 case K_LEFT: c = K_UP; break; 3389 case K_LEFT: c = K_UP; break;
3408 case K_RIGHT: c = K_DOWN; break; 3390 case K_RIGHT: c = K_DOWN; break;
3409 default: break; 3391 default: break;
3410 } 3392 }
3411 } 3393 }
3412 #endif
3413 3394
3414 if (did_wild_list) 3395 if (did_wild_list)
3415 { 3396 {
3416 if (c == K_LEFT) 3397 if (c == K_LEFT)
3417 c = Ctrl_P; 3398 c = Ctrl_P;
3667 KeyTyped = skt; 3648 KeyTyped = skt;
3668 wild_menu_showing = 0; 3649 wild_menu_showing = 0;
3669 if (cclp->input_fn) 3650 if (cclp->input_fn)
3670 RedrawingDisabled = old_RedrawingDisabled; 3651 RedrawingDisabled = old_RedrawingDisabled;
3671 } 3652 }
3672 #endif
3673 3653
3674 #if defined(FEAT_EVAL) || defined(PROTO) 3654 #if defined(FEAT_EVAL) || defined(PROTO)
3675 /* 3655 /*
3676 * "getcompletion()" function 3656 * "getcompletion()" function
3677 */ 3657 */