To: vim_dev@googlegroups.com Subject: Patch 8.2.2084 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2084 Problem: CTRL-V U doesn't work to enter a Unicode character when modifyOtherKeys is effective. (Ken Takata) Solution: Add a flag to get_literal() for the shift key. (closes #7413) Files: src/edit.c, src/proto/edit.pro, src/ex_getln.c, src/getchar.c, src/normal.c, src/testdir/test_termcodes.vim *** ../vim-8.2.2083/src/edit.c 2020-11-14 21:34:12.249496540 +0100 --- src/edit.c 2020-12-03 19:46:29.311493614 +0100 *************** *** 1534,1540 **** { int c; int did_putchar = FALSE; - int prev_mod_mask = mod_mask; // may need to redraw when no more chars available now ins_redraw(FALSE); --- 1534,1539 ---- *************** *** 1550,1556 **** add_to_showcmd_c(Ctrl_V); #endif ! c = get_literal(); if (did_putchar) // when the line fits in 'columns' the '^' is at the start of the next // line and will not removed by the redraw --- 1549,1557 ---- add_to_showcmd_c(Ctrl_V); #endif ! // Do not change any modifyOtherKeys ESC sequence to a normal key for ! // CTRL-SHIFT-V. ! c = get_literal(mod_mask & MOD_MASK_SHIFT); if (did_putchar) // when the line fits in 'columns' the '^' is at the start of the next // line and will not removed by the redraw *************** *** 1559,1569 **** clear_showcmd(); #endif - if ((c == ESC || c == CSI) && !(prev_mod_mask & MOD_MASK_SHIFT)) - // Using CTRL-V: Change any modifyOtherKeys ESC sequence to a normal - // key. Don't do this for CTRL-SHIFT-V. - c = decodeModifyOtherKeys(c); - insert_special(c, FALSE, TRUE); #ifdef FEAT_RIGHTLEFT revins_chars++; --- 1560,1565 ---- *************** *** 1845,1853 **** * A one, two or three digit decimal number is interpreted as its byte value. * If one or two digits are entered, the next character is given to vungetc(). * For Unicode a character > 255 may be returned. */ int ! get_literal(void) { int cc; int nc; --- 1841,1851 ---- * A one, two or three digit decimal number is interpreted as its byte value. * If one or two digits are entered, the next character is given to vungetc(). * For Unicode a character > 255 may be returned. + * If "noReduceKeys" is TRUE do not change any modifyOtherKeys ESC sequence + * into a normal key, return ESC. */ int ! get_literal(int noReduceKeys) { int cc; int nc; *************** *** 1878,1883 **** --- 1876,1884 ---- for (;;) { nc = plain_vgetc(); + if ((nc == ESC || nc == CSI) && !noReduceKeys) + nc = decodeModifyOtherKeys(nc); + #ifdef FEAT_CMDL_INFO if (!(State & CMDLINE) && MB_BYTE2LEN_CHECK(nc) == 1) add_to_showcmd(nc); *************** *** 3812,3819 **** { if (State & VREPLACE_FLAG) restart_edit = 'V'; ! else ! if (State & REPLACE_FLAG) restart_edit = 'R'; else restart_edit = 'I'; --- 3813,3819 ---- { if (State & VREPLACE_FLAG) restart_edit = 'V'; ! else if (State & REPLACE_FLAG) restart_edit = 'R'; else restart_edit = 'I'; *** ../vim-8.2.2083/src/proto/edit.pro 2020-09-05 15:48:32.469546692 +0200 --- src/proto/edit.pro 2020-12-03 19:34:12.849669769 +0100 *************** *** 10,16 **** void undisplay_dollar(void); void truncate_spaces(char_u *line); void backspace_until_column(int col); ! int get_literal(void); void insertchar(int c, int flags, int second_indent); void start_arrow(pos_T *end_insert_pos); int stop_arrow(void); --- 10,16 ---- void undisplay_dollar(void); void truncate_spaces(char_u *line); void backspace_until_column(int col); ! int get_literal(int noReduceKeys); void insertchar(int c, int flags, int second_indent); void start_arrow(pos_T *end_insert_pos); int stop_arrow(void); *** ../vim-8.2.2083/src/ex_getln.c 2020-11-14 14:21:59.518406461 +0100 --- src/ex_getln.c 2020-12-03 19:46:58.567401250 +0100 *************** *** 2206,2218 **** case Ctrl_V: case Ctrl_Q: { - int prev_mod_mask = mod_mask; - ignore_drag_release = TRUE; putcmdline('^', TRUE); ! no_reduce_keys = TRUE; // don't merge modifyOtherKeys ! c = get_literal(); // get next (two) character(s) ! no_reduce_keys = FALSE; do_abbr = FALSE; // don't do abbreviation now extra_char = NUL; // may need to remove ^ when composing char was typed --- 2206,2219 ---- case Ctrl_V: case Ctrl_Q: { ignore_drag_release = TRUE; putcmdline('^', TRUE); ! ! // Get next (two) character(s). Do not change any ! // modifyOtherKeys ESC sequence to a normal key for ! // CTRL-SHIFT-V. ! c = get_literal(mod_mask & MOD_MASK_SHIFT); ! do_abbr = FALSE; // don't do abbreviation now extra_char = NUL; // may need to remove ^ when composing char was typed *************** *** 2223,2235 **** msg_putchar(' '); cursorcmd(); } - - if ((c == ESC || c == CSI) - && !(prev_mod_mask & MOD_MASK_SHIFT)) - // Using CTRL-V: Change any modifyOtherKeys ESC - // sequence to a normal key. Don't do this for - // CTRL-SHIFT-V. - c = decodeModifyOtherKeys(c); } break; --- 2224,2229 ---- *** ../vim-8.2.2083/src/getchar.c 2020-11-28 14:43:23.950237798 +0100 --- src/getchar.c 2020-12-03 19:40:42.084564340 +0100 *************** *** 2580,2590 **** typebuf.tb_off] == RM_YES)) && !*timedout) { ! keylen = check_termcode(max_mlen + 1, ! NULL, 0, NULL); ! // If no termcode matched but 'pastetoggle' matched partially it's ! // like an incomplete key sequence. if (keylen == 0 && save_keylen == KEYLEN_PART_KEY) keylen = KEYLEN_PART_KEY; --- 2580,2589 ---- typebuf.tb_off] == RM_YES)) && !*timedout) { ! keylen = check_termcode(max_mlen + 1, NULL, 0, NULL); ! // If no termcode matched but 'pastetoggle' matched partially ! // it's like an incomplete key sequence. if (keylen == 0 && save_keylen == KEYLEN_PART_KEY) keylen = KEYLEN_PART_KEY; *************** *** 3680,3686 **** // CTRL-V is followed by octal, hex or other characters, reverses // what AppendToRedobuffLit() does. no_reduce_keys = TRUE; // don't merge modifyOtherKeys ! c1 = get_literal(); no_reduce_keys = FALSE; } --- 3679,3685 ---- // CTRL-V is followed by octal, hex or other characters, reverses // what AppendToRedobuffLit() does. no_reduce_keys = TRUE; // don't merge modifyOtherKeys ! c1 = get_literal(TRUE); no_reduce_keys = FALSE; } *** ../vim-8.2.2083/src/normal.c 2020-11-26 20:33:56.856583887 +0100 --- src/normal.c 2020-12-03 19:30:08.474267692 +0100 *************** *** 4927,4933 **** if (cap->nchar == Ctrl_V) { had_ctrl_v = Ctrl_V; ! cap->nchar = get_literal(); // Don't redo a multibyte character with CTRL-V. if (cap->nchar > DEL) had_ctrl_v = NUL; --- 4927,4933 ---- if (cap->nchar == Ctrl_V) { had_ctrl_v = Ctrl_V; ! cap->nchar = get_literal(FALSE); // Don't redo a multibyte character with CTRL-V. if (cap->nchar > DEL) had_ctrl_v = NUL; *************** *** 5208,5214 **** else { if (cap->extra_char == Ctrl_V) // get another character ! cap->extra_char = get_literal(); stuffcharReadbuff(cap->extra_char); stuffcharReadbuff(ESC); if (virtual_active()) --- 5208,5214 ---- else { if (cap->extra_char == Ctrl_V) // get another character ! cap->extra_char = get_literal(FALSE); stuffcharReadbuff(cap->extra_char); stuffcharReadbuff(ESC); if (virtual_active()) *** ../vim-8.2.2083/src/testdir/test_termcodes.vim 2020-11-27 20:54:56.609430538 +0100 --- src/testdir/test_termcodes.vim 2020-12-03 19:44:39.199838712 +0100 *************** *** 1966,1971 **** --- 1966,1981 ---- bwipe aaa bwipe bbb + " Ctrl-V X 33 is 3 + call setline(1, '') + call feedkeys("a\" .. a:func('X', 2) .. "33\", 'Lx!') + call assert_equal("3", getline(1)) + + " Ctrl-V U 12345 is Unicode 12345 + call setline(1, '') + call feedkeys("a\" .. a:func('U', 2) .. "12345\", 'Lx!') + call assert_equal("\U12345", getline(1)) + bwipe! set timeoutlen& endfunc *** ../vim-8.2.2083/src/version.c 2020-12-02 20:51:17.944731846 +0100 --- src/version.c 2020-12-03 19:33:41.653751348 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2084, /**/ -- TALL KNIGHT: When you have found the shrubbery, then you must cut down the mightiest tree in the forest ... with a herring. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///