Skip to content

Commit 4cd583c

Browse files
committed
patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Problem: Cannot specify highlighting for popup window scrollbar. Solution: Add "scrollbarhighlight" and "thumbhighlight" options.
1 parent 6efd76a commit 4cd583c

7 files changed

Lines changed: 56 additions & 14 deletions

File tree

src/popupwin.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,26 @@ apply_move_options(win_T *wp, dict_T *d)
269269
get_pos_options(wp, d);
270270
}
271271

272+
static void
273+
check_highlight(dict_T *dict, char *name, char_u **pval)
274+
{
275+
dictitem_T *di;
276+
char_u *str;
277+
278+
di = dict_find(dict, (char_u *)name, -1);
279+
if (di != NULL)
280+
{
281+
if (di->di_tv.v_type != VAR_STRING)
282+
semsg(_(e_invargval), name);
283+
else
284+
{
285+
str = tv_get_string(&di->di_tv);
286+
if (*str != NUL)
287+
*pval = vim_strsave(str);
288+
}
289+
}
290+
}
291+
272292
/*
273293
* Shared between popup_create() and f_popup_setoptions().
274294
*/
@@ -375,6 +395,9 @@ apply_general_options(win_T *wp, dict_T *dict)
375395
}
376396
}
377397

398+
check_highlight(dict, "scrollbarhighlight", &wp->w_scrollbar_highlight);
399+
check_highlight(dict, "thumbhighlight", &wp->w_thumb_highlight);
400+
378401
di = dict_find(dict, (char_u *)"zindex", -1);
379402
if (di != NULL)
380403
{
@@ -1677,6 +1700,11 @@ f_popup_getoptions(typval_T *argvars, typval_T *rettv)
16771700
dict_add_number(dict, "wrap", wp->w_p_wrap);
16781701
dict_add_number(dict, "drag", wp->w_popup_drag);
16791702
dict_add_string(dict, "highlight", wp->w_p_wcr);
1703+
if (wp->w_scrollbar_highlight != NULL)
1704+
dict_add_string(dict, "scrollbarhighlight",
1705+
wp->w_scrollbar_highlight);
1706+
if (wp->w_thumb_highlight != NULL)
1707+
dict_add_string(dict, "thumbhighlight", wp->w_thumb_highlight);
16801708

16811709
// find the tabpage that holds this popup
16821710
i = 1;
@@ -2131,8 +2159,8 @@ update_popups(void (*win_update)(win_T *wp))
21312159
int i;
21322160
int sb_thumb_top = 0;
21332161
int sb_thumb_height = 0;
2134-
int attr_scroll = highlight_attr[HLF_PSB];
2135-
int attr_thumb = highlight_attr[HLF_PST];
2162+
int attr_scroll = 0;
2163+
int attr_thumb = 0;
21362164

21372165
// Find the window with the lowest zindex that hasn't been updated yet,
21382166
// 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))
22462274
sb_thumb_top = (wp->w_topline - 1 + (linecount / wp->w_height) / 2)
22472275
* (wp->w_height - sb_thumb_height)
22482276
/ (linecount - wp->w_height);
2277+
if (wp->w_scrollbar_highlight != NULL)
2278+
attr_scroll = syn_name2attr(wp->w_scrollbar_highlight);
2279+
else
2280+
attr_scroll = highlight_attr[HLF_PSB];
2281+
if (wp->w_thumb_highlight != NULL)
2282+
attr_thumb = syn_name2attr(wp->w_thumb_highlight);
2283+
else
2284+
attr_thumb = highlight_attr[HLF_PST];
22492285
}
22502286

22512287
for (i = wp->w_popup_border[0];

src/structs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,6 +2904,8 @@ struct window_S
29042904
int w_firstline; // "firstline" for popup window
29052905
int w_want_scrollbar; // when zero don't use a scrollbar
29062906
int w_has_scrollbar; // scrollbar displayed
2907+
char_u *w_scrollbar_highlight; // "scrollbarhighlight"
2908+
char_u *w_thumb_highlight; // "thumbhighlight"
29072909
int w_popup_padding[4]; // popup padding top/right/bot/left
29082910
int w_popup_border[4]; // popup border top/right/bot/left
29092911
char_u *w_border_highlight[4]; // popup border highlight
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
>1+0&#ffffff0| @73
22
|2| @73
33
|3| @73
4-
|4| @31|o+0#0000001#ffd7ff255|n|e| @4| +0#0000000#0000001| +0&#ffffff0@32
5-
|5| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#0000001| +0&#ffffff0@32
6-
|6| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32
7-
|7| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#a8a8a8255| +0&#ffffff0@32
4+
|4| @31|o+0#0000001#ffd7ff255|n|e| @4| +0#0000000#4040ff13| +0&#ffffff0@32
5+
|5| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#4040ff13| +0&#ffffff0@32
6+
|6| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#ff404010| +0&#ffffff0@32
7+
|7| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#ff404010| +0&#ffffff0@32
88
|8| @73
99
|9| @73
1010
|:|c|a|l@1| |S|c|r|o|l@1|U|p|(|)| @40|1|,|1| @10|T|o|p|
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
>1+0&#ffffff0| @73
22
|2| @73
33
|3| @73
4-
|4| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32
5-
|5| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#0000001| +0&#ffffff0@32
6-
|6| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#0000001| +0&#ffffff0@32
7-
|7| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32
4+
|4| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#ff404010| +0&#ffffff0@32
5+
|5| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#4040ff13| +0&#ffffff0@32
6+
|6| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32
7+
|7| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32
88
|8| @73
99
|9| @73
1010
|:|c|a|l@1| |S|c|r|o|l@1|D|o|w|n|(|)| @38|1|,|1| @10|T|o|p|
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
>1+0&#ffffff0| @73
22
|2| @73
33
|3| @73
4-
|4| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32
5-
|5| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32
6-
|6| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#0000001| +0&#ffffff0@32
7-
|7| @31|n+0#0000001#ffd7ff255|i|n|e| @3| +0#0000000#0000001| +0&#ffffff0@32
4+
|4| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32
5+
|5| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#ff404010| +0&#ffffff0@32
6+
|6| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#4040ff13| +0&#ffffff0@32
7+
|7| @31|n+0#0000001#ffd7ff255|i|n|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32
88
|8| @73
99
|9| @73
1010
|:|c|a|l@1| |S|c|r|o|l@1|D|o|w|n|(|)| @38|1|,|1| @10|T|o|p|

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ static char *(features[]) =
777777

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1600,
780782
/**/
781783
1599,
782784
/**/

src/window.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4857,6 +4857,8 @@ win_free(
48574857
free_callback(&wp->w_filter_cb);
48584858
for (i = 0; i < 4; ++i)
48594859
VIM_CLEAR(wp->w_border_highlight[i]);
4860+
vim_free(wp->w_scrollbar_highlight);
4861+
vim_free(wp->w_thumb_highlight);
48604862
vim_free(wp->w_popup_title);
48614863
list_unref(wp->w_popup_mask);
48624864
#endif

0 commit comments

Comments
 (0)