]> granicus.if.org Git - vim/commitdiff
patch 8.1.1718: popup menu highlighting does not look good v8.1.1718
authorBram Moolenaar <Bram@vim.org>
Sat, 20 Jul 2019 14:51:19 +0000 (16:51 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 20 Jul 2019 14:51:19 +0000 (16:51 +0200)
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.

14 files changed:
src/popupwin.c
src/proto/sign.pro
src/screen.c
src/sign.c
src/testdir/dumps/Test_popupwin_menu_01.dump
src/testdir/dumps/Test_popupwin_menu_02.dump
src/testdir/dumps/Test_popupwin_menu_04.dump
src/testdir/dumps/Test_popupwin_menu_scroll_1.dump
src/testdir/dumps/Test_popupwin_menu_scroll_2.dump
src/testdir/dumps/Test_popupwin_menu_scroll_3.dump
src/testdir/dumps/Test_popupwin_menu_scroll_4.dump
src/testdir/dumps/Test_popupwin_menu_scroll_5.dump
src/testdir/dumps/Test_popupwin_menu_scroll_6.dump
src/version.c

index 47a5c789dce1445870904ecad7f9376c46acde4a..d22c00dcdbec6257ead1c96cfd41baca2bc2091d 100644 (file)
@@ -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);
index 50b74aaa428fa02640a41acd7abbfa5751f65292..7362cc06d5d3c037fa7e103276a7413be813f5e0 100644 (file)
@@ -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);
index 5cffdf13046219214051e01069f92a11da38115c..79987108e4222cbf9c012c8b1b56474772f017f8 100644 (file)
@@ -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
                }
index bf238d907cb2a66c8670f96a3116be129df243b4..2cec269f94b0c7f333b4170af53065e58a38f949 100644 (file)
@@ -1024,11 +1024,20 @@ sign_define_by_name(
     return OK;
 }
 
+/*
+ * 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;
     }
 }
index bc1552018c6d5c391b91352f193d0ef7990b62c0..3f09f3e08a26b28c696c2d625fc3a588b3fbbf28 100644 (file)
@@ -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
index 594daf4c871aa320fa1aeef86d4faffe68cd0218..464e276434a93d543c8a0aa8449a60f5107555a8 100644 (file)
@@ -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
index bfa660cd5a0b6ee717220f6b2aea6aa8f4b45371..30706a76cd020915e7630ca244688330d051c23a 100644 (file)
@@ -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
index 8db8436f087e7682001b717cd4d6ad03a4b4b2a5..95d020ffcfdcf909566d7236344b64eb94ecd32c 100644 (file)
@@ -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
index 2b8d27050f1f0a9c6cd67487150818b903dbe469..935e3b445d9166be2b36b141ae4413dac45f3583 100644 (file)
@@ -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
index ca958122d2a39077df91dc626f7b46f4e4eae60b..00fe0c816a016301c7b6074595151e1ef76f00ad 100644 (file)
@@ -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
index dece66aa105fd6cf17f611750420a140238ab9fb..d019c86a0dcea951f4533a12790f531047fad507 100644 (file)
@@ -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
index 0410eb9036ab628bce1e0e00cf9179c7088c4e2a..132137af47079e2e6c55aba9f69dda1d70f7eae1 100644 (file)
@@ -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
index 55726bb83913c2d9aa00f0ba6155a66ecfa66dc4..6718bb37b0d4c379422fbf099d25d68a355e772f 100644 (file)
@@ -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
index 47b044f572b4191bb1ce3a33c8e831092f7bd6fa..e9e04465875ccb132a311d9e7c13561c2fecb841 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1718,
 /**/
     1717,
 /**/