Mercurial > vim
comparison src/popupmnu.c @ 13392:d5347779fb20 v8.0.1570
patch 8.0.1570: can't use :popup for a menu in the terminal
commit https://github.com/vim/vim/commit/29a2c08d792e4458a0af8371f5341394829fce29
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Mar 5 21:06:23 2018 +0100
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 05 Mar 2018 21:15:05 +0100 |
parents | 244ff1b6d2ad |
children | c415cdd49ea4 |
comparison
equal
deleted
inserted
replaced
13391:6ef2dba73dab | 13392:d5347779fb20 |
---|---|
1130 int idx = 0; | 1130 int idx = 0; |
1131 pumitem_T *array; | 1131 pumitem_T *array; |
1132 #ifdef FEAT_BEVAL_TERM | 1132 #ifdef FEAT_BEVAL_TERM |
1133 int save_bevalterm = p_bevalterm; | 1133 int save_bevalterm = p_bevalterm; |
1134 #endif | 1134 #endif |
1135 int mode; | |
1135 | 1136 |
1136 pum_undisplay(); | 1137 pum_undisplay(); |
1137 pum_size = 0; | 1138 pum_size = 0; |
1139 mode = get_menu_mode_flag(); | |
1138 | 1140 |
1139 for (mp = menu->children; mp != NULL; mp = mp->next) | 1141 for (mp = menu->children; mp != NULL; mp = mp->next) |
1140 ++pum_size; | 1142 if (menu_is_separator(mp->dname) |
1143 || (mp->modes & mp->enabled & mode)) | |
1144 ++pum_size; | |
1141 | 1145 |
1142 array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size); | 1146 array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size); |
1143 if (array == NULL) | 1147 if (array == NULL) |
1144 return; | 1148 return; |
1145 | 1149 |
1146 for (mp = menu->children; mp != NULL; mp = mp->next) | 1150 for (mp = menu->children; mp != NULL; mp = mp->next) |
1147 if (menu_is_separator(mp->dname)) | 1151 if (menu_is_separator(mp->dname)) |
1148 array[idx++].pum_text = (char_u *)""; | 1152 array[idx++].pum_text = (char_u *)""; |
1149 else | 1153 else if (mp->modes & mp->enabled & mode) |
1150 array[idx++].pum_text = mp->dname; | 1154 array[idx++].pum_text = mp->dname; |
1151 | 1155 |
1152 pum_array = array; | 1156 pum_array = array; |
1153 pum_compute_size(); | 1157 pum_compute_size(); |
1154 pum_scrollbar = 0; | 1158 pum_scrollbar = 0; |
1230 # ifdef FEAT_BEVAL_TERM | 1234 # ifdef FEAT_BEVAL_TERM |
1231 p_bevalterm = save_bevalterm; | 1235 p_bevalterm = save_bevalterm; |
1232 mch_setmouse(TRUE); | 1236 mch_setmouse(TRUE); |
1233 # endif | 1237 # endif |
1234 } | 1238 } |
1239 | |
1240 void | |
1241 pum_make_popup(char_u *path_name, int use_mouse_pos) | |
1242 { | |
1243 vimmenu_T *menu; | |
1244 | |
1245 if (!use_mouse_pos) | |
1246 { | |
1247 /* Hack: set mouse position at the cursor so that the menu pops up | |
1248 * around there. */ | |
1249 mouse_row = curwin->w_winrow + curwin->w_wrow; | |
1250 mouse_col = curwin->w_wincol + curwin->w_wcol; | |
1251 } | |
1252 | |
1253 menu = gui_find_menu(path_name); | |
1254 if (menu != NULL) | |
1255 pum_show_popupmenu(menu); | |
1256 } | |
1235 # endif | 1257 # endif |
1236 | 1258 |
1237 #endif | 1259 #endif |