Patch 9.0.0903
Problem: Key code checker doesn't check modifyOtherKeys resource.
Solution: Request the modifyOtherKeys resource value. Drop resource DCS
responses.
Files: src/term.c, src/testdir/keycode_check.vim
*** ../vim-9.0.0902/src/term.c 2022-11-17 22:05:08.602034256 +0000
--- src/term.c 2022-11-18 21:08:10.678990245 +0000
***************
*** 5244,5249 ****
--- 5244,5252 ----
* {flag} can be '0' or '1'
* {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:
* {lead}1$r<digit> q{tail}
*
***************
*** 5260,5266 ****
j = 1 + (tp[0] == ESC);
if (len < j + 3)
i = len; // need more chars
! else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r')
i = 0; // no match
else if (argp[1] == '+')
// key code response
--- 5263,5270 ----
j = 1 + (tp[0] == ESC);
if (len < j + 3)
i = len; // need more chars
! else if ((argp[1] != '+' && argp[1] != '$')
! || (argp[2] != 'r' && argp[2] != 'R'))
i = 0; // no match
else if (argp[1] == '+')
// key code response
***************
*** 5269,5275 ****
if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\')
|| tp[i] == STERM)
{
! if (i - j >= 3)
got_code_from_term(tp + j, i);
key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE;
--- 5273,5280 ----
if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\')
|| tp[i] == STERM)
{
! // handle a key code response, drop a resource response
! if (i - j >= 3 && argp[2] == 'r')
got_code_from_term(tp + j, i);
key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE;
***************
*** 5674,5682 ****
// Check for key code response from xterm,
// starting with <Esc>P or DCS
! else if ((check_for_codes || rcs_status.tr_progress == STATUS_SENT)
! && ((tp[0] == ESC && len >= 2 && tp[1] == 'P')
! || tp[0] == DCS))
{
if (handle_dcs(tp, argp, len, key_name, &slen) == FAIL)
return -1;
--- 5679,5688 ----
// Check for key code response from xterm,
// starting with <Esc>P or DCS
! // It would only be needed with this condition:
! // (check_for_codes || rcs_status.tr_progress == STATUS_SENT)
! // 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)
return -1;
*** ../vim-9.0.0902/src/testdir/keycode_check.vim 2022-11-16
16:08:26.987063566 +0000
--- src/testdir/keycode_check.vim 2022-11-18 21:19:22.983286114 +0000
***************
*** 134,140 ****
endif
sort(terms)
! var items = ['protocol', 'version', 'status']
+ key_entries->copy()->map((_, v) => v[1])
# For each terminal compute the needed width, add two.
--- 134,140 ----
endif
sort(terms)
! var items = ['protocol', 'version', 'status', 'resource']
+ key_entries->copy()->map((_, v) => v[1])
# For each terminal compute the needed width, add two.
***************
*** 198,205 ****
if proto == 1
&t_TI = ""
elseif proto == 2
! # Enable modifyOtherKeys level 2 - no status is reported
! &t_TI = "\<Esc>[>4;2m"
proto_name = 'mok2'
elseif proto == 3
# Enable Kitty keyboard protocol and request the status
--- 198,206 ----
if proto == 1
&t_TI = ""
elseif proto == 2
! # Enable modifyOtherKeys level 2
! # Request the resource value: DCS + Q modifyOtherKeys ST
! &t_TI = "\<Esc>[>4;2m" ..
"\<Esc>P+Q6d6f646966794f746865724b657973\<Esc>\\"
proto_name = 'mok2'
elseif proto == 3
# Enable Kitty keyboard protocol and request the status
***************
*** 217,225 ****
# Pattern that matches the line with the version response.
const version_pattern = "\<Esc>\\[>\\d\\+;\\d\\+;\\d*c"
# Pattern that matches the line with the status. Currently what terminals
# return for the Kitty keyboard protocol.
! const status_pattern = "\<Esc>\\[?\\d\\+u"
ch_logfile('keylog', 'w')
--- 218,231 ----
# Pattern that matches the line with the version response.
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
# return for the Kitty keyboard protocol.
! const kitty_status_pattern = "\<Esc>\\[?\\d\\+u"
ch_logfile('keylog', 'w')
***************
*** 244,249 ****
--- 250,256 ----
endfor
endif
if reltime(startTime)->reltimefloat() > 3
+ # break out after three seconds
break
endif
endwhile
***************
*** 257,274 ****
keycodes[name]['protocol'] = proto_name
keycodes[name]['version'] = ''
keycodes[name]['status'] = ''
# Check the log file for a status and the version response
ch_logfile('', '')
var log = readfile('keylog')
delete('keylog')
for line in log
if line =~ 'raw key input'
var code = substitute(line, '.*raw key input: "\([^"]*\).*', '\1', '')
# Check for kitty keyboard protocol status
! if code =~ status_pattern
! var status = substitute(code, '.*\(' .. status_pattern .. '\).*', '\1',
'')
! keycodes[name]['status'] = Literal2hex(status)
endif
if code =~ version_pattern
--- 264,302 ----
keycodes[name]['protocol'] = proto_name
keycodes[name]['version'] = ''
keycodes[name]['status'] = ''
+ keycodes[name]['resource'] = ''
# Check the log file for a status and the version response
ch_logfile('', '')
var log = readfile('keylog')
delete('keylog')
+
for line in log
if line =~ 'raw key input'
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
! if code =~ kitty_status_pattern
! var status = substitute(code, '.*\(' .. kitty_status_pattern .. '\).*',
'\1', '')
! # 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
if code =~ version_pattern
***************
*** 282,294 ****
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"
for entry in key_entries
# Consume any typeahead. Wait a bit for any responses to arrive.
! sleep 100m
! while getchar(1)
! getchar()
sleep 100m
endwhile
ch_logfile('keylog', 'w')
echo $'Press the {entry[0]} key (q to quit):'
--- 310,332 ----
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"
+ # The log of ignored typeahead is left around for debugging, start with an
+ # empty file here.
+ delete('keylog-ignore')
+
for entry in key_entries
# Consume any typeahead. Wait a bit for any responses to arrive.
! ch_logfile('keylog-ignore', 'a')
! while 1
sleep 100m
+ if !getchar(1)
+ break
+ endif
+ while getchar(1)
+ getchar()
+ endwhile
endwhile
+ ch_logfile('', '')
ch_logfile('keylog', 'w')
echo $'Press the {entry[0]} key (q to quit):'
***************
*** 297,309 ****
if r == 'q'
break
endif
log = readfile('keylog')
! if entry[1] == 'Tab'
! # keep a copy
! rename('keylog', 'keylog-tab')
! else
! delete('keylog')
! endif
if len(log) < 2
echoerr 'failed to read result'
return
--- 335,343 ----
if r == 'q'
break
endif
+
log = readfile('keylog')
! delete('keylog')
if len(log) < 2
echoerr 'failed to read result'
return
***************
*** 321,327 ****
code = substitute(code, cappat, '', 'g')
# Remove any kitty status reply
! code = substitute(code, status_pattern, '', 'g')
if code == ''
continue
endif
--- 355,361 ----
code = substitute(code, cappat, '', 'g')
# Remove any kitty status reply
! code = substitute(code, kitty_status_pattern, '', 'g')
if code == ''
continue
endif
*** ../vim-9.0.0902/src/version.c 2022-11-18 17:53:29.761863978 +0000
--- src/version.c 2022-11-18 21:13:22.195127327 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 903,
/**/
--
>From "know your smileys":
:'-D Laughing so much that they're crying
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20221118212057.76DF71C0A23%40moolenaar.net.