multigrid: test refactor

This commit is contained in:
Björn Linse
2018-11-17 18:23:42 +01:00
parent 13f74635fa
commit ed3da23cf4
2 changed files with 359 additions and 269 deletions

View File

@@ -44,18 +44,18 @@ describe('multigrid screen', function()
it('default initial screen', function() it('default initial screen', function()
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
| |
## grid 2 ## grid 2
@@ -78,18 +78,18 @@ describe('multigrid screen', function()
command('vsplit') command('vsplit')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{11:[No Name] }{12:[No Name] }| {11:[No Name] }{12:[No Name] }|
| |
## grid 2 ## grid 2
@@ -128,18 +128,18 @@ describe('multigrid screen', function()
command('split') command('split')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} | [3:--------------------------]{12:│}[4:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[4:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[4:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[4:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[4:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[4:--------------------------]|
{12:│}{11:[No Name] }| [3:--------------------------]{12:│}{11:[No Name] }|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:[No Name] [No Name] }| {12:[No Name] [No Name] }|
| |
## grid 2 ## grid 2
@@ -179,18 +179,18 @@ describe('multigrid screen', function()
command('q') command('q')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} | [4:-----------------------------------------------------]|
{12:│} | [4:-----------------------------------------------------]|
{12:│} | [4:-----------------------------------------------------]|
{12:│} | [4:-----------------------------------------------------]|
{12:│} | [4:-----------------------------------------------------]|
{12:│} | [4:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
{12:│} | [2:-----------------------------------------------------]|
{12:│} | [2:-----------------------------------------------------]|
{12:│} | [2:-----------------------------------------------------]|
{12:│} | [2:-----------------------------------------------------]|
{12:│} | [2:-----------------------------------------------------]|
{12:[No Name] }| {12:[No Name] }|
| |
## grid 2 ## grid 2
@@ -220,18 +220,18 @@ describe('multigrid screen', function()
command('sp') command('sp')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{12:[No Name] }| {12:[No Name] }|
| |
## grid 2 ## grid 2
@@ -253,21 +253,20 @@ describe('multigrid screen', function()
it('resizes grids', function () it('resizes grids', function ()
command('sp') command('sp')
command('resize 8') command('resize 8')
-- see "Note 1" for info about why there are three statuslines
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
| [3:-----------------------------------------------------]|
[3:-----------------------------------------------------]|
[3:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
| [2:-----------------------------------------------------]|
{11:[No Name] }| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
|
|
{12:[No Name] }| {12:[No Name] }|
| |
## grid 2 ## grid 2
@@ -292,18 +291,18 @@ describe('multigrid screen', function()
command('vsp') command('vsp')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{11:[No Name] }{12:[No Name] [No Name] }| {11:[No Name] }{12:[No Name] [No Name] }|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{12:[No Name] }| {12:[No Name] }|
| |
## grid 2 ## grid 2
@@ -337,18 +336,18 @@ describe('multigrid screen', function()
insert('hello') insert('hello')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{12:│} {12:│} | [5:--------------------]{12:│}[4:----------------]{12:│}[3:---------------]|
{11:[No Name] [+] }{12:[No Name] [+] [No Name] [+] }| {11:[No Name] [+] }{12:[No Name] [+] [No Name] [+] }|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{12:[No Name] [+] }| {12:[No Name] [+] }|
| |
## grid 2 ## grid 2
@@ -382,21 +381,51 @@ describe('multigrid screen', function()
end) end)
it('closes splits', function () it('closes splits', function ()
command('sp') command('sp')
screen:expect([[
## grid 1
[3:-----------------------------------------------------]|
[3:-----------------------------------------------------]|
[3:-----------------------------------------------------]|
[3:-----------------------------------------------------]|
[3:-----------------------------------------------------]|
[3:-----------------------------------------------------]|
{11:[No Name] }|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{12:[No Name] }|
|
## grid 2
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
]])
command('q') command('q')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{11:[No Name] }| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
| |
## grid 2 ## grid 2
@@ -421,18 +450,18 @@ describe('multigrid screen', function()
command('vsp') command('vsp')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{11:[No Name] }{12:[No Name] }| {11:[No Name] }{12:[No Name] }|
| |
## grid 2 ## grid 2
@@ -469,18 +498,18 @@ describe('multigrid screen', function()
-- see "Note 1" for info about why there are two vseps -- see "Note 1" for info about why there are two vseps
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{12:│} {12:│} | [3:----------]{12:│}[2:------------------------------------------]|
{11:<No Name] }{12:[No Name] }| {11:<No Name] }{12:[No Name] }|
| |
## grid 2 ## grid 2
@@ -516,18 +545,18 @@ describe('multigrid screen', function()
command('sp') command('sp')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{11:[No Name] }{12:│} | {11:[No Name] }{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:[No Name] [No Name] }| {12:[No Name] [No Name] }|
| |
## grid 2 ## grid 2
@@ -560,18 +589,18 @@ describe('multigrid screen', function()
insert('hello') insert('hello')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [4:--------------------------]{12:│}[2:--------------------------]|
{11:[No Name] [+] }{12:│} | {11:[No Name] [+] }{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:[No Name] [+] [No Name] [+] }| {12:[No Name] [+] [No Name] [+] }|
| |
## grid 2 ## grid 2
@@ -600,26 +629,68 @@ describe('multigrid screen', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
]]) ]])
end) end)
it('closes splits', function () it('closes splits', function ()
command('vsp') command('vsp')
command('q')
-- see "Note 1" for info about why there is a vsep
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{12:│} | [3:--------------------------]{12:│}[2:--------------------------]|
{11:[No Name] }{12:[No Name] }|
|
## grid 2
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
]])
command('q')
screen:expect([[
## grid 1
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
| |
## grid 2 ## grid 2
@@ -645,10 +716,10 @@ describe('multigrid screen', function()
screen:try_resize(25, 6) screen:try_resize(25, 6)
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:-------------------------]|
| [2:-------------------------]|
| [2:-------------------------]|
| [2:-------------------------]|
{11:[No Name] }| {11:[No Name] }|
| |
## grid 2 ## grid 2
@@ -663,7 +734,7 @@ describe('multigrid screen', function()
screen:try_resize(1, 1) screen:try_resize(1, 1)
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:------------]|
{11:[No Name] }| {11:[No Name] }|
| |
## grid 2 ## grid 2
@@ -673,7 +744,7 @@ describe('multigrid screen', function()
feed('<esc>:ls') feed('<esc>:ls')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:------------]|
{11:[No Name] }| {11:[No Name] }|
:ls^ | :ls^ |
## grid 2 ## grid 2
@@ -687,18 +758,18 @@ describe('multigrid screen', function()
screen:try_resize_grid(2, 8, 5) screen:try_resize_grid(2, 8, 5)
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
| |
## grid 2 ## grid 2
@@ -716,18 +787,18 @@ describe('multigrid screen', function()
screen:try_resize_grid(2, 80, 20) screen:try_resize_grid(2, 80, 20)
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
| |
## grid 2 ## grid 2
@@ -763,18 +834,18 @@ describe('multigrid screen', function()
insert(('a'):rep(60).."\n") insert(('a'):rep(60).."\n")
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{11:[No Name] [+] }| {11:[No Name] [+] }|
| |
## grid 2 ## grid 2
@@ -805,18 +876,18 @@ describe('multigrid screen', function()
insert(('b'):rep(80).."\n") insert(('b'):rep(80).."\n")
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{11:[No Name] [+] }| {11:[No Name] [+] }|
| |
## grid 2 ## grid 2
@@ -848,18 +919,18 @@ describe('multigrid screen', function()
' long message"') ' long message"')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
this is a very very very...ry very very long message | this is a very very very...ry very very long message |
## grid 2 ## grid 2
@@ -891,18 +962,18 @@ describe('multigrid screen', function()
feed('kzfgg') feed('kzfgg')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
| [2:-----------------------------------------------------]|
{11:[No Name] [+] }| {11:[No Name] [+] }|
| |
## grid 2 ## grid 2

View File

@@ -704,7 +704,7 @@ end
function Screen:_handle_grid_destroy(grid) function Screen:_handle_grid_destroy(grid)
self._grids[grid] = nil self._grids[grid] = nil
if self._multigrid then if self._options.ext_multigrid then
assert(self.win_position[grid]) assert(self.win_position[grid])
self.win_position[grid] = nil self.win_position[grid] = nil
end end
@@ -810,7 +810,6 @@ function Screen:_handle_win_pos(grid, win, startrow, startcol, width, height)
width = width, width = width,
height = height height = height
} }
-- TODO(utkarshme): Take apt action
end end
function Screen:_handle_win_hide(grid) function Screen:_handle_win_hide(grid)
@@ -981,31 +980,51 @@ function Screen:_clear_row_section(grid, rownum, startcol, stopcol)
end end
end end
function Screen:_row_repr(row, attr_state, cursor) function Screen:_row_repr(gridnr, rownr, attr_state, cursor)
local rv = {} local rv = {}
local current_attr_id local current_attr_id
for i = 1, #row do local i = 1
local attrs = row[i].attrs local has_windows = self._options.ext_multigrid and gridnr == 1
if self._options.ext_linegrid then local row = self._grids[gridnr].rows[rownr]
attrs = attrs[(self._options.rgb and 1) or 2] while i <= #row do
local did_window = false
if has_windows then
for id,pos in pairs(self.win_position) do
if i-1 == pos.startcol and pos.startrow <= rownr-1 and rownr-1 < pos.startrow + pos.height then
if current_attr_id then
-- close current attribute bracket
table.insert(rv, '}')
current_attr_id = nil
end
table.insert(rv, '['..id..':'..string.rep('-',pos.width)..']')
i = i + pos.width
did_window = true
end
end
end end
local attr_id = self:_get_attr_id(attr_state, attrs, row[i].hl_id)
if current_attr_id and attr_id ~= current_attr_id then if not did_window then
-- close current attribute bracket, add it before any whitespace local attrs = row[i].attrs
-- up to the current cell if self._options.ext_linegrid then
-- table.insert(rv, backward_find_meaningful(rv, i), '}') attrs = attrs[(self._options.rgb and 1) or 2]
table.insert(rv, '}') end
current_attr_id = nil local attr_id = self:_get_attr_id(attr_state, attrs, row[i].hl_id)
if current_attr_id and attr_id ~= current_attr_id then
-- close current attribute bracket
table.insert(rv, '}')
current_attr_id = nil
end
if not current_attr_id and attr_id then
-- open a new attribute bracket
table.insert(rv, '{' .. attr_id .. ':')
current_attr_id = attr_id
end
if not self._busy and cursor and self._cursor.col == i then
table.insert(rv, '^')
end
table.insert(rv, row[i].text)
i = i + 1
end end
if not current_attr_id and attr_id then
-- open a new attribute bracket
table.insert(rv, '{' .. attr_id .. ':')
current_attr_id = attr_id
end
if not self._busy and cursor and self._cursor.col == i then
table.insert(rv, '^')
end
table.insert(rv, row[i].text)
end end
if current_attr_id then if current_attr_id then
table.insert(rv, '}') table.insert(rv, '}')
@@ -1090,7 +1109,7 @@ function Screen:render(headers, attr_state, preview)
for i = 1, grid.height do for i = 1, grid.height do
local cursor = self._cursor.grid == igrid and self._cursor.row == i local cursor = self._cursor.grid == igrid and self._cursor.row == i
local prefix = (headers or preview) and " " or "" local prefix = (headers or preview) and " " or ""
table.insert(rv, prefix..self:_row_repr(grid.rows[i], attr_state, cursor).."|") table.insert(rv, prefix..self:_row_repr(igrid, i, attr_state, cursor).."|")
end end
end end
return rv return rv