mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
feat(float): implement footer
Problem: Now way to show text at the bottom part of floating window border (a.k.a. "footer"). Solution: Allows `footer` and `footer_pos` config fields similar to `title` and `title_pos`.
This commit is contained in:
@@ -1851,6 +1851,39 @@ describe('float window', function()
|
||||
eq('center', title_pos)
|
||||
end)
|
||||
|
||||
it('validates footer footer_pos', function()
|
||||
local buf = meths.create_buf(false,false)
|
||||
eq("footer requires border to be set",
|
||||
pcall_err(meths.open_win,buf, false, {
|
||||
relative='editor', width=9, height=2, row=2, col=5, footer='Footer',
|
||||
}))
|
||||
eq("footer_pos requires footer to be set",
|
||||
pcall_err(meths.open_win,buf, false, {
|
||||
relative='editor', width=9, height=2, row=2, col=5,
|
||||
border='single', footer_pos='left',
|
||||
}))
|
||||
end)
|
||||
|
||||
it('validate footer_pos in nvim_win_get_config', function()
|
||||
local footer_pos = exec_lua([[
|
||||
local bufnr = vim.api.nvim_create_buf(false, false)
|
||||
local opts = {
|
||||
relative = 'editor',
|
||||
col = 2,
|
||||
row = 5,
|
||||
height = 2,
|
||||
width = 9,
|
||||
border = 'double',
|
||||
footer = 'Test',
|
||||
footer_pos = 'center'
|
||||
}
|
||||
|
||||
local win_id = vim.api.nvim_open_win(bufnr, true, opts)
|
||||
return vim.api.nvim_win_get_config(win_id).footer_pos
|
||||
]])
|
||||
|
||||
eq('center', footer_pos)
|
||||
end)
|
||||
|
||||
it('border with title', function()
|
||||
local buf = meths.create_buf(false, false)
|
||||
@@ -2033,6 +2066,368 @@ describe('float window', function()
|
||||
end
|
||||
end)
|
||||
|
||||
it('border with footer', function()
|
||||
local buf = meths.create_buf(false, false)
|
||||
meths.buf_set_lines(buf, 0, -1, true, {' halloj! ',
|
||||
' BORDAA '})
|
||||
local win = meths.open_win(buf, false, {
|
||||
relative='editor', width=9, height=2, row=2, col=5, border="double",
|
||||
footer = "Left",footer_pos = "left",
|
||||
})
|
||||
|
||||
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
|
||||
{5:╔═════════╗}|
|
||||
{5:║}{1: halloj! }{5:║}|
|
||||
{5:║}{1: BORDAA }{5:║}|
|
||||
{5:╚}{11:Left}{5:═════╝}|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true }
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{5:╔═════════╗}{0: }|
|
||||
{0:~ }{5:║}{1: halloj! }{5:║}{0: }|
|
||||
{0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
|
||||
{0:~ }{5:╚}{11:Left}{5:═════╝}{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
|
||||
meths.win_set_config(win, {footer= "Center",footer_pos="center"})
|
||||
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
|
||||
{5:╔═════════╗}|
|
||||
{5:║}{1: halloj! }{5:║}|
|
||||
{5:║}{1: BORDAA }{5:║}|
|
||||
{5:╚═}{11:Center}{5:══╝}|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true }
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{5:╔═════════╗}{0: }|
|
||||
{0:~ }{5:║}{1: halloj! }{5:║}{0: }|
|
||||
{0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
|
||||
{0:~ }{5:╚═}{11:Center}{5:══╝}{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
|
||||
meths.win_set_config(win, {footer= "Right",footer_pos="right"})
|
||||
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
|
||||
{5:╔═════════╗}|
|
||||
{5:║}{1: halloj! }{5:║}|
|
||||
{5:║}{1: BORDAA }{5:║}|
|
||||
{5:╚════}{11:Right}{5:╝}|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true }
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{5:╔═════════╗}{0: }|
|
||||
{0:~ }{5:║}{1: halloj! }{5:║}{0: }|
|
||||
{0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
|
||||
{0:~ }{5:╚════}{11:Right}{5:╝}{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
|
||||
meths.win_set_config(win, {footer= { {"🦄"},{"BB"}},footer_pos="right"})
|
||||
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
|
||||
{5:╔═════════╗}|
|
||||
{5:║}{1: halloj! }{5:║}|
|
||||
{5:║}{1: BORDAA }{5:║}|
|
||||
{5:╚═════}🦄BB{5:╝}|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true }
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{5:╔═════════╗}{0: }|
|
||||
{0:~ }{5:║}{1: halloj! }{5:║}{0: }|
|
||||
{0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
|
||||
{0:~ }{5:╚═════}🦄BB{5:╝}{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
end)
|
||||
|
||||
it('border with title and footer', function()
|
||||
local buf = meths.create_buf(false, false)
|
||||
meths.buf_set_lines(buf, 0, -1, true, {' halloj! ',
|
||||
' BORDAA '})
|
||||
local win = meths.open_win(buf, false, {
|
||||
relative='editor', width=9, height=2, row=2, col=5, border="double",
|
||||
title = "Left", title_pos = "left", footer = "Right", footer_pos = "right",
|
||||
})
|
||||
|
||||
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
|
||||
{5:╔}{11:Left}{5:═════╗}|
|
||||
{5:║}{1: halloj! }{5:║}|
|
||||
{5:║}{1: BORDAA }{5:║}|
|
||||
{5:╚════}{11:Right}{5:╝}|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true }
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{5:╔}{11:Left}{5:═════╗}{0: }|
|
||||
{0:~ }{5:║}{1: halloj! }{5:║}{0: }|
|
||||
{0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
|
||||
{0:~ }{5:╚════}{11:Right}{5:╝}{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
|
||||
meths.win_set_config(win, {title= "Center",title_pos="center",footer= "Center",footer_pos="center"})
|
||||
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
|
||||
{5:╔═}{11:Center}{5:══╗}|
|
||||
{5:║}{1: halloj! }{5:║}|
|
||||
{5:║}{1: BORDAA }{5:║}|
|
||||
{5:╚═}{11:Center}{5:══╝}|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true }
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{5:╔═}{11:Center}{5:══╗}{0: }|
|
||||
{0:~ }{5:║}{1: halloj! }{5:║}{0: }|
|
||||
{0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
|
||||
{0:~ }{5:╚═}{11:Center}{5:══╝}{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
|
||||
meths.win_set_config(win, {title= "Right",title_pos="right",footer= "Left",footer_pos="left"})
|
||||
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
|
||||
{5:╔════}{11:Right}{5:╗}|
|
||||
{5:║}{1: halloj! }{5:║}|
|
||||
{5:║}{1: BORDAA }{5:║}|
|
||||
{5:╚}{11:Left}{5:═════╝}|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true }
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{5:╔════}{11:Right}{5:╗}{0: }|
|
||||
{0:~ }{5:║}{1: halloj! }{5:║}{0: }|
|
||||
{0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
|
||||
{0:~ }{5:╚}{11:Left}{5:═════╝}{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
|
||||
meths.win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right",footer= { {"🦄"},{"BB"}},footer_pos="right"})
|
||||
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
|
||||
{5:╔═════}🦄BB{5:╗}|
|
||||
{5:║}{1: halloj! }{5:║}|
|
||||
{5:║}{1: BORDAA }{5:║}|
|
||||
{5:╚═════}🦄BB{5:╝}|
|
||||
]], float_pos={
|
||||
[4] = { { id = 1001 }, "NW", 1, 2, 5, true }
|
||||
}, win_viewport={
|
||||
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
|
||||
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
|
||||
}}
|
||||
else
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }{5:╔═════}🦄BB{5:╗}{0: }|
|
||||
{0:~ }{5:║}{1: halloj! }{5:║}{0: }|
|
||||
{0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
|
||||
{0:~ }{5:╚═════}🦄BB{5:╝}{0: }|
|
||||
|
|
||||
]]}
|
||||
end
|
||||
end)
|
||||
|
||||
it('terminates border on edge of viewport when window extends past viewport', function()
|
||||
local buf = meths.create_buf(false, false)
|
||||
meths.open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single", zindex=201})
|
||||
|
Reference in New Issue
Block a user