window: allow resize wincmds for floats

This commit is contained in:
Björn Linse 2019-06-10 15:42:09 +02:00
parent 44e150bd46
commit d11a146516
4 changed files with 374 additions and 22 deletions

View File

@ -6922,16 +6922,17 @@ static void ex_resize(exarg_T *eap)
n = atol((char *)eap->arg);
if (cmdmod.split & WSP_VERT) {
if (*eap->arg == '-' || *eap->arg == '+')
if (*eap->arg == '-' || *eap->arg == '+') {
n += curwin->w_width;
else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */
n = 9999;
} else if (n == 0 && eap->arg[0] == NUL) { // default is very wide
n = Columns;
}
win_setwidth_win(n, wp);
} else {
if (*eap->arg == '-' || *eap->arg == '+') {
n += curwin->w_height;
} else if (n == 0 && eap->arg[0] == NUL) { // default is very high
n = 9999;
n = Rows-1;
}
win_setheight_win(n, wp);
}

View File

@ -372,6 +372,14 @@ void ui_grid_cursor_goto(handle_T grid_handle, int new_row, int new_col)
pending_cursor_update = true;
}
/// moving the cursor grid will implicitly move the cursor
void ui_check_cursor_grid(handle_T grid_handle)
{
if (cursor_grid_handle == grid_handle) {
pending_cursor_update = true;
}
}
void ui_mode_info_set(void)
{
pending_mode_info_update = true;

View File

@ -375,7 +375,7 @@ newwindow:
/* set current window height */
case Ctrl__:
case '_':
win_setheight(Prenum ? (int)Prenum : 9999);
win_setheight(Prenum ? (int)Prenum : Rows-1);
break;
/* increase current window width */
@ -390,7 +390,7 @@ newwindow:
/* set current window width */
case '|':
win_setwidth(Prenum != 0 ? (int)Prenum : 9999);
win_setwidth(Prenum != 0 ? (int)Prenum : Columns);
break;
/* jump to tag and split window if tag exists (in preview window) */
@ -694,6 +694,7 @@ static void ui_ext_win_position(win_T *wp)
bool on_top = (curwin == wp) || !curwin->w_floating;
ui_comp_put_grid(&wp->w_grid, comp_row, comp_col, wp->w_height,
wp->w_width, valid, on_top);
ui_check_cursor_grid(wp->w_grid.handle);
if (!valid) {
wp->w_grid.valid = false;
redraw_win_later(wp, NOT_VALID);
@ -4865,13 +4866,9 @@ void win_setheight_win(int height, win_T *win)
}
if (win->w_floating) {
if (win->w_float_config.external) {
win->w_float_config.height = height;
win_config_float(win, win->w_float_config);
} else {
beep_flush();
return;
}
win->w_float_config.height = height;
win_config_float(win, win->w_float_config);
redraw_win_later(win, NOT_VALID);
} else {
frame_setheight(win->w_frame, height + win->w_status_height);
@ -4886,9 +4883,9 @@ void win_setheight_win(int height, win_T *win)
cmdline_row = row;
msg_row = row;
msg_col = 0;
redraw_all_later(NOT_VALID);
}
redraw_all_later(NOT_VALID);
}
@ -5071,21 +5068,17 @@ void win_setwidth_win(int width, win_T *wp)
width = 1;
}
if (wp->w_floating) {
if (wp->w_float_config.external) {
wp->w_float_config.width = width;
win_config_float(wp, wp->w_float_config);
} else {
beep_flush();
return;
}
wp->w_float_config.width = width;
win_config_float(wp, wp->w_float_config);
redraw_win_later(wp, NOT_VALID);
} else {
frame_setwidth(wp->w_frame, width + wp->w_vsep_width);
// recompute the window positions
(void)win_comp_pos();
redraw_all_later(NOT_VALID);
}
redraw_all_later(NOT_VALID);
}
/*

View File

@ -2663,6 +2663,356 @@ describe('floating windows', function()
end)
it("vertical resize + - _", function()
feed('<c-w>w')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
{2:~ }|
]], float_pos=expected_pos}
else
screen:expect([[
x |
{0:~ }|
{0:~ }{1:^y }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }|
{0:~ }|
|
]])
end
feed('<c-w>+')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
{2:~ }|
{2:~ }|
]], float_pos=expected_pos}
else
screen:expect([[
x |
{0:~ }|
{0:~ }{1:^y }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }|
|
]])
end
feed('<c-w>2-')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
]], float_pos=expected_pos}
else
screen:expect([[
x |
{0:~ }|
{0:~ }{1:^y }{0: }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end
feed('<c-w>4_')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
{2:~ }|
{2:~ }|
{2:~ }|
]], float_pos=expected_pos}
else
screen:expect([[
x |
{0:~ }|
{0:~ }{1:^y }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }{2:~ }{0: }|
|
]])
end
feed('<c-w>_')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
{2:~ }|
{2:~ }|
{2:~ }|
{2:~ }|
{2:~ }|
]], float_pos=expected_pos}
else
screen:expect([[
x {1:^y } |
{0:~ }{2:~ }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }{2:~ }{0: }|
|
]])
end
end)
it("horizontal resize > < |", function()
feed('<c-w>w')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
{2:~ }|
]], float_pos=expected_pos}
else
screen:expect([[
x |
{0:~ }|
{0:~ }{1:^y }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }|
{0:~ }|
|
]])
end
feed('<c-w>>')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
{2:~ }|
]], float_pos=expected_pos}
else
screen:expect([[
x |
{0:~ }|
{0:~ }{1:^y }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }|
{0:~ }|
|
]])
end
feed('<c-w>10<lt>')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
{2:~ }|
]], float_pos=expected_pos}
else
screen:expect([[
x |
{0:~ }|
{0:~ }{1:^y }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }|
{0:~ }|
|
]])
end
feed('<c-w>15|')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
{2:~ }|
]], float_pos=expected_pos}
else
screen:expect([[
x |
{0:~ }|
{0:~ }{1:^y }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }|
{0:~ }|
|
]])
end
feed('<c-w>|')
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
x |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1:^y }|
{2:~ }|
]], float_pos=expected_pos}
else
screen:expect([[
x |
{0:~ }|
{1:^y }|
{2:~ }|
{0:~ }|
{0:~ }|
|
]])
end
end)
it("s :split (non-float)", function()
feed("<c-w>s")
if multigrid then