comparison src/ex_getln.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 4291eb97e479
children d8fc1effa724
comparison
equal deleted inserted replaced
29880:bd3aac5d1d9e 29881:0cc9a3001717
918 { 918 {
919 // if 'wildmode' contains "list" may still need to list 919 // if 'wildmode' contains "list" may still need to list
920 if (xp->xp_numfiles > 1 920 if (xp->xp_numfiles > 1
921 && !*did_wild_list 921 && !*did_wild_list
922 && ((wim_flags[wim_index] & WIM_LIST) 922 && ((wim_flags[wim_index] & WIM_LIST)
923 #ifdef FEAT_WILDMENU 923 || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0)))
924 || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0) 924 {
925 #endif
926 ))
927 {
928 #ifdef FEAT_WILDMENU
929 (void)showmatches(xp, 925 (void)showmatches(xp,
930 p_wmnu && ((wim_flags[wim_index] & WIM_LIST) == 0)); 926 p_wmnu && ((wim_flags[wim_index] & WIM_LIST) == 0));
931 #else
932 (void)showmatches(xp, FALSE);
933 #endif
934 redrawcmd(); 927 redrawcmd();
935 *did_wild_list = TRUE; 928 *did_wild_list = TRUE;
936 } 929 }
937 if (wim_flags[wim_index] & WIM_LONGEST) 930 if (wim_flags[wim_index] & WIM_LONGEST)
938 res = nextwild(xp, WILD_LONGEST, options, escape); 931 res = nextwild(xp, WILD_LONGEST, options, escape);
956 if (got_int) 949 if (got_int)
957 { 950 {
958 (void)vpeekc(); // remove <C-C> from input stream 951 (void)vpeekc(); // remove <C-C> from input stream
959 got_int = FALSE; // don't abandon the command line 952 got_int = FALSE; // don't abandon the command line
960 (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE); 953 (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE);
961 #ifdef FEAT_WILDMENU
962 xp->xp_context = EXPAND_NOTHING; 954 xp->xp_context = EXPAND_NOTHING;
963 #endif
964 *wim_index_p = wim_index; 955 *wim_index_p = wim_index;
965 return CMDLINE_CHANGED; 956 return CMDLINE_CHANGED;
966 } 957 }
967 958
968 // when more than one match, and 'wildmode' first contains 959 // when more than one match, and 'wildmode' first contains
973 // a "longest" that didn't do anything is skipped (but not 964 // a "longest" that didn't do anything is skipped (but not
974 // "list:longest") 965 // "list:longest")
975 if (wim_flags[0] == WIM_LONGEST && ccline.cmdpos == j) 966 if (wim_flags[0] == WIM_LONGEST && ccline.cmdpos == j)
976 wim_index = 1; 967 wim_index = 1;
977 if ((wim_flags[wim_index] & WIM_LIST) 968 if ((wim_flags[wim_index] & WIM_LIST)
978 #ifdef FEAT_WILDMENU 969 || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0))
979 || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0)
980 #endif
981 )
982 { 970 {
983 if (!(wim_flags[0] & WIM_LONGEST)) 971 if (!(wim_flags[0] & WIM_LONGEST))
984 { 972 {
985 #ifdef FEAT_WILDMENU
986 int p_wmnu_save = p_wmnu; 973 int p_wmnu_save = p_wmnu;
974
987 p_wmnu = 0; 975 p_wmnu = 0;
988 #endif 976
989 // remove match 977 // remove match
990 nextwild(xp, WILD_PREV, 0, escape); 978 nextwild(xp, WILD_PREV, 0, escape);
991 #ifdef FEAT_WILDMENU
992 p_wmnu = p_wmnu_save; 979 p_wmnu = p_wmnu_save;
993 #endif
994 } 980 }
995 #ifdef FEAT_WILDMENU
996 (void)showmatches(xp, p_wmnu 981 (void)showmatches(xp, p_wmnu
997 && ((wim_flags[wim_index] & WIM_LIST) == 0)); 982 && ((wim_flags[wim_index] & WIM_LIST) == 0));
998 #else
999 (void)showmatches(xp, FALSE);
1000 #endif
1001 redrawcmd(); 983 redrawcmd();
1002 *did_wild_list = TRUE; 984 *did_wild_list = TRUE;
1003 if (wim_flags[wim_index] & WIM_LONGEST) 985 if (wim_flags[wim_index] & WIM_LONGEST)
1004 nextwild(xp, WILD_LONGEST, options, escape); 986 nextwild(xp, WILD_LONGEST, options, escape);
1005 else if (wim_flags[wim_index] & WIM_FULL) 987 else if (wim_flags[wim_index] & WIM_FULL)
1006 nextwild(xp, WILD_NEXT, options, escape); 988 nextwild(xp, WILD_NEXT, options, escape);
1007 } 989 }
1008 else 990 else
1009 vim_beep(BO_WILD); 991 vim_beep(BO_WILD);
1010 } 992 }
1011 #ifdef FEAT_WILDMENU
1012 else if (xp->xp_numfiles == -1) 993 else if (xp->xp_numfiles == -1)
1013 xp->xp_context = EXPAND_NOTHING; 994 xp->xp_context = EXPAND_NOTHING;
1014 #endif
1015 } 995 }
1016 if (wim_index < 3) 996 if (wim_index < 3)
1017 ++wim_index; 997 ++wim_index;
1018 if (c == ESC) 998 if (c == ESC)
1019 *gotesc = TRUE; 999 *gotesc = TRUE;
1893 * CTRL-P (unless 'wc' is <S-Tab>). 1873 * CTRL-P (unless 'wc' is <S-Tab>).
1894 */ 1874 */
1895 if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles > 0) 1875 if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles > 0)
1896 c = Ctrl_P; 1876 c = Ctrl_P;
1897 1877
1898 #ifdef FEAT_WILDMENU
1899 if (p_wmnu) 1878 if (p_wmnu)
1900 c = wildmenu_translate_key(&ccline, c, &xpc, did_wild_list); 1879 c = wildmenu_translate_key(&ccline, c, &xpc, did_wild_list);
1901 1880
1902 if (cmdline_pum_active()) 1881 if (cmdline_pum_active())
1903 { 1882 {
1911 firstc != '@') == FAIL) 1890 firstc != '@') == FAIL)
1912 break; 1891 break;
1913 c = Ctrl_E; 1892 c = Ctrl_E;
1914 } 1893 }
1915 } 1894 }
1916 #endif
1917 1895
1918 // The wildmenu is cleared if the pressed key is not used for 1896 // The wildmenu is cleared if the pressed key is not used for
1919 // navigating the wild menu (i.e. the key is not 'wildchar' or 1897 // navigating the wild menu (i.e. the key is not 'wildchar' or
1920 // 'wildcharm' or Ctrl-N or Ctrl-P or Ctrl-A or Ctrl-L). 1898 // 'wildcharm' or Ctrl-N or Ctrl-P or Ctrl-A or Ctrl-L).
1921 // If the popup menu is displayed, then PageDown and PageUp keys are 1899 // If the popup menu is displayed, then PageDown and PageUp keys are
1922 // also used to navigate the menu. 1900 // also used to navigate the menu.
1923 end_wildmenu = (!(c == p_wc && KeyTyped) && c != p_wcm 1901 end_wildmenu = (!(c == p_wc && KeyTyped) && c != p_wcm
1924 && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A && c != Ctrl_L); 1902 && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A && c != Ctrl_L);
1925 #ifdef FEAT_WILDMENU
1926 end_wildmenu = end_wildmenu && (!cmdline_pum_active() || 1903 end_wildmenu = end_wildmenu && (!cmdline_pum_active() ||
1927 (c != K_PAGEDOWN && c != K_PAGEUP 1904 (c != K_PAGEDOWN && c != K_PAGEUP
1928 && c != K_KPAGEDOWN && c != K_KPAGEUP)); 1905 && c != K_KPAGEDOWN && c != K_KPAGEUP));
1929 #endif
1930 1906
1931 // free expanded names when finished walking through matches 1907 // free expanded names when finished walking through matches
1932 if (end_wildmenu) 1908 if (end_wildmenu)
1933 { 1909 {
1934 #ifdef FEAT_WILDMENU
1935 if (cmdline_pum_active()) 1910 if (cmdline_pum_active())
1936 cmdline_pum_remove(); 1911 cmdline_pum_remove();
1937 #endif
1938 if (xpc.xp_numfiles != -1) 1912 if (xpc.xp_numfiles != -1)
1939 (void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE); 1913 (void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE);
1940 did_wild_list = FALSE; 1914 did_wild_list = FALSE;
1941 #ifdef FEAT_WILDMENU
1942 if (!p_wmnu || (c != K_UP && c != K_DOWN)) 1915 if (!p_wmnu || (c != K_UP && c != K_DOWN))
1943 #endif
1944 xpc.xp_context = EXPAND_NOTHING; 1916 xpc.xp_context = EXPAND_NOTHING;
1945 wim_index = 0; 1917 wim_index = 0;
1946 #ifdef FEAT_WILDMENU
1947 wildmenu_cleanup(&ccline); 1918 wildmenu_cleanup(&ccline);
1948 #endif 1919 }
1949 } 1920
1950
1951 #ifdef FEAT_WILDMENU
1952 if (p_wmnu) 1921 if (p_wmnu)
1953 c = wildmenu_process_key(&ccline, c, &xpc); 1922 c = wildmenu_process_key(&ccline, c, &xpc);
1954 #endif
1955 1923
1956 // CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to Insert 1924 // CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to Insert
1957 // mode when 'insertmode' is set, CTRL-\ e prompts for an expression. 1925 // mode when 'insertmode' is set, CTRL-\ e prompts for an expression.
1958 if (c == Ctrl_BSL) 1926 if (c == Ctrl_BSL)
1959 { 1927 {
2033 { 2001 {
2034 if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK) 2002 if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK)
2035 { 2003 {
2036 if (xpc.xp_numfiles > 1 2004 if (xpc.xp_numfiles > 1
2037 && ((!did_wild_list && (wim_flags[wim_index] & WIM_LIST)) 2005 && ((!did_wild_list && (wim_flags[wim_index] & WIM_LIST))
2038 #ifdef FEAT_WILDMENU 2006 || p_wmnu))
2039 || p_wmnu
2040 #endif
2041 ))
2042 { 2007 {
2043 #ifdef FEAT_WILDMENU
2044 // Trigger the popup menu when wildoptions=pum 2008 // Trigger the popup menu when wildoptions=pum
2045 showmatches(&xpc, p_wmnu 2009 showmatches(&xpc, p_wmnu
2046 && ((wim_flags[wim_index] & WIM_LIST) == 0)); 2010 && ((wim_flags[wim_index] & WIM_LIST) == 0));
2047 #else
2048 (void)showmatches(&xpc, FALSE);
2049 #endif
2050 } 2011 }
2051 if (nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK 2012 if (nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK
2052 && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK) 2013 && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK)
2053 goto cmdline_changed; 2014 goto cmdline_changed;
2054 } 2015 }
2316 ccline.cmdpos = ccline.cmdlen; 2277 ccline.cmdpos = ccline.cmdlen;
2317 set_cmdspos_cursor(); 2278 set_cmdspos_cursor();
2318 goto cmdline_not_changed; 2279 goto cmdline_not_changed;
2319 2280
2320 case Ctrl_A: // all matches 2281 case Ctrl_A: // all matches
2321 #ifdef FEAT_WILDMENU
2322 if (cmdline_pum_active()) 2282 if (cmdline_pum_active())
2323 // As Ctrl-A completes all the matches, close the popup 2283 // As Ctrl-A completes all the matches, close the popup
2324 // menu (if present) 2284 // menu (if present)
2325 cmdline_pum_cleanup(&ccline); 2285 cmdline_pum_cleanup(&ccline);
2326 #endif 2286
2327 if (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL) 2287 if (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL)
2328 break; 2288 break;
2329 xpc.xp_context = EXPAND_NOTHING; 2289 xpc.xp_context = EXPAND_NOTHING;
2330 did_wild_list = FALSE; 2290 did_wild_list = FALSE;
2331 goto cmdline_changed; 2291 goto cmdline_changed;
2357 case K_S_DOWN: 2317 case K_S_DOWN:
2358 case K_PAGEUP: 2318 case K_PAGEUP:
2359 case K_KPAGEUP: 2319 case K_KPAGEUP:
2360 case K_PAGEDOWN: 2320 case K_PAGEDOWN:
2361 case K_KPAGEDOWN: 2321 case K_KPAGEDOWN:
2362 #ifdef FEAT_WILDMENU
2363 if (cmdline_pum_active() 2322 if (cmdline_pum_active()
2364 && (c == K_PAGEUP || c == K_PAGEDOWN || 2323 && (c == K_PAGEUP || c == K_PAGEDOWN ||
2365 c == K_KPAGEUP || c == K_KPAGEDOWN)) 2324 c == K_KPAGEUP || c == K_KPAGEDOWN))
2366 { 2325 {
2367 // If the popup menu is displayed, then PageUp and PageDown 2326 // If the popup menu is displayed, then PageUp and PageDown
2372 if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL) 2331 if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL)
2373 break; 2332 break;
2374 goto cmdline_not_changed; 2333 goto cmdline_not_changed;
2375 } 2334 }
2376 else 2335 else
2377 #endif
2378 { 2336 {
2379 res = cmdline_browse_history(c, firstc, &lookfor, histype, 2337 res = cmdline_browse_history(c, firstc, &lookfor, histype,
2380 &hiscnt, &xpc); 2338 &hiscnt, &xpc);
2381 if (res == CMDLINE_CHANGED) 2339 if (res == CMDLINE_CHANGED)
2382 goto cmdline_changed; 2340 goto cmdline_changed;