To: vim_dev@googlegroups.com Subject: Patch 8.0.1570 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1570 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. Files: src/ex_docmd.c, src/popupmnu.c, src/proto/popupmnu.pro, src/menu.c, src/proto/menu.pro *** ../vim-8.0.1569/src/ex_docmd.c 2018-03-04 20:14:08.244064367 +0100 --- src/ex_docmd.c 2018-03-05 20:33:27.651337765 +0100 *************** *** 204,210 **** #else # define ex_tearoff ex_ni #endif ! #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) static void ex_popup(exarg_T *eap); #else # define ex_popup ex_ni --- 204,211 ---- #else # define ex_tearoff ex_ni #endif ! #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ ! || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) static void ex_popup(exarg_T *eap); #else # define ex_popup ex_ni *************** *** 8741,8751 **** } #endif ! #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) static void ex_popup(exarg_T *eap) { ! gui_make_popup(eap->arg, eap->forceit); } #endif --- 8742,8762 ---- } #endif ! #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ ! || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) static void ex_popup(exarg_T *eap) { ! # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) ! if (gui.in_use) ! gui_make_popup(eap->arg, eap->forceit); ! # ifdef FEAT_TERM_POPUP_MENU ! else ! # endif ! # endif ! # ifdef FEAT_TERM_POPUP_MENU ! pum_make_popup(eap->arg, eap->forceit); ! # endif } #endif *** ../vim-8.0.1569/src/popupmnu.c 2018-03-03 18:59:11.612531627 +0100 --- src/popupmnu.c 2018-03-05 21:01:01.461275616 +0100 *************** *** 1132,1143 **** #ifdef FEAT_BEVAL_TERM int save_bevalterm = p_bevalterm; #endif pum_undisplay(); pum_size = 0; for (mp = menu->children; mp != NULL; mp = mp->next) ! ++pum_size; array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size); if (array == NULL) --- 1132,1147 ---- #ifdef FEAT_BEVAL_TERM int save_bevalterm = p_bevalterm; #endif + int mode; pum_undisplay(); pum_size = 0; + mode = get_menu_mode_flag(); for (mp = menu->children; mp != NULL; mp = mp->next) ! if (menu_is_separator(mp->dname) ! || (mp->modes & mp->enabled & mode)) ! ++pum_size; array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size); if (array == NULL) *************** *** 1146,1152 **** for (mp = menu->children; mp != NULL; mp = mp->next) if (menu_is_separator(mp->dname)) array[idx++].pum_text = (char_u *)""; ! else array[idx++].pum_text = mp->dname; pum_array = array; --- 1150,1156 ---- for (mp = menu->children; mp != NULL; mp = mp->next) if (menu_is_separator(mp->dname)) array[idx++].pum_text = (char_u *)""; ! else if (mp->modes & mp->enabled & mode) array[idx++].pum_text = mp->dname; pum_array = array; *************** *** 1232,1237 **** --- 1236,1259 ---- mch_setmouse(TRUE); # endif } + + void + pum_make_popup(char_u *path_name, int use_mouse_pos) + { + vimmenu_T *menu; + + 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; + } + + menu = gui_find_menu(path_name); + if (menu != NULL) + pum_show_popupmenu(menu); + } # endif #endif *** ../vim-8.0.1569/src/proto/popupmnu.pro 2018-03-03 18:59:11.612531627 +0100 --- src/proto/popupmnu.pro 2018-03-05 20:31:35.520024601 +0100 *************** *** 10,13 **** --- 10,14 ---- void ui_post_balloon(char_u *mesg, list_T *list); void ui_may_remove_balloon(void); void pum_show_popupmenu(vimmenu_T *menu); + void pum_make_popup(char_u *path_name, int mouse_pos); /* vim: set ft=c : */ *** ../vim-8.0.1569/src/menu.c 2018-03-04 18:07:04.260592398 +0100 --- src/menu.c 2018-03-05 21:06:04.967346391 +0100 *************** *** 1891,1896 **** --- 1891,1906 ---- return MENU_INDEX_INVALID; } + int + get_menu_mode_flag(void) + { + int mode = get_menu_mode(); + + if (mode == MENU_INDEX_INVALID) + return 0; + return 1 << mode; + } + /* * Display the Special "PopUp" menu as a pop-up at the current mouse * position. The "PopUpn" menu is for Normal mode, "PopUpi" for Insert mode, *************** *** 2044,2056 **** if (modes != 0x0) mode = modes; else ! { ! mode = get_menu_mode(); ! if (mode == MENU_INDEX_INVALID) ! mode = 0; ! else ! mode = (1 << mode); ! } if (force_menu_update || mode != prev_mode) { --- 2054,2060 ---- if (modes != 0x0) mode = modes; else ! mode = get_menu_mode_flag(); if (force_menu_update || mode != prev_mode) { *** ../vim-8.0.1569/src/proto/menu.pro 2018-03-03 18:59:11.616531601 +0100 --- src/proto/menu.pro 2018-03-05 20:52:27.192395127 +0100 *************** *** 12,17 **** --- 12,18 ---- int menu_is_child_of_popup(vimmenu_T *menu); int menu_is_toolbar(char_u *name); int menu_is_separator(char_u *name); + int get_menu_mode_flag(void); void show_popupmenu(void); int check_menu_pointer(vimmenu_T *root, vimmenu_T *menu_to_check); void gui_create_initial_menus(vimmenu_T *menu); *** ../vim-8.0.1569/src/version.c 2018-03-05 12:42:38.394154092 +0100 --- src/version.c 2018-03-05 20:31:25.976083094 +0100 *************** *** 768,769 **** --- 768,771 ---- { /* Add new patch number below this line */ + /**/ + 1570, /**/ -- ARTHUR: Old woman! DENNIS: Man! ARTHUR: Man. I'm sorry. Old man, What knight live in that castle over there? DENNIS: I'm thirty-seven. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///