diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-18 16:35:23 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-18 16:35:23 +0200 |
commit | 62a0cb443c3184f24a6dac73d3505f9056cf6056 (patch) | |
tree | 42ee160304d76f887d29e4e9a193c426d8bacb75 /src | |
parent | f4665e78f2d1b2ca64de5f5331d03de7d61c8c66 (diff) | |
download | vim-git-62a0cb443c3184f24a6dac73d3505f9056cf6056.tar.gz |
patch 8.1.1882: cannot specify properties of the info popup windowv8.1.1882
Problem: Cannot specify properties of the info popup window.
Solution: Add the 'completepopup' option. Default to PmenuSel highlight.
Diffstat (limited to 'src')
-rw-r--r-- | src/option.c | 15 | ||||
-rw-r--r-- | src/option.h | 1 | ||||
-rw-r--r-- | src/popupwin.c | 60 | ||||
-rw-r--r-- | src/proto/popupwin.pro | 1 | ||||
-rw-r--r-- | src/screen.c | 7 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popupwin_infopopup_1.dump | 6 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popupwin_infopopup_2.dump | 12 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popupwin_infopopup_3.dump | 12 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 4 | ||||
-rw-r--r-- | src/version.c | 2 |
10 files changed, 92 insertions, 28 deletions
diff --git a/src/option.c b/src/option.c index 5bcb33e50..65403b58f 100644 --- a/src/option.c +++ b/src/option.c @@ -893,6 +893,15 @@ static struct vimoption options[] = {(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,6 +7835,12 @@ did_set_string_option( 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. */ diff --git a/src/option.h b/src/option.h index 29ecd8ac3..71a599ef5 100644 --- a/src/option.h +++ b/src/option.h @@ -503,6 +503,7 @@ EXTERN int p_fs; // 'fsync' #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 diff --git a/src/popupwin.c b/src/popupwin.c index 0198fb569..ff7aa01aa 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -550,8 +550,7 @@ popup_highlight_curline(win_T *wp) if (syn_name2id((char_u *)linehl) == 0) linehl = "PmenuSel"; - sign_define_by_name(sign_name, NULL, - (char_u *)linehl, NULL, NULL); + sign_define_by_name(sign_name, NULL, (char_u *)linehl, NULL, NULL); } sign_place(&sign_id, (char_u *)"popupmenu", sign_name, @@ -1286,16 +1285,16 @@ popup_set_buffer_text(buf_T *buf, typval_T text) } /* - * Parse the 'previewpopup' option and apply the values to window "wp" if it - * not NULL. + * Parse the 'previewpopup' or 'completepopup' 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) + static int +parse_popup_option(win_T *wp, int is_preview) { char_u *p; - for (p = p_pvp; *p != NUL; p += (*p == ',' ? 1 : 0)) + for (p = is_preview ? p_pvp : p_cpp; *p != NUL; p += (*p == ',' ? 1 : 0)) { char_u *e, *dig; char_u *s = p; @@ -1310,25 +1309,41 @@ parse_previewpopup(win_T *wp) p = e + STRLEN(e); dig = e + 1; x = getdigits(&dig); - if (dig != p) - return FAIL; if (STRNCMP(s, "height:", 7) == 0) { + if (dig != p) + return FAIL; if (wp != NULL) { - wp->w_minheight = x; + 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) { - wp->w_minwidth = x; + 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,6 +1351,28 @@ parse_previewpopup(win_T *wp) } /* + * 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,6 +1678,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type) 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) diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro index f2cbf074b..0fad5ae83 100644 --- a/src/proto/popupwin.pro +++ b/src/proto/popupwin.pro @@ -11,6 +11,7 @@ int popup_width(win_T *wp); 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); diff --git a/src/screen.c b/src/screen.c index 760cd2c1f..cb2d07b02 100644 --- a/src/screen.c +++ b/src/screen.c @@ -996,7 +996,12 @@ get_wcr_attr(win_T *wp) wcr_attr = syn_name2attr(wp->w_p_wcr); #ifdef FEAT_TEXT_PROP else if (WIN_IS_POPUP(wp)) - wcr_attr = HL_ATTR(HLF_PNI); + { + 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; } diff --git a/src/testdir/dumps/Test_popupwin_infopopup_1.dump b/src/testdir/dumps/Test_popupwin_infopopup_1.dump index ba5925aff..36bb2ee05 100644 --- a/src/testdir/dumps/Test_popupwin_infopopup_1.dump +++ b/src/testdir/dumps/Test_popupwin_infopopup_1.dump @@ -1,6 +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 +|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 diff --git a/src/testdir/dumps/Test_popupwin_infopopup_2.dump b/src/testdir/dumps/Test_popupwin_infopopup_2.dump index 059055e5a..34c46e9f4 100644 --- a/src/testdir/dumps/Test_popupwin_infopopup_2.dump +++ b/src/testdir/dumps/Test_popupwin_infopopup_2.dump @@ -1,10 +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&| @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 diff --git a/src/testdir/dumps/Test_popupwin_infopopup_3.dump b/src/testdir/dumps/Test_popupwin_infopopup_3.dump index 3295cb247..fe5e7b14a 100644 --- a/src/testdir/dumps/Test_popupwin_infopopup_3.dump +++ b/src/testdir/dumps/Test_popupwin_infopopup_3.dump @@ -1,11 +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 +|~| @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 diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 07ed81b45..15a61f962 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -2199,6 +2199,8 @@ func Test_popupmenu_info() 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,7 +2232,7 @@ func Test_popupmenu_info() \ 'word': 'noinfo', \ 'abbr': 'noawrd', \ 'menu': 'extra text', - \ 'info': 'no words here', + \ 'info': "lets\nshow\na\nscrollbar\nhere", \ 'kind': 'W', \ 'user_data': 'notest' \ }, diff --git a/src/version.c b/src/version.c index 15b77c395..6a7068813 100644 --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1882, +/**/ 1881, /**/ 1880, |