summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-06-26 05:13:57 +0200
committerBram Moolenaar <Bram@vim.org>2019-06-26 05:13:57 +0200
commit4cd583c6da08ce2f87e1c07b6490a74bb3c3d0c0 (patch)
tree69d196edbe6544f3c902c5000b21bbb96d313bbd
parent6efd76ae4a5cb60facd261abd5d64800ec96402d (diff)
patch 8.1.1600: cannot specify highlighting for popup window scrollbarv8.1.1600
Problem: Cannot specify highlighting for popup window scrollbar. Solution: Add "scrollbarhighlight" and "thumbhighlight" options.
-rw-r--r--src/popupwin.c40
-rw-r--r--src/structs.h2
-rw-r--r--src/testdir/dumps/Test_popupwin_scroll_5.dump8
-rw-r--r--src/testdir/dumps/Test_popupwin_scroll_6.dump8
-rw-r--r--src/testdir/dumps/Test_popupwin_scroll_7.dump8
-rw-r--r--src/version.c2
-rw-r--r--src/window.c2
7 files changed, 56 insertions, 14 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index 2158a8036d..5aab84a4aa 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -269,6 +269,26 @@ apply_move_options(win_T *wp, dict_T *d)
get_pos_options(wp, d);
}
+ static void
+check_highlight(dict_T *dict, char *name, char_u **pval)
+{
+ dictitem_T *di;
+ char_u *str;
+
+ di = dict_find(dict, (char_u *)name, -1);
+ if (di != NULL)
+ {
+ if (di->di_tv.v_type != VAR_STRING)
+ semsg(_(e_invargval), name);
+ else
+ {
+ str = tv_get_string(&di->di_tv);
+ if (*str != NUL)
+ *pval = vim_strsave(str);
+ }
+ }
+}
+
/*
* Shared between popup_create() and f_popup_setoptions().
*/
@@ -375,6 +395,9 @@ apply_general_options(win_T *wp, dict_T *dict)
}
}
+ check_highlight(dict, "scrollbarhighlight", &wp->w_scrollbar_highlight);
+ check_highlight(dict, "thumbhighlight", &wp->w_thumb_highlight);
+
di = dict_find(dict, (char_u *)"zindex", -1);
if (di != NULL)
{
@@ -1677,6 +1700,11 @@ f_popup_getoptions(typval_T *argvars, typval_T *rettv)
dict_add_number(dict, "wrap", wp->w_p_wrap);
dict_add_number(dict, "drag", wp->w_popup_drag);
dict_add_string(dict, "highlight", wp->w_p_wcr);
+ if (wp->w_scrollbar_highlight != NULL)
+ dict_add_string(dict, "scrollbarhighlight",
+ wp->w_scrollbar_highlight);
+ if (wp->w_thumb_highlight != NULL)
+ dict_add_string(dict, "thumbhighlight", wp->w_thumb_highlight);
// find the tabpage that holds this popup
i = 1;
@@ -2131,8 +2159,8 @@ update_popups(void (*win_update)(win_T *wp))
int i;
int sb_thumb_top = 0;
int sb_thumb_height = 0;
- int attr_scroll = highlight_attr[HLF_PSB];
- int attr_thumb = highlight_attr[HLF_PST];
+ int attr_scroll = 0;
+ int attr_thumb = 0;
// Find the window with the lowest zindex that hasn't been updated yet,
// so that the window with a higher zindex is drawn later, thus goes on
@@ -2246,6 +2274,14 @@ update_popups(void (*win_update)(win_T *wp))
sb_thumb_top = (wp->w_topline - 1 + (linecount / wp->w_height) / 2)
* (wp->w_height - sb_thumb_height)
/ (linecount - wp->w_height);
+ if (wp->w_scrollbar_highlight != NULL)
+ attr_scroll = syn_name2attr(wp->w_scrollbar_highlight);
+ else
+ attr_scroll = highlight_attr[HLF_PSB];
+ if (wp->w_thumb_highlight != NULL)
+ attr_thumb = syn_name2attr(wp->w_thumb_highlight);
+ else
+ attr_thumb = highlight_attr[HLF_PST];
}
for (i = wp->w_popup_border[0];
diff --git a/src/structs.h b/src/structs.h
index 9992e99fd5..b368c9e968 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -2904,6 +2904,8 @@ struct window_S
int w_firstline; // "firstline" for popup window
int w_want_scrollbar; // when zero don't use a scrollbar
int w_has_scrollbar; // scrollbar displayed
+ char_u *w_scrollbar_highlight; // "scrollbarhighlight"
+ char_u *w_thumb_highlight; // "thumbhighlight"
int w_popup_padding[4]; // popup padding top/right/bot/left
int w_popup_border[4]; // popup border top/right/bot/left
char_u *w_border_highlight[4]; // popup border highlight
diff --git a/src/testdir/dumps/Test_popupwin_scroll_5.dump b/src/testdir/dumps/Test_popupwin_scroll_5.dump
index 2ce996443e..0437d451f2 100644
--- a/src/testdir/dumps/Test_popupwin_scroll_5.dump
+++ b/src/testdir/dumps/Test_popupwin_scroll_5.dump
@@ -1,10 +1,10 @@
>1+0&#ffffff0| @73
|2| @73
|3| @73
-|4| @31|o+0#0000001#ffd7ff255|n|e| @4| +0#0000000#0000001| +0&#ffffff0@32
-|5| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#0000001| +0&#ffffff0@32
-|6| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32
-|7| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#a8a8a8255| +0&#ffffff0@32
+|4| @31|o+0#0000001#ffd7ff255|n|e| @4| +0#0000000#4040ff13| +0&#ffffff0@32
+|5| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#4040ff13| +0&#ffffff0@32
+|6| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#ff404010| +0&#ffffff0@32
+|7| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#ff404010| +0&#ffffff0@32
|8| @73
|9| @73
|:|c|a|l@1| |S|c|r|o|l@1|U|p|(|)| @40|1|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_popupwin_scroll_6.dump b/src/testdir/dumps/Test_popupwin_scroll_6.dump
index 02c5958440..a0b5988f90 100644
--- a/src/testdir/dumps/Test_popupwin_scroll_6.dump
+++ b/src/testdir/dumps/Test_popupwin_scroll_6.dump
@@ -1,10 +1,10 @@
>1+0&#ffffff0| @73
|2| @73
|3| @73
-|4| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32
-|5| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#0000001| +0&#ffffff0@32
-|6| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#0000001| +0&#ffffff0@32
-|7| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32
+|4| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#ff404010| +0&#ffffff0@32
+|5| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#4040ff13| +0&#ffffff0@32
+|6| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32
+|7| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32
|8| @73
|9| @73
|:|c|a|l@1| |S|c|r|o|l@1|D|o|w|n|(|)| @38|1|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_popupwin_scroll_7.dump b/src/testdir/dumps/Test_popupwin_scroll_7.dump
index f4f0363bbf..1ee91b1ed6 100644
--- a/src/testdir/dumps/Test_popupwin_scroll_7.dump
+++ b/src/testdir/dumps/Test_popupwin_scroll_7.dump
@@ -1,10 +1,10 @@
>1+0&#ffffff0| @73
|2| @73
|3| @73
-|4| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32
-|5| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32
-|6| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#0000001| +0&#ffffff0@32
-|7| @31|n+0#0000001#ffd7ff255|i|n|e| @3| +0#0000000#0000001| +0&#ffffff0@32
+|4| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32
+|5| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#ff404010| +0&#ffffff0@32
+|6| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#4040ff13| +0&#ffffff0@32
+|7| @31|n+0#0000001#ffd7ff255|i|n|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32
|8| @73
|9| @73
|:|c|a|l@1| |S|c|r|o|l@1|D|o|w|n|(|)| @38|1|,|1| @10|T|o|p|
diff --git a/src/version.c b/src/version.c
index eada1792c7..b34071ea3d 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 */
/**/
+ 1600,
+/**/
1599,
/**/
1598,
diff --git a/src/window.c b/src/window.c
index c6d4aa34ac..d40b060966 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4857,6 +4857,8 @@ win_free(
free_callback(&wp->w_filter_cb);
for (i = 0; i < 4; ++i)
VIM_CLEAR(wp->w_border_highlight[i]);
+ vim_free(wp->w_scrollbar_highlight);
+ vim_free(wp->w_thumb_highlight);
vim_free(wp->w_popup_title);
list_unref(wp->w_popup_mask);
#endif