diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-06-30 15:30:54 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2022-07-01 10:17:39 +0800 |
| commit | 610cf9f95032bd219cb5695d169fe2cd698ec307 (patch) | |
| tree | e294c5bcae1401e0ba3fa37ed6c60417d47f960f /src/nvim/popupmnu.c | |
| parent | cf8df141f3c7e706c86aadba404ae8ad54d5c795 (diff) | |
| download | rneovim-610cf9f95032bd219cb5695d169fe2cd698ec307.tar.gz rneovim-610cf9f95032bd219cb5695d169fe2cd698ec307.tar.bz2 rneovim-610cf9f95032bd219cb5695d169fe2cd698ec307.zip | |
vim-patch:8.0.1570: can't use :popup for a menu in the terminal
Problem: Can't use :popup for a menu in the terminal. (Wei Zhang)
Solution: Make :popup work in the terminal. Also fix that entries were
included that don't work in the current state.
https://github.com/vim/vim/commit/29a2c08d792e4458a0af8371f5341394829fce29
Diffstat (limited to 'src/nvim/popupmnu.c')
| -rw-r--r-- | src/nvim/popupmnu.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index cf87f469b9..82ad409c39 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -1000,9 +1000,12 @@ void pum_show_popupmenu(vimmenu_T *menu) { pum_undisplay(true); pum_size = 0; + int mode = get_menu_mode_flag(); for (vimmenu_T *mp = menu->children; mp != NULL; mp = mp->next) { - pum_size++; + if (menu_is_separator(mp->dname) || (mp->modes & mp->enabled & mode)) { + pum_size++; + } } int idx = 0; @@ -1011,7 +1014,7 @@ void pum_show_popupmenu(vimmenu_T *menu) for (vimmenu_T *mp = menu->children; mp != NULL; mp = mp->next) { if (menu_is_separator(mp->dname)) { array[idx++].pum_text = (char_u *)""; - } else { + } else if (mp->modes & mp->enabled & mode) { array[idx++].pum_text = (char_u *)mp->dname; } } @@ -1079,3 +1082,18 @@ void pum_show_popupmenu(vimmenu_T *menu) xfree(array); pum_undisplay(true); } + +void pum_make_popup(const char *path_name, int use_mouse_pos) +{ + if (!use_mouse_pos) { + // Hack: set mouse position at the cursor so that the menu pops up + // around there. + mouse_row = curwin->w_winrow + curwin->w_wrow; + mouse_col = curwin->w_wincol + curwin->w_wcol; + } + + vimmenu_T *menu = menu_find(path_name); + if (menu != NULL) { + pum_show_popupmenu(menu); + } +} |