fix(ui): make winbar work with floats and multigrid

This commit is contained in:
bfredl
2022-05-18 13:51:59 +02:00
parent c28192e6f9
commit 17758fe7ad
5 changed files with 93 additions and 4 deletions

View File

@ -183,7 +183,7 @@ void os_breakcheck(void)
// We do not want screen_resize() to redraw here.
// TODO(bfredl): we are already special casing redraw events, is this
// hack still needed?
updating_screen++;
updating_screen = true;
loop_poll_events(&main_loop, 0);

View File

@ -5324,8 +5324,10 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler)
use_sandbox = was_set_insecurely(wp, "tabline", 0);
} else if (draw_winbar) {
stl = (char_u *)((*wp->w_p_wbr != NUL) ? wp->w_p_wbr : p_wbr);
row = wp->w_winrow;
col = wp->w_wincol;
row = -1; // row zero is first row of text
col = 0;
grid = &wp->w_grid;
grid_adjust(&grid, &row, &col);
fillchar = wp->w_p_fcs_chars.wbr;
attr = (wp == curwin) ? HL_ATTR(HLF_WBR) : HL_ATTR(HLF_WBRNC);
maxwidth = wp->w_width_inner;

View File

@ -6296,7 +6296,7 @@ void win_set_inner_size(win_T *wp)
static int win_extra_height(win_T *wp)
{
return wp->w_border_adj[0] + wp->w_border_adj[2];
return wp->w_border_adj[0] + wp->w_border_adj[2] + wp->w_winbar_height;
}
static int win_extra_width(win_T *wp)

View File

@ -7591,6 +7591,53 @@ describe('float window', function()
]]}
end
end)
it('can use winbar', function()
local buf = meths.create_buf(false,false)
local win1 = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5})
meths.win_set_option(win1, 'winbar', 'floaty bar')
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
{3:floaty bar }|
{1: }|
{2:~ }|
]], float_pos={
[4] = {{id = 1001}, "NW", 1, 1, 5, true, 50};
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
}}
else
screen:expect{grid=[[
^ |
{0:~ }{3:floaty bar }{0: }|
{0:~ }{1: }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }|
{0:~ }|
|
]]}
end
end)
end
describe('with ext_multigrid', function()

View File

@ -2369,4 +2369,44 @@ describe('ext_multigrid', function()
[2] = {win = {id = 1000}, topline = 6, botline = 12, curline = 10, curcol = 1, linecount = 11},
}}
end)
it('with winbar', function()
command 'split'
command 'setlocal winbar=very\\ bar'
screen:expect{grid=[[
## grid 1
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
[4:-----------------------------------------------------]|
{11:[No Name] }|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{12:[No Name] }|
[3:-----------------------------------------------------]|
## grid 2
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
|
## grid 4
{7:very bar }|
^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
]], win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
[4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
}}
end)
end)