comparison src/getchar.c @ 779:fb913578cbf5

updated for version 7.0228
author vimboss
date Sat, 18 Mar 2006 21:30:13 +0000
parents ebd1799949ff
children b5aed52a4881
comparison
equal deleted inserted replaced
778:c3f63ed316b6 779:fb913578cbf5
3271 /* need to loop over all hash lists */ 3271 /* need to loop over all hash lists */
3272 for (hash = 0; hash < 256 && !got_int; ++hash) 3272 for (hash = 0; hash < 256 && !got_int; ++hash)
3273 { 3273 {
3274 if (abbrev) 3274 if (abbrev)
3275 { 3275 {
3276 if (hash != 0) /* there is only one abbreviation list */ 3276 if (hash > 0) /* there is only one abbreviation list */
3277 break; 3277 break;
3278 mpp = abbr_table; 3278 mpp = abbr_table;
3279 } 3279 }
3280 else 3280 else
3281 mpp = &(map_table[hash]); 3281 mpp = &(map_table[hash]);
3593 3593
3594 for (hash = 0; hash < 256; ++hash) 3594 for (hash = 0; hash < 256; ++hash)
3595 { 3595 {
3596 if (abbr) 3596 if (abbr)
3597 { 3597 {
3598 if (hash) /* there is only one abbrlist */ 3598 if (hash > 0) /* there is only one abbrlist */
3599 break; 3599 break;
3600 #ifdef FEAT_LOCALMAP 3600 #ifdef FEAT_LOCALMAP
3601 if (local) 3601 if (local)
3602 mpp = &buf->b_first_abbr; 3602 mpp = &buf->b_first_abbr;
3603 else 3603 else
3732 * Return TRUE if a map exists that has "str" in the rhs for mode "modechars". 3732 * Return TRUE if a map exists that has "str" in the rhs for mode "modechars".
3733 * Recognize termcap codes in "str". 3733 * Recognize termcap codes in "str".
3734 * Also checks mappings local to the current buffer. 3734 * Also checks mappings local to the current buffer.
3735 */ 3735 */
3736 int 3736 int
3737 map_to_exists(str, modechars) 3737 map_to_exists(str, modechars, abbr)
3738 char_u *str; 3738 char_u *str;
3739 char_u *modechars; 3739 char_u *modechars;
3740 int abbr;
3740 { 3741 {
3741 int mode = 0; 3742 int mode = 0;
3742 char_u *rhs; 3743 char_u *rhs;
3743 char_u *buf; 3744 char_u *buf;
3744 int retval; 3745 int retval;
3756 if (vim_strchr(modechars, 'l') != NULL) 3757 if (vim_strchr(modechars, 'l') != NULL)
3757 mode |= LANGMAP; 3758 mode |= LANGMAP;
3758 if (vim_strchr(modechars, 'c') != NULL) 3759 if (vim_strchr(modechars, 'c') != NULL)
3759 mode |= CMDLINE; 3760 mode |= CMDLINE;
3760 3761
3761 retval = map_to_exists_mode(rhs, mode); 3762 retval = map_to_exists_mode(rhs, mode, abbr);
3762 vim_free(buf); 3763 vim_free(buf);
3763 3764
3764 return retval; 3765 return retval;
3765 } 3766 }
3766 #endif 3767 #endif
3768 /* 3769 /*
3769 * Return TRUE if a map exists that has "str" in the rhs for mode "mode". 3770 * Return TRUE if a map exists that has "str" in the rhs for mode "mode".
3770 * Also checks mappings local to the current buffer. 3771 * Also checks mappings local to the current buffer.
3771 */ 3772 */
3772 int 3773 int
3773 map_to_exists_mode(rhs, mode) 3774 map_to_exists_mode(rhs, mode, abbr)
3774 char_u *rhs; 3775 char_u *rhs;
3775 int mode; 3776 int mode;
3777 int abbr;
3776 { 3778 {
3777 mapblock_T *mp; 3779 mapblock_T *mp;
3778 int hash; 3780 int hash;
3779 # ifdef FEAT_LOCALMAP 3781 # ifdef FEAT_LOCALMAP
3780 int expand_buffer = FALSE; 3782 int expand_buffer = FALSE;
3785 for (;;) 3787 for (;;)
3786 { 3788 {
3787 # endif 3789 # endif
3788 for (hash = 0; hash < 256; ++hash) 3790 for (hash = 0; hash < 256; ++hash)
3789 { 3791 {
3792 if (abbr)
3793 {
3794 if (hash > 0) /* there is only one abbr list */
3795 break;
3796 #ifdef FEAT_LOCALMAP
3797 if (expand_buffer)
3798 mp = curbuf->b_first_abbr;
3799 else
3800 #endif
3801 mp = first_abbr;
3802 }
3790 # ifdef FEAT_LOCALMAP 3803 # ifdef FEAT_LOCALMAP
3791 if (expand_buffer) 3804 else if (expand_buffer)
3792 mp = curbuf->b_maphash[hash]; 3805 mp = curbuf->b_maphash[hash];
3806 # endif
3793 else 3807 else
3794 # endif
3795 mp = maphash[hash]; 3808 mp = maphash[hash];
3796 for (; mp; mp = mp->m_next) 3809 for (; mp; mp = mp->m_next)
3797 { 3810 {
3798 if ((mp->m_mode & mode) 3811 if ((mp->m_mode & mode)
3799 && strstr((char *)mp->m_str, (char *)rhs) != NULL) 3812 && strstr((char *)mp->m_str, (char *)rhs) != NULL)
3952 3965
3953 for (hash = 0; hash < 256; ++hash) 3966 for (hash = 0; hash < 256; ++hash)
3954 { 3967 {
3955 if (expand_isabbrev) 3968 if (expand_isabbrev)
3956 { 3969 {
3957 if (hash) /* only one abbrev list */ 3970 if (hash > 0) /* only one abbrev list */
3958 break; /* for (hash) */ 3971 break; /* for (hash) */
3959 mp = first_abbr; 3972 mp = first_abbr;
3960 } 3973 }
3961 #ifdef FEAT_LOCALMAP 3974 #ifdef FEAT_LOCALMAP
3962 else if (expand_buffer) 3975 else if (expand_buffer)
4253 for (abbr = 0; abbr < 2; ++abbr) 4266 for (abbr = 0; abbr < 2; ++abbr)
4254 for (hash = 0; hash < 256; ++hash) 4267 for (hash = 0; hash < 256; ++hash)
4255 { 4268 {
4256 if (abbr) 4269 if (abbr)
4257 { 4270 {
4258 if (hash) /* there is only one abbr list */ 4271 if (hash > 0) /* there is only one abbr list */
4259 break; 4272 break;
4260 #ifdef FEAT_LOCALMAP 4273 #ifdef FEAT_LOCALMAP
4261 if (buf != NULL) 4274 if (buf != NULL)
4262 mp = buf->b_first_abbr; 4275 mp = buf->b_first_abbr;
4263 else 4276 else
4612 * Check the string "keys" against the lhs of all mappings 4625 * Check the string "keys" against the lhs of all mappings
4613 * Return pointer to rhs of mapping (mapblock->m_str) 4626 * Return pointer to rhs of mapping (mapblock->m_str)
4614 * NULL otherwise 4627 * NULL otherwise
4615 */ 4628 */
4616 char_u * 4629 char_u *
4617 check_map(keys, mode, exact, ign_mod) 4630 check_map(keys, mode, exact, ign_mod, abbr)
4618 char_u *keys; 4631 char_u *keys;
4619 int mode; 4632 int mode;
4620 int exact; /* require exact match */ 4633 int exact; /* require exact match */
4621 int ign_mod; /* ignore preceding modifier */ 4634 int ign_mod; /* ignore preceding modifier */
4635 int abbr; /* do abbreviations */
4622 { 4636 {
4623 int hash; 4637 int hash;
4624 int len, minlen; 4638 int len, minlen;
4625 mapblock_T *mp; 4639 mapblock_T *mp;
4626 char_u *s; 4640 char_u *s;
4635 for (local = 1; local >= 0; --local) 4649 for (local = 1; local >= 0; --local)
4636 #endif 4650 #endif
4637 /* loop over all hash lists */ 4651 /* loop over all hash lists */
4638 for (hash = 0; hash < 256; ++hash) 4652 for (hash = 0; hash < 256; ++hash)
4639 { 4653 {
4654 if (abbr)
4655 {
4656 if (hash > 0) /* there is only one list. */
4657 break;
4640 #ifdef FEAT_LOCALMAP 4658 #ifdef FEAT_LOCALMAP
4641 if (local) 4659 if (local)
4660 mp = curbuf->b_first_abbr;
4661 else
4662 #endif
4663 mp = first_abbr;
4664 }
4665 #ifdef FEAT_LOCALMAP
4666 else if (local)
4642 mp = curbuf->b_maphash[hash]; 4667 mp = curbuf->b_maphash[hash];
4668 #endif
4643 else 4669 else
4644 #endif
4645 mp = maphash[hash]; 4670 mp = maphash[hash];
4646 for ( ; mp != NULL; mp = mp->m_next) 4671 for ( ; mp != NULL; mp = mp->m_next)
4647 { 4672 {
4648 /* skip entries with wrong mode, wrong length and not matching 4673 /* skip entries with wrong mode, wrong length and not matching
4649 * ones */ 4674 * ones */