Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
16883:c7c1b4618acb | 16884:59e4148c0c73 |
---|---|
99 if (nr != -1) | 99 if (nr != -1) |
100 semsg(_(e_invarg2), str); | 100 semsg(_(e_invarg2), str); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 static void | |
105 get_padding_border(dict_T *dict, int *array, char *name, int max_val) | |
106 { | |
107 dictitem_T *di; | |
108 | |
109 vim_memset(array, 0, sizeof(int) * 4); | |
110 di = dict_find(dict, (char_u *)name, -1); | |
111 if (di != NULL) | |
112 { | |
113 if (di->di_tv.v_type != VAR_LIST) | |
114 emsg(_(e_listreq)); | |
115 else | |
116 { | |
117 list_T *list = di->di_tv.vval.v_list; | |
118 listitem_T *li; | |
119 int i; | |
120 int nr; | |
121 | |
122 for (i = 0; i < 4; ++i) | |
123 array[i] = 1; | |
124 if (list != NULL) | |
125 for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len; | |
126 ++i, li = li->li_next) | |
127 { | |
128 nr = (int)tv_get_number(&li->li_tv); | |
129 if (nr >= 0) | |
130 array[i] = nr > max_val ? max_val : nr; | |
131 } | |
132 } | |
133 } | |
134 } | |
135 | |
104 /* | 136 /* |
105 * Go through the options in "dict" and apply them to buffer "buf" displayed in | 137 * Go through the options in "dict" and apply them to buffer "buf" displayed in |
106 * popup window "wp". | 138 * popup window "wp". |
107 * When called from f_popup_atcursor() "atcursor" is TRUE. | 139 * When called from f_popup_atcursor() "atcursor" is TRUE. |
108 */ | 140 */ |
174 callback_T callback = get_callback(&di->di_tv); | 206 callback_T callback = get_callback(&di->di_tv); |
175 | 207 |
176 if (callback.cb_name != NULL) | 208 if (callback.cb_name != NULL) |
177 set_callback(&wp->w_filter_cb, &callback); | 209 set_callback(&wp->w_filter_cb, &callback); |
178 } | 210 } |
211 | |
212 get_padding_border(dict, wp->w_popup_padding, "padding", 999); | |
213 get_padding_border(dict, wp->w_popup_border, "border", 1); | |
179 } | 214 } |
180 | 215 |
181 /* | 216 /* |
182 * Add lines to the popup from a list of strings. | 217 * Add lines to the popup from a list of strings. |
183 */ | 218 */ |
698 f_popup_getpos(typval_T *argvars, typval_T *rettv) | 733 f_popup_getpos(typval_T *argvars, typval_T *rettv) |
699 { | 734 { |
700 dict_T *dict; | 735 dict_T *dict; |
701 int id = (int)tv_get_number(argvars); | 736 int id = (int)tv_get_number(argvars); |
702 win_T *wp = find_popup_win(id); | 737 win_T *wp = find_popup_win(id); |
738 int top_extra; | |
739 int left_extra; | |
703 | 740 |
704 if (rettv_dict_alloc(rettv) == OK) | 741 if (rettv_dict_alloc(rettv) == OK) |
705 { | 742 { |
706 if (wp == NULL) | 743 if (wp == NULL) |
707 return; // invalid {id} | 744 return; // invalid {id} |
745 top_extra = wp->w_popup_border[0] + wp->w_popup_padding[0]; | |
746 left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3]; | |
747 | |
708 dict = rettv->vval.v_dict; | 748 dict = rettv->vval.v_dict; |
749 | |
709 dict_add_number(dict, "line", wp->w_winrow + 1); | 750 dict_add_number(dict, "line", wp->w_winrow + 1); |
710 dict_add_number(dict, "col", wp->w_wincol + 1); | 751 dict_add_number(dict, "col", wp->w_wincol + 1); |
711 dict_add_number(dict, "width", wp->w_width); | 752 dict_add_number(dict, "width", wp->w_width + left_extra + wp->w_popup_border[1] + wp->w_popup_padding[1]); |
712 dict_add_number(dict, "height", wp->w_height); | 753 dict_add_number(dict, "height", wp->w_height + top_extra + wp->w_popup_border[2] + wp->w_popup_padding[2]); |
754 | |
755 dict_add_number(dict, "core_line", wp->w_winrow + 1 + top_extra); | |
756 dict_add_number(dict, "core_col", wp->w_wincol + 1 + left_extra); | |
757 dict_add_number(dict, "core_width", wp->w_width); | |
758 dict_add_number(dict, "core_height", wp->w_height); | |
759 | |
713 dict_add_number(dict, "visible", | 760 dict_add_number(dict, "visible", |
714 (wp->w_popup_flags & POPF_HIDDEN) == 0); | 761 (wp->w_popup_flags & POPF_HIDDEN) == 0); |
715 } | 762 } |
716 } | 763 } |
717 | 764 |