mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 19:06:31 +00:00
api: add width/height to FloatConfig
This commit is contained in:
@@ -1004,8 +1004,6 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err)
|
||||
///
|
||||
/// @param buffer handle of buffer to be displayed in the window
|
||||
/// @param enter whether the window should be entered (made the current window)
|
||||
/// @param width width of window (in character cells)
|
||||
/// @param height height of window (in character cells)
|
||||
/// @param options dict of options for configuring window positioning
|
||||
/// accepts the following keys:
|
||||
/// `relative`: If set, the window becomes a floating window. The window
|
||||
@@ -1023,6 +1021,8 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err)
|
||||
/// `focusable`: Whether window can be focused by wincmds and
|
||||
/// mouse events. Defaults to true. Even if set to false, the window
|
||||
/// can still be entered using |nvim_set_current_win()| API call.
|
||||
/// `height`: window height (in character cells). Cannot be smaller than 1.
|
||||
/// `width`: window width (in character cells). Cannot be smaller than 2.
|
||||
/// `row`: row position. Screen cell height are used as unit. Can be
|
||||
/// floating point.
|
||||
/// `col`: column position. Screen cell width is used as unit. Can be
|
||||
@@ -1047,16 +1047,15 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err)
|
||||
///
|
||||
/// @param[out] err Error details, if any
|
||||
/// @return the window handle or 0 when error
|
||||
Window nvim_open_win(Buffer buffer, Boolean enter,
|
||||
Integer width, Integer height,
|
||||
Dictionary options, Error *err)
|
||||
Window nvim_open_win(Buffer buffer, Boolean enter, Dictionary options,
|
||||
Error *err)
|
||||
FUNC_API_SINCE(6)
|
||||
{
|
||||
FloatConfig config = FLOAT_CONFIG_INIT;
|
||||
if (!parse_float_config(options, &config, false, err)) {
|
||||
return 0;
|
||||
}
|
||||
win_T *wp = win_new_float(NULL, (int)width, (int)height, config, err);
|
||||
win_T *wp = win_new_float(NULL, config, err);
|
||||
if (!wp) {
|
||||
return 0;
|
||||
}
|
||||
|
@@ -439,13 +439,12 @@ Boolean nvim_win_is_valid(Window window)
|
||||
/// types).
|
||||
///
|
||||
/// See documentation at |nvim_open_win()|, for the meaning of parameters. Pass
|
||||
/// in -1 for 'witdh' and 'height' to keep exiting size.
|
||||
/// in 0 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_set_config(Window window, Integer width, Integer height,
|
||||
Dictionary options, Error *err)
|
||||
void nvim_win_set_config(Window window, Dictionary options, Error *err)
|
||||
FUNC_API_SINCE(6)
|
||||
{
|
||||
win_T *win = find_window_by_handle(window, err);
|
||||
@@ -453,21 +452,21 @@ void nvim_win_set_config(Window window, Integer width, Integer height,
|
||||
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;
|
||||
}
|
||||
config.height = config.height > 0 ? config.height : win->w_height;
|
||||
config.width = config.width > 0 ? config.width : win->w_width;
|
||||
if (new_float) {
|
||||
if (!win_new_float(win, (int)width, (int)height, config, err)) {
|
||||
if (!win_new_float(win, config, err)) {
|
||||
return;
|
||||
}
|
||||
redraw_later(NOT_VALID);
|
||||
} else {
|
||||
win_config_float(win, (int)width, (int)height, config);
|
||||
win_config_float(win, config);
|
||||
win->w_pos_changed = true;
|
||||
}
|
||||
}
|
||||
@@ -490,8 +489,8 @@ Dictionary nvim_win_get_config(Window window, Error *err)
|
||||
return rv;
|
||||
}
|
||||
|
||||
PUT(rv, "height", INTEGER_OBJ(wp->w_height));
|
||||
PUT(rv, "width", INTEGER_OBJ(wp->w_width));
|
||||
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(
|
||||
|
Reference in New Issue
Block a user