]> granicus.if.org Git - vim/commitdiff
patch 8.1.1538: cannot specify highlighting for notifications v8.1.1538
authorBram Moolenaar <Bram@vim.org>
Sat, 15 Jun 2019 12:31:55 +0000 (14:31 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 15 Jun 2019 12:31:55 +0000 (14:31 +0200)
Problem:    Cannot specify highlighting for notifications.
Solution:   Use the PopupNotification group if it exists. Add a minimal width
            to notifications.

runtime/doc/popup.txt
src/popupwin.c
src/testdir/dumps/Test_popupwin_notify_01.dump
src/testdir/dumps/Test_popupwin_notify_02.dump
src/testdir/test_popupwin.vim
src/version.c

index 71c7bc0d30ffecdd43dd13347bcf3c6fbfb676e1..3ee92f2698083b53053d5c3de8f0e696ca69bdbe 100644 (file)
@@ -1,4 +1,4 @@
-*popup.txt*  For Vim version 8.1.  Last change: 2019 Jun 12
+*popup.txt*  For Vim version 8.1.  Last change: 2019 Jun 15
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -93,8 +93,6 @@ TODO:
 - Add 'balloonpopup': instead of showing text, let the callback open a popup
   window and return the window ID.   The popup will then be closed when the
   mouse moves, except when it moves inside the popup.
-- For notifications use the PopupNotification highlight group, fall back to
-  WarningMsg if it isn't defined.
 - For the "moved" property also include mouse movement?
 - Make redrawing more efficient and avoid flicker:
     - put popup menu also put in popup_mask?
@@ -300,6 +298,7 @@ popup_notification({text}, {options})                        *popup_notification()*
                        call popup_create({text}, {
                                \ 'line': 1,
                                \ 'col': 10,
+                               \ 'minwidth': 20,
                                \ 'time': 3000,
                                \ 'tabpage': -1,
                                \ 'zindex': 200,
@@ -308,6 +307,8 @@ popup_notification({text}, {options})                        *popup_notification()*
                                \ 'border': [],
                                \ 'padding': [0,1,0,1],
                                \ })
+<              The PopupNotification highlight group is used instead of
+               WarningMsg if it is defined.
 <              The position will be adjusted to avoid overlap with other
                notifications.
                Use {options} to change the properties.
index 594fca8a005cbbc0c6e0d39adc3c2e00d6484d00..aeed2e79b4a68f6fb045bcbad5cd41851dd3681d 100644 (file)
@@ -258,7 +258,9 @@ apply_options(win_T *wp, buf_T *buf UNUSED, dict_T *dict)
     dictitem_T *di;
     int                i;
 
-    wp->w_minwidth = dict_get_number(dict, (char_u *)"minwidth");
+    di = dict_find(dict, (char_u *)"minwidth", -1);
+    if (di != NULL)
+       wp->w_minwidth = dict_get_number(dict, (char_u *)"minwidth");
     wp->w_minheight = dict_get_number(dict, (char_u *)"minheight");
     wp->w_maxwidth = dict_get_number(dict, (char_u *)"maxwidth");
     wp->w_maxheight = dict_get_number(dict, (char_u *)"maxheight");
@@ -856,13 +858,17 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
 
        wp->w_wantcol = 10;
        wp->w_zindex = POPUPWIN_NOTIFICATION_ZINDEX;
+       wp->w_minwidth = 20;
+       wp->w_popup_drag = 1;
        for (i = 0; i < 4; ++i)
            wp->w_popup_border[i] = 1;
        wp->w_popup_padding[1] = 1;
        wp->w_popup_padding[3] = 1;
+
+       nr = syn_name2id((char_u *)"PopupNotification");
        set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
-                               (char_u *)"WarningMsg", OPT_FREE|OPT_LOCAL, 0);
-       wp->w_popup_drag = 1;
+               (char_u *)(nr == 0 ? "WarningMsg" : "PopupNotification"),
+               OPT_FREE|OPT_LOCAL, 0);
     }
 
     // Deal with options.
index 2ecd5ee1d075ff826e4d2e00eb2b291c9b2cda21..bad62f6d9adf113491f6020077c201cf5521442c 100644 (file)
@@ -1,6 +1,6 @@
->1+0&#ffffff0| @7|╔+0#e000002&|═@19|╗| +0#0000000&@43
-|2| @7|║+0#e000002&| |f|i|r|s|t| |n|o|t|i|f|i|c|a|t|i|o|n| |║| +0#0000000&@43
-|3| @7|╚+0#e000002&|═@19|╝| +0#0000000&@43
+>1+0&#ffffff0| @7|╔+0#e000002&|═@21|╗| +0#0000000&@41
+|2| @7|║+0#e000002&| |f|i|r|s|t| |n|o|t|i|f|i|c|a|t|i|o|n| @2|║| +0#0000000&@41
+|3| @7|╚+0#e000002&|═@21|╝| +0#0000000&@41
 |4| @73
 |5| @73
 |6| @73
index 10170619a291ee369a1e95dccc0b02a2efd2dab9..72e2895f167a4cc4c71f27ab2c1bd320a3593b09 100644 (file)
@@ -1,10 +1,10 @@
->1+0&#ffffff0| @7|╔+0#e000002&|═@19|╗| +0#0000000&@43
-|2| @7|║+0#e000002&| |f|i|r|s|t| |n|o|t|i|f|i|c|a|t|i|o|n| |║| +0#0000000&@43
-|3| @7|╚+0#e000002&|═@19|╝| +0#0000000&@43
+>1+0&#ffffff0| @7|╔+0#e000002&|═@21|╗| +0#0000000&@41
+|2| @7|║+0#e000002&| |f|i|r|s|t| |n|o|t|i|f|i|c|a|t|i|o|n| @2|║| +0#0000000&@41
+|3| @7|╚+0#e000002&|═@21|╝| +0#0000000&@41
 |4| @7|╔+0&#5fd7ff255|═@31|╗| +0&#ffffff0@31
 |5| @7|║+0&#5fd7ff255| |a|n|o|t|h|e|r| |i|m|p|o|r|t|a|n|t| |n|o|t|i|f|i|c|a|t|i|o|n| |║| +0&#ffffff0@31
 |6| @7|╚+0&#5fd7ff255|═@31|╝| +0&#ffffff0@31
 |7| @73
 |8| @73
 |9| @73
-@57|1|,|1| @10|T|o|p| 
+|:|c|a|l@1| |p|o|p|u|p|_|n|o|t|i|f|i|c|a|t|i|o|n|(|'|a|n|o|t|h|e|r| |i|m|p|o|r|t|a|n|t| |n|o|t|i|f|i|c|a|t|i|o|n|'|1|,|1| @10|T|o|p| 
index 789c8599f7da153cff6bc00f6d0d6bdca88af304..d9b0b295f742465816b2178009eda43f0ce93f11 100644 (file)
@@ -1191,7 +1191,8 @@ func Test_notifications()
   call VerifyScreenDump(buf, 'Test_popupwin_notify_01', {})
 
   " second one goes below the first one
-  call term_sendkeys(buf, ":call popup_notification('another important notification', {'highlight': 'Notification'})\<CR>")
+  call term_sendkeys(buf, ":hi link PopupNotification Notification\<CR>")
+  call term_sendkeys(buf, ":call popup_notification('another important notification', {})\<CR>")
   call VerifyScreenDump(buf, 'Test_popupwin_notify_02', {})
 
 
index f36b98689d064dd54ae53f443805e73720a24483..4a6fb006a6079337b8c0ff4128ab6e5ead8da86a 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1538,
 /**/
     1537,
 /**/