}
}
-#define KL_PART_KEY -1 /* keylen value for incomplete key-code */
-#define KL_PART_MAP -2 /* keylen value for incomplete mapping */
-
/*
* Get the next input character.
* Can return a special key or a multi-byte character.
if (!timedout)
{
/* break at a partly match */
- keylen = KL_PART_MAP;
+ keylen = KEYLEN_PART_MAP;
break;
}
}
/* If no partly match found, use the longest full
* match. */
- if (keylen != KL_PART_MAP)
+ if (keylen != KEYLEN_PART_MAP)
{
mp = mp_match;
keylen = mp_match_len;
}
/* Need more chars for partly match. */
if (mlen == typebuf.tb_len)
- keylen = KL_PART_KEY;
+ keylen = KEYLEN_PART_KEY;
else if (max_mlen < mlen)
/* no match, may have to check for termcode at
* next character */
}
if ((mp == NULL || max_mlen >= mp_match_len)
- && keylen != KL_PART_MAP)
+ && keylen != KEYLEN_PART_MAP)
{
int save_keylen = keylen;
/* If no termcode matched but 'pastetoggle'
* matched partially it's like an incomplete key
* sequence. */
- if (keylen == 0 && save_keylen == KL_PART_KEY)
- keylen = KL_PART_KEY;
+ if (keylen == 0 && save_keylen == KEYLEN_PART_KEY)
+ keylen = KEYLEN_PART_KEY;
/*
* When getting a partial match, but the last
continue;
}
if (*s == NUL) /* need more characters */
- keylen = KL_PART_KEY;
+ keylen = KEYLEN_PART_KEY;
}
if (keylen >= 0)
#endif
if (keylen > 0) /* full matching terminal code */
{
#if defined(FEAT_GUI) && defined(FEAT_MENU)
- if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
+ if (typebuf.tb_len >= 2
+ && typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
&& typebuf.tb_buf[typebuf.tb_off + 1]
== KS_MENU)
{
/* Partial match: get some more characters. When a
* matching mapping was found use that one. */
if (mp == NULL || keylen < 0)
- keylen = KL_PART_KEY;
+ keylen = KEYLEN_PART_KEY;
else
keylen = mp_match_len;
}
#endif
&& typebuf.tb_maplen == 0
&& (State & INSERT)
- && (p_timeout || (keylen == KL_PART_KEY && p_ttimeout))
+ && (p_timeout
+ || (keylen == KEYLEN_PART_KEY && p_ttimeout))
&& (c = inchar(typebuf.tb_buf + typebuf.tb_off
+ typebuf.tb_len, 3, 25L,
typebuf.tb_change_cnt)) == 0)
? 0
: ((typebuf.tb_len == 0
|| !(p_timeout || (p_ttimeout
- && keylen == KL_PART_KEY)))
+ && keylen == KEYLEN_PART_KEY)))
? -1L
- : ((keylen == KL_PART_KEY && p_ttm >= 0)
+ : ((keylen == KEYLEN_PART_KEY && p_ttm >= 0)
? p_ttm
: p_tm)), typebuf.tb_change_cnt);
* Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off
* + max_offset].
* Return 0 for no match, -1 for partial match, > 0 for full match.
+ * Return KEYLEN_REMOVED when a key code was deleted.
* With a match, the match is removed, the replacement code is inserted in
* typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is
* returned.
int slen = 0; /* init for GCC */
int modslen;
int len;
+ int retval = 0;
int offset;
char_u key_name[2];
int modifiers;
#endif
string[new_slen++] = key_name[1];
}
+ else if (new_slen == 0 && key_name[0] == KS_EXTRA
+ && key_name[1] == KE_IGNORE)
+ {
+ /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED
+ * to indicate what happened. */
+ retval = KEYLEN_REMOVED;
+ }
else
{
string[new_slen++] = K_SPECIAL;
(size_t)(buflen - offset));
mch_memmove(buf + offset, string, (size_t)new_slen);
}
- return (len + extra + offset);
+ return retval == 0 ? (len + extra + offset) : retval;
}
return 0; /* no match found */