/* vi:set ts=8 sts=4 sw=4 noet: * * VIM - Vi IMproved by Bram Moolenaar * * Do ":help uganda" in Vim to read copying and usage conditions. * Do ":help credits" in Vim to see a list of people who contributed. * See README.txt for an overview of the Vim source code. *//* * popupmnu.c: Popup menu (PUM) */#include"vim.h"#if defined(FEAT_INS_EXPAND) || defined(PROTO)staticpumitem_T*pum_array=NULL;/* items of displayed pum */staticintpum_size;/* nr of items in "pum_array" */staticintpum_selected;/* index of selected item or -1 */staticintpum_first=0;/* index of top item */staticintpum_height;/* nr of displayed pum items */staticintpum_width;/* width of displayed pum items */staticintpum_base_width;/* width of pum items base */staticintpum_kind_width;/* width of pum items kind column */staticintpum_extra_width;/* width of extra stuff */staticintpum_scrollbar;/* TRUE when scrollbar present */staticintpum_row;/* top row of pum */staticintpum_col;/* left column of pum */staticwin_T*pum_window=NULL;staticintpum_win_row;staticintpum_win_height;staticintpum_win_col;staticintpum_win_wcol;staticintpum_win_width;staticintpum_do_redraw=FALSE;/* do redraw anyway */staticintpum_set_selected(intn,intrepeat);#define PUM_DEF_HEIGHT 10#define PUM_DEF_WIDTH 15staticvoidpum_compute_size(void){inti;intw;/* Compute the width of the widest match and the widest extra. */pum_base_width=0;pum_kind_width=0;pum_extra_width=0;for(i=0;i<pum_size;++i){w=vim_strsize(pum_array[i].pum_text);if(pum_base_width<w)pum_base_width=w;if(pum_array[i].pum_kind!=NULL){w=vim_strsize(pum_array[i].pum_kind)+1;if(pum_kind_width<w)pum_kind_width=w;}if(pum_array[i].pum_extra!=NULL){w=vim_strsize(pum_array[i].pum_extra)+1;if(pum_extra_width<w)pum_extra_width=w;}}}/* * Show the popup menu with items "array[size]". * "array" must remain valid until pum_undisplay() is called! * When possible the leftmost character is aligned with cursor column. * The menu appears above the screen line "row" or at "row" + "height" - 1. */voidpum_display(pumitem_T