Mercurial > vim
comparison src/getchar.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 | 8cc12c8d7842 |
children | 49b78d6465e5 |
comparison
equal
deleted
inserted
replaced
18716:9568bc68c45d | 18717:14d2a210fab1 |
---|---|
1520 if (c == 0 || (p_uc > 0 && ++count >= p_uc)) | 1520 if (c == 0 || (p_uc > 0 && ++count >= p_uc)) |
1521 { | 1521 { |
1522 ml_sync_all(c == 0, TRUE); | 1522 ml_sync_all(c == 0, TRUE); |
1523 count = 0; | 1523 count = 0; |
1524 } | 1524 } |
1525 } | |
1526 | |
1527 /* | |
1528 * Convert "c" plus "mod_mask" to merge the effect of modifyOtherKeys into the | |
1529 * character. | |
1530 */ | |
1531 int | |
1532 merge_modifyOtherKeys(int c_arg) | |
1533 { | |
1534 int c = c_arg; | |
1535 | |
1536 if (mod_mask & MOD_MASK_CTRL) | |
1537 { | |
1538 if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_')) | |
1539 { | |
1540 c &= 0x1f; | |
1541 mod_mask &= ~MOD_MASK_CTRL; | |
1542 } | |
1543 else if (c == '6') | |
1544 { | |
1545 // CTRL-6 is equivalent to CTRL-^ | |
1546 c = 0x1e; | |
1547 mod_mask &= ~MOD_MASK_CTRL; | |
1548 } | |
1549 } | |
1550 if ((mod_mask & (MOD_MASK_META | MOD_MASK_ALT)) | |
1551 && c >= 0 && c <= 127) | |
1552 { | |
1553 c += 0x80; | |
1554 mod_mask &= ~(MOD_MASK_META|MOD_MASK_ALT); | |
1555 } | |
1556 return c; | |
1525 } | 1557 } |
1526 | 1558 |
1527 /* | 1559 /* |
1528 * Get the next input character. | 1560 * Get the next input character. |
1529 * Can return a special key or a multi-byte character. | 1561 * Can return a special key or a multi-byte character. |
1763 --no_mapping; | 1795 --no_mapping; |
1764 c = (*mb_ptr2char)(buf); | 1796 c = (*mb_ptr2char)(buf); |
1765 } | 1797 } |
1766 | 1798 |
1767 if (!no_reduce_keys) | 1799 if (!no_reduce_keys) |
1768 { | |
1769 // A modifier was not used for a mapping, apply it to ASCII | 1800 // A modifier was not used for a mapping, apply it to ASCII |
1770 // keys. Shift would already have been applied. | 1801 // keys. Shift would already have been applied. |
1771 if (mod_mask & MOD_MASK_CTRL) | 1802 c = merge_modifyOtherKeys(c); |
1772 { | |
1773 if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_')) | |
1774 { | |
1775 c &= 0x1f; | |
1776 mod_mask &= ~MOD_MASK_CTRL; | |
1777 } | |
1778 else if (c == '6') | |
1779 { | |
1780 // CTRL-6 is equivalent to CTRL-^ | |
1781 c = 0x1e; | |
1782 mod_mask &= ~MOD_MASK_CTRL; | |
1783 } | |
1784 } | |
1785 if ((mod_mask & (MOD_MASK_META | MOD_MASK_ALT)) | |
1786 && c >= 0 && c <= 127) | |
1787 { | |
1788 c += 0x80; | |
1789 mod_mask &= ~(MOD_MASK_META|MOD_MASK_ALT); | |
1790 } | |
1791 } | |
1792 | 1803 |
1793 break; | 1804 break; |
1794 } | 1805 } |
1795 } | 1806 } |
1796 | 1807 |