aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/window.c
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2019-03-15 18:23:37 +0100
committerMarco Hinz <mh.codebro@gmail.com>2019-03-16 12:35:52 +0100
commitcfed9a4123afe3184c3914b6123869f2a52be250 (patch)
tree335d01f8134c5ee8ab2c465aed3d7586c40cc2f2 /src/nvim/api/window.c
parent175398f21645552b708a7626309b826ae0f3d8a8 (diff)
downloadrneovim-cfed9a4123afe3184c3914b6123869f2a52be250.tar.gz
rneovim-cfed9a4123afe3184c3914b6123869f2a52be250.tar.bz2
rneovim-cfed9a4123afe3184c3914b6123869f2a52be250.zip
api: add nvim_win_get_config()
Diffstat (limited to 'src/nvim/api/window.c')
-rw-r--r--src/nvim/api/window.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index 157f73c9fa..8a03d7acef 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -472,6 +472,61 @@ void nvim_win_config(Window window, Integer width, Integer height,
}
}
+/// Return window configuration.
+///
+/// Return a dictionary containing the same options that can be given to
+/// |nvim_open_win()|.
+///
+/// @param window Window handle
+/// @param[out] err Error details, if any
+/// @return Window configuration
+Dictionary nvim_win_get_config(Window window, Error *err)
+ FUNC_API_SINCE(6)
+{
+ Dictionary rv = ARRAY_DICT_INIT;
+
+ win_T *wp = find_window_by_handle(window, err);
+ if (!wp) {
+ return rv;
+ }
+
+ PUT(rv, "height", INTEGER_OBJ(wp->w_height));
+ PUT(rv, "width", INTEGER_OBJ(wp->w_width));
+ 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;
+ }
+
+ PUT(rv, "row", FLOAT_OBJ(wp->w_float_config.row));
+ PUT(rv, "col", FLOAT_OBJ(wp->w_float_config.col));
+
+ if (wp->w_floating) {
+ switch (wp->w_float_config.relative) {
+ case kFloatRelativeEditor:
+ PUT(rv, "relative", STRING_OBJ(cstr_to_string("editor")));
+ break;
+ case kFloatRelativeWindow:
+ PUT(rv, "relative", STRING_OBJ(cstr_to_string("win")));
+ break;
+ case kFloatRelativeCursor:
+ PUT(rv, "relative", STRING_OBJ(cstr_to_string("cursor")));
+ break;
+ }
+ } else {
+ PUT(rv, "relative", STRING_OBJ(cstr_to_string("")));
+ }
+
+ return rv;
+}
+
/// Close a window.
///
/// This is equivalent to |:close| with count except that it takes a window id.