From 2a2d2882287c27f29dbe50ccee7973efd27c678f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Linse?= Date: Wed, 26 Jun 2019 08:29:06 +0200 Subject: [PATCH] compositor: handle scrolling of blended window --- src/nvim/ui_compositor.c | 5 ++-- test/functional/ui/float_spec.lua | 45 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index 0c3e771eb8..d12a411019 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -329,7 +329,7 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, memcpy(linebuf+(col-startcol), grid->chars+off, n * sizeof(*linebuf)); memcpy(attrbuf+(col-startcol), grid->attrs+off, n * sizeof(*attrbuf)); - // 'pumblend' + // 'pumblend' and 'winblend' if (grid->blending) { for (int i = col-(int)startcol; i < until-startcol; i++) { bool thru = strequal((char *)linebuf[i], " "); // negative space @@ -467,7 +467,8 @@ static void ui_comp_grid_scroll(UI *ui, Integer grid, Integer top, bot += curgrid->comp_row; left += curgrid->comp_col; right += curgrid->comp_col; - if (!msg_scroll_mode && kv_size(layers) > curgrid->comp_index+1) { + bool covered = kv_size(layers) > curgrid->comp_index+1 || curgrid->blending; + if (!msg_scroll_mode && covered) { // TODO(bfredl): // 1. check if rectangles actually overlap // 2. calulate subareas that can scroll. diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 3c7418167c..41ba542899 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -3774,6 +3774,8 @@ describe('floating windows', function() [4] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta}, [5] = {foreground = tonumber('0x990000'), background = tonumber('0xfff1ff')}, [6] = {foreground = tonumber('0x332533'), background = tonumber('0xfff1ff')}, + [7] = {background = tonumber('0xffcfff'), bold = true, foreground = tonumber('0x0000d8')}, + [8] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1} }) insert([[ Lorem ipsum dolor sit amet, consectetur @@ -3953,6 +3955,49 @@ describe('floating windows', function() | ]]) end + + -- Test scrolling by mouse + if multigrid then + meths.input_mouse('wheel', 'down', '', 4, 2, 2) + screen:expect{grid=[[ + ## grid 1 + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + | + ## grid 2 + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + ea commodo consequat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | + dolore eu fugiat nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + laborum^. | + ## grid 4 + {4:popup text}{1: }| + {8:~ }| + {8:~ }| + ]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}} + else + meths.input_mouse('wheel', 'down', '', 0, 4, 7) + screen:expect([[ + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + ea co{5:popup}{6: con}{5:text}{3:at}. Duis aute irure dolor in | + repre{7:~}{3:enderit in vol}uptate velit esse cillum | + dolor{7:~}{3: eu fugiat nul}la pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + laborum^. | + | + ]]) + end end) end