diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-12-24 23:15:20 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2021-10-20 13:07:43 +0200 |
commit | 9e41e82481753cf13171ab9402bf6f761afc1b66 (patch) | |
tree | ad215306cbaf4fa2b262f7d65271ae5d501d8452 /test/functional/api/vim_spec.lua | |
parent | 9086938f7bd6d6ccb7f4a30fb78aeaf0d84e4471 (diff) | |
download | rneovim-9e41e82481753cf13171ab9402bf6f761afc1b66.tar.gz rneovim-9e41e82481753cf13171ab9402bf6f761afc1b66.tar.bz2 rneovim-9e41e82481753cf13171ab9402bf6f761afc1b66.zip |
feat(nvim_open_term): support input callback in lua
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r-- | test/functional/api/vim_spec.lua | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index f030cfe00e..c95c24fabe 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -22,6 +22,7 @@ local source = helpers.source local next_msg = helpers.next_msg local tmpname = helpers.tmpname local write_file = helpers.write_file +local exec_lua = helpers.exec_lua local pcall_err = helpers.pcall_err local format_string = helpers.format_string @@ -2264,6 +2265,9 @@ describe('API', function() [2] = {background = tonumber('0xffff40'), bg_indexed = true}; [3] = {background = Screen.colors.Plum1, fg_indexed = true, foreground = tonumber('0x00e000')}; [4] = {bold = true, reverse = true, background = Screen.colors.Plum1}; + [5] = {foreground = Screen.colors.Blue, background = Screen.colors.LightMagenta, bold = true}; + [6] = {bold = true}; + [7] = {reverse = true, background = Screen.colors.LightMagenta}; }) end) @@ -2311,6 +2315,74 @@ describe('API', function() | ]]} end) + + it('can handle input', function() + screen:try_resize(50, 10) + eq({3, 2}, exec_lua [[ + buf = vim.api.nvim_create_buf(1,1) + + stream = '' + do_the_echo = false + function input(_,t1,b1,data) + stream = stream .. data + _G.vals = {t1, b1} + if do_the_echo then + vim.api.nvim_chan_send(t1, data) + end + end + + term = vim.api.nvim_open_term(buf, {on_input=input}) + vim.api.nvim_open_win(buf, true, {width=40, height=5, row=1, col=1, relative='editor'}) + return {term, buf} + ]]) + + screen:expect{grid=[[ + | + {0:~}{1:^ }{0: }| + {0:~}{1: }{0: }| + {0:~}{1: }{0: }| + {0:~}{1: }{0: }| + {0:~}{1: }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + + feed 'iba<c-x>bla' + screen:expect{grid=[[ + | + {0:~}{7: }{1: }{0: }| + {0:~}{1: }{0: }| + {0:~}{1: }{0: }| + {0:~}{1: }{0: }| + {0:~}{1: }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {6:-- TERMINAL --} | + ]]} + + eq('ba\024bla', exec_lua [[ return stream ]]) + eq({3,2}, exec_lua [[ return vals ]]) + + exec_lua [[ do_the_echo = true ]] + feed 'herrejösses!' + + screen:expect{grid=[[ + | + {0:~}{1:herrejösses!}{7: }{1: }{0: }| + {0:~}{1: }{0: }| + {0:~}{1: }{0: }| + {0:~}{1: }{0: }| + {0:~}{1: }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {6:-- TERMINAL --} | + ]]} + eq('ba\024blaherrejösses!', exec_lua [[ return stream ]]) + end) end) describe('nvim_del_mark', function() |