comparison src/getchar.c @ 275:fb70e333c94e

updated for version 7.0074
author vimboss
date Fri, 20 May 2005 21:19:57 +0000
parents 723a01584c3e
children 86cd0a77d2ae
comparison
equal deleted inserted replaced
274:8fa8d7964cf1 275:fb70e333c94e
4520 * Check the string "keys" against the lhs of all mappings 4520 * Check the string "keys" against the lhs of all mappings
4521 * Return pointer to rhs of mapping (mapblock->m_str) 4521 * Return pointer to rhs of mapping (mapblock->m_str)
4522 * NULL otherwise 4522 * NULL otherwise
4523 */ 4523 */
4524 char_u * 4524 char_u *
4525 check_map(keys, mode, exact) 4525 check_map(keys, mode, exact, ign_mod)
4526 char_u *keys; 4526 char_u *keys;
4527 int mode; 4527 int mode;
4528 int exact; /* require exact match */ 4528 int exact; /* require exact match */
4529 int ign_mod; /* ignore preceding modifier */
4529 { 4530 {
4530 int hash; 4531 int hash;
4531 int len, minlen; 4532 int len, minlen;
4532 mapblock_T *mp; 4533 mapblock_T *mp;
4534 char_u *s;
4533 #ifdef FEAT_LOCALMAP 4535 #ifdef FEAT_LOCALMAP
4534 int local; 4536 int local;
4535 #endif 4537 #endif
4536 4538
4537 validate_maphash(); 4539 validate_maphash();
4551 mp = maphash[hash]; 4553 mp = maphash[hash];
4552 for ( ; mp != NULL; mp = mp->m_next) 4554 for ( ; mp != NULL; mp = mp->m_next)
4553 { 4555 {
4554 /* skip entries with wrong mode, wrong length and not matching 4556 /* skip entries with wrong mode, wrong length and not matching
4555 * ones */ 4557 * ones */
4556 if (mp->m_keylen < len) 4558 if ((mp->m_mode & mode) && (!exact || mp->m_keylen == len))
4557 minlen = mp->m_keylen; 4559 {
4558 else 4560 if (len > mp->m_keylen)
4559 minlen = len; 4561 minlen = mp->m_keylen;
4560 if ((mp->m_mode & mode) 4562 else
4561 && (!exact || mp->m_keylen == len) 4563 minlen = len;
4562 && STRNCMP(mp->m_keys, keys, minlen) == 0) 4564 s = mp->m_keys;
4563 return mp->m_str; 4565 if (ign_mod && s[0] == K_SPECIAL && s[1] == KS_MODIFIER
4566 && s[2] != NUL)
4567 {
4568 s += 3;
4569 if (len > mp->m_keylen - 3)
4570 minlen = mp->m_keylen - 3;
4571 }
4572 if (STRNCMP(s, keys, minlen) == 0)
4573 return mp->m_str;
4574 }
4564 } 4575 }
4565 } 4576 }
4566 4577
4567 return NULL; 4578 return NULL;
4568 } 4579 }