mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.0903: key code checker doesn't check modifyOtherKeys resource
Problem: Key code checker doesn't check modifyOtherKeys resource. Solution: Request the modifyOtherKeys resource value. Drop resource DCS responses.
This commit is contained in:
parent
696d0a8625
commit
236dffab43
16
src/term.c
16
src/term.c
@ -5244,6 +5244,9 @@ handle_osc(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen)
|
|||||||
* {flag} can be '0' or '1'
|
* {flag} can be '0' or '1'
|
||||||
* {tail} can be Esc>\ or STERM
|
* {tail} can be Esc>\ or STERM
|
||||||
*
|
*
|
||||||
|
* Check for resource response from xterm (and drop it):
|
||||||
|
* {lead}{flag}+R<hex bytes>=<value>{tail}
|
||||||
|
*
|
||||||
* Check for cursor shape response from xterm:
|
* Check for cursor shape response from xterm:
|
||||||
* {lead}1$r<digit> q{tail}
|
* {lead}1$r<digit> q{tail}
|
||||||
*
|
*
|
||||||
@ -5260,7 +5263,8 @@ handle_dcs(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen)
|
|||||||
j = 1 + (tp[0] == ESC);
|
j = 1 + (tp[0] == ESC);
|
||||||
if (len < j + 3)
|
if (len < j + 3)
|
||||||
i = len; // need more chars
|
i = len; // need more chars
|
||||||
else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r')
|
else if ((argp[1] != '+' && argp[1] != '$')
|
||||||
|
|| (argp[2] != 'r' && argp[2] != 'R'))
|
||||||
i = 0; // no match
|
i = 0; // no match
|
||||||
else if (argp[1] == '+')
|
else if (argp[1] == '+')
|
||||||
// key code response
|
// key code response
|
||||||
@ -5269,7 +5273,8 @@ handle_dcs(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen)
|
|||||||
if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\')
|
if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\')
|
||||||
|| tp[i] == STERM)
|
|| tp[i] == STERM)
|
||||||
{
|
{
|
||||||
if (i - j >= 3)
|
// handle a key code response, drop a resource response
|
||||||
|
if (i - j >= 3 && argp[2] == 'r')
|
||||||
got_code_from_term(tp + j, i);
|
got_code_from_term(tp + j, i);
|
||||||
key_name[0] = (int)KS_EXTRA;
|
key_name[0] = (int)KS_EXTRA;
|
||||||
key_name[1] = (int)KE_IGNORE;
|
key_name[1] = (int)KE_IGNORE;
|
||||||
@ -5674,9 +5679,10 @@ check_termcode(
|
|||||||
|
|
||||||
// Check for key code response from xterm,
|
// Check for key code response from xterm,
|
||||||
// starting with <Esc>P or DCS
|
// starting with <Esc>P or DCS
|
||||||
else if ((check_for_codes || rcs_status.tr_progress == STATUS_SENT)
|
// It would only be needed with this condition:
|
||||||
&& ((tp[0] == ESC && len >= 2 && tp[1] == 'P')
|
// (check_for_codes || rcs_status.tr_progress == STATUS_SENT)
|
||||||
|| tp[0] == DCS))
|
// Now this is always done so that DCS codes don't mess up things.
|
||||||
|
else if ((tp[0] == ESC && len >= 2 && tp[1] == 'P') || tp[0] == DCS)
|
||||||
{
|
{
|
||||||
if (handle_dcs(tp, argp, len, key_name, &slen) == FAIL)
|
if (handle_dcs(tp, argp, len, key_name, &slen) == FAIL)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -134,7 +134,7 @@ def ActionList()
|
|||||||
endif
|
endif
|
||||||
sort(terms)
|
sort(terms)
|
||||||
|
|
||||||
var items = ['protocol', 'version', 'status']
|
var items = ['protocol', 'version', 'status', 'resource']
|
||||||
+ key_entries->copy()->map((_, v) => v[1])
|
+ key_entries->copy()->map((_, v) => v[1])
|
||||||
|
|
||||||
# For each terminal compute the needed width, add two.
|
# For each terminal compute the needed width, add two.
|
||||||
@ -198,8 +198,9 @@ def DoTerm(name: string)
|
|||||||
if proto == 1
|
if proto == 1
|
||||||
&t_TI = ""
|
&t_TI = ""
|
||||||
elseif proto == 2
|
elseif proto == 2
|
||||||
# Enable modifyOtherKeys level 2 - no status is reported
|
# Enable modifyOtherKeys level 2
|
||||||
&t_TI = "\<Esc>[>4;2m"
|
# Request the resource value: DCS + Q modifyOtherKeys ST
|
||||||
|
&t_TI = "\<Esc>[>4;2m" .. "\<Esc>P+Q6d6f646966794f746865724b657973\<Esc>\\"
|
||||||
proto_name = 'mok2'
|
proto_name = 'mok2'
|
||||||
elseif proto == 3
|
elseif proto == 3
|
||||||
# Enable Kitty keyboard protocol and request the status
|
# Enable Kitty keyboard protocol and request the status
|
||||||
@ -217,9 +218,14 @@ def DoTerm(name: string)
|
|||||||
# Pattern that matches the line with the version response.
|
# Pattern that matches the line with the version response.
|
||||||
const version_pattern = "\<Esc>\\[>\\d\\+;\\d\\+;\\d*c"
|
const version_pattern = "\<Esc>\\[>\\d\\+;\\d\\+;\\d*c"
|
||||||
|
|
||||||
|
# Pattern that matches the resource value response:
|
||||||
|
# DCS 1 + R Pt ST valid
|
||||||
|
# DCS 0 + R Pt ST invalid
|
||||||
|
const resource_pattern = "\<Esc>P[01]+R.*\<Esc>\\\\"
|
||||||
|
|
||||||
# Pattern that matches the line with the status. Currently what terminals
|
# Pattern that matches the line with the status. Currently what terminals
|
||||||
# return for the Kitty keyboard protocol.
|
# return for the Kitty keyboard protocol.
|
||||||
const status_pattern = "\<Esc>\\[?\\d\\+u"
|
const kitty_status_pattern = "\<Esc>\\[?\\d\\+u"
|
||||||
|
|
||||||
ch_logfile('keylog', 'w')
|
ch_logfile('keylog', 'w')
|
||||||
|
|
||||||
@ -244,6 +250,7 @@ def DoTerm(name: string)
|
|||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
if reltime(startTime)->reltimefloat() > 3
|
if reltime(startTime)->reltimefloat() > 3
|
||||||
|
# break out after three seconds
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
@ -257,18 +264,39 @@ def DoTerm(name: string)
|
|||||||
keycodes[name]['protocol'] = proto_name
|
keycodes[name]['protocol'] = proto_name
|
||||||
keycodes[name]['version'] = ''
|
keycodes[name]['version'] = ''
|
||||||
keycodes[name]['status'] = ''
|
keycodes[name]['status'] = ''
|
||||||
|
keycodes[name]['resource'] = ''
|
||||||
|
|
||||||
# Check the log file for a status and the version response
|
# Check the log file for a status and the version response
|
||||||
ch_logfile('', '')
|
ch_logfile('', '')
|
||||||
var log = readfile('keylog')
|
var log = readfile('keylog')
|
||||||
delete('keylog')
|
delete('keylog')
|
||||||
|
|
||||||
for line in log
|
for line in log
|
||||||
if line =~ 'raw key input'
|
if line =~ 'raw key input'
|
||||||
var code = substitute(line, '.*raw key input: "\([^"]*\).*', '\1', '')
|
var code = substitute(line, '.*raw key input: "\([^"]*\).*', '\1', '')
|
||||||
|
|
||||||
|
# Check for resource value response
|
||||||
|
if code =~ resource_pattern
|
||||||
|
var resource = substitute(code, '.*\(' .. resource_pattern .. '\).*', '\1', '')
|
||||||
|
# use the value as the resource, "=30" means zero
|
||||||
|
resource = substitute(resource, '.*\(=\p\+\).*', '\1', '')
|
||||||
|
|
||||||
|
if keycodes[name]['resource'] != ''
|
||||||
|
echomsg 'Another resource found after ' .. keycodes[name]['resource']
|
||||||
|
endif
|
||||||
|
keycodes[name]['resource'] = resource
|
||||||
|
endif
|
||||||
|
|
||||||
# Check for kitty keyboard protocol status
|
# Check for kitty keyboard protocol status
|
||||||
if code =~ status_pattern
|
if code =~ kitty_status_pattern
|
||||||
var status = substitute(code, '.*\(' .. status_pattern .. '\).*', '\1', '')
|
var status = substitute(code, '.*\(' .. kitty_status_pattern .. '\).*', '\1', '')
|
||||||
keycodes[name]['status'] = Literal2hex(status)
|
# use the response itself as the status
|
||||||
|
status = Literal2hex(status)
|
||||||
|
|
||||||
|
if keycodes[name]['status'] != ''
|
||||||
|
echomsg 'Another status found after ' .. keycodes[name]['status']
|
||||||
|
endif
|
||||||
|
keycodes[name]['status'] = status
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if code =~ version_pattern
|
if code =~ version_pattern
|
||||||
@ -282,13 +310,23 @@ def DoTerm(name: string)
|
|||||||
echo "For Alt to work you may need to press the Windows/Super key as well"
|
echo "For Alt to work you may need to press the Windows/Super key as well"
|
||||||
echo "When a key press doesn't get to Vim (e.g. when using Alt) press x"
|
echo "When a key press doesn't get to Vim (e.g. when using Alt) press x"
|
||||||
|
|
||||||
|
# The log of ignored typeahead is left around for debugging, start with an
|
||||||
|
# empty file here.
|
||||||
|
delete('keylog-ignore')
|
||||||
|
|
||||||
for entry in key_entries
|
for entry in key_entries
|
||||||
# Consume any typeahead. Wait a bit for any responses to arrive.
|
# Consume any typeahead. Wait a bit for any responses to arrive.
|
||||||
sleep 100m
|
ch_logfile('keylog-ignore', 'a')
|
||||||
while getchar(1)
|
while 1
|
||||||
getchar()
|
|
||||||
sleep 100m
|
sleep 100m
|
||||||
|
if !getchar(1)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
while getchar(1)
|
||||||
|
getchar()
|
||||||
|
endwhile
|
||||||
endwhile
|
endwhile
|
||||||
|
ch_logfile('', '')
|
||||||
|
|
||||||
ch_logfile('keylog', 'w')
|
ch_logfile('keylog', 'w')
|
||||||
echo $'Press the {entry[0]} key (q to quit):'
|
echo $'Press the {entry[0]} key (q to quit):'
|
||||||
@ -297,13 +335,9 @@ def DoTerm(name: string)
|
|||||||
if r == 'q'
|
if r == 'q'
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
|
|
||||||
log = readfile('keylog')
|
log = readfile('keylog')
|
||||||
if entry[1] == 'Tab'
|
delete('keylog')
|
||||||
# keep a copy
|
|
||||||
rename('keylog', 'keylog-tab')
|
|
||||||
else
|
|
||||||
delete('keylog')
|
|
||||||
endif
|
|
||||||
if len(log) < 2
|
if len(log) < 2
|
||||||
echoerr 'failed to read result'
|
echoerr 'failed to read result'
|
||||||
return
|
return
|
||||||
@ -321,7 +355,7 @@ rename('keylog', 'keylog-tab')
|
|||||||
code = substitute(code, cappat, '', 'g')
|
code = substitute(code, cappat, '', 'g')
|
||||||
|
|
||||||
# Remove any kitty status reply
|
# Remove any kitty status reply
|
||||||
code = substitute(code, status_pattern, '', 'g')
|
code = substitute(code, kitty_status_pattern, '', 'g')
|
||||||
if code == ''
|
if code == ''
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
903,
|
||||||
/**/
|
/**/
|
||||||
902,
|
902,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user