Mercurial > vim
comparison src/testdir/term_util.vim @ 31245:fbc4d3b0302d v9.0.0956
patch 9.0.0956: terminal tests fail when using key with modifier
Commit: https://github.com/vim/vim/commit/9f14557d6a5b4f832029c292d7b3359b68336058
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 27 12:45:41 2022 +0000
patch 9.0.0956: terminal tests fail when using key with modifier
Problem: Terminal tests fail when using key with modifier.
Solution: Use the modifyOtherKeys encoding when using RunVimInTerminal().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 27 Nov 2022 14:00:05 +0100 |
parents | 8bb07c88ac27 |
children | a864e75257dd |
comparison
equal
deleted
inserted
replaced
31244:1866e7eb3b85 | 31245:fbc4d3b0302d |
---|---|
187 " Return concatenated lines in terminal. | 187 " Return concatenated lines in terminal. |
188 func Term_getlines(buf, lines) | 188 func Term_getlines(buf, lines) |
189 return join(map(a:lines, 'term_getline(a:buf, v:val)'), '') | 189 return join(map(a:lines, 'term_getline(a:buf, v:val)'), '') |
190 endfunc | 190 endfunc |
191 | 191 |
192 " When using RunVimInTerminal() we expect modifyOtherKeys level 2 to be enabled | |
193 " automatically. The key + modifier Escape codes must then use the | |
194 " modifyOtherKeys encoding. They are recognized anyway, thus it's safer to use | |
195 " than the raw code. | |
196 | |
197 " Return the modifyOtherKeys level 2 encoding for "key" with "modifier" | |
198 " (number value, e.g. CTRL is 5). | |
199 func GetEscCodeCSI27(key, modifier) | |
200 let key = printf("%d", char2nr(a:key)) | |
201 let mod = printf("%d", a:modifier) | |
202 return "\<Esc>[27;" .. mod .. ';' .. key .. '~' | |
203 endfunc | |
204 | |
205 " Return the modifyOtherKeys level 2 encoding for "key" with "modifier" | |
206 " (character value, e.g. CTRL is "C"). | |
207 func GetEscCodeWithModifier(modifier, key) | |
208 let modifier = get({'C': 5}, a:modifier, '') | |
209 if modifier == '' | |
210 echoerr 'Unknown modifier: ' .. a:modifier | |
211 endif | |
212 return GetEscCodeCSI27(a:key, modifier) | |
213 endfunc | |
214 | |
215 " Return the kitty keyboard protocol encoding for "key" with "modifier" | |
216 " (number value, e.g. CTRL is 5). | |
217 func GetEscCodeCSIu(key, modifier) | |
218 let key = printf("%d", char2nr(a:key)) | |
219 let mod = printf("%d", a:modifier) | |
220 return "\<Esc>[" .. key .. ';' .. mod .. 'u' | |
221 endfunc | |
222 | |
223 " Return the kitty keyboard protocol encoding for "key" without a modifier. | |
224 " Used for the Escape key. | |
225 func GetEscCodeCSIuWithoutModifier(key) | |
226 let key = printf("%d", char2nr(a:key)) | |
227 return "\<Esc>[" .. key .. 'u' | |
228 endfunc | |
229 | |
230 | |
192 " vim: shiftwidth=2 sts=2 expandtab | 231 " vim: shiftwidth=2 sts=2 expandtab |