To: vim_dev@googlegroups.com Subject: Patch 8.1.1882 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1882 Problem: Cannot specify properties of the info popup window. Solution: Add the 'completepopup' option. Default to PmenuSel highlight. Files: runtime/doc/options.txt, runtime/doc/insert.txt, src/option.c, src/popupwin.c, src/proto/popupwin.pro, src/option.h, src/testdir/test_popupwin.vim, src/screen.c, src/testdir/dumps/Test_popupwin_infopopup_1.dump, src/testdir/dumps/Test_popupwin_infopopup_2.dump, src/testdir/dumps/Test_popupwin_infopopup_3.dump *** ../vim-8.1.1881/runtime/doc/options.txt 2019-08-18 15:24:23.197608923 +0200 --- runtime/doc/options.txt 2019-08-18 15:50:02.968185340 +0200 *************** *** 1922,1927 **** --- 1918,1924 ---- popup Show extra information about the currently selected completion in a popup window. Only works in combination with "menu" or "menuone". Overrides "preview". + See |'completepopup'| for specifying properties. {only works when compiled with the +textprop feature} noinsert Do not insert any text for a match until the user selects *************** *** 1933,1938 **** --- 1930,1944 ---- "menu" or "menuone". + *'completepopup'* *'cpp'* + 'completepopup' 'cpp' string (default empty) + global + {not available when compiled without the |+textprop| + or |+quickfix| feature} + When 'completeopt' contains "popup" then this option is used for the + properties of the info popup. See |complete-popup|. + + *'concealcursor'* *'cocu'* 'concealcursor' 'cocu' string (default: "") local to window *************** *** 5657,5673 **** *'previewpopup'* *'pvp'* 'previewpopup' 'pvp' string (default empty) global ! {not available when compiled without the |+windows|, ! |+textprop| or |+quickfix| feature} When not empty a popup window is used for commands that would open a preview window. See |preview-popup|. *'previewwindow'* *'nopreviewwindow'* *'pvw'* *'nopvw'* *E590* 'previewwindow' 'pvw' boolean (default off) local to window ! {not available when compiled without the |+windows| or ! |+quickfix| features} Identifies the preview window. Only one window can have this option set. It's normally not set directly, but by using one of the commands |:ptag|, |:pedit|, etc. --- 5657,5675 ---- *'previewpopup'* *'pvp'* 'previewpopup' 'pvp' string (default empty) global ! {not available when compiled without the |+textprop| ! or |+quickfix| feature} When not empty a popup window is used for commands that would open a preview window. See |preview-popup|. + Not used for the insert completion info, add "popup" to + 'completeopt' for that. *'previewwindow'* *'nopreviewwindow'* *'pvw'* *'nopvw'* *E590* 'previewwindow' 'pvw' boolean (default off) local to window ! {not available when compiled without the |+quickfix| ! feature} Identifies the preview window. Only one window can have this option set. It's normally not set directly, but by using one of the commands |:ptag|, |:pedit|, etc. *** ../vim-8.1.1881/runtime/doc/insert.txt 2019-05-05 18:11:46.316590662 +0200 --- runtime/doc/insert.txt 2019-08-18 15:59:21.235887750 +0200 *************** *** 1094,1100 **** menu extra text for the popup menu, displayed after "word" or "abbr" info more information about the item, can be displayed in a ! preview window kind single letter indicating the type of completion icase when non-zero case is to be ignored when comparing items to be equal; when omitted zero is used, thus --- 1092,1098 ---- menu extra text for the popup menu, displayed after "word" or "abbr" info more information about the item, can be displayed in a ! preview or popup window kind single letter indicating the type of completion icase when non-zero case is to be ignored when comparing items to be equal; when omitted zero is used, thus *************** *** 1116,1126 **** The "menu" item is used in the popup menu and may be truncated, thus it should be relatively short. The "info" item can be longer, it will be displayed in ! the preview window when "preview" appears in 'completeopt'. The "info" item ! will also remain displayed after the popup menu has been removed. This is ! useful for function arguments. Use a single space for "info" to remove ! existing text in the preview window. The size of the preview window is three ! lines, but 'previewheight' is used when it has a value of 1 or 2. The "kind" item uses a single letter to indicate the kind of completion. This may be used to show the completion differently (different color or icon). --- 1114,1135 ---- The "menu" item is used in the popup menu and may be truncated, thus it should be relatively short. The "info" item can be longer, it will be displayed in ! the preview window when "preview" appears in 'completeopt' or in a popup ! window when "popup" appears in 'completeopt'. In the preview window the ! "info" item will also remain displayed after the popup menu has been removed. ! This is useful for function arguments. Use a single space for "info" to ! remove existing text in the preview window. The size of the preview window is ! three lines, but 'previewheight' is used when it has a value of 1 or 2. ! ! *complete-popup* ! When "popup" is in 'completeopt' a popup window is used to display the "info". ! Then the 'completepopup' option specifies the properties of the popup. The ! option is a comma separated list of values: ! height maximum height of the popup ! width maximum width of the popup ! highlight highlight group of the popup (default is Pmenu) ! Example: > ! :set completepopup=height:10,width:60,highlight:InfoPopup The "kind" item uses a single letter to indicate the kind of completion. This may be used to show the completion differently (different color or icon). *** ../vim-8.1.1881/src/option.c 2019-08-18 15:24:23.201608907 +0200 --- src/option.c 2019-08-18 16:01:17.379121351 +0200 *************** *** 893,898 **** --- 893,907 ---- {(char_u *)0L, (char_u *)0L} #endif SCTX_INIT}, + {"completepopup", "cpp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, + #ifdef FEAT_TEXT_PROP + (char_u *)&p_cpp, PV_NONE, + {(char_u *)"", (char_u *)0L} + #else + (char_u *)NULL, PV_NONE, + {(char_u *)NULL, (char_u *)0L} + #endif + SCTX_INIT}, {"completeslash", "csl", P_STRING|P_VI_DEF|P_VIM, #if defined(FEAT_INS_EXPAND) && defined(BACKSLASH_IN_FILENAME) (char_u *)&p_csl, PV_CSL, *************** *** 7826,7831 **** --- 7835,7846 ---- if (parse_previewpopup(NULL) == FAIL) errmsg = e_invarg; } + // 'completepopup' + else if (varp == &p_cpp) + { + if (parse_completepopup(NULL) == FAIL) + errmsg = e_invarg; + } #endif /* Options that are a list of flags. */ *** ../vim-8.1.1881/src/popupwin.c 2019-08-18 15:24:23.197608923 +0200 --- src/popupwin.c 2019-08-18 16:29:56.705039421 +0200 *************** *** 550,557 **** if (syn_name2id((char_u *)linehl) == 0) linehl = "PmenuSel"; ! sign_define_by_name(sign_name, NULL, ! (char_u *)linehl, NULL, NULL); } sign_place(&sign_id, (char_u *)"popupmenu", sign_name, --- 550,556 ---- if (syn_name2id((char_u *)linehl) == 0) linehl = "PmenuSel"; ! sign_define_by_name(sign_name, NULL, (char_u *)linehl, NULL, NULL); } sign_place(&sign_id, (char_u *)"popupmenu", sign_name, *************** *** 1286,1301 **** } /* ! * Parse the 'previewpopup' option and apply the values to window "wp" if it ! * not NULL. * Return FAIL if the parsing fails. */ ! int ! parse_previewpopup(win_T *wp) { char_u *p; ! for (p = p_pvp; *p != NUL; p += (*p == ',' ? 1 : 0)) { char_u *e, *dig; char_u *s = p; --- 1285,1300 ---- } /* ! * Parse the 'previewpopup' or 'completepopup' option and apply the values to ! * window "wp" if it is not NULL. * Return FAIL if the parsing fails. */ ! static int ! parse_popup_option(win_T *wp, int is_preview) { char_u *p; ! for (p = is_preview ? p_pvp : p_cpp; *p != NUL; p += (*p == ',' ? 1 : 0)) { char_u *e, *dig; char_u *s = p; *************** *** 1310,1334 **** p = e + STRLEN(e); dig = e + 1; x = getdigits(&dig); - if (dig != p) - return FAIL; if (STRNCMP(s, "height:", 7) == 0) { if (wp != NULL) { ! wp->w_minheight = x; wp->w_maxheight = x; } } else if (STRNCMP(s, "width:", 6) == 0) { if (wp != NULL) { ! wp->w_minwidth = x; wp->w_maxwidth = x; } } else return FAIL; } --- 1309,1349 ---- p = e + STRLEN(e); dig = e + 1; x = getdigits(&dig); if (STRNCMP(s, "height:", 7) == 0) { + if (dig != p) + return FAIL; if (wp != NULL) { ! if (is_preview) ! wp->w_minheight = x; wp->w_maxheight = x; } } else if (STRNCMP(s, "width:", 6) == 0) { + if (dig != p) + return FAIL; if (wp != NULL) { ! if (is_preview) ! wp->w_minwidth = x; wp->w_maxwidth = x; } } + else if (STRNCMP(s, "highlight:", 10) == 0) + { + if (wp != NULL) + { + int c = *p; + + *p = NUL; + set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1, + s + 10, OPT_FREE|OPT_LOCAL, 0); + *p = c; + } + } else return FAIL; } *************** *** 1336,1341 **** --- 1351,1378 ---- } /* + * Parse the 'previewpopup' option and apply the values to window "wp" if it + * is not NULL. + * Return FAIL if the parsing fails. + */ + int + parse_previewpopup(win_T *wp) + { + return parse_popup_option(wp, TRUE); + } + + /* + * Parse the 'completepopup' option and apply the values to window "wp" if it + * is not NULL. + * Return FAIL if the parsing fails. + */ + int + parse_completepopup(win_T *wp) + { + return parse_popup_option(wp, FALSE); + } + + /* * Set w_wantline and w_wantcol for the cursor position in the current window. * Keep at least "width" columns from the right of the screen. */ *************** *** 1641,1646 **** --- 1678,1684 ---- wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE; wp->w_popup_close = POPCLOSE_BUTTON; add_border_left_right_padding(wp); + parse_completepopup(wp); } for (i = 0; i < 4; ++i) *** ../vim-8.1.1881/src/proto/popupwin.pro 2019-08-18 15:24:23.197608923 +0200 --- src/proto/popupwin.pro 2019-08-18 16:03:39.446217448 +0200 *************** *** 11,16 **** --- 11,17 ---- int popup_extra_width(win_T *wp); void popup_adjust_position(win_T *wp); int parse_previewpopup(win_T *wp); + int parse_completepopup(win_T *wp); void popup_set_wantpos_cursor(win_T *wp, int width); void popup_set_wantpos_rowcol(win_T *wp, int row, int col); void f_popup_clear(typval_T *argvars, typval_T *rettv); *** ../vim-8.1.1881/src/option.h 2019-07-28 16:36:31.673949528 +0200 --- src/option.h 2019-08-18 16:03:57.262106285 +0200 *************** *** 503,508 **** --- 503,509 ---- #endif EXTERN int p_gd; // 'gdefault' #ifdef FEAT_TEXT_PROP + EXTERN char_u *p_cpp; // 'completepopup' EXTERN char_u *p_pvp; // 'previewpopup' #endif #ifdef FEAT_PRINTER *** ../vim-8.1.1881/src/testdir/test_popupwin.vim 2019-08-18 15:42:07.201075048 +0200 --- src/testdir/test_popupwin.vim 2019-08-18 16:14:59.070187079 +0200 *************** *** 2199,2204 **** --- 2199,2206 ---- let lines =<< trim END set completeopt+=preview,popup set completefunc=CompleteFuncDict + hi InfoPopup ctermbg=yellow + set completepopup=height:4,highlight:InfoPopup func CompleteFuncDict(findstart, base) if a:findstart *************** *** 2230,2236 **** \ 'word': 'noinfo', \ 'abbr': 'noawrd', \ 'menu': 'extra text', ! \ 'info': 'no words here', \ 'kind': 'W', \ 'user_data': 'notest' \ }, --- 2232,2238 ---- \ 'word': 'noinfo', \ 'abbr': 'noawrd', \ 'menu': 'extra text', ! \ 'info': "lets\nshow\na\nscrollbar\nhere", \ 'kind': 'W', \ 'user_data': 'notest' \ }, *** ../vim-8.1.1881/src/screen.c 2019-08-17 14:10:52.828496043 +0200 --- src/screen.c 2019-08-18 16:31:27.124529815 +0200 *************** *** 996,1002 **** wcr_attr = syn_name2attr(wp->w_p_wcr); #ifdef FEAT_TEXT_PROP else if (WIN_IS_POPUP(wp)) ! wcr_attr = HL_ATTR(HLF_PNI); #endif return wcr_attr; } --- 996,1007 ---- wcr_attr = syn_name2attr(wp->w_p_wcr); #ifdef FEAT_TEXT_PROP else if (WIN_IS_POPUP(wp)) ! { ! if (wp->w_popup_flags & POPF_INFO) ! wcr_attr = HL_ATTR(HLF_PSI); // PmenuSel ! else ! wcr_attr = HL_ATTR(HLF_PNI); // Pmenu ! } #endif return wcr_attr; } *** ../vim-8.1.1881/src/testdir/dumps/Test_popupwin_infopopup_1.dump 2019-08-18 15:24:23.201608907 +0200 --- src/testdir/dumps/Test_popupwin_infopopup_1.dump 2019-08-18 16:21:44.839839820 +0200 *************** *** 1,6 **** ! |t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|a|w|o|r|d> @15|╔+0#0000001#ffd7ff255|═@15|X| +0#0000000#ffffff0@9 ! |~+0#4040ff13&| @23| +0#0000001#e0e0e08|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| |║+0&#ffd7ff255| |w|o|r|d|s| |a|r|e| |c|o@1|l| |║| +0#4040ff13#ffffff0@9 ! |~| @23| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |╚|═@15|⇲| +0#4040ff13#ffffff0@9 |~| @23| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 |~| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 |~| @73 --- 1,6 ---- ! |t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|a|w|o|r|d> @15|╔+0&#ffff4012|═@15|X| +0&#ffffff0@9 ! |~+0#4040ff13&| @23| +0#0000001#e0e0e08|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| |║+0#0000000#ffff4012| |w|o|r|d|s| |a|r|e| |c|o@1|l| |║| +0#4040ff13#ffffff0@9 ! |~| @23| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |╚+0#0000000#ffff4012|═@15|⇲| +0#4040ff13#ffffff0@9 |~| @23| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 |~| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 |~| @73 *** ../vim-8.1.1881/src/testdir/dumps/Test_popupwin_infopopup_2.dump 2019-08-18 15:24:23.201608907 +0200 --- src/testdir/dumps/Test_popupwin_infopopup_2.dump 2019-08-18 16:21:45.895833736 +0200 *************** *** 1,10 **** |t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|a|n|o|t|h|e|r|w|o|r|d> @37 ! |~+0#4040ff13&| @23| +0#0000001#ffd7ff255|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| |╔|═@25|X ! |~+0#4040ff13#ffffff0| @23| +0#0000001#e0e0e08|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |║+0&#ffd7ff255| |o|t|h|e|r| |w|o|r|d|s| |a|r|e| @9|║ ! |~+0#4040ff13#ffffff0| @23| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| |║| |c|o@1|l|e|r| |t|h|a|n| |t|h|i|s| |a|n|d| |s|o|m| |║ ! |~+0#4040ff13#ffffff0| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |║| |e| |m|o|r|e| |t|e|x|t| @13|║ ! |~+0#4040ff13#ffffff0| @45|║+0#0000001#ffd7ff255| |t|o| |m|a|k|e| |w|r|a|p| @12|║ ! |~+0#4040ff13#ffffff0| @45|╚+0#0000001#ffd7ff255|═@25|⇲ |~+0#4040ff13#ffffff0| @73 |~| @73 |~| @73 --- 1,10 ---- |t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|a|n|o|t|h|e|r|w|o|r|d> @37 ! |~+0#4040ff13&| @23| +0#0000001#ffd7ff255|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| |╔+0#0000000#ffff4012|═@25|X ! |~+0#4040ff13#ffffff0| @23| +0#0000001#e0e0e08|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |║+0#0000000#ffff4012| |o|t|h|e|r| |w|o|r|d|s| |a|r|e| @9|║ ! |~+0#4040ff13#ffffff0| @23| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| |║+0#0000000#ffff4012| |c|o@1|l|e|r| |t|h|a|n| |t|h|i|s| |a|n|d| |s|o|m| |║ ! |~+0#4040ff13#ffffff0| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |║+0#0000000#ffff4012| |e| |m|o|r|e| |t|e|x|t| @13|║ ! |~+0#4040ff13#ffffff0| @45|║+0#0000000#ffff4012| |t|o| |m|a|k|e| |w|r|a|p| @12|║ ! |~+0#4040ff13#ffffff0| @45|╚+0#0000000#ffff4012|═@25|⇲ |~+0#4040ff13#ffffff0| @73 |~| @73 |~| @73 *** ../vim-8.1.1881/src/testdir/dumps/Test_popupwin_infopopup_3.dump 2019-08-18 15:24:23.201608907 +0200 --- src/testdir/dumps/Test_popupwin_infopopup_3.dump 2019-08-18 16:21:46.951827652 +0200 *************** *** 1,11 **** |t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|n|o|i|n|f|o> @42 |~+0#4040ff13&| @23| +0#0000001#ffd7ff255|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 ! |~| @23| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |╔|═@14|X| +0#4040ff13#ffffff0@10 ! |~| @23| +0#0000001#e0e0e08|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| |║+0&#ffd7ff255| |n|o| |w|o|r|d|s| |h|e|r|e| |║| +0#4040ff13#ffffff0@10 ! |~| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |╚|═@14|⇲| +0#4040ff13#ffffff0@10 ! |~| @73 ! |~| @73 ! |~| @73 |~| @73 |~| @73 |~| @73 --- 1,11 ---- |t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|n|o|i|n|f|o> @42 |~+0#4040ff13&| @23| +0#0000001#ffd7ff255|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@27 ! |~| @23| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |╔+0#0000000#ffff4012|═@11|X| +0#4040ff13#ffffff0@13 ! |~| @23| +0#0000001#e0e0e08|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| |║+0#0000000#ffff4012| |l|e|t|s| @5| +0|║+0&#ffff4012| +0#4040ff13#ffffff0@13 ! |~| @23| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| |║+0#0000000#ffff4012| |s|h|o|w| @5| +0|║+0&#ffff4012| +0#4040ff13#ffffff0@13 ! |~| @45|║+0#0000000#ffff4012| |a| @8| +0|║+0&#ffff4012| +0#4040ff13#ffffff0@13 ! |~| @45|║+0#0000000#ffff4012| |s|c|r|o|l@1|b|a|r| | +0&#a8a8a8255|║+0&#ffff4012| +0#4040ff13#ffffff0@13 ! |~| @45|╚+0#0000000#ffff4012|═@11|⇲| +0#4040ff13#ffffff0@13 |~| @73 |~| @73 |~| @73 *** ../vim-8.1.1881/src/version.c 2019-08-18 15:42:07.201075048 +0200 --- src/version.c 2019-08-18 16:32:05.504313828 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1882, /**/ -- From "know your smileys": :^[/ mean-smiley-with-cigarette /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///