Patch 9.0.0956

4 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 27, 2022, 7:46:31 AM11/27/22
to vim...@googlegroups.com

Patch 9.0.0956
Problem: Terminal tests fail when using key with modifier.
Solution: Use the modifyOtherKeys encoding when using RunVimInTerminal().
Files: src/testdir/test_mapping.vim, src/testdir/test_popupwin.vim,
src/testdir/test_termcodes.vim, src/testdir/term_util.vim


*** ../vim-9.0.0955/src/testdir/test_mapping.vim 2022-11-26 19:16:44.186717893 +0000
--- src/testdir/test_mapping.vim 2022-11-27 12:42:47.716280928 +0000
***************
*** 584,590 ****
END
call writefile(lines, 'XtestExprMap', 'D')
let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10})
! call term_sendkeys(buf, "\<C-B>")
call VerifyScreenDump(buf, 'Test_map_expr_1', {})

" clean up
--- 584,590 ----
END
call writefile(lines, 'XtestExprMap', 'D')
let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10})
! call term_sendkeys(buf, GetEscCodeWithModifier('C', 'B'))
call VerifyScreenDump(buf, 'Test_map_expr_1', {})

" clean up
*** ../vim-9.0.0955/src/testdir/test_popupwin.vim 2022-11-02 13:30:37.546314580 +0000
--- src/testdir/test_popupwin.vim 2022-11-27 12:43:02.352224448 +0000
***************
*** 4,9 ****
--- 4,10 ----
CheckFeature popupwin

source screendump.vim
+ source term_util.vim

func Test_simple_popup()
CheckScreendump
***************
*** 3722,3728 ****
let buf = RunVimInTerminal('-S XtestPopupmenuMasking', #{rows: 14})
call TermWait(buf, 25)

! call term_sendkeys(buf, "A\<C-X>\<C-U>\<C-A>")
call VerifyScreenDump(buf, 'Test_popupwin_popupmenu_masking_1', {})

call term_sendkeys(buf, "\<Esc>")
--- 3723,3731 ----
let buf = RunVimInTerminal('-S XtestPopupmenuMasking', #{rows: 14})
call TermWait(buf, 25)

! call term_sendkeys(buf, "A" .. GetEscCodeWithModifier('C', 'X')
! \ .. GetEscCodeWithModifier('C', 'U')
! \ .. GetEscCodeWithModifier('C', 'A'))
call VerifyScreenDump(buf, 'Test_popupwin_popupmenu_masking_1', {})

call term_sendkeys(buf, "\<Esc>")
*** ../vim-9.0.0955/src/testdir/test_termcodes.vim 2022-11-26 19:16:44.186717893 +0000
--- src/testdir/test_termcodes.vim 2022-11-27 12:35:13.497117286 +0000
***************
*** 2094,2116 ****
call StopVimInTerminal('')
endfunc

- func GetEscCodeCSI27(key, modifier)
- let key = printf("%d", char2nr(a:key))
- let mod = printf("%d", a:modifier)
- return "\<Esc>[27;" .. mod .. ';' .. key .. '~'
- endfunc
-
- func GetEscCodeCSIu(key, modifier)
- let key = printf("%d", char2nr(a:key))
- let mod = printf("%d", a:modifier)
- return "\<Esc>[" .. key .. ';' .. mod .. 'u'
- endfunc
-
- func GetEscCodeCSIuWithoutModifier(key)
- let key = printf("%d", char2nr(a:key))
- return "\<Esc>[" .. key .. 'u'
- endfunc
-
" This checks the CSI sequences when in modifyOtherKeys mode.
" The mode doesn't need to be enabled, the codes are always detected.
func RunTest_modifyOtherKeys(func)
--- 2094,2099 ----
*** ../vim-9.0.0955/src/testdir/term_util.vim 2022-05-20 10:37:59.000000000 +0100
--- src/testdir/term_util.vim 2022-11-27 12:42:38.568316972 +0000
***************
*** 189,192 ****
--- 189,231 ----
return join(map(a:lines, 'term_getline(a:buf, v:val)'), '')
endfunc

+ " When using RunVimInTerminal() we expect modifyOtherKeys level 2 to be enabled
+ " automatically. The key + modifier Escape codes must then use the
+ " modifyOtherKeys encoding. They are recognized anyway, thus it's safer to use
+ " than the raw code.
+
+ " Return the modifyOtherKeys level 2 encoding for "key" with "modifier"
+ " (number value, e.g. CTRL is 5).
+ func GetEscCodeCSI27(key, modifier)
+ let key = printf("%d", char2nr(a:key))
+ let mod = printf("%d", a:modifier)
+ return "\<Esc>[27;" .. mod .. ';' .. key .. '~'
+ endfunc
+
+ " Return the modifyOtherKeys level 2 encoding for "key" with "modifier"
+ " (character value, e.g. CTRL is "C").
+ func GetEscCodeWithModifier(modifier, key)
+ let modifier = get({'C': 5}, a:modifier, '')
+ if modifier == ''
+ echoerr 'Unknown modifier: ' .. a:modifier
+ endif
+ return GetEscCodeCSI27(a:key, modifier)
+ endfunc
+
+ " Return the kitty keyboard protocol encoding for "key" with "modifier"
+ " (number value, e.g. CTRL is 5).
+ func GetEscCodeCSIu(key, modifier)
+ let key = printf("%d", char2nr(a:key))
+ let mod = printf("%d", a:modifier)
+ return "\<Esc>[" .. key .. ';' .. mod .. 'u'
+ endfunc
+
+ " Return the kitty keyboard protocol encoding for "key" without a modifier.
+ " Used for the Escape key.
+ func GetEscCodeCSIuWithoutModifier(key)
+ let key = printf("%d", char2nr(a:key))
+ return "\<Esc>[" .. key .. 'u'
+ endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.0955/src/version.c 2022-11-27 11:31:20.645181563 +0000
--- src/version.c 2022-11-27 12:26:11.696980372 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 956,
/**/

--
hundred-and-one symptoms of being an internet addict:
156. You forget your friend's name but not her e-mail address.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages