mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
ui_pum_get_pos: return internal pum position if external pum pos not found
This commit is contained in:
parent
630ec6cfb8
commit
9c85caa390
@ -2352,10 +2352,10 @@ nvim_ui_pum_set_bounds({width}, {height}, {row}, {col})
|
||||
including visual decorations such as boarders and sliders.
|
||||
|
||||
Parameters: ~
|
||||
{width} Popupmenu width, must be greater than zero.
|
||||
{height} Popupmenu height, must be greater than zero.
|
||||
{row} Popupmenu row, must be greater or equal to zero.
|
||||
{height} Popupmenu height, must be greater or equal to zero.
|
||||
{width} Popupmenu width.
|
||||
{height} Popupmenu height.
|
||||
{row} Popupmenu row.
|
||||
{height} Popupmenu height.
|
||||
|
||||
nvim_ui_set_option({name}, {value}) *nvim_ui_set_option()*
|
||||
TODO: Documentation
|
||||
|
@ -357,11 +357,11 @@ void nvim_ui_pum_set_height(uint64_t channel_id, Integer height, Error *err)
|
||||
/// including visual decorations such as boarders and sliders.
|
||||
///
|
||||
/// @param channel_id
|
||||
/// @param width Popupmenu width, must be greater than zero.
|
||||
/// @param height Popupmenu height, must be greater than zero.
|
||||
/// @param row Popupmenu row, must be greater or equal to zero.
|
||||
/// @param col Popupmenu height, must be greater or equal to zero.
|
||||
/// @param[out] err Error details, if any. On error, suspend pum position reporting for the current UI.
|
||||
/// @param width Popupmenu width.
|
||||
/// @param height Popupmenu height.
|
||||
/// @param row Popupmenu row.
|
||||
/// @param col Popupmenu height.
|
||||
/// @param[out] err Error details, if any.
|
||||
void nvim_ui_pum_set_bounds(uint64_t channel_id, Integer width, Integer height,
|
||||
Integer row, Integer col, Error *err)
|
||||
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY
|
||||
@ -375,31 +375,21 @@ void nvim_ui_pum_set_bounds(uint64_t channel_id, Integer width, Integer height,
|
||||
UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
|
||||
if (!ui->ui_ext[kUIPopupmenu]) {
|
||||
api_set_error(err, kErrorTypeValidation,
|
||||
"It must support the ext_popupmenu option");
|
||||
"UI must support the ext_popupmenu option");
|
||||
return;
|
||||
}
|
||||
|
||||
if (row < 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Expected pumpos row >= 0");
|
||||
ui->pum_pos = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (col < 0) {
|
||||
} else if (col < 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Expected pumpos col >= 0");
|
||||
ui->pum_pos = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (width <= 0) {
|
||||
} else if (width <= 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Expected pumpos width > 0");
|
||||
ui->pum_pos = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (height <= 0) {
|
||||
} else if (height <= 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Expected pumpos height > 0");
|
||||
ui->pum_pos = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -902,6 +902,18 @@ int pum_get_height(void)
|
||||
return pum_height;
|
||||
}
|
||||
|
||||
/// Gets the internal pum geometry.
|
||||
///
|
||||
/// @return the internal pum geometry. Ignores UI external pum geometry.
|
||||
/// Only valid when pum_visible() returns TRUE!
|
||||
void pum_get_internal_pos(int* pwidth, int* pheight, int* prow, int* pcol)
|
||||
{
|
||||
*pwidth = pum_width;
|
||||
*pheight = pum_height;
|
||||
*prow = pum_row;
|
||||
*pcol = pum_col;
|
||||
}
|
||||
|
||||
/// Add size information about the pum to "dict".
|
||||
void pum_set_event_info(dict_T *dict)
|
||||
{
|
||||
@ -909,17 +921,11 @@ void pum_set_event_info(dict_T *dict)
|
||||
return;
|
||||
}
|
||||
int w,h,r,c;
|
||||
if (!ui_pum_get_pos(&w, &h, &r, &c)){
|
||||
tv_dict_add_nr(dict, S_LEN("height"), pum_height);
|
||||
tv_dict_add_nr(dict, S_LEN("width"), pum_width);
|
||||
tv_dict_add_nr(dict, S_LEN("row"), pum_row);
|
||||
tv_dict_add_nr(dict, S_LEN("col"), pum_col);
|
||||
} else {
|
||||
tv_dict_add_nr(dict, S_LEN("height"), h);
|
||||
tv_dict_add_nr(dict, S_LEN("width"), w);
|
||||
tv_dict_add_nr(dict, S_LEN("row"), r);
|
||||
tv_dict_add_nr(dict, S_LEN("col"), c);
|
||||
}
|
||||
ui_pum_get_pos(&w, &h, &r, &c);
|
||||
tv_dict_add_nr(dict, S_LEN("height"), h);
|
||||
tv_dict_add_nr(dict, S_LEN("width"), w);
|
||||
tv_dict_add_nr(dict, S_LEN("row"), r);
|
||||
tv_dict_add_nr(dict, S_LEN("col"), c);
|
||||
tv_dict_add_nr(dict, S_LEN("size"), pum_size);
|
||||
tv_dict_add_special(dict, S_LEN("scrollbar"),
|
||||
pum_scrollbar ? kSpecialVarTrue : kSpecialVarFalse);
|
||||
|
@ -226,7 +226,7 @@ int ui_pum_get_height(void)
|
||||
{
|
||||
int pum_height = 0;
|
||||
for (size_t i = 1; i < ui_count; i++) {
|
||||
int ui_pum_height = uis[i]->pum_height;
|
||||
int ui_pum_height = uis[i]->pum_nlines;
|
||||
if (ui_pum_height) {
|
||||
pum_height =
|
||||
pum_height != 0 ? MIN(pum_height, ui_pum_height) : ui_pum_height;
|
||||
@ -235,7 +235,7 @@ int ui_pum_get_height(void)
|
||||
return pum_height;
|
||||
}
|
||||
|
||||
bool ui_pum_get_pos(int* pwidth, int *pheight, int* prow, int* pcol)
|
||||
void ui_pum_get_pos(int* pwidth, int *pheight, int* prow, int* pcol)
|
||||
{
|
||||
int w=0,h=0,r=-1,c=-1;
|
||||
bool found = false;
|
||||
@ -254,11 +254,14 @@ bool ui_pum_get_pos(int* pwidth, int *pheight, int* prow, int* pcol)
|
||||
c = MIN(uis[i]->pum_col, c);
|
||||
}
|
||||
}
|
||||
*pwidth = w;
|
||||
*pheight = h;
|
||||
*prow = r;
|
||||
*pcol = c;
|
||||
return found;
|
||||
if (found) {
|
||||
*pwidth = w;
|
||||
*pheight = h;
|
||||
*prow = r;
|
||||
*pcol = c;
|
||||
} else {
|
||||
pum_get_internal_pos(pwidth, pheight, prow, pcol);
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_refresh_event(void **argv)
|
||||
|
Loading…
Reference in New Issue
Block a user