aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/window.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-04-13 14:25:15 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2019-04-14 10:12:09 +0200
commitc8acbe3b623a4d7636e88b30f779c03845cf548f (patch)
tree7e8698c31b6e4988a10eb4fb4160ee9339b4c206 /src/nvim/api/window.c
parentd08692a8246039b938b5645a6c01b4ff7f51671e (diff)
downloadrneovim-c8acbe3b623a4d7636e88b30f779c03845cf548f.tar.gz
rneovim-c8acbe3b623a4d7636e88b30f779c03845cf548f.tar.bz2
rneovim-c8acbe3b623a4d7636e88b30f779c03845cf548f.zip
windows: float config changes
- Allow floating windows of width 1. #9846 - For a new floating window the size must be specified. Later on we might try to calculate a reasonable size by buffer contents - Remember the configured size of a window, just like its position. - Make get_config and set_config more consistent. Handle relative='' properly in set_config. get_config doesn't return keys that don't make sense for a non-floating window. - Don't use width=0 for non-changed width, just omit the key.
Diffstat (limited to 'src/nvim/api/window.c')
-rw-r--r--src/nvim/api/window.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index 01cb9a6847..e1c50cb89d 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -466,8 +466,6 @@ void nvim_win_set_config(Window window, Dictionary config, Error *err)
if (!parse_float_config(config, &fconfig, !new_float, err)) {
return;
}
- fconfig.height = fconfig.height > 0 ? fconfig.height : win->w_height;
- fconfig.width = fconfig.width > 0 ? fconfig.width : win->w_width;
if (new_float) {
if (!win_new_float(win, fconfig, err)) {
return;
@@ -499,26 +497,25 @@ Dictionary nvim_win_get_config(Window window, Error *err)
return rv;
}
- PUT(rv, "width", INTEGER_OBJ(wp->w_float_config.width));
- PUT(rv, "height", INTEGER_OBJ(wp->w_float_config.height));
PUT(rv, "focusable", BOOLEAN_OBJ(wp->w_float_config.focusable));
PUT(rv, "external", BOOLEAN_OBJ(wp->w_float_config.external));
- PUT(rv, "anchor", STRING_OBJ(cstr_to_string(
- float_anchor_str[wp->w_float_config.anchor])));
- if (wp->w_float_config.relative == kFloatRelativeWindow) {
- PUT(rv, "win", INTEGER_OBJ(wp->w_float_config.window));
- }
-
- if (wp->w_float_config.external) {
- return rv;
+ if (wp->w_floating) {
+ PUT(rv, "width", INTEGER_OBJ(wp->w_float_config.width));
+ PUT(rv, "height", INTEGER_OBJ(wp->w_float_config.height));
+ if (!wp->w_float_config.external) {
+ if (wp->w_float_config.relative == kFloatRelativeWindow) {
+ PUT(rv, "win", INTEGER_OBJ(wp->w_float_config.window));
+ }
+ PUT(rv, "anchor", STRING_OBJ(cstr_to_string(
+ float_anchor_str[wp->w_float_config.anchor])));
+ PUT(rv, "row", FLOAT_OBJ(wp->w_float_config.row));
+ PUT(rv, "col", FLOAT_OBJ(wp->w_float_config.col));
+ }
}
- PUT(rv, "row", FLOAT_OBJ(wp->w_float_config.row));
- PUT(rv, "col", FLOAT_OBJ(wp->w_float_config.col));
-
- const char *rel =
- wp->w_floating ? float_relative_str[wp->w_float_config.relative] : "";
+ const char *rel = (wp->w_floating && !wp->w_float_config.external
+ ? float_relative_str[wp->w_float_config.relative] : "");
PUT(rv, "relative", STRING_OBJ(cstr_to_string(rel)));
return rv;