mirror of
https://github.com/neovim/neovim
synced 2025-07-17 17:51:48 +00:00
fix(float): add fixd option
This commit is contained in:
@ -3172,6 +3172,8 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
|
|||||||
• noautocmd: If true then no buffer-related autocommand
|
• noautocmd: If true then no buffer-related autocommand
|
||||||
events such as |BufEnter|, |BufLeave| or |BufWinEnter| may
|
events such as |BufEnter|, |BufLeave| or |BufWinEnter| may
|
||||||
fire from calling this function.
|
fire from calling this function.
|
||||||
|
• fixed: If true when anchor is NW or SW, the float window
|
||||||
|
would be kept fixed even if the window would be truncated.
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
Window handle, or 0 on error
|
Window handle, or 0 on error
|
||||||
|
2
runtime/lua/vim/_meta/api.lua
generated
2
runtime/lua/vim/_meta/api.lua
generated
@ -1585,6 +1585,8 @@ function vim.api.nvim_open_term(buffer, opts) end
|
|||||||
--- • noautocmd: If true then no buffer-related autocommand
|
--- • noautocmd: If true then no buffer-related autocommand
|
||||||
--- events such as `BufEnter`, `BufLeave` or `BufWinEnter` may
|
--- events such as `BufEnter`, `BufLeave` or `BufWinEnter` may
|
||||||
--- fire from calling this function.
|
--- fire from calling this function.
|
||||||
|
--- • fixed: If true when anchor is NW or SW, the float window
|
||||||
|
--- would be kept fixed even if the window would be truncated.
|
||||||
--- @return integer
|
--- @return integer
|
||||||
function vim.api.nvim_open_win(buffer, enter, config) end
|
function vim.api.nvim_open_win(buffer, enter, config) end
|
||||||
|
|
||||||
|
1
runtime/lua/vim/_meta/api_keysets.lua
generated
1
runtime/lua/vim/_meta/api_keysets.lua
generated
@ -112,6 +112,7 @@ error('Cannot require a meta file')
|
|||||||
--- @field footer_pos? string
|
--- @field footer_pos? string
|
||||||
--- @field style? string
|
--- @field style? string
|
||||||
--- @field noautocmd? boolean
|
--- @field noautocmd? boolean
|
||||||
|
--- @field fixed? boolean
|
||||||
|
|
||||||
--- @class vim.api.keyset.get_autocmds
|
--- @class vim.api.keyset.get_autocmds
|
||||||
--- @field event? any
|
--- @field event? any
|
||||||
|
@ -112,6 +112,7 @@ typedef struct {
|
|||||||
String footer_pos;
|
String footer_pos;
|
||||||
String style;
|
String style;
|
||||||
Boolean noautocmd;
|
Boolean noautocmd;
|
||||||
|
Boolean fixed;
|
||||||
} Dict(float_config);
|
} Dict(float_config);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -160,6 +160,8 @@
|
|||||||
/// - noautocmd: If true then no buffer-related autocommand events such as
|
/// - noautocmd: If true then no buffer-related autocommand events such as
|
||||||
/// |BufEnter|, |BufLeave| or |BufWinEnter| may fire from
|
/// |BufEnter|, |BufLeave| or |BufWinEnter| may fire from
|
||||||
/// calling this function.
|
/// calling this function.
|
||||||
|
/// - fixed: If true when anchor is NW or SW, the float window
|
||||||
|
/// would be kept fixed even if the window would be truncated.
|
||||||
///
|
///
|
||||||
/// @param[out] err Error details, if any
|
/// @param[out] err Error details, if any
|
||||||
///
|
///
|
||||||
@ -841,6 +843,10 @@ static bool parse_float_config(Dict(float_config) *config, FloatConfig *fconfig,
|
|||||||
fconfig->noautocmd = config->noautocmd;
|
fconfig->noautocmd = config->noautocmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (HAS_KEY_X(config, fixed)) {
|
||||||
|
fconfig->fixed = config->fixed;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#undef HAS_KEY_X
|
#undef HAS_KEY_X
|
||||||
}
|
}
|
||||||
|
@ -966,6 +966,7 @@ typedef struct {
|
|||||||
VirtText footer_chunks;
|
VirtText footer_chunks;
|
||||||
int footer_width;
|
int footer_width;
|
||||||
bool noautocmd;
|
bool noautocmd;
|
||||||
|
bool fixed;
|
||||||
} FloatConfig;
|
} FloatConfig;
|
||||||
|
|
||||||
#define FLOAT_CONFIG_INIT ((FloatConfig){ .height = 0, .width = 0, \
|
#define FLOAT_CONFIG_INIT ((FloatConfig){ .height = 0, .width = 0, \
|
||||||
@ -975,7 +976,8 @@ typedef struct {
|
|||||||
.focusable = true, \
|
.focusable = true, \
|
||||||
.zindex = kZIndexFloatDefault, \
|
.zindex = kZIndexFloatDefault, \
|
||||||
.style = kWinStyleUnused, \
|
.style = kWinStyleUnused, \
|
||||||
.noautocmd = false })
|
.noautocmd = false, \
|
||||||
|
.fixed = false })
|
||||||
|
|
||||||
// Structure to store last cursor position and topline. Used by check_lnums()
|
// Structure to store last cursor position and topline. Used by check_lnums()
|
||||||
// and reset_lnums().
|
// and reset_lnums().
|
||||||
|
@ -1010,6 +1010,10 @@ void ui_ext_win_position(win_T *wp, bool validate)
|
|||||||
comp_col += grid->comp_col;
|
comp_col += grid->comp_col;
|
||||||
comp_row = MAX(MIN(comp_row, Rows - wp->w_height_outer - (p_ch > 0 ? 1 : 0)), 0);
|
comp_row = MAX(MIN(comp_row, Rows - wp->w_height_outer - (p_ch > 0 ? 1 : 0)), 0);
|
||||||
comp_col = MAX(MIN(comp_col, Columns - wp->w_width_outer), 0);
|
comp_col = MAX(MIN(comp_col, Columns - wp->w_width_outer), 0);
|
||||||
|
int right_extra = Columns - (int)c.col - wp->w_width - (c.border_chars[2][0] != 0);
|
||||||
|
if (!(c.anchor & kFloatAnchorEast) && c.fixed && right_extra < 0) {
|
||||||
|
comp_col = (int)c.col;
|
||||||
|
}
|
||||||
wp->w_winrow = comp_row;
|
wp->w_winrow = comp_row;
|
||||||
wp->w_wincol = comp_col;
|
wp->w_wincol = comp_col;
|
||||||
ui_comp_put_grid(&wp->w_grid_alloc, comp_row, comp_col,
|
ui_comp_put_grid(&wp->w_grid_alloc, comp_row, comp_col,
|
||||||
|
@ -899,6 +899,89 @@ describe('float window', function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('window position fixed', function()
|
||||||
|
local buf = meths.create_buf(false,false)
|
||||||
|
command("set nowrap")
|
||||||
|
local win = meths.open_win(buf, false, {
|
||||||
|
relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = true})
|
||||||
|
local expected_pos = {
|
||||||
|
[4]={{id=1001}, 'NW', 1, 2, 30, true},
|
||||||
|
}
|
||||||
|
|
||||||
|
if multigrid then
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[3:----------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
## grid 4
|
||||||
|
{1: }|
|
||||||
|
{2:~ }|
|
||||||
|
]], float_pos=expected_pos}
|
||||||
|
else
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }{1: }|
|
||||||
|
{0:~ }{2:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end
|
||||||
|
|
||||||
|
meths.win_set_config(win, {
|
||||||
|
relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = false})
|
||||||
|
|
||||||
|
if multigrid then
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[3:----------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
## grid 4
|
||||||
|
{1: }|
|
||||||
|
{2:~ }|
|
||||||
|
]], float_pos=expected_pos}
|
||||||
|
else
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }{1: }|
|
||||||
|
{0:~ }{2:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
it('draws correctly with redrawdebug=compositor', function()
|
it('draws correctly with redrawdebug=compositor', function()
|
||||||
-- NB: we do not test that it produces the "correct" debug info
|
-- NB: we do not test that it produces the "correct" debug info
|
||||||
-- (as it is intermediate only, and is allowed to change by internal
|
-- (as it is intermediate only, and is allowed to change by internal
|
||||||
|
Reference in New Issue
Block a user