summaryrefslogtreecommitdiff
path: root/src/testdir/view_util.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-02-05 21:14:50 +0100
committerBram Moolenaar <Bram@vim.org>2017-02-05 21:14:50 +0100
commit544d3bc9f0e494cb712a33b61558b8e8e12b1e0b (patch)
tree01fcc92049bb5f2a7730db2508a3385bfb9aaca4 /src/testdir/view_util.vim
parent13c724fb3a630257b736a1c91643b396fee917c1 (diff)
downloadvim-git-544d3bc9f0e494cb712a33b61558b8e8e12b1e0b.tar.gz
patch 8.0.0311: linebreak tests are old stylev8.0.0311
Problem: Linebreak tests are old style. Solution: Turn the tests into new style. Share utility functions. (Ozaki Kiichi, closes #1444)
Diffstat (limited to 'src/testdir/view_util.vim')
-rw-r--r--src/testdir/view_util.vim30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/testdir/view_util.vim b/src/testdir/view_util.vim
new file mode 100644
index 000000000..eb9263076
--- /dev/null
+++ b/src/testdir/view_util.vim
@@ -0,0 +1,30 @@
+" Functions about view shared by several tests
+
+" ScreenLines(lnum, width) or
+" ScreenLines([start, end], width)
+function! ScreenLines(lnum, width) abort
+ redraw!
+ if type(a:lnum) == v:t_list
+ let start = a:lnum[0]
+ let end = a:lnum[1]
+ else
+ let start = a:lnum
+ let end = a:lnum
+ endif
+ let lines = []
+ for l in range(start, end)
+ let lines += [join(map(range(1, a:width), 'nr2char(screenchar(l, v:val))'), '')]
+ endfor
+ return lines
+endfunction
+
+function! NewWindow(height, width) abort
+ exe a:height . 'new'
+ exe a:width . 'vsp'
+ redraw!
+endfunction
+
+function! CloseWindow() abort
+ bw!
+ redraw!
+endfunction