summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-07-20 16:51:19 +0200
committerBram Moolenaar <Bram@vim.org>2019-07-20 16:51:19 +0200
commitcb5ff34c1b8a89fcdb86653ab18d0aa53f665642 (patch)
treeba5f73ac45c6598f28588ddc714887c0703fa0f9
parentf914a33c9c8ec5c30da684a4a16edad3e0224f0a (diff)
patch 8.1.1718: popup menu highlighting does not look goodv8.1.1718
Problem: Popup menu highlighting does not look good. Solution: Highlight the whole window line. Fix that sign line HL is not displayed in a window with a background color.
-rw-r--r--src/popupwin.c54
-rw-r--r--src/proto/sign.pro4
-rw-r--r--src/screen.c2
-rw-r--r--src/sign.c22
-rw-r--r--src/testdir/dumps/Test_popupwin_menu_01.dump2
-rw-r--r--src/testdir/dumps/Test_popupwin_menu_02.dump2
-rw-r--r--src/testdir/dumps/Test_popupwin_menu_04.dump2
-rw-r--r--src/testdir/dumps/Test_popupwin_menu_scroll_1.dump2
-rw-r--r--src/testdir/dumps/Test_popupwin_menu_scroll_2.dump2
-rw-r--r--src/testdir/dumps/Test_popupwin_menu_scroll_3.dump2
-rw-r--r--src/testdir/dumps/Test_popupwin_menu_scroll_4.dump2
-rw-r--r--src/testdir/dumps/Test_popupwin_menu_scroll_5.dump2
-rw-r--r--src/testdir/dumps/Test_popupwin_menu_scroll_6.dump2
-rw-r--r--src/version.c2
14 files changed, 75 insertions, 27 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index 47a5c789dc..d22c00dcdb 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -451,6 +451,22 @@ popup_show_curline(win_T *wp)
wp->w_topline = wp->w_cursor.lnum;
else if (wp->w_cursor.lnum >= wp->w_botline)
wp->w_topline = wp->w_cursor.lnum - wp->w_height + 1;
+
+ // Don't use "firstline" now.
+ wp->w_firstline = 0;
+}
+
+/*
+ * Get the sign group name for window "wp".
+ * Returns a pointer to a static buffer, overwritten on the next call.
+ */
+ static char_u *
+popup_get_sign_name(win_T *wp)
+{
+ static char buf[30];
+
+ vim_snprintf(buf, sizeof(buf), "popup-%d", wp->w_id);
+ return (char_u *)buf;
}
/*
@@ -460,20 +476,31 @@ popup_show_curline(win_T *wp)
static void
popup_highlight_curline(win_T *wp)
{
- int id;
- char buf[100];
+ int sign_id = 0;
+ char_u *sign_name = popup_get_sign_name(wp);
- match_delete(wp, 1, FALSE);
+ buf_delete_signs(wp->w_buffer, (char_u *)"popupmenu");
if ((wp->w_popup_flags & POPF_CURSORLINE) != 0)
{
popup_show_curline(wp);
- id = syn_name2id((char_u *)"PopupSelected");
- vim_snprintf(buf, sizeof(buf), "\\%%%dl.*", (int)wp->w_cursor.lnum);
- match_add(wp, (char_u *)(id == 0 ? "PmenuSel" : "PopupSelected"),
- (char_u *)buf, 10, 1, NULL, NULL);
+ if (!sign_exists_by_name(sign_name))
+ {
+ char *linehl = "PopupSelected";
+
+ 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,
+ wp->w_buffer, wp->w_cursor.lnum, SIGN_DEF_PRIO);
+ redraw_win_later(wp, NOT_VALID);
}
+ else
+ sign_undefine_by_name(sign_name, FALSE);
}
/*
@@ -545,6 +572,8 @@ apply_general_options(win_T *wp, dict_T *dict)
set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
str, OPT_FREE|OPT_LOCAL, 0);
+ set_string_option_direct_in_win(wp, (char_u *)"signcolumn", -1,
+ (char_u *)"no", OPT_FREE|OPT_LOCAL, 0);
set_padding_border(dict, wp->w_popup_padding, "padding", 999);
set_padding_border(dict, wp->w_popup_border, "border", 1);
@@ -1219,7 +1248,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
if (argvars != NULL)
{
- // Check arguments look OK.
+ // Check that arguments look OK.
if (argvars[0].v_type == VAR_NUMBER)
{
buf = buflist_findnr( argvars[0].vval.v_number);
@@ -1671,7 +1700,7 @@ f_popup_filter_menu(typval_T *argvars, typval_T *rettv)
++wp->w_cursor.lnum;
if (old_lnum != wp->w_cursor.lnum)
{
- popup_highlight_curline(wp);
+ // caller will call popup_highlight_curline()
return;
}
@@ -1849,10 +1878,12 @@ f_popup_settext(typval_T *argvars, typval_T *rettv UNUSED)
static void
popup_free(win_T *wp)
{
+ sign_undefine_by_name(popup_get_sign_name(wp), FALSE);
wp->w_buffer->b_locked = FALSE;
if (wp->w_winrow + wp->w_height >= cmdline_row)
clear_cmdline = TRUE;
win_free_popup(wp);
+
redraw_all_later(NOT_VALID);
popup_mask_refresh = TRUE;
}
@@ -2161,7 +2192,8 @@ f_popup_getoptions(typval_T *argvars, typval_T *rettv)
dict_add_string(dict, "title", wp->w_popup_title);
dict_add_number(dict, "wrap", wp->w_p_wrap);
dict_add_number(dict, "drag", wp->w_popup_drag);
- dict_add_number(dict, "cursorline", (wp->w_popup_flags & POPF_CURSORLINE) != 0);
+ dict_add_number(dict, "cursorline",
+ (wp->w_popup_flags & POPF_CURSORLINE) != 0);
dict_add_string(dict, "highlight", wp->w_p_wcr);
if (wp->w_scrollbar_highlight != NULL)
dict_add_string(dict, "scrollbarhighlight",
@@ -2321,7 +2353,7 @@ invoke_popup_filter(win_T *wp, int c)
// NOTE: The callback might close the popup, thus make "wp" invalid.
call_callback(&wp->w_filter_cb, -1,
&rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE, NULL);
- if (old_lnum != wp->w_cursor.lnum)
+ if (win_valid_popup(wp) && old_lnum != wp->w_cursor.lnum)
popup_highlight_curline(wp);
res = tv_get_number(&rettv);
diff --git a/src/proto/sign.pro b/src/proto/sign.pro
index 50b74aaa42..7362cc06d5 100644
--- a/src/proto/sign.pro
+++ b/src/proto/sign.pro
@@ -9,7 +9,9 @@ int buf_signcount(buf_T *buf, linenr_T lnum);
void buf_delete_signs(buf_T *buf, char_u *group);
void sign_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after);
int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text, char_u *texthl);
-int sign_undefine_by_name(char_u *name);
+int sign_exists_by_name(char_u *name);
+int sign_undefine_by_name(char_u *name, int give_error);
+int sign_place(int *sign_id, char_u *sign_group, char_u *sign_name, buf_T *buf, linenr_T lnum, int prio);
void ex_sign(exarg_T *eap);
void get_buffer_signs(buf_T *buf, list_T *l);
void sign_gui_started(void);
diff --git a/src/screen.c b/src/screen.c
index 5cffdf1304..79987108e4 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -5366,6 +5366,8 @@ win_line(
if (wp->w_p_cul && lnum == wp->w_cursor.lnum)
char_attr = hl_combine_attr(char_attr,
HL_ATTR(HLF_CUL));
+ else if (line_attr)
+ char_attr = hl_combine_attr(char_attr, line_attr);
}
# endif
}
diff --git a/src/sign.c b/src/sign.c
index bf238d907c..2cec269f94 100644
--- a/src/sign.c
+++ b/src/sign.c
@@ -1025,10 +1025,19 @@ sign_define_by_name(
}
/*
+ * Return TRUE if sign "name" exists.
+ */
+ int
+sign_exists_by_name(char_u *name)
+{
+ return sign_find(name, NULL) != NULL;
+}
+
+/*
* Free the sign specified by 'name'.
*/
int
-sign_undefine_by_name(char_u *name)
+sign_undefine_by_name(char_u *name, int give_error)
{
sign_T *sp_prev;
sign_T *sp;
@@ -1036,7 +1045,8 @@ sign_undefine_by_name(char_u *name)
sp = sign_find(name, &sp_prev);
if (sp == NULL)
{
- semsg(_("E155: Unknown sign: %s"), name);
+ if (give_error)
+ semsg(_("E155: Unknown sign: %s"), name);
return FAIL;
}
sign_undefine(sp, sp_prev);
@@ -1076,7 +1086,7 @@ may_force_numberwidth_recompute(buf_T *buf, int unplace)
/*
* Place a sign at the specified file location or update a sign.
*/
- static int
+ int
sign_place(
int *sign_id,
char_u *sign_group,
@@ -1591,7 +1601,7 @@ ex_sign(exarg_T *eap)
sign_list_by_name(name);
else
// ":sign undefine {name}"
- sign_undefine_by_name(name);
+ sign_undefine_by_name(name, TRUE);
vim_free(name);
return;
@@ -2512,7 +2522,7 @@ sign_undefine_multiple(list_T *l, list_T *retlist)
{
retval = -1;
name = tv_get_string_chk(&li->li_tv);
- if (name != NULL && (sign_undefine_by_name(name) == OK))
+ if (name != NULL && (sign_undefine_by_name(name, TRUE) == OK))
retval = 0;
list_append_number(retlist, retval);
}
@@ -2551,7 +2561,7 @@ f_sign_undefine(typval_T *argvars, typval_T *rettv)
if (name == NULL)
return;
- if (sign_undefine_by_name(name) == OK)
+ if (sign_undefine_by_name(name, TRUE) == OK)
rettv->vval.v_number = 0;
}
}
diff --git a/src/testdir/dumps/Test_popupwin_menu_01.dump b/src/testdir/dumps/Test_popupwin_menu_01.dump
index bc1552018c..3f09f3e08a 100644
--- a/src/testdir/dumps/Test_popupwin_menu_01.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_01.dump
@@ -1,7 +1,7 @@
>1+0&#ffffff0| @73
|2| @73
|3| @20|╔+0#0000001#ffd7ff255| |m|a|k|e| |a| |c|h|o|i|c|e| |f|r|o|m| |t|h|e| |l|i|s|t| |╗| +0#0000000#ffffff0@21
-|4| @20|║+0#0000001#ffd7ff255| |o+0#0000000#5fd7ff255|n|e| +0#0000001#ffd7ff255@24|║| +0#0000000#ffffff0@21
+|4| @20|║+0#0000001#ffd7ff255| |o+0#0000000#5fd7ff255|n|e| +0#0000001&@23| +0&#ffd7ff255|║| +0#0000000#ffffff0@21
|5| @20|║+0#0000001#ffd7ff255| |t|w|o| @24|║| +0#0000000#ffffff0@21
|6| @20|║+0#0000001#ffd7ff255| |a|n|o|t|h|e|r| @20|║| +0#0000000#ffffff0@21
|7| @20|╚+0#0000001#ffd7ff255|═@28|╝| +0#0000000#ffffff0@21
diff --git a/src/testdir/dumps/Test_popupwin_menu_02.dump b/src/testdir/dumps/Test_popupwin_menu_02.dump
index 594daf4c87..464e276434 100644
--- a/src/testdir/dumps/Test_popupwin_menu_02.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_02.dump
@@ -3,7 +3,7 @@
|3| @20|╔+0#0000001#ffd7ff255| |m|a|k|e| |a| |c|h|o|i|c|e| |f|r|o|m| |t|h|e| |l|i|s|t| |╗| +0#0000000#ffffff0@21
|4| @20|║+0#0000001#ffd7ff255| |o|n|e| @24|║| +0#0000000#ffffff0@21
|5| @20|║+0#0000001#ffd7ff255| |t|w|o| @24|║| +0#0000000#ffffff0@21
-|6| @20|║+0#0000001#ffd7ff255| |a+0#0000000#5fd7ff255|n|o|t|h|e|r| +0#0000001#ffd7ff255@20|║| +0#0000000#ffffff0@21
+|6| @20|║+0#0000001#ffd7ff255| |a+0#0000000#5fd7ff255|n|o|t|h|e|r| +0#0000001&@19| +0&#ffd7ff255|║| +0#0000000#ffffff0@21
|7| @20|╚+0#0000001#ffd7ff255|═@28|╝| +0#0000000#ffffff0@21
|8| @73
|9| @73
diff --git a/src/testdir/dumps/Test_popupwin_menu_04.dump b/src/testdir/dumps/Test_popupwin_menu_04.dump
index bfa660cd5a..30706a76cd 100644
--- a/src/testdir/dumps/Test_popupwin_menu_04.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_04.dump
@@ -1,7 +1,7 @@
>1+0&#ffffff0| @73
|2| @73
|3| @31|╔+0#0000001#ffd7ff255|═@6|╗| +0#0000000#ffffff0@32
-|4| @31|║+0#0000001#ffd7ff255| |o+0#0000000#40ff4011|n|e| +0#0000001#ffd7ff255@2|║| +0#0000000#ffffff0@32
+|4| @31|║+0#0000001#ffd7ff255| |o+0#0000000#40ff4011|n|e| +0#0000001&@1| +0&#ffd7ff255|║| +0#0000000#ffffff0@32
|5| @31|║+0#0000001#ffd7ff255| |t|w|o| @2|║| +0#0000000#ffffff0@32
|6| @31|║+0#0000001#ffd7ff255| |t|h|r|e@1| |║| +0#0000000#ffffff0@32
|7| @31|╚+0#0000001#ffd7ff255|═@6|╝| +0#0000000#ffffff0@32
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_1.dump b/src/testdir/dumps/Test_popupwin_menu_scroll_1.dump
index 8db8436f08..95d020ffcf 100644
--- a/src/testdir/dumps/Test_popupwin_menu_scroll_1.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_1.dump
@@ -2,7 +2,7 @@
|2| @73
|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
|4| @29|║+0#0000001#ffd7ff255| |o|n|e| @5| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
-|5| @29|║+0#0000001#ffd7ff255| |t+0&#e0e0e08|w|o| +0&#ffd7ff255@5| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|5| @29|║+0#0000001#ffd7ff255| |t+0&#e0e0e08|w|o| @4| +0&#ffd7ff255| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|6| @29|║+0#0000001#ffd7ff255| |t|h|r|e@1| @3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
|8| @73
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_2.dump b/src/testdir/dumps/Test_popupwin_menu_scroll_2.dump
index 2b8d27050f..935e3b445d 100644
--- a/src/testdir/dumps/Test_popupwin_menu_scroll_2.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_2.dump
@@ -3,7 +3,7 @@
|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
|4| @29|║+0#0000001#ffd7ff255| |t|h|r|e@1| @3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|5| @29|║+0#0000001#ffd7ff255| |f|o|u|r| @4| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
-|6| @29|║+0#0000001#ffd7ff255| |f+0&#e0e0e08|i|v|e| +0&#ffd7ff255@4| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|6| @29|║+0#0000001#ffd7ff255| |f+0&#e0e0e08|i|v|e| @3| +0&#ffd7ff255| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
|8| @73
|9| @73
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_3.dump b/src/testdir/dumps/Test_popupwin_menu_scroll_3.dump
index ca958122d2..00fe0c816a 100644
--- a/src/testdir/dumps/Test_popupwin_menu_scroll_3.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_3.dump
@@ -3,7 +3,7 @@
|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
|4| @29|║+0#0000001#ffd7ff255| |s|e|v|e|n| @3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|5| @29|║+0#0000001#ffd7ff255| |e|i|g|h|t| @3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
-|6| @29|║+0#0000001#ffd7ff255| |n+0&#e0e0e08|i|n|e| +0&#ffd7ff255@4| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|6| @29|║+0#0000001#ffd7ff255| |n+0&#e0e0e08|i|n|e| @3| +0&#ffd7ff255| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
|8| @73
|9| @73
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_4.dump b/src/testdir/dumps/Test_popupwin_menu_scroll_4.dump
index dece66aa10..d019c86a0d 100644
--- a/src/testdir/dumps/Test_popupwin_menu_scroll_4.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_4.dump
@@ -1,7 +1,7 @@
>1+0&#ffffff0| @73
|2| @73
|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
-|4| @29|║+0#0000001#ffd7ff255| |s+0&#e0e0e08|e|v|e|n| +0&#ffd7ff255@3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|4| @29|║+0#0000001#ffd7ff255| |s+0&#e0e0e08|e|v|e|n| @2| +0&#ffd7ff255| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|5| @29|║+0#0000001#ffd7ff255| |e|i|g|h|t| @3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|6| @29|║+0#0000001#ffd7ff255| |n|i|n|e| @4| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_5.dump b/src/testdir/dumps/Test_popupwin_menu_scroll_5.dump
index 0410eb9036..132137af47 100644
--- a/src/testdir/dumps/Test_popupwin_menu_scroll_5.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_5.dump
@@ -1,7 +1,7 @@
>1+0&#ffffff0| @73
|2| @73
|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
-|4| @29|║+0#0000001#ffd7ff255| |s+0&#e0e0e08|i|x| +0&#ffd7ff255@5| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|4| @29|║+0#0000001#ffd7ff255| |s+0&#e0e0e08|i|x| @4| +0&#ffd7ff255| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|5| @29|║+0#0000001#ffd7ff255| |s|e|v|e|n| @3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|6| @29|║+0#0000001#ffd7ff255| |e|i|g|h|t| @3| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_6.dump b/src/testdir/dumps/Test_popupwin_menu_scroll_6.dump
index 55726bb839..6718bb37b0 100644
--- a/src/testdir/dumps/Test_popupwin_menu_scroll_6.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_6.dump
@@ -1,7 +1,7 @@
>1+0&#ffffff0| @73
|2| @73
|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
-|4| @29|║+0#0000001#ffd7ff255| |o+0&#e0e0e08|n|e| +0&#ffd7ff255@5| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|4| @29|║+0#0000001#ffd7ff255| |o+0&#e0e0e08|n|e| @4| +0&#ffd7ff255| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|5| @29|║+0#0000001#ffd7ff255| |t|w|o| @5| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|6| @29|║+0#0000001#ffd7ff255| |t|h|r|e@1| @3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
diff --git a/src/version.c b/src/version.c
index 47b044f572..e9e0446587 100644
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1718,
+/**/
1717,
/**/
1716,