mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge pull request #19445 from famiu/fix/local_winbar_tabs
fix: local winbar with tabs
This commit is contained in:
@@ -3022,7 +3022,7 @@ ambw_end:
|
|||||||
}
|
}
|
||||||
// add / remove window bars for 'winbar'
|
// add / remove window bars for 'winbar'
|
||||||
if (gvarp == (char_u **)&p_wbr) {
|
if (gvarp == (char_u **)&p_wbr) {
|
||||||
set_winbar();
|
set_winbar(true);
|
||||||
}
|
}
|
||||||
} else if (gvarp == &p_cpt) {
|
} else if (gvarp == &p_cpt) {
|
||||||
// check if it is a valid value for 'complete' -- Acevedo
|
// check if it is a valid value for 'complete' -- Acevedo
|
||||||
@@ -6456,6 +6456,7 @@ void didset_window_options(win_T *wp)
|
|||||||
set_chars_option(wp, &wp->w_p_lcs, true);
|
set_chars_option(wp, &wp->w_p_lcs, true);
|
||||||
parse_winhl_opt(wp); // sets w_hl_needs_update also for w_p_winbl
|
parse_winhl_opt(wp); // sets w_hl_needs_update also for w_p_winbl
|
||||||
check_blending(wp);
|
check_blending(wp);
|
||||||
|
set_winbar_win(wp, false);
|
||||||
wp->w_grid_alloc.blending = wp->w_p_winbl > 0;
|
wp->w_grid_alloc.blending = wp->w_p_winbl > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4111,7 +4111,6 @@ int win_new_tabpage(int after, char_u *filename)
|
|||||||
|
|
||||||
newtp->tp_topframe = topframe;
|
newtp->tp_topframe = topframe;
|
||||||
last_status(false);
|
last_status(false);
|
||||||
set_winbar();
|
|
||||||
|
|
||||||
redraw_all_later(NOT_VALID);
|
redraw_all_later(NOT_VALID);
|
||||||
|
|
||||||
@@ -6740,34 +6739,50 @@ static void last_status_rec(frame_T *fr, bool statusline, bool is_stl_global)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add or remove window bars from windows depending on the value of 'winbar'.
|
/// Add or remove window bar from window "wp".
|
||||||
void set_winbar(void)
|
///
|
||||||
|
/// @param make_room Whether to resize frames to make room for winbar.
|
||||||
|
///
|
||||||
|
/// @return Success status.
|
||||||
|
int set_winbar_win(win_T *wp, bool make_room)
|
||||||
|
{
|
||||||
|
// Require the local value to be set in order to show winbar on a floating window.
|
||||||
|
int winbar_height = wp->w_floating ? ((*wp->w_p_wbr != NUL) ? 1 : 0)
|
||||||
|
: ((*p_wbr != NUL || *wp->w_p_wbr != NUL) ? 1 : 0);
|
||||||
|
|
||||||
|
if (wp->w_winbar_height != winbar_height) {
|
||||||
|
if (winbar_height == 1 && wp->w_height_inner <= 1) {
|
||||||
|
if (wp->w_floating) {
|
||||||
|
emsg(_(e_noroom));
|
||||||
|
return NOTDONE;
|
||||||
|
} else if (!make_room || !resize_frame_for_winbar(wp->w_frame)) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wp->w_winbar_height = winbar_height;
|
||||||
|
win_set_inner_size(wp);
|
||||||
|
wp->w_redr_status = wp->w_redr_status || winbar_height;
|
||||||
|
|
||||||
|
if (winbar_height == 0) {
|
||||||
|
// When removing winbar, deallocate the w_winbar_click_defs array
|
||||||
|
stl_clear_click_defs(wp->w_winbar_click_defs, wp->w_winbar_click_defs_size);
|
||||||
|
xfree(wp->w_winbar_click_defs);
|
||||||
|
wp->w_winbar_click_defs_size = 0;
|
||||||
|
wp->w_winbar_click_defs = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Add or remove window bars from all windows in tab depending on the value of 'winbar'.
|
||||||
|
///
|
||||||
|
/// @param make_room Whether to resize frames to make room for winbar.
|
||||||
|
void set_winbar(bool make_room)
|
||||||
{
|
{
|
||||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||||
// Require the local value to be set in order to show winbar on a floating window.
|
if (set_winbar_win(wp, make_room) == FAIL) {
|
||||||
int winbar_height = wp->w_floating ? ((*wp->w_p_wbr != NUL) ? 1 : 0)
|
break;
|
||||||
: ((*p_wbr != NUL || *wp->w_p_wbr != NUL) ? 1 : 0);
|
|
||||||
|
|
||||||
if (wp->w_winbar_height != winbar_height) {
|
|
||||||
if (winbar_height == 1 && wp->w_height_inner <= 1) {
|
|
||||||
if (wp->w_floating) {
|
|
||||||
emsg(_(e_noroom));
|
|
||||||
continue;
|
|
||||||
} else if (!resize_frame_for_winbar(wp->w_frame)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wp->w_winbar_height = winbar_height;
|
|
||||||
win_set_inner_size(wp);
|
|
||||||
wp->w_redr_status = wp->w_redr_status || winbar_height;
|
|
||||||
|
|
||||||
if (winbar_height == 0) {
|
|
||||||
// When removing winbar, deallocate the w_winbar_click_defs array
|
|
||||||
stl_clear_click_defs(wp->w_winbar_click_defs, wp->w_winbar_click_defs_size);
|
|
||||||
xfree(wp->w_winbar_click_defs);
|
|
||||||
wp->w_winbar_click_defs_size = 0;
|
|
||||||
wp->w_winbar_click_defs = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -578,3 +578,48 @@ describe('winbar', function()
|
|||||||
eq('Vim(set):E36: Not enough room', pcall_err(command, 'set winbar=test'))
|
eq('Vim(set):E36: Not enough room', pcall_err(command, 'set winbar=test'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('local winbar works with tabs', function()
|
||||||
|
clear()
|
||||||
|
local screen = Screen.new(60, 13)
|
||||||
|
screen:attach()
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[1] = {bold = true},
|
||||||
|
[2] = {reverse = true},
|
||||||
|
[3] = {bold = true, foreground = Screen.colors.Blue},
|
||||||
|
[4] = {underline = true, background = Screen.colors.LightGray}
|
||||||
|
})
|
||||||
|
meths.set_option_value('winbar', 'foo', { scope = 'local', win = 0 })
|
||||||
|
command('tabnew')
|
||||||
|
screen:expect([[
|
||||||
|
{4: [No Name] }{1: [No Name] }{2: }{4:X}|
|
||||||
|
^ |
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
command('tabnext')
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{1: [No Name] }{4: [No Name] }{2: }{4:X}|
|
||||||
|
{1:foo }|
|
||||||
|
^ |
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
{3:~ }|
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
end)
|
||||||
|
Reference in New Issue
Block a user