1" Functions about view shared by several tests 2 3" Only load this script once. 4if exists('*ScreenLines') 5 finish 6endif 7 8" Get text on the screen, including composing characters. 9" ScreenLines(lnum, width) or 10" ScreenLines([start, end], width) 11function! ScreenLines(lnum, width) abort 12 redraw! 13 if type(a:lnum) == v:t_list 14 let start = a:lnum[0] 15 let end = a:lnum[1] 16 else 17 let start = a:lnum 18 let end = a:lnum 19 endif 20 let lines = [] 21 for l in range(start, end) 22 let lines += [join(map(range(1, a:width), 'screenstring(l, v:val)'), '')] 23 endfor 24 return lines 25endfunction 26 27function! ScreenAttrs(lnum, width) abort 28 redraw! 29 if type(a:lnum) == v:t_list 30 let start = a:lnum[0] 31 let end = a:lnum[1] 32 else 33 let start = a:lnum 34 let end = a:lnum 35 endif 36 let attrs = [] 37 for l in range(start, end) 38 let attrs += [map(range(1, a:width), 'screenattr(l, v:val)')] 39 endfor 40 return attrs 41endfunction 42 43function! NewWindow(height, width) abort 44 exe a:height . 'new' 45 exe a:width . 'vsp' 46 redraw! 47endfunction 48 49function! CloseWindow() abort 50 bw! 51 redraw! 52endfunction 53