aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/input_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-04-02 01:00:40 +0300
committerZyX <kp-pav@yandex.ru>2017-06-27 01:34:54 +0300
commit407abb3a6c5c1c706bf8797a1431e57e97a6b797 (patch)
treef4d2171c0ea34db451b43495b284d7f73d72e98e /test/functional/eval/input_spec.lua
parentd82741f8c04d003bb9925d9c46d7e07179810ed4 (diff)
downloadrneovim-407abb3a6c5c1c706bf8797a1431e57e97a6b797.tar.gz
rneovim-407abb3a6c5c1c706bf8797a1431e57e97a6b797.tar.bz2
rneovim-407abb3a6c5c1c706bf8797a1431e57e97a6b797.zip
eval,ex_getln: Add support for coloring input() prompts
Diffstat (limited to 'test/functional/eval/input_spec.lua')
-rw-r--r--test/functional/eval/input_spec.lua57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua
index 74ad32bc6c..f0c1314754 100644
--- a/test/functional/eval/input_spec.lua
+++ b/test/functional/eval/input_spec.lua
@@ -23,10 +23,41 @@ before_each(function()
function CustomListCompl(...)
return ['FOO']
endfunction
+
+ highlight RBP1 guibg=Red
+ highlight RBP2 guibg=Yellow
+ highlight RBP3 guibg=Green
+ highlight RBP4 guibg=Blue
+ let g:NUM_LVLS = 4
+ function Redraw()
+ redraw!
+ return ''
+ endfunction
+ cnoremap <expr> {REDRAW} Redraw()
+ function RainBowParens(cmdline)
+ let ret = []
+ let i = 0
+ let lvl = 0
+ while i < len(a:cmdline)
+ if a:cmdline[i] is# '('
+ call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)])
+ let lvl += 1
+ elseif a:cmdline[i] is# ')'
+ let lvl -= 1
+ call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)])
+ endif
+ let i += 1
+ endwhile
+ return ret
+ endfunction
]])
screen:set_default_attr_ids({
EOB={bold = true, foreground = Screen.colors.Blue1},
T={foreground=Screen.colors.Red},
+ RBP1={background=Screen.colors.Red},
+ RBP2={background=Screen.colors.Yellow},
+ RBP3={background=Screen.colors.Green},
+ RBP4={background=Screen.colors.Blue},
})
end)
@@ -196,6 +227,19 @@ describe('input()', function()
eq('Vim(call):E118: Too many arguments for function: input',
exc_exec('call input("prompt> ", "default", "file", "extra")'))
end)
+ it('supports highlighting', function()
+ feed([[:call input({"highlight": "RainBowParens"})<CR>]])
+ wait()
+ feed('(())')
+ wait()
+ screen:expect([[
+ {EOB:~ }|
+ {EOB:~ }|
+ {EOB:~ }|
+ |
+ {RBP1:(}{RBP2:()}{RBP1:)}^ |
+ ]])
+ end)
end)
describe('inputdialog()', function()
it('works with multiline prompts', function()
@@ -363,4 +407,17 @@ describe('inputdialog()', function()
eq('Vim(call):E118: Too many arguments for function: inputdialog',
exc_exec('call inputdialog("prompt> ", "default", "file", "extra")'))
end)
+ it('supports highlighting', function()
+ feed([[:call inputdialog({"highlight": "RainBowParens"})<CR>]])
+ wait()
+ feed('(())')
+ wait()
+ screen:expect([[
+ {EOB:~ }|
+ {EOB:~ }|
+ {EOB:~ }|
+ |
+ {RBP1:(}{RBP2:()}{RBP1:)}^ |
+ ]])
+ end)
end)