Mercurial > vim
comparison src/buffer.c @ 15595:1ec942f1b648 v8.1.0805
patch 8.1.0805: too many #ifdefs
commit https://github.com/vim/vim/commit/135059724f140ceac889c9f8136bd1bf5c41d49d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 24 15:04:48 2019 +0100
patch 8.1.0805: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 1.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jan 2019 15:15:06 +0100 |
parents | c0560da7873e |
children | 6f1c7e9a6393 |
comparison
equal
deleted
inserted
replaced
15594:7a8983fe4f97 | 15595:1ec942f1b648 |
---|---|
702 buf->b_ml.ml_line_count = 1; | 702 buf->b_ml.ml_line_count = 1; |
703 unchanged(buf, TRUE); | 703 unchanged(buf, TRUE); |
704 buf->b_shortname = FALSE; | 704 buf->b_shortname = FALSE; |
705 buf->b_p_eol = TRUE; | 705 buf->b_p_eol = TRUE; |
706 buf->b_start_eol = TRUE; | 706 buf->b_start_eol = TRUE; |
707 #ifdef FEAT_MBYTE | |
708 buf->b_p_bomb = FALSE; | 707 buf->b_p_bomb = FALSE; |
709 buf->b_start_bomb = FALSE; | 708 buf->b_start_bomb = FALSE; |
710 #endif | |
711 buf->b_ml.ml_mfp = NULL; | 709 buf->b_ml.ml_mfp = NULL; |
712 buf->b_ml.ml_flags = ML_EMPTY; /* empty buffer */ | 710 buf->b_ml.ml_flags = ML_EMPTY; /* empty buffer */ |
713 #ifdef FEAT_NETBEANS_INTG | 711 #ifdef FEAT_NETBEANS_INTG |
714 netbeans_deleted_all_lines(buf); | 712 netbeans_deleted_all_lines(buf); |
715 #endif | 713 #endif |
938 #endif | 936 #endif |
939 #ifdef FEAT_LOCALMAP | 937 #ifdef FEAT_LOCALMAP |
940 map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); /* clear local mappings */ | 938 map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); /* clear local mappings */ |
941 map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */ | 939 map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */ |
942 #endif | 940 #endif |
943 #ifdef FEAT_MBYTE | |
944 VIM_CLEAR(buf->b_start_fenc); | 941 VIM_CLEAR(buf->b_start_fenc); |
945 #endif | |
946 } | 942 } |
947 | 943 |
948 /* | 944 /* |
949 * Free the b_wininfo list for buffer "buf". | 945 * Free the b_wininfo list for buffer "buf". |
950 */ | 946 */ |
2131 buf_T *buf, | 2127 buf_T *buf, |
2132 int free_p_ff) | 2128 int free_p_ff) |
2133 { | 2129 { |
2134 if (free_p_ff) | 2130 if (free_p_ff) |
2135 { | 2131 { |
2136 #ifdef FEAT_MBYTE | |
2137 clear_string_option(&buf->b_p_fenc); | 2132 clear_string_option(&buf->b_p_fenc); |
2138 #endif | |
2139 clear_string_option(&buf->b_p_ff); | 2133 clear_string_option(&buf->b_p_ff); |
2140 clear_string_option(&buf->b_p_bh); | 2134 clear_string_option(&buf->b_p_bh); |
2141 clear_string_option(&buf->b_p_bt); | 2135 clear_string_option(&buf->b_p_bt); |
2142 } | 2136 } |
2143 #ifdef FEAT_FIND_ID | 2137 #ifdef FEAT_FIND_ID |
2243 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | 2237 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
2244 #ifdef FEAT_LISP | 2238 #ifdef FEAT_LISP |
2245 clear_string_option(&buf->b_p_lw); | 2239 clear_string_option(&buf->b_p_lw); |
2246 #endif | 2240 #endif |
2247 clear_string_option(&buf->b_p_bkc); | 2241 clear_string_option(&buf->b_p_bkc); |
2248 #ifdef FEAT_MBYTE | |
2249 clear_string_option(&buf->b_p_menc); | 2242 clear_string_option(&buf->b_p_menc); |
2250 #endif | |
2251 } | 2243 } |
2252 | 2244 |
2253 /* | 2245 /* |
2254 * Get alternate file "n". | 2246 * Get alternate file "n". |
2255 * Set linenr to "lnum" or altfpos.lnum if "lnum" == 0. | 2247 * Set linenr to "lnum" or altfpos.lnum if "lnum" == 0. |
3776 /* Truncate name at 100 bytes. */ | 3768 /* Truncate name at 100 bytes. */ |
3777 len = (int)STRLEN(p); | 3769 len = (int)STRLEN(p); |
3778 if (len > 100) | 3770 if (len > 100) |
3779 { | 3771 { |
3780 len -= 100; | 3772 len -= 100; |
3781 #ifdef FEAT_MBYTE | |
3782 if (has_mbyte) | 3773 if (has_mbyte) |
3783 len += (*mb_tail_off)(p, p + len) + 1; | 3774 len += (*mb_tail_off)(p, p + len) + 1; |
3784 #endif | |
3785 p += len; | 3775 p += len; |
3786 } | 3776 } |
3787 STRCPY(icon_str, p); | 3777 STRCPY(icon_str, p); |
3788 trans_characters(icon_str, IOSIZE); | 3778 trans_characters(icon_str, IOSIZE); |
3789 } | 3779 } |
3937 } | 3927 } |
3938 #endif | 3928 #endif |
3939 | 3929 |
3940 if (fillchar == 0) | 3930 if (fillchar == 0) |
3941 fillchar = ' '; | 3931 fillchar = ' '; |
3942 #ifdef FEAT_MBYTE | |
3943 /* Can't handle a multi-byte fill character yet. */ | 3932 /* Can't handle a multi-byte fill character yet. */ |
3944 else if (mb_char2len(fillchar) > 1) | 3933 else if (mb_char2len(fillchar) > 1) |
3945 fillchar = '-'; | 3934 fillchar = '-'; |
3946 #endif | |
3947 | 3935 |
3948 // The cursor in windows other than the current one isn't always | 3936 // The cursor in windows other than the current one isn't always |
3949 // up-to-date, esp. because of autocommands and timers. | 3937 // up-to-date, esp. because of autocommands and timers. |
3950 lnum = wp->w_cursor.lnum; | 3938 lnum = wp->w_cursor.lnum; |
3951 if (lnum > wp->w_buffer->b_ml.ml_line_count) | 3939 if (lnum > wp->w_buffer->b_ml.ml_line_count) |
3971 wp->w_cursor.coladd = 0; | 3959 wp->w_cursor.coladd = 0; |
3972 #endif | 3960 #endif |
3973 byteval = 0; | 3961 byteval = 0; |
3974 } | 3962 } |
3975 else | 3963 else |
3976 #ifdef FEAT_MBYTE | |
3977 byteval = (*mb_ptr2char)(p + wp->w_cursor.col); | 3964 byteval = (*mb_ptr2char)(p + wp->w_cursor.col); |
3978 #else | |
3979 byteval = p[wp->w_cursor.col]; | |
3980 #endif | |
3981 | 3965 |
3982 groupdepth = 0; | 3966 groupdepth = 0; |
3983 p = out; | 3967 p = out; |
3984 curitem = 0; | 3968 curitem = 0; |
3985 prevchar_isflag = TRUE; | 3969 prevchar_isflag = TRUE; |
4077 } | 4061 } |
4078 } | 4062 } |
4079 if (l > item[groupitem[groupdepth]].maxwid) | 4063 if (l > item[groupitem[groupdepth]].maxwid) |
4080 { | 4064 { |
4081 /* truncate, remove n bytes of text at the start */ | 4065 /* truncate, remove n bytes of text at the start */ |
4082 #ifdef FEAT_MBYTE | |
4083 if (has_mbyte) | 4066 if (has_mbyte) |
4084 { | 4067 { |
4085 /* Find the first character that should be included. */ | 4068 /* Find the first character that should be included. */ |
4086 n = 0; | 4069 n = 0; |
4087 while (l >= item[groupitem[groupdepth]].maxwid) | 4070 while (l >= item[groupitem[groupdepth]].maxwid) |
4089 l -= ptr2cells(t + n); | 4072 l -= ptr2cells(t + n); |
4090 n += (*mb_ptr2len)(t + n); | 4073 n += (*mb_ptr2len)(t + n); |
4091 } | 4074 } |
4092 } | 4075 } |
4093 else | 4076 else |
4094 #endif | |
4095 n = (long)(p - t) - item[groupitem[groupdepth]].maxwid + 1; | 4077 n = (long)(p - t) - item[groupitem[groupdepth]].maxwid + 1; |
4096 | 4078 |
4097 *t = '<'; | 4079 *t = '<'; |
4098 mch_memmove(t + 1, t + n, (size_t)(p - (t + n))); | 4080 mch_memmove(t + 1, t + n, (size_t)(p - (t + n))); |
4099 p = p - n + 1; | 4081 p = p - n + 1; |
4100 #ifdef FEAT_MBYTE | 4082 |
4101 /* Fill up space left over by half a double-wide char. */ | 4083 // Fill up space left over by half a double-wide char. |
4102 while (++l < item[groupitem[groupdepth]].minwid) | 4084 while (++l < item[groupitem[groupdepth]].minwid) |
4103 *p++ = fillchar; | 4085 *p++ = fillchar; |
4104 #endif | |
4105 | 4086 |
4106 /* correct the start of the items for the truncation */ | 4087 /* correct the start of the items for the truncation */ |
4107 for (l = groupitem[groupdepth] + 1; l < curitem; l++) | 4088 for (l = groupitem[groupdepth] + 1; l < curitem; l++) |
4108 { | 4089 { |
4109 item[l].start -= n; | 4090 item[l].start -= n; |
4481 if (l > 0) | 4462 if (l > 0) |
4482 prevchar_isitem = TRUE; | 4463 prevchar_isitem = TRUE; |
4483 if (l > maxwid) | 4464 if (l > maxwid) |
4484 { | 4465 { |
4485 while (l >= maxwid) | 4466 while (l >= maxwid) |
4486 #ifdef FEAT_MBYTE | |
4487 if (has_mbyte) | 4467 if (has_mbyte) |
4488 { | 4468 { |
4489 l -= ptr2cells(t); | 4469 l -= ptr2cells(t); |
4490 t += (*mb_ptr2len)(t); | 4470 t += (*mb_ptr2len)(t); |
4491 } | 4471 } |
4492 else | 4472 else |
4493 #endif | |
4494 l -= byte2cells(*t++); | 4473 l -= byte2cells(*t++); |
4495 if (p + 1 >= out + outlen) | 4474 if (p + 1 >= out + outlen) |
4496 break; | 4475 break; |
4497 *p++ = '<'; | 4476 *p++ = '<'; |
4498 } | 4477 } |
4608 } | 4587 } |
4609 | 4588 |
4610 if (width - vim_strsize(s) >= maxwidth) | 4589 if (width - vim_strsize(s) >= maxwidth) |
4611 { | 4590 { |
4612 /* Truncation mark is beyond max length */ | 4591 /* Truncation mark is beyond max length */ |
4613 #ifdef FEAT_MBYTE | |
4614 if (has_mbyte) | 4592 if (has_mbyte) |
4615 { | 4593 { |
4616 s = out; | 4594 s = out; |
4617 width = 0; | 4595 width = 0; |
4618 for (;;) | 4596 for (;;) |
4625 /* Fill up for half a double-wide character. */ | 4603 /* Fill up for half a double-wide character. */ |
4626 while (++width < maxwidth) | 4604 while (++width < maxwidth) |
4627 *s++ = fillchar; | 4605 *s++ = fillchar; |
4628 } | 4606 } |
4629 else | 4607 else |
4630 #endif | |
4631 s = out + maxwidth - 1; | 4608 s = out + maxwidth - 1; |
4632 for (l = 0; l < itemcnt; l++) | 4609 for (l = 0; l < itemcnt; l++) |
4633 if (item[l].start > s) | 4610 if (item[l].start > s) |
4634 break; | 4611 break; |
4635 itemcnt = l; | 4612 itemcnt = l; |
4636 *s++ = '>'; | 4613 *s++ = '>'; |
4637 *s = 0; | 4614 *s = 0; |
4638 } | 4615 } |
4639 else | 4616 else |
4640 { | 4617 { |
4641 #ifdef FEAT_MBYTE | |
4642 if (has_mbyte) | 4618 if (has_mbyte) |
4643 { | 4619 { |
4644 n = 0; | 4620 n = 0; |
4645 while (width >= maxwidth) | 4621 while (width >= maxwidth) |
4646 { | 4622 { |
4647 width -= ptr2cells(s + n); | 4623 width -= ptr2cells(s + n); |
4648 n += (*mb_ptr2len)(s + n); | 4624 n += (*mb_ptr2len)(s + n); |
4649 } | 4625 } |
4650 } | 4626 } |
4651 else | 4627 else |
4652 #endif | |
4653 n = width - maxwidth + 1; | 4628 n = width - maxwidth + 1; |
4654 p = s + n; | 4629 p = s + n; |
4655 STRMOVE(s + 1, p); | 4630 STRMOVE(s + 1, p); |
4656 *s = '<'; | 4631 *s = '<'; |
4657 | 4632 |