Improved tablemode#table#IsHeader()

Automatically improves header border creation, especially when
overriding g:table_mode_header_fillchar #31
This commit is contained in:
Dhruva Sagar
2014-11-18 07:48:23 +05:30
parent 8810818e32
commit af0254e816

View File

@@ -29,7 +29,7 @@ function! s:GenerateHeaderBorder(line) "{{{2
let border = substitute(line_val[stridx(line_val, g:table_mode_separator):strridx(line_val, g:table_mode_separator)], g:table_mode_separator, g:table_mode_corner, 'g') let border = substitute(line_val[stridx(line_val, g:table_mode_separator):strridx(line_val, g:table_mode_separator)], g:table_mode_separator, g:table_mode_corner, 'g')
" To accurately deal with unicode double width characters " To accurately deal with unicode double width characters
if tablemode#table#IsHeader(line - 1) || tablemode#spreadsheet#RowNr(line - 1) == 1 if tablemode#table#IsHeader(line - 1)
let fill_columns = map(split(border, g:table_mode_corner), 'repeat(g:table_mode_header_fillchar, tablemode#utils#StrDisplayWidth(v:val))') let fill_columns = map(split(border, g:table_mode_corner), 'repeat(g:table_mode_header_fillchar, tablemode#utils#StrDisplayWidth(v:val))')
else else
let fill_columns = map(split(border, g:table_mode_corner), 'repeat(g:table_mode_fillchar, tablemode#utils#StrDisplayWidth(v:val))') let fill_columns = map(split(border, g:table_mode_corner), 'repeat(g:table_mode_fillchar, tablemode#utils#StrDisplayWidth(v:val))')
@@ -137,8 +137,12 @@ endfunction
function! tablemode#table#IsHeader(line) "{{{2 function! tablemode#table#IsHeader(line) "{{{2
let line = tablemode#utils#line(a:line) let line = tablemode#utils#line(a:line)
if line <= 0 || line > line('$') | return 0 | endif " if line <= 0 || line > line('$') | return 0 | endif
return tablemode#table#IsBorder(line+1) && !tablemode#table#IsRow(line-1) && !tablemode#table#IsRow(line-2) return tablemode#table#IsRow(line)
\ && !tablemode#table#IsRow(line-1)
\ && !tablemode#table#IsRow(line-2)
\ && !tablemode#table#IsBorder(line-2)
\ && tablemode#table#IsBorder(line+1)
endfunction endfunction
function! tablemode#table#IsRow(line) "{{{2 function! tablemode#table#IsRow(line) "{{{2