Merge pull request #10234 from bfredl/resizefloat

window: allow resize wincmds for floats
This commit is contained in:
Björn Linse 2019-07-08 19:50:43 +02:00 committed by GitHub
commit 42bdccdf6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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); n = atol((char *)eap->arg);
if (cmdmod.split & WSP_VERT) { if (cmdmod.split & WSP_VERT) {
if (*eap->arg == '-' || *eap->arg == '+') if (*eap->arg == '-' || *eap->arg == '+') {
n += curwin->w_width; n += curwin->w_width;
else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */ } else if (n == 0 && eap->arg[0] == NUL) { // default is very wide
n = 9999; n = Columns;
}
win_setwidth_win(n, wp); win_setwidth_win(n, wp);
} else { } else {
if (*eap->arg == '-' || *eap->arg == '+') { if (*eap->arg == '-' || *eap->arg == '+') {
n += curwin->w_height; n += curwin->w_height;
} else if (n == 0 && eap->arg[0] == NUL) { // default is very high } else if (n == 0 && eap->arg[0] == NUL) { // default is very high
n = 9999; n = Rows-1;
} }
win_setheight_win(n, wp); 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; 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) void ui_mode_info_set(void)
{ {
pending_mode_info_update = true; pending_mode_info_update = true;

View File

@ -375,7 +375,7 @@ newwindow:
/* set current window height */ /* set current window height */
case Ctrl__: case Ctrl__:
case '_': case '_':
win_setheight(Prenum ? (int)Prenum : 9999); win_setheight(Prenum ? (int)Prenum : Rows-1);
break; break;
/* increase current window width */ /* increase current window width */
@ -390,7 +390,7 @@ newwindow:
/* set current window width */ /* set current window width */
case '|': case '|':
win_setwidth(Prenum != 0 ? (int)Prenum : 9999); win_setwidth(Prenum != 0 ? (int)Prenum : Columns);
break; break;
/* jump to tag and split window if tag exists (in preview window) */ /* 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; bool on_top = (curwin == wp) || !curwin->w_floating;
ui_comp_put_grid(&wp->w_grid, comp_row, comp_col, wp->w_height, ui_comp_put_grid(&wp->w_grid, comp_row, comp_col, wp->w_height,
wp->w_width, valid, on_top); wp->w_width, valid, on_top);
ui_check_cursor_grid(wp->w_grid.handle);
if (!valid) { if (!valid) {
wp->w_grid.valid = false; wp->w_grid.valid = false;
redraw_win_later(wp, NOT_VALID); 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_floating) {
if (win->w_float_config.external) {
win->w_float_config.height = height; win->w_float_config.height = height;
win_config_float(win, win->w_float_config); win_config_float(win, win->w_float_config);
} else { redraw_win_later(win, NOT_VALID);
beep_flush();
return;
}
} else { } else {
frame_setheight(win->w_frame, height + win->w_status_height); 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; cmdline_row = row;
msg_row = row; msg_row = row;
msg_col = 0; 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; width = 1;
} }
if (wp->w_floating) { if (wp->w_floating) {
if (wp->w_float_config.external) {
wp->w_float_config.width = width; wp->w_float_config.width = width;
win_config_float(wp, wp->w_float_config); win_config_float(wp, wp->w_float_config);
} else { redraw_win_later(wp, NOT_VALID);
beep_flush();
return;
}
} else { } else {
frame_setwidth(wp->w_frame, width + wp->w_vsep_width); frame_setwidth(wp->w_frame, width + wp->w_vsep_width);
// recompute the window positions // recompute the window positions
(void)win_comp_pos(); (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) 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() it("s :split (non-float)", function()
feed("<c-w>s") feed("<c-w>s")
if multigrid then if multigrid then