Skip to content

Commit

Permalink
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Browse files Browse the repository at this point in the history
Problem:    Cannot map <C-H> when modifyOtherKeys is enabled.
Solution:   Add the <C-H> mapping twice, both with modifier and as 0x08.  Use
            only the first one when modifyOtherKeys has been detected.
  • Loading branch information
brammool committed Oct 13, 2019
1 parent 171a921 commit 459fd78
Show file tree
Hide file tree
Showing 21 changed files with 535 additions and 337 deletions.
3 changes: 2 additions & 1 deletion src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3526,7 +3526,8 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
break;

/* Special key, e.g.: "\<C-W>" */
case '<': extra = trans_special(&p, name, TRUE, TRUE);
case '<': extra = trans_special(&p, name, TRUE, TRUE,
TRUE, NULL);
if (extra != 0)
{
name += extra;
Expand Down
5 changes: 3 additions & 2 deletions src/getchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int typeahead_char = 0; /* typeahead char that's not flushed */
*/
static int block_redo = FALSE;

static int KeyNoremap = 0; /* remapping flags */
static int KeyNoremap = 0; // remapping flags

/*
* Variables used by vgetorpeek() and flush_buffers().
Expand Down Expand Up @@ -1771,7 +1771,7 @@ vgetc(void)
if (!no_reduce_keys)
{
// A modifier was not used for a mapping, apply it to ASCII
// keys.
// keys. Shift would already have been applied.
if ((mod_mask & MOD_MASK_CTRL)
&& ((c >= '`' && c <= 0x7f)
|| (c >= '@' && c <= '_')))
Expand Down Expand Up @@ -2240,6 +2240,7 @@ handle_mapping(
// Skip ":lmap" mappings if keys were mapped.
if (mp->m_keys[0] == tb_c1
&& (mp->m_mode & local_State)
&& !(mp->m_simplified && seenModifyOtherKeys)
&& ((mp->m_mode & LANGMAP) == 0 || typebuf.tb_maplen == 0))
{
#ifdef FEAT_LANGMAP
Expand Down
4 changes: 4 additions & 0 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,10 @@ EXTERN int ex_no_reprint INIT(= FALSE); // no need to print after z or p
EXTERN int reg_recording INIT(= 0); // register for recording or zero
EXTERN int reg_executing INIT(= 0); // register being executed or zero

// Set when a modifyOtherKeys sequence was seen, then simplified mappings will
// no longer be used.
EXTERN int seenModifyOtherKeys INIT(= FALSE);

EXTERN int no_mapping INIT(= FALSE); // currently no mapping allowed
EXTERN int no_zero_mapping INIT(= 0); // mapping zero not allowed
EXTERN int allow_keys INIT(= FALSE); // allow key codes when no_mapping
Expand Down
6 changes: 4 additions & 2 deletions src/gui_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,8 @@ gui_mac_unicode_key_event(
key_char = simplify_key(key_char, (int *)&vimModifiers);

/* Interpret META, include SHIFT, etc. */
key_char = extract_modifiers(key_char, (int *)&vimModifiers);
key_char = extract_modifiers(key_char, (int *)&vimModifiers,
TRUE, NULL);
if (key_char == CSI)
key_char = K_CSI;

Expand Down Expand Up @@ -4772,7 +4773,8 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx)
char_u *p_actext;

p_actext = menu->actext;
key = find_special_key(&p_actext, &modifiers, FALSE, FALSE, FALSE);
key = find_special_key(&p_actext, &modifiers, FALSE, FALSE, FALSE,
TRUE, NULL);
if (*p_actext != 0)
key = 0; /* error: trailing text */
/* find_special_key() returns a keycode with as many of the
Expand Down
2 changes: 1 addition & 1 deletion src/gui_w32.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ _OnSysChar(
modifiers &= ~MOD_MASK_SHIFT;

/* Interpret the ALT key as making the key META, include SHIFT, etc. */
ch = extract_modifiers(ch, &modifiers);
ch = extract_modifiers(ch, &modifiers, TRUE, NULL);
if (ch == CSI)
ch = K_CSI;

Expand Down
3 changes: 2 additions & 1 deletion src/highlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,8 @@ do_highlight(
*/
for (p = arg, off = 0; off < 100 - 6 && *p; )
{
len = trans_special(&p, buf + off, FALSE, FALSE);
len = trans_special(&p, buf + off, FALSE, FALSE,
TRUE, NULL);
if (len > 0) // recognized special char
off += len;
else // copy as normal char
Expand Down
2 changes: 1 addition & 1 deletion src/if_ole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ CVim::SendKeys(BSTR keys)
}

/* Translate key codes like <Esc> */
str = replace_termcodes((char_u *)buffer, &ptr, FALSE, TRUE, FALSE);
str = replace_termcodes((char_u *)buffer, &ptr, REPTERM_DO_LT, NULL);

/* If ptr was set, then a new buffer was allocated,
* so we can free the old one.
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4339,7 +4339,7 @@ server_to_input_buf(char_u *str)
* <lt> sequence is recognised - needed for a real backslash.
*/
p_cpo = (char_u *)"Bk";
str = replace_termcodes((char_u *)str, &ptr, FALSE, TRUE, FALSE);
str = replace_termcodes((char_u *)str, &ptr, REPTERM_DO_LT, NULL);
p_cpo = cpo_save;

if (*ptr != NUL) /* trailing CTRL-V results in nothing */
Expand Down
Loading

0 comments on commit 459fd78

Please sign in to comment.