diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-03-02 17:26:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-02 17:26:50 +0100 |
commit | 7a6da502b9d8deecfc89d1497a8e8da15e65f31e (patch) | |
tree | e3811b52dd00e67175383f11f1b67b42acc88f4c /src/nvim/api/window.c | |
parent | 0aba4d825a5b18c5fa937c0426788f61f756e086 (diff) | |
parent | 9a1675b065394734ddaef91a314896028e2b1d46 (diff) | |
download | rneovim-7a6da502b9d8deecfc89d1497a8e8da15e65f31e.tar.gz rneovim-7a6da502b9d8deecfc89d1497a8e8da15e65f31e.tar.bz2 rneovim-7a6da502b9d8deecfc89d1497a8e8da15e65f31e.zip |
Merge pull request #6619 from bfredl/floating
Floating windows in TUI and Remote UI
Diffstat (limited to 'src/nvim/api/window.c')
-rw-r--r-- | src/nvim/api/window.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 33857f95b7..e1d84cfc9e 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -432,3 +432,41 @@ Boolean nvim_win_is_valid(Window window) return ret; } + +/// Configure window position. Currently this is only used to configure +/// floating and external windows (including changing a split window to these +/// types). +/// +/// See documentation at |nvim_open_win()|, for the meaning of parameters. Pass +/// in -1 for 'witdh' and 'height' to keep exiting size. +/// +/// When reconfiguring a floating window, absent option keys will not be +/// changed. The following restriction apply: `row`, `col` and `relative` +/// must be reconfigured together. Only changing a subset of these is an error. +void nvim_win_config(Window window, Integer width, Integer height, + Dictionary options, Error *err) + FUNC_API_SINCE(6) +{ + win_T *win = find_window_by_handle(window, err); + if (!win) { + return; + } + bool new_float = !win->w_floating; + width = width > 0 ? width: win->w_width; + height = height > 0 ? height : win->w_height; + // reuse old values, if not overriden + FloatConfig config = new_float ? FLOAT_CONFIG_INIT : win->w_float_config; + + if (!parse_float_config(options, &config, !new_float, err)) { + return; + } + if (new_float) { + if (!win_new_float(win, (int)width, (int)height, config, err)) { + return; + } + redraw_later(NOT_VALID); + } else { + win_config_float(win, (int)width, (int)height, config); + win->w_pos_changed = true; + } +} |