diff options
Diffstat (limited to 'src/nvim/api')
-rw-r--r-- | src/nvim/api/private/defs.h | 3 | ||||
-rw-r--r-- | src/nvim/api/ui.c | 24 | ||||
-rw-r--r-- | src/nvim/api/ui_events.in.h | 15 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 10 |
4 files changed, 43 insertions, 9 deletions
diff --git a/src/nvim/api/private/defs.h b/src/nvim/api/private/defs.h index 390b7e8363..feca140547 100644 --- a/src/nvim/api/private/defs.h +++ b/src/nvim/api/private/defs.h @@ -6,6 +6,7 @@ #include <string.h> #include "nvim/func_attr.h" +#include "nvim/types.h" #define ARRAY_DICT_INIT {.size = 0, .capacity = 0, .items = NULL} #define STRING_INIT {.data = NULL, .size = 0} @@ -20,8 +21,6 @@ # define DictionaryOf(...) Dictionary #endif -typedef int handle_T; - // Basic types typedef enum { kErrorTypeNone = -1, diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 01f8c9f71c..7ba5251c60 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -126,7 +126,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, } } - if (ui->ui_ext[kUIHlState]) { + if (ui->ui_ext[kUIHlState] || ui->ui_ext[kUIMultigrid]) { ui->ui_ext[kUILinegrid] = true; } @@ -245,6 +245,28 @@ static void ui_set_option(UI *ui, bool init, String name, Object value, name.data); } +/// Tell nvim to resize a grid. Nvim sends grid_resize event with the +/// requested grid size is within size limits and with maximum allowed size +/// otherwise. +/// +/// On invalid grid handle, fails with error. +/// +/// @param grid The handle of the grid to be changed. +/// @param width The new requested width. +/// @param height The new requested height. +void nvim_ui_try_resize_grid(uint64_t channel_id, Integer grid, Integer width, + Integer height, Error *error) + FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY +{ + if (!pmap_has(uint64_t)(connected_uis, channel_id)) { + api_set_error(error, kErrorTypeException, + "UI not attached to channel: %" PRId64, channel_id); + return; + } + + ui_grid_resize((handle_T)grid, (int)width, (int)height, error); +} + /// Pushes data into UI.UIData, to be consumed later by remote_ui_flush(). static void push_call(UI *ui, const char *name, Array args) { diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 10331fd5c2..59a7780651 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -81,8 +81,21 @@ void grid_line(Integer grid, Integer row, Integer col_start, Array data) void grid_scroll(Integer grid, Integer top, Integer bot, Integer left, Integer right, Integer rows, Integer cols) FUNC_API_SINCE(5) FUNC_API_REMOTE_IMPL; +void grid_destroy(Integer grid) + FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; -void popupmenu_show(Array items, Integer selected, Integer row, Integer col) +void win_pos(Integer grid, Integer win, Integer startrow, + Integer startcol, Integer width, Integer height) + FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; +void win_hide(Integer grid) + FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; +void win_scroll_over_start(void) + FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; +void win_scroll_over_reset(void) + FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; + +void popupmenu_show(Array items, Integer selected, + Integer row, Integer col, Integer grid) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void popupmenu_hide(void) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index ecfff1ea8f..2a724a85ec 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1920,13 +1920,13 @@ Object nvim_get_proc(Integer pid, Error *err) Array nvim__inspect_cell(Integer row, Integer col, Error *err) { Array ret = ARRAY_DICT_INIT; - if (row < 0 || row >= screen_Rows - || col < 0 || col >= screen_Columns) { + if (row < 0 || row >= default_grid.Rows + || col < 0 || col >= default_grid.Columns) { return ret; } - size_t off = LineOffset[(size_t)row] + (size_t)col; - ADD(ret, STRING_OBJ(cstr_to_string((char *)ScreenLines[off]))); - int attr = ScreenAttrs[off]; + size_t off = default_grid.line_offset[(size_t)row] + (size_t)col; + ADD(ret, STRING_OBJ(cstr_to_string((char *)default_grid.chars[off]))); + int attr = default_grid.attrs[off]; ADD(ret, DICTIONARY_OBJ(hl_get_attr_by_id(attr, true, err))); // will not work first time if (!highlight_use_hlstate()) { |