diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-03-11 10:05:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-11 10:05:47 +0800 |
commit | 8cb5b995b6e4d86035e6950d92c0c68ab4e46787 (patch) | |
tree | f82e021bea111cc4ad18a16c52f72efcde1e6c8b /src/nvim/popupmenu.c | |
parent | 29a43ef8affbb9ecbae03b75db346205ffe9ec14 (diff) | |
download | rneovim-8cb5b995b6e4d86035e6950d92c0c68ab4e46787.tar.gz rneovim-8cb5b995b6e4d86035e6950d92c0c68ab4e46787.tar.bz2 rneovim-8cb5b995b6e4d86035e6950d92c0c68ab4e46787.zip |
vim-patch:9.0.1397: highlight for popupmenu kind and extra cannot be set (#22619)
Problem: Highlight for popupmenu kind and extra cannot be set.
Solution: Add PmenuKind, PmenuKindSel, PmenuExtra and PmenuExtraSel
highlight groups and use them. (Gianmaria Bajo, closes vim/vim#12114)
https://github.com/vim/vim/commit/6a7c7749204b256e779c245b1e999bf852ad7b64
Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
Diffstat (limited to 'src/nvim/popupmenu.c')
-rw-r--r-- | src/nvim/popupmenu.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index cdf8d5720b..8db36e594c 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -407,8 +407,6 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i void pum_redraw(void) { int row = 0; - int attr_norm = win_hl_attr(curwin, HLF_PNI); - int attr_select = win_hl_attr(curwin, HLF_PSI); int attr_scroll = win_hl_attr(curwin, HLF_PSB); int attr_thumb = win_hl_attr(curwin, HLF_PST); int i; @@ -418,9 +416,14 @@ void pum_redraw(void) int w; int thumb_pos = 0; int thumb_height = 1; - int round; int n; +#define HA(hlf) (win_hl_attr(curwin, (hlf))) + // "word" "kind" "extra text" + const int attrsNorm[3] = { HA(HLF_PNI), HA(HLF_PNK), HA(HLF_PNX) }; + const int attrsSel[3] = { HA(HLF_PSI), HA(HLF_PSK), HA(HLF_PSX) }; +#undef HA + int grid_width = pum_width; int col_off = 0; bool extra_space = false; @@ -482,7 +485,8 @@ void pum_redraw(void) for (i = 0; i < pum_height; i++) { int idx = i + pum_first; - int attr = (idx == pum_selected) ? attr_select : attr_norm; + const int *const attrs = (idx == pum_selected) ? attrsSel : attrsNorm; + int attr = attrs[0]; // start with "word" highlight grid_puts_line_start(&pum_grid, row); @@ -496,26 +500,25 @@ void pum_redraw(void) } // Display each entry, use two spaces for a Tab. - // Do this 3 times: For the main text, kind and extra info + // Do this 3 times: + // 0 - main text + // 1 - kind + // 2 - extra info int grid_col = col_off; int totwidth = 0; - for (round = 1; round <= 3; round++) { + for (int round = 0; round < 3; round++) { + attr = attrs[round]; width = 0; s = NULL; switch (round) { + case 0: + p = pum_array[idx].pum_text; break; case 1: - p = pum_array[idx].pum_text; - break; - + p = pum_array[idx].pum_kind; break; case 2: - p = pum_array[idx].pum_kind; - break; - - case 3: - p = pum_array[idx].pum_extra; - break; + p = pum_array[idx].pum_extra; break; } if (p != NULL) { @@ -592,17 +595,17 @@ void pum_redraw(void) } } - if (round > 1) { + if (round > 0) { n = pum_kind_width + 1; } else { n = 1; } // Stop when there is nothing more to display. - if ((round == 3) - || ((round == 2) - && (pum_array[idx].pum_extra == NULL)) + if ((round == 2) || ((round == 1) + && (pum_array[idx].pum_extra == NULL)) + || ((round == 0) && (pum_array[idx].pum_kind == NULL) && (pum_array[idx].pum_extra == NULL)) || (pum_base_width + n >= pum_width)) { |