To: vim_dev@googlegroups.com Subject: Patch 9.0.0955 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0955 Problem: Libvterm does not support the XTQMODKEYS request. Solution: Implement the XTQMODKEYS request and response. Update the keycode check results. Files: src/libvterm/src/state.c, src/testdir/keycode_check.vim, src/testdir/keycode_check.json *** ../vim-9.0.0954/src/libvterm/src/state.c 2022-11-23 20:19:17.125682463 +0000 --- src/libvterm/src/state.c 2022-11-27 11:05:53.426930794 +0000 *************** *** 1400,1406 **** vterm_state_setpen(state, args, argcount); break; ! case LEADER('?', 0x6d): // DECSGR /* No actual DEC terminal recognised these, but some printers did. These * are alternative ways to request subscript/superscript/off */ --- 1400,1414 ---- vterm_state_setpen(state, args, argcount); break; ! case LEADER('?', 0x6d): // DECSGR and XTQMODKEYS ! // CSI ? 4 m XTQMODKEYS: request modifyOtherKeys level ! if (argcount == 1 && CSI_ARG(args[0]) == 4) ! { ! vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, ">4;%dm", ! state->mode.modify_other_keys ? 2 : 0); ! break; ! } ! /* No actual DEC terminal recognised these, but some printers did. These * are alternative ways to request subscript/superscript/off */ *************** *** 1424,1440 **** break; case LEADER('>', 0x6d): // CSI > 4 ; Pv m xterm resource modifyOtherKeys ! if (argcount == 2 && args[0] == 4) { // can't have both modify_other_keys and kitty_keyboard state->mode.kitty_keyboard = 0; ! state->mode.modify_other_keys = args[1] == 2; } break; case LEADER('>', 0x75): // CSI > 1 u enable kitty keyboard protocol ! if (argcount == 1 && args[0] == 1) { // can't have both modify_other_keys and kitty_keyboard state->mode.modify_other_keys = 0; --- 1432,1448 ---- break; case LEADER('>', 0x6d): // CSI > 4 ; Pv m xterm resource modifyOtherKeys ! if (argcount == 2 && CSI_ARG(args[0]) == 4) { // can't have both modify_other_keys and kitty_keyboard state->mode.kitty_keyboard = 0; ! state->mode.modify_other_keys = CSI_ARG(args[1]) == 2; } break; case LEADER('>', 0x75): // CSI > 1 u enable kitty keyboard protocol ! if (argcount == 1 && CSI_ARG(args[0]) == 1) { // can't have both modify_other_keys and kitty_keyboard state->mode.modify_other_keys = 0; *** ../vim-9.0.0954/src/testdir/keycode_check.vim 2022-11-26 19:16:44.186717893 +0000 --- src/testdir/keycode_check.vim 2022-11-27 11:16:57.745976886 +0000 *************** *** 134,140 **** endif sort(terms) ! var items = ['protocol', 'version', 'status', 'modkeys'] + 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', 'kitty', 'modkeys'] + key_entries->copy()->map((_, v) => v[1]) # For each terminal compute the needed width, add two. *************** *** 194,208 **** ]) echo "\n" &t_TE = "\[>4;m" ! var proto_name = 'none' if proto == 1 ! &t_TI = "" elseif proto == 2 ! # Enable modifyOtherKeys level 2. Request the XTQMODKEYS value. &t_TI = "\[>4;2m" .. "\[?4m" proto_name = 'mok2' elseif proto == 3 ! # Enable Kitty keyboard protocol and request the status &t_TI = "\[>1u" .. "\[?u" proto_name = 'kitty' else --- 194,210 ---- ]) echo "\n" &t_TE = "\[>4;m" ! var proto_name = 'unknown' if proto == 1 ! # Request the XTQMODKEYS value and request the kitty keyboard protocol status. ! &t_TI = "\[?4m" .. "\[?u" ! proto_name = 'none' elseif proto == 2 ! # Enable modifyOtherKeys level 2 and request the XTQMODKEYS value. &t_TI = "\[>4;2m" .. "\[?4m" proto_name = 'mok2' elseif proto == 3 ! # Enable Kitty keyboard protocol and request the status. &t_TI = "\[>1u" .. "\[?u" proto_name = 'kitty' else *************** *** 262,268 **** endif keycodes[name]['protocol'] = proto_name keycodes[name]['version'] = '' ! keycodes[name]['status'] = '' keycodes[name]['modkeys'] = '' # Check the log file for a status and the version response --- 264,270 ---- endif keycodes[name]['protocol'] = proto_name keycodes[name]['version'] = '' ! keycodes[name]['kitty'] = '' keycodes[name]['modkeys'] = '' # Check the log file for a status and the version response *************** *** 277,284 **** # Check for the XTQMODKEYS response. if code =~ modkeys_pattern var modkeys = substitute(code, '.*\(' .. modkeys_pattern .. '\).*', '\1', '') ! # Get the level out of the response ! modkeys = substitute(modkeys, '.*4;\(\d\)m', '\1', '') if keycodes[name]['modkeys'] != '' echomsg 'Another modkeys found after ' .. keycodes[name]['modkeys'] --- 279,287 ---- # Check for the XTQMODKEYS response. if code =~ modkeys_pattern var modkeys = substitute(code, '.*\(' .. modkeys_pattern .. '\).*', '\1', '') ! # We could get the level out of the response, but showing the response ! # itself provides more information. ! # modkeys = substitute(modkeys, '.*4;\(\d\)m', '\1', '') if keycodes[name]['modkeys'] != '' echomsg 'Another modkeys found after ' .. keycodes[name]['modkeys'] *************** *** 292,301 **** # 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 --- 295,304 ---- # use the response itself as the status status = Literal2hex(status) ! if keycodes[name]['kitty'] != '' ! echomsg 'Another status found after ' .. keycodes[name]['kitty'] endif ! keycodes[name]['kitty'] = status endif if code =~ version_pattern *** ../vim-9.0.0954/src/testdir/keycode_check.json 2022-11-26 19:16:44.186717893 +0000 --- src/testdir/keycode_check.json 2022-11-27 11:30:02.637228419 +0000 *************** *** 1 **** ! {"31kitty":{"Space":"20","version":"1b5b3e313b343030303b323163","C-Tab":"","A-Esc":"1b5b32373b313175","C-Space":"1b5b33323b3575","status":"1b5b3f3175","S-C-I":"1b5b3130353b3675","C-I":"1b5b3130353b3575","S-Tab":"1b5b393b3275","Tab":"09","resource":"","A-Tab":"1b5b393b313175","S-Space":"20","C-Esc":"1b5b32373b3575","protocol":"kitty","A-Space":"1b5b33323b313175","S-Esc":"1b5b32373b3275","Esc":"1b5b323775"},"32libvterm":{"Space":"20","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b393b3575","A-Esc":"1b5b32373b3375","C-Space":"1b5b33323b3575","status":"1b5b3f3175","S-C-I":"1b5b3130353b3675","C-I":"1b5b3130353b3575","S-Tab":"1b5b393b3275","Tab":"09","resource":"","A-Tab":"1b5b393b3375","S-Space":"1b5b33323b3275","C-Esc":"1b5b32373b3575","protocol":"kitty","A-Space":"1b5b33323b3375","S-Esc":"1b5b323775","Esc":"1b5b323775"},"22libvterm":{"Space":"20","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b32373b353b397e","A-Esc":"1b5b32373b333b32377e","C-Space":"1b5b32373b353b33327e","status":"","S-C-I":"1b5b32373b363b37337e","C-I":"1b5b32373b353b3130357e","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"1b5b32373b333b397e","S-Space":"1b5b32373b323b33327e","C-Esc":"1b5b32373b353b32377e","protocol":"mok2","A-Space":"1b5b32373b333b33327e","S-Esc":"1b5b32373b323b32377e","Esc":"1b"},"13kitty":{"Space":"20","version":"1b5b3e313b343030303b323163","C-Tab":"","A-Esc":"1b1b","status":"","S-C-I":"1b5b3130353b3675","C-I":"09","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"1b09","S-Space":"20","C-Esc":"1b","protocol":"none","A-Space":"1b5b33323b313175","S-Esc":"1b","Esc":"1b"},"21xterm":{"Space":"20","modkeys":"2","version":"1b5b3e34313b3337373b3063","C-Tab":"1b5b32373b353b397e","A-Esc":"1b5b32373b333b32377e","C-Space":"1b5b32373b353b33327e","status":"","S-C-I":"1b5b32373b363b37337e","C-I":"1b5b32373b353b3130357e","S-Tab":"1b5b5a","Tab":"09","resource":"=30","A-Tab":"1b5b32373b333b397e","S-Space":"1b5b32373b323b33327e","C-Esc":"1b5b32373b353b32377e","protocol":"mok2","A-Space":"1b5b32373b333b33327e","S-Esc":"1b5b32373b323b32377e","Esc":"1b"},"12libvterm":{"Space":"20","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b393b3575","A-Esc":"9b00","status":"","S-C-I":"1b5b5a","C-I":"09","S-Tab":"1b5b5a","Tab":"09","S-Space":"1b5b33323b3275","A-Tab":"8900","resource":"","C-Esc":"1b5b32373b3575","protocol":"none","A-Space":"a000","S-Esc":"1b","Esc":"1b"},"11xterm":{"Space":"20","version":"1b5b3e34313b3337373b3063","C-Tab":"09","A-Esc":"9b00","status":"","S-C-I":"09","C-I":"09","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"8900","S-Space":"20","C-Esc":"1b","protocol":"none","A-Space":"a000","S-Esc":"1b","Esc":"1b"}} --- 1 ---- ! {"31kitty":{"Space":"20","modkeys":"","version":"1b5b3e313b343030303b323163","C-Tab":"","A-Esc":"1b5b32373b313175","C-Space":"1b5b33323b3575","S-C-I":"1b5b3130353b3675","C-I":"1b5b3130353b3575","S-Tab":"1b5b393b3275","Tab":"09","resource":"","A-Tab":"1b5b393b313175","S-Space":"20","C-Esc":"1b5b32373b3575","kitty":"1b5b3f3175","protocol":"kitty","A-Space":"1b5b33323b313175","S-Esc":"1b5b32373b3275","Esc":"1b5b323775"},"32libvterm":{"Space":"20","modkeys":"","version":"1b5b3e303b3130303b3063","C-Tab":"","A-Esc":"1b5b32373b3375","C-Space":"1b5b33323b3575","S-C-I":"1b5b3130353b3675","C-I":"1b5b3130353b3575","S-Tab":"1b5b393b3275","Tab":"09","resource":"","A-Tab":"1b5b393b3375","S-Space":"20","C-Esc":"1b5b32373b3575","kitty":"1b5b3f3175","protocol":"kitty","A-Space":"1b5b33323b3375","S-Esc":"1b5b32373b3275","Esc":"1b5b323775"},"22libvterm":{"Space":"20","modkeys":"\u001b[>4;2m","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b32373b353b397e","A-Esc":"1b5b32373b333b32377e","C-Space":"1b5b32373b353b33327e","S-C-I":"1b5b32373b363b37337e","C-I":"1b5b32373b353b3130357e","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"1b5b32373b333b397e","S-Space":"1b5b32373b323b33327e","C-Esc":"1b5b32373b353b32377e","kitty":"","protocol":"mok2","A-Space":"1b5b32373b333b33327e","S-Esc":"1b5b32373b323b32377e","Esc":"1b"},"13kitty":{"Space":"20","modkeys":"","version":"1b5b3e313b343030303b323163","C-Tab":"","A-Esc":"1b1b","S-C-I":"1b5b3130353b3675","C-I":"09","S-Tab":"1b5b5a","Tab":"09","S-Space":"20","A-Tab":"1b09","resource":"","C-Esc":"1b","kitty":"1b5b3f3075","protocol":"none","A-Space":"1b5b33323b313175","S-Esc":"1b","Esc":"1b"},"21xterm":{"Space":"20","modkeys":"\u001b[>4;2m","version":"1b5b3e34313b3337373b3063","C-Tab":"1b5b32373b353b397e","A-Esc":"1b5b32373b333b32377e","C-Space":"1b5b32373b353b33327e","S-C-I":"1b5b32373b363b37337e","C-I":"1b5b32373b353b3130357e","S-Tab":"1b5b5a","Tab":"09","resource":"=30","A-Tab":"1b5b32373b333b397e","S-Space":"1b5b32373b323b33327e","C-Esc":"1b5b32373b353b32377e","kitty":"","protocol":"mok2","A-Space":"1b5b32373b333b33327e","S-Esc":"1b5b32373b323b32377e","Esc":"1b"},"12libvterm":{"Space":"20","modkeys":"\u001b[>4;0m","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b393b3575","A-Esc":"9b00","S-C-I":"1b5b5a","C-I":"09","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"8900","S-Space":"1b5b33323b3275","C-Esc":"1b5b32373b3575","kitty":"1b5b3f3075","protocol":"none","A-Space":"a000","S-Esc":"1b5b32373b3275","Esc":"1b"},"11xterm":{"Space":"20","modkeys":"\u001b[>4;0m","version":"1b5b3e34313b3337373b3063","C-Tab":"09","A-Esc":"9b00","S-C-I":"09","C-I":"09","S-Tab":"1b5b5a","Tab":"09","S-Space":"20","A-Tab":"8900","resource":"","C-Esc":"1b","kitty":"","protocol":"none","A-Space":"a000","S-Esc":"1b","Esc":"1b"}} *** ../vim-9.0.0954/src/version.c 2022-11-26 19:16:44.186717893 +0000 --- src/version.c 2022-11-27 11:01:02.867610285 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 955, /**/ -- hundred-and-one symptoms of being an internet addict: 155. You forget to eat because you're too busy surfing the net. /// Bram Moolenaar -- Bram@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 ///