Mercurial > vim
comparison src/popupwin.c @ 17202:4b40e8821f56 v8.1.1600
patch 8.1.1600: cannot specify highlighting for popup window scrollbar
commit https://github.com/vim/vim/commit/4cd583c6da08ce2f87e1c07b6490a74bb3c3d0c0
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 26 05:13:57 2019 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 26 Jun 2019 05:15:05 +0200 |
parents | db81cee3a0e1 |
children | 8ca93f88b84a |
comparison
equal
deleted
inserted
replaced
17201:ed5e42387f8b | 17202:4b40e8821f56 |
---|---|
265 if ((nr = dict_get_number(d, (char_u *)"maxwidth")) > 0) | 265 if ((nr = dict_get_number(d, (char_u *)"maxwidth")) > 0) |
266 wp->w_maxwidth = nr; | 266 wp->w_maxwidth = nr; |
267 if ((nr = dict_get_number(d, (char_u *)"maxheight")) > 0) | 267 if ((nr = dict_get_number(d, (char_u *)"maxheight")) > 0) |
268 wp->w_maxheight = nr; | 268 wp->w_maxheight = nr; |
269 get_pos_options(wp, d); | 269 get_pos_options(wp, d); |
270 } | |
271 | |
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 } | |
270 } | 290 } |
271 | 291 |
272 /* | 292 /* |
273 * Shared between popup_create() and f_popup_setoptions(). | 293 * Shared between popup_create() and f_popup_setoptions(). |
274 */ | 294 */ |
372 for (i = 1; i < 4; ++i) | 392 for (i = 1; i < 4; ++i) |
373 wp->w_border_char[i] = wp->w_border_char[0]; | 393 wp->w_border_char[i] = wp->w_border_char[0]; |
374 } | 394 } |
375 } | 395 } |
376 } | 396 } |
397 | |
398 check_highlight(dict, "scrollbarhighlight", &wp->w_scrollbar_highlight); | |
399 check_highlight(dict, "thumbhighlight", &wp->w_thumb_highlight); | |
377 | 400 |
378 di = dict_find(dict, (char_u *)"zindex", -1); | 401 di = dict_find(dict, (char_u *)"zindex", -1); |
379 if (di != NULL) | 402 if (di != NULL) |
380 { | 403 { |
381 wp->w_zindex = dict_get_number(dict, (char_u *)"zindex"); | 404 wp->w_zindex = dict_get_number(dict, (char_u *)"zindex"); |
1675 dict_add_number(dict, "fixed", wp->w_popup_fixed); | 1698 dict_add_number(dict, "fixed", wp->w_popup_fixed); |
1676 dict_add_string(dict, "title", wp->w_popup_title); | 1699 dict_add_string(dict, "title", wp->w_popup_title); |
1677 dict_add_number(dict, "wrap", wp->w_p_wrap); | 1700 dict_add_number(dict, "wrap", wp->w_p_wrap); |
1678 dict_add_number(dict, "drag", wp->w_popup_drag); | 1701 dict_add_number(dict, "drag", wp->w_popup_drag); |
1679 dict_add_string(dict, "highlight", wp->w_p_wcr); | 1702 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); | |
1680 | 1708 |
1681 // find the tabpage that holds this popup | 1709 // find the tabpage that holds this popup |
1682 i = 1; | 1710 i = 1; |
1683 FOR_ALL_TABPAGES(tp) | 1711 FOR_ALL_TABPAGES(tp) |
1684 { | 1712 { |
2129 char_u buf[MB_MAXBYTES]; | 2157 char_u buf[MB_MAXBYTES]; |
2130 int row; | 2158 int row; |
2131 int i; | 2159 int i; |
2132 int sb_thumb_top = 0; | 2160 int sb_thumb_top = 0; |
2133 int sb_thumb_height = 0; | 2161 int sb_thumb_height = 0; |
2134 int attr_scroll = highlight_attr[HLF_PSB]; | 2162 int attr_scroll = 0; |
2135 int attr_thumb = highlight_attr[HLF_PST]; | 2163 int attr_thumb = 0; |
2136 | 2164 |
2137 // Find the window with the lowest zindex that hasn't been updated yet, | 2165 // Find the window with the lowest zindex that hasn't been updated yet, |
2138 // so that the window with a higher zindex is drawn later, thus goes on | 2166 // so that the window with a higher zindex is drawn later, thus goes on |
2139 // top. | 2167 // top. |
2140 popup_reset_handled(); | 2168 popup_reset_handled(); |
2244 if (sb_thumb_height == 0) | 2272 if (sb_thumb_height == 0) |
2245 sb_thumb_height = 1; | 2273 sb_thumb_height = 1; |
2246 sb_thumb_top = (wp->w_topline - 1 + (linecount / wp->w_height) / 2) | 2274 sb_thumb_top = (wp->w_topline - 1 + (linecount / wp->w_height) / 2) |
2247 * (wp->w_height - sb_thumb_height) | 2275 * (wp->w_height - sb_thumb_height) |
2248 / (linecount - wp->w_height); | 2276 / (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]; | |
2249 } | 2285 } |
2250 | 2286 |
2251 for (i = wp->w_popup_border[0]; | 2287 for (i = wp->w_popup_border[0]; |
2252 i < total_height - wp->w_popup_border[2]; ++i) | 2288 i < total_height - wp->w_popup_border[2]; ++i) |
2253 { | 2289 { |