Mercurial > vim
diff src/popupwin.c @ 16884:59e4148c0c73 v8.1.1443
patch 8.1.1443: popup window padding and border not implemented yet
commit https://github.com/vim/vim/commit/2fd8e35e16e502c98045c4b4e09a91eca840fb97
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 1 20:16:48 2019 +0200
patch 8.1.1443: popup window padding and border not implemented yet
Problem: Popup window padding and border not implemented yet.
Solution: Implement padding and border. Add core position and size to
popup_getpos().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Jun 2019 20:30:05 +0200 |
parents | 998603a243d7 |
children | ec61b6b79865 |
line wrap: on
line diff
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -101,6 +101,38 @@ get_pos_options(win_T *wp, dict_T *dict) } } + static void +get_padding_border(dict_T *dict, int *array, char *name, int max_val) +{ + dictitem_T *di; + + vim_memset(array, 0, sizeof(int) * 4); + di = dict_find(dict, (char_u *)name, -1); + if (di != NULL) + { + if (di->di_tv.v_type != VAR_LIST) + emsg(_(e_listreq)); + else + { + list_T *list = di->di_tv.vval.v_list; + listitem_T *li; + int i; + int nr; + + for (i = 0; i < 4; ++i) + array[i] = 1; + if (list != NULL) + for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len; + ++i, li = li->li_next) + { + nr = (int)tv_get_number(&li->li_tv); + if (nr >= 0) + array[i] = nr > max_val ? max_val : nr; + } + } + } +} + /* * Go through the options in "dict" and apply them to buffer "buf" displayed in * popup window "wp". @@ -176,6 +208,9 @@ apply_options(win_T *wp, buf_T *buf UNUS if (callback.cb_name != NULL) set_callback(&wp->w_filter_cb, &callback); } + + get_padding_border(dict, wp->w_popup_padding, "padding", 999); + get_padding_border(dict, wp->w_popup_border, "border", 1); } /* @@ -700,16 +735,28 @@ f_popup_getpos(typval_T *argvars, typval dict_T *dict; int id = (int)tv_get_number(argvars); win_T *wp = find_popup_win(id); + int top_extra; + int left_extra; if (rettv_dict_alloc(rettv) == OK) { if (wp == NULL) return; // invalid {id} + top_extra = wp->w_popup_border[0] + wp->w_popup_padding[0]; + left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3]; + dict = rettv->vval.v_dict; + dict_add_number(dict, "line", wp->w_winrow + 1); dict_add_number(dict, "col", wp->w_wincol + 1); - dict_add_number(dict, "width", wp->w_width); - dict_add_number(dict, "height", wp->w_height); + dict_add_number(dict, "width", wp->w_width + left_extra + wp->w_popup_border[1] + wp->w_popup_padding[1]); + dict_add_number(dict, "height", wp->w_height + top_extra + wp->w_popup_border[2] + wp->w_popup_padding[2]); + + dict_add_number(dict, "core_line", wp->w_winrow + 1 + top_extra); + dict_add_number(dict, "core_col", wp->w_wincol + 1 + left_extra); + dict_add_number(dict, "core_width", wp->w_width); + dict_add_number(dict, "core_height", wp->w_height); + dict_add_number(dict, "visible", (wp->w_popup_flags & POPF_HIDDEN) == 0); }