comparison src/testdir/test_termcodes.vim @ 18289:16dd8ebc2339 v8.1.2139

patch 8.1.2139: the modifyOtherKeys codes are not tested Commit: https://github.com/vim/vim/commit/18a79a68413365cd7672728d54615ca708764e23 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 12 15:36:11 2019 +0200 patch 8.1.2139: the modifyOtherKeys codes are not tested Problem: The modifyOtherKeys codes are not tested. Solution: Add a test case.
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Oct 2019 15:45:06 +0200
parents db8cd5e56586
children 43e9523f6d84
comparison
equal deleted inserted replaced
18288:d65f4e1cc30f 18289:16dd8ebc2339
843 let &term = term_save 843 let &term = term_save
844 endif 844 endif
845 845
846 set ttybuiltin 846 set ttybuiltin
847 endfunc 847 endfunc
848
849 func GetEscCodeCSI27(key, modifier)
850 let key = printf("%d", char2nr(a:key))
851 let mod = printf("%d", a:modifier)
852 return "\<Esc>[27;" .. mod .. ';' .. key .. '~'
853 endfunc
854
855 func GetEscCodeCSIu(key, modifier)
856 let key = printf("%d", char2nr(a:key))
857 let mod = printf("%d", a:modifier)
858 return "\<Esc>[" .. key .. ';' .. mod .. 'u'
859 endfunc
860
861 " This checks the CSI sequences when in modifyOtherKeys mode.
862 " The mode doesn't need to be enabled, the codes are always detected.
863 func RunTest_modifyOtherKeys(func)
864 new
865 set timeoutlen=20
866
867 " Shift-X is send as 'X' with the shift modifier
868 call feedkeys('a' .. a:func('X', 2) .. "\<Esc>", 'Lx!')
869 call assert_equal('X', getline(1))
870
871 " Ctrl-i is Tab
872 call setline(1, '')
873 call feedkeys('a' .. a:func('i', 5) .. "\<Esc>", 'Lx!')
874 call assert_equal("\t", getline(1))
875
876 " Ctrl-I is also Tab
877 call setline(1, '')
878 call feedkeys('a' .. a:func('I', 5) .. "\<Esc>", 'Lx!')
879 call assert_equal("\t", getline(1))
880
881 " Alt-x is ø
882 call setline(1, '')
883 call feedkeys('a' .. a:func('x', 3) .. "\<Esc>", 'Lx!')
884 call assert_equal("ø", getline(1))
885
886 " Meta-x is also ø
887 call setline(1, '')
888 call feedkeys('a' .. a:func('x', 9) .. "\<Esc>", 'Lx!')
889 call assert_equal("ø", getline(1))
890
891 " Alt-X is Ø
892 call setline(1, '')
893 call feedkeys('a' .. a:func('X', 3) .. "\<Esc>", 'Lx!')
894 call assert_equal("Ø", getline(1))
895
896 " Meta-X is ø
897 call setline(1, '')
898 call feedkeys('a' .. a:func('X', 9) .. "\<Esc>", 'Lx!')
899 call assert_equal("Ø", getline(1))
900
901 bwipe!
902 set timeoutlen&
903 endfunc
904
905 func Test_modifyOtherKeys_CSI27()
906 call RunTest_modifyOtherKeys(function('GetEscCodeCSI27'))
907 endfunc
908
909 func Test_modifyOtherKeys_CSIu()
910 call RunTest_modifyOtherKeys(function('GetEscCodeCSIu'))
911 endfunc