Mercurial > vim
comparison src/edit.c @ 18717:14d2a210fab1 v8.1.2350
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Commit: https://github.com/vim/vim/commit/fc4ea2a72d36de1196a3ce17352e72f8fe90f4bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Nov 26 19:33:22 2019 +0100
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Problem: Other text for CTRL-V in Insert mode with modifyOtherKeys.
Solution: Convert the Escape sequence back to key as if modifyOtherKeys is
not set, and use CTRL-SHIFT-V to get the Escape sequence itself.
(closes #5254)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 26 Nov 2019 19:45:04 +0100 |
parents | ac08c7ad9d37 |
children | 49b78d6465e5 |
comparison
equal
deleted
inserted
replaced
18716:9568bc68c45d | 18717:14d2a210fab1 |
---|---|
1529 static void | 1529 static void |
1530 ins_ctrl_v(void) | 1530 ins_ctrl_v(void) |
1531 { | 1531 { |
1532 int c; | 1532 int c; |
1533 int did_putchar = FALSE; | 1533 int did_putchar = FALSE; |
1534 int prev_mod_mask = mod_mask; | |
1534 | 1535 |
1535 /* may need to redraw when no more chars available now */ | 1536 /* may need to redraw when no more chars available now */ |
1536 ins_redraw(FALSE); | 1537 ins_redraw(FALSE); |
1537 | 1538 |
1538 if (redrawing() && !char_avail()) | 1539 if (redrawing() && !char_avail()) |
1552 * line and will not removed by the redraw */ | 1553 * line and will not removed by the redraw */ |
1553 edit_unputchar(); | 1554 edit_unputchar(); |
1554 #ifdef FEAT_CMDL_INFO | 1555 #ifdef FEAT_CMDL_INFO |
1555 clear_showcmd(); | 1556 clear_showcmd(); |
1556 #endif | 1557 #endif |
1558 | |
1559 if ((c == ESC || c == CSI) && !(prev_mod_mask & MOD_MASK_SHIFT)) | |
1560 // Using CTRL-V: Change any modifyOtherKeys ESC sequence to a normal | |
1561 // key. Don't do this for CTRL-SHIFT-V. | |
1562 c = decodeModifyOtherKeys(c); | |
1563 | |
1557 insert_special(c, FALSE, TRUE); | 1564 insert_special(c, FALSE, TRUE); |
1558 #ifdef FEAT_RIGHTLEFT | 1565 #ifdef FEAT_RIGHTLEFT |
1559 revins_chars++; | 1566 revins_chars++; |
1560 revins_legal++; | 1567 revins_legal++; |
1561 #endif | 1568 #endif |
1569 } | |
1570 | |
1571 /* | |
1572 * After getting an ESC or CSI for a literal key: If the typeahead buffer | |
1573 * contains a modifyOtherKeys sequence then decode it and return the result. | |
1574 * Otherwise return "c". | |
1575 * Note that this doesn't wait for characters, they must be in the typeahead | |
1576 * buffer already. | |
1577 */ | |
1578 int | |
1579 decodeModifyOtherKeys(int c) | |
1580 { | |
1581 char_u *p = typebuf.tb_buf + typebuf.tb_off; | |
1582 int idx; | |
1583 int form = 0; | |
1584 int argidx = 0; | |
1585 int arg[2] = {0, 0}; | |
1586 | |
1587 // Recognize: | |
1588 // form 0: {lead}{key};{modifier}u | |
1589 // form 1: {lead}27;{modifier};{key}~ | |
1590 if ((c == CSI || (c == ESC && *p == '[')) && typebuf.tb_len >= 4) | |
1591 { | |
1592 idx = (*p == '['); | |
1593 if (p[idx] == '2' && p[idx + 1] == '7' && p[idx + 2] == ';') | |
1594 { | |
1595 form = 1; | |
1596 idx += 3; | |
1597 } | |
1598 while (idx < typebuf.tb_len && argidx < 2) | |
1599 { | |
1600 if (p[idx] == ';') | |
1601 ++argidx; | |
1602 else if (VIM_ISDIGIT(p[idx])) | |
1603 arg[argidx] = arg[argidx] * 10 + (p[idx] - '0'); | |
1604 else | |
1605 break; | |
1606 ++idx; | |
1607 } | |
1608 if (idx < typebuf.tb_len | |
1609 && p[idx] == (form == 1 ? '~' : 'u') | |
1610 && argidx == 1) | |
1611 { | |
1612 // Match, consume the code. | |
1613 typebuf.tb_off += idx + 1; | |
1614 typebuf.tb_len -= idx + 1; | |
1615 | |
1616 mod_mask = decode_modifiers(arg[!form]); | |
1617 c = merge_modifyOtherKeys(arg[form]); | |
1618 } | |
1619 } | |
1620 | |
1621 return c; | |
1562 } | 1622 } |
1563 | 1623 |
1564 /* | 1624 /* |
1565 * Put a character directly onto the screen. It's not stored in a buffer. | 1625 * Put a character directly onto the screen. It's not stored in a buffer. |
1566 * Used while handling CTRL-K, CTRL-V, etc. in Insert mode. | 1626 * Used while handling CTRL-K, CTRL-V, etc. in Insert mode. |