diff options
author | erw7 <erw7.github@gmail.com> | 2019-07-12 12:47:20 +0900 |
---|---|---|
committer | erw7 <erw7.github@gmail.com> | 2019-09-08 12:25:49 +0900 |
commit | 55b1126a22394a3c6c212cc323d53de405cca98d (patch) | |
tree | b11ed6bb29cf229ce7f75a5e4cefc6c1615e6e03 /src/nvim/api/ui.c | |
parent | 3dbd94dafa25b6bd5a425b3a5b0c57ee196bde27 (diff) | |
download | rneovim-55b1126a22394a3c6c212cc323d53de405cca98d.tar.gz rneovim-55b1126a22394a3c6c212cc323d53de405cca98d.tar.bz2 rneovim-55b1126a22394a3c6c212cc323d53de405cca98d.zip |
Add nvim_ui_pum_set_height to api
Diffstat (limited to 'src/nvim/api/ui.c')
-rw-r--r-- | src/nvim/api/ui.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 7e45abb897..9ff2a529ae 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -109,6 +109,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, UI *ui = xcalloc(1, sizeof(UI)); ui->width = (int)width; ui->height = (int)height; + ui->pum_height = 0; ui->rgb = true; ui->override = false; ui->grid_resize = remote_ui_grid_resize; @@ -313,6 +314,38 @@ void nvim_ui_try_resize_grid(uint64_t channel_id, Integer grid, Integer width, ui_grid_resize((handle_T)grid, (int)width, (int)height, err); } +/// Tell Nvim the number of element displayed in popumenu. The amount of +/// movement by <PageUp> or <PageDown> is determined by the value set by this. +/// +/// If the ext_popupmenu option is false or the height is 0 or less, fails +/// with error. +/// +/// @param channel_id +/// @param height The popupmenu height. +/// @param[out] err Error details, if any +void nvim_ui_pum_set_height(uint64_t channel_id, Integer height, Error *err) + FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY +{ + if (!pmap_has(uint64_t)(connected_uis, channel_id)) { + api_set_error(err, kErrorTypeException, + "UI not attached to channel: %" PRId64, channel_id); + return; + } + + if (height <= 0) { + api_set_error(err, kErrorTypeValidation, "Expected pum height > 0"); + return; + } + + 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"); + return; + } + ui->pum_height = (int)height; +} + /// Pushes data into UI.UIData, to be consumed later by remote_ui_flush(). static void push_call(UI *ui, const char *name, Array args) { |