mirror of
https://github.com/neovim/neovim.git
synced 2026-03-28 19:32:01 +00:00
refactor(window): lastwin_nofloating takes tp
This commit is contained in:
@@ -680,17 +680,9 @@ static bool win_config_float_tp(win_T *win, const Dict(win_config) *config,
|
||||
// Check again, in case autocommands above moved windows to the same tabpage.
|
||||
if (win_tp != parent_tp) {
|
||||
win_remove(win, win_tp == curtab ? NULL : win_tp);
|
||||
win_T *after;
|
||||
if (parent_tp == curtab) {
|
||||
after = lastwin_nofloating();
|
||||
} else {
|
||||
after = parent_tp->tp_lastwin;
|
||||
while (after->w_floating) {
|
||||
after = after->w_prev;
|
||||
}
|
||||
}
|
||||
tabpage_T *append_tp = parent_tp == curtab ? NULL : parent_tp;
|
||||
win_append(lastwin_nofloating(append_tp), win, append_tp);
|
||||
|
||||
win_append(after, win, parent_tp == curtab ? NULL : parent_tp);
|
||||
// If `win` was the curwin of its old tabpage, select a new curwin for it.
|
||||
if (win_tp != curtab && win_tp->tp_curwin == win) {
|
||||
win_tp->tp_curwin = win_float_find_altwin(win, win_tp);
|
||||
|
||||
@@ -1116,7 +1116,7 @@ static void do_arg_all(int count, int forceit, int keep_tabs)
|
||||
last_curwin = curwin;
|
||||
last_curtab = curtab;
|
||||
// lastwin may be aucmd_win
|
||||
win_enter(lastwin_nofloating(), false);
|
||||
win_enter(lastwin_nofloating(NULL), false);
|
||||
|
||||
// Open up to "count" windows.
|
||||
arg_all_open_windows(&aall, count);
|
||||
|
||||
@@ -3692,7 +3692,7 @@ void ex_buffer_all(exarg_T *eap)
|
||||
// Don't execute Win/Buf Enter/Leave autocommands here.
|
||||
autocmd_no_enter++;
|
||||
// lastwin may be aucmd_win
|
||||
win_enter(lastwin_nofloating(), false);
|
||||
win_enter(lastwin_nofloating(NULL), false);
|
||||
autocmd_no_leave++;
|
||||
for (buf_T *buf = firstbuf; buf != NULL && open_wins < count; buf = buf->b_next) {
|
||||
// Check if this buffer needs a window
|
||||
|
||||
@@ -4062,7 +4062,7 @@ void compute_cmdrow(void)
|
||||
if (exmode_active || msg_scrolled != 0) {
|
||||
cmdline_row = Rows - 1;
|
||||
} else {
|
||||
win_T *wp = lastwin_nofloating();
|
||||
win_T *wp = lastwin_nofloating(NULL);
|
||||
cmdline_row = wp->w_winrow + wp->w_height
|
||||
+ wp->w_hsep_height + wp->w_status_height + global_stl_height();
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ void win_redr_winbar(win_T *wp)
|
||||
void redraw_ruler(void)
|
||||
{
|
||||
static int did_ruler_col = -1;
|
||||
win_T *wp = curwin->w_status_height == 0 ? curwin : lastwin_nofloating();
|
||||
win_T *wp = curwin->w_status_height == 0 ? curwin : lastwin_nofloating(NULL);
|
||||
bool is_stl_global = global_stl_height() > 0;
|
||||
|
||||
// Check if ruler should be drawn, clear if it was drawn before.
|
||||
|
||||
@@ -505,7 +505,7 @@ newwindow:
|
||||
// cursor to bottom-right window
|
||||
case 'b':
|
||||
case Ctrl_B:
|
||||
win_goto(lastwin_nofloating());
|
||||
win_goto(lastwin_nofloating(NULL));
|
||||
break;
|
||||
|
||||
// cursor to last accessed (previous) window
|
||||
@@ -1158,7 +1158,7 @@ win_T *win_split_ins(int size, int flags, win_T *new_wp, int dir, frame_T *to_fl
|
||||
oldwin = firstwin;
|
||||
} else if (flags & WSP_BOT || curwin->w_floating) {
|
||||
// can't split float, use last nonfloating window instead
|
||||
oldwin = lastwin_nofloating();
|
||||
oldwin = lastwin_nofloating(NULL);
|
||||
} else {
|
||||
oldwin = curwin;
|
||||
}
|
||||
@@ -4800,7 +4800,7 @@ static void tabpage_check_windows(tabpage_T *old_curtab)
|
||||
if (wp->w_floating) {
|
||||
if (wp->w_config.external) {
|
||||
win_remove(wp, old_curtab);
|
||||
win_append(lastwin_nofloating(), wp, NULL);
|
||||
win_append(lastwin_nofloating(NULL), wp, NULL);
|
||||
} else {
|
||||
ui_comp_remove_grid(&wp->w_grid_alloc);
|
||||
}
|
||||
@@ -6237,7 +6237,7 @@ static void frame_setheight(frame_T *curfrp, int height)
|
||||
if (curfrp->fr_width != Columns) {
|
||||
room_cmdline = 0;
|
||||
} else {
|
||||
win_T *wp = lastwin_nofloating();
|
||||
win_T *wp = lastwin_nofloating(NULL);
|
||||
room_cmdline = Rows - (int)p_ch - global_stl_height()
|
||||
- (wp->w_winrow + wp->w_height + wp->w_hsep_height + wp->w_status_height);
|
||||
room_cmdline = MAX(room_cmdline, 0);
|
||||
@@ -7051,7 +7051,7 @@ void command_height(void)
|
||||
int old_p_ch = (int)curtab->tp_ch_used;
|
||||
|
||||
// Find bottom frame with width of screen.
|
||||
frame_T *frp = lastwin_nofloating()->w_frame;
|
||||
frame_T *frp = lastwin_nofloating(NULL)->w_frame;
|
||||
while (frp->fr_width != Columns && frp->fr_parent != NULL) {
|
||||
frp = frp->fr_parent;
|
||||
}
|
||||
@@ -7804,9 +7804,11 @@ void win_ui_flush(bool validate)
|
||||
msg_ui_flush();
|
||||
}
|
||||
|
||||
win_T *lastwin_nofloating(void)
|
||||
/// @return last non-floating window in `tp`, or NULL for current tabpage.
|
||||
win_T *lastwin_nofloating(tabpage_T *tp)
|
||||
{
|
||||
win_T *res = lastwin;
|
||||
assert(tp != curtab || !tp);
|
||||
win_T *res = tp ? tp->tp_lastwin : lastwin;
|
||||
while (res->w_floating) {
|
||||
res = res->w_prev;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err)
|
||||
{
|
||||
if (wp == NULL) {
|
||||
tabpage_T *tp = NULL;
|
||||
win_T *tp_last = last ? lastwin : lastwin_nofloating();
|
||||
win_T *tp_last = last ? lastwin : lastwin_nofloating(NULL);
|
||||
if (fconfig.window != 0) {
|
||||
assert(!last);
|
||||
win_T *parent_wp = find_window_by_handle(fconfig.window, err);
|
||||
@@ -57,10 +57,7 @@ win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err)
|
||||
if (!tp) {
|
||||
return NULL;
|
||||
}
|
||||
tp_last = tp == curtab ? lastwin : tp->tp_lastwin;
|
||||
while (tp_last->w_floating && tp_last->w_prev) {
|
||||
tp_last = tp_last->w_prev;
|
||||
}
|
||||
tp_last = lastwin_nofloating(tp == curtab ? NULL : tp);
|
||||
}
|
||||
wp = win_alloc(tp_last, false);
|
||||
win_init(wp, curwin, 0);
|
||||
@@ -77,7 +74,7 @@ win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err)
|
||||
} else {
|
||||
assert(!last);
|
||||
assert(!wp->w_floating);
|
||||
if (firstwin == wp && lastwin_nofloating() == wp) {
|
||||
if (firstwin == wp && lastwin_nofloating(NULL) == wp) {
|
||||
// last non-float
|
||||
api_set_error(err, kErrorTypeException,
|
||||
"Cannot change last window into float");
|
||||
@@ -105,7 +102,7 @@ win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err)
|
||||
XFREE_CLEAR(wp->w_frame);
|
||||
win_comp_pos(); // recompute window positions
|
||||
win_remove(wp, NULL);
|
||||
win_append(lastwin_nofloating(), wp, NULL);
|
||||
win_append(lastwin_nofloating(NULL), wp, NULL);
|
||||
}
|
||||
wp->w_floating = true;
|
||||
wp->w_status_height = wp->w_p_stl && *wp->w_p_stl != NUL
|
||||
|
||||
Reference in New Issue
Block a user