Mercurial > emacs
comparison src/xdisp.c @ 20926:b304072b893c
(try_window_id): Use DEC_POS only for multibyte buffer.
display_text_line): Handling of a wide-column character fixed.
Make the behaviour consistent with INC_POS.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 20 Feb 1998 01:40:47 +0000 |
parents | ec8cd27243b6 |
children | 4cad33afd914 |
comparison
equal
deleted
inserted
replaced
20925:f61425242f70 | 20926:b304072b893c |
---|---|
2518 int last_text_vpos = 0; | 2518 int last_text_vpos = 0; |
2519 int stop_vpos; | 2519 int stop_vpos; |
2520 int selective = (INTEGERP (current_buffer->selective_display) | 2520 int selective = (INTEGERP (current_buffer->selective_display) |
2521 ? XINT (current_buffer->selective_display) | 2521 ? XINT (current_buffer->selective_display) |
2522 : !NILP (current_buffer->selective_display) ? -1 : 0); | 2522 : !NILP (current_buffer->selective_display) ? -1 : 0); |
2523 | 2523 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
2524 struct position val, bp, ep, xp, pp; | 2524 struct position val, bp, ep, xp, pp; |
2525 int scroll_amount = 0; | 2525 int scroll_amount = 0; |
2526 int delta; | 2526 int delta; |
2527 int epto, old_tick; | 2527 int epto, old_tick; |
2528 | 2528 |
2598 { | 2598 { |
2599 val.hpos = bp.prevhpos - width + lmargin; | 2599 val.hpos = bp.prevhpos - width + lmargin; |
2600 val.tab_offset = bp.tab_offset + bp.prevhpos - width; | 2600 val.tab_offset = bp.tab_offset + bp.prevhpos - width; |
2601 did_motion = 1; | 2601 did_motion = 1; |
2602 pos--; | 2602 pos--; |
2603 DEC_POS (pos_byte); | 2603 if (multibyte) |
2604 DEC_POS (pos_byte); | |
2605 else | |
2606 pos_byte--; | |
2604 } | 2607 } |
2605 | 2608 |
2606 bp.vpos = vpos; | 2609 bp.vpos = vpos; |
2607 | 2610 |
2608 /* Find first visible newline after which no more is changed. */ | 2611 /* Find first visible newline after which no more is changed. */ |
2862 else if (xp.contin && xp.hpos != lmargin) | 2865 else if (xp.contin && xp.hpos != lmargin) |
2863 { | 2866 { |
2864 val.hpos = xp.prevhpos - width + lmargin; | 2867 val.hpos = xp.prevhpos - width + lmargin; |
2865 val.tab_offset = xp.tab_offset + bp.prevhpos - width; | 2868 val.tab_offset = xp.tab_offset + bp.prevhpos - width; |
2866 pos--; | 2869 pos--; |
2867 DEC_POS (pos_byte); | 2870 if (multibyte) |
2871 DEC_POS (pos_byte); | |
2872 else | |
2873 pos_byte--; | |
2868 } | 2874 } |
2869 | 2875 |
2870 blank_end_of_window = 1; | 2876 blank_end_of_window = 1; |
2871 /* The following code is omitted because we maintain tab offset | 2877 /* The following code is omitted because we maintain tab offset |
2872 in val.tab_offset. */ | 2878 in val.tab_offset. */ |
3115 register unsigned char *p; | 3121 register unsigned char *p; |
3116 GLYPH *endp; | 3122 GLYPH *endp; |
3117 register GLYPH *leftmargin; | 3123 register GLYPH *leftmargin; |
3118 register GLYPH *p1prev; | 3124 register GLYPH *p1prev; |
3119 register GLYPH *p1start; | 3125 register GLYPH *p1start; |
3126 GLYPH *p1_wide_column_end = (GLYPH *) 0; | |
3120 int prevpos, prevpos_byte; | 3127 int prevpos, prevpos_byte; |
3121 int *charstart; | 3128 int *charstart; |
3122 FRAME_PTR f = XFRAME (w->frame); | 3129 FRAME_PTR f = XFRAME (w->frame); |
3123 int tab_width = XINT (current_buffer->tab_width); | 3130 int tab_width = XINT (current_buffer->tab_width); |
3124 int ctl_arrow = !NILP (current_buffer->ctl_arrow); | 3131 int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
3268 requested, if we hit a multi-column character, or the end of | 3275 requested, if we hit a multi-column character, or the end of |
3269 the line. If so, back up. */ | 3276 the line. If so, back up. */ |
3270 if (left_edge->vpos > vpos | 3277 if (left_edge->vpos > vpos |
3271 || left_edge->hpos > 0) | 3278 || left_edge->hpos > 0) |
3272 { | 3279 { |
3273 pos = left_edge->bufpos; | 3280 pos = left_edge->bufpos - 1; |
3274 /* Since this should not be a valid multibyte character, we | 3281 pos_byte = left_edge->bytepos; |
3275 can decrease POS by 1. */ | 3282 if (multibyte) |
3276 pos--; | 3283 DEC_POS (pos_byte); |
3277 pos_byte = left_edge->bytepos - 1; | 3284 else |
3285 pos_byte--; | |
3278 hpos = left_edge->prevhpos; | 3286 hpos = left_edge->prevhpos; |
3279 } | 3287 } |
3280 else | 3288 else |
3281 { | 3289 { |
3282 pos = left_edge->bufpos; | 3290 pos = left_edge->bufpos; |
3324 cursor_hpos = p1 - leftmargin; | 3332 cursor_hpos = p1 - leftmargin; |
3325 } | 3333 } |
3326 | 3334 |
3327 while (p1 < endp) | 3335 while (p1 < endp) |
3328 { | 3336 { |
3337 int eat_following_binary_data; | |
3338 | |
3329 if (pos >= pause) | 3339 if (pos >= pause) |
3330 { | 3340 { |
3331 int e_t_h; | 3341 int e_t_h; |
3332 | 3342 |
3333 while (pos == next_boundary) | 3343 while (pos == next_boundary) |
3529 | 3539 |
3530 if (p1 >= endp) | 3540 if (p1 >= endp) |
3531 break; | 3541 break; |
3532 | 3542 |
3533 p1prev = p1; | 3543 p1prev = p1; |
3544 p1_wide_column_end = (GLYPH *) 0; | |
3534 | 3545 |
3535 if (multibyte) | 3546 if (multibyte) |
3536 c = STRING_CHAR_AND_LENGTH (p, limit_byte - pos_byte, len), p += len; | 3547 c = STRING_CHAR_AND_LENGTH (p, limit_byte - pos_byte, len), p += len; |
3537 else | 3548 else |
3538 c = *p++, len = 1; | 3549 c = *p++, len = 1; |
3710 p1++; | 3721 p1++; |
3711 } | 3722 } |
3712 else if (len == 1) | 3723 else if (len == 1) |
3713 { | 3724 { |
3714 /* C is not a multibyte character. */ | 3725 /* C is not a multibyte character. */ |
3715 if (p1 >= leftmargin) | 3726 eat_following_binary_data = multibyte && BASE_LEADING_CODE_P (c); |
3716 *p1 = (fix_glyph | 3727 |
3717 (f, (dp && INTEGERP (DISP_ESCAPE_GLYPH (dp)) | 3728 label_display_binary_data: |
3718 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp))) | 3729 do { |
3719 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'), | 3730 if (p1 >= leftmargin && p1 < endp) |
3720 current_face) | 3731 *p1 = (fix_glyph |
3721 | rev_dir_bit); | 3732 (f, (dp && INTEGERP (DISP_ESCAPE_GLYPH (dp)) |
3722 p1++; | 3733 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (dp))) |
3723 if (p1 >= leftmargin && p1 < endp) | 3734 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'), |
3724 *p1 = MAKE_GLYPH (f, (c >> 6) + '0', current_face) | rev_dir_bit; | 3735 current_face) |
3725 p1++; | 3736 | rev_dir_bit); |
3726 if (p1 >= leftmargin && p1 < endp) | 3737 p1++; |
3727 *p1 = (MAKE_GLYPH (f, (7 & (c >> 3)) + '0', current_face) | 3738 if (p1 >= leftmargin && p1 < endp) |
3728 | rev_dir_bit); | 3739 *p1 = MAKE_GLYPH (f, (c >> 6) + '0', current_face) | rev_dir_bit; |
3729 p1++; | 3740 p1++; |
3730 if (p1 >= leftmargin && p1 < endp) | 3741 if (p1 >= leftmargin && p1 < endp) |
3731 *p1 = MAKE_GLYPH (f, (7 & c) + '0', current_face) | rev_dir_bit; | 3742 *p1 = (MAKE_GLYPH (f, (7 & (c >> 3)) + '0', current_face) |
3732 p1++; | 3743 | rev_dir_bit); |
3744 p1++; | |
3745 if (p1 >= leftmargin && p1 < endp) | |
3746 *p1 = MAKE_GLYPH (f, (7 & c) + '0', current_face) | rev_dir_bit; | |
3747 p1++; | |
3748 } while (eat_following_binary_data | |
3749 && (pos_byte + len) < limit_byte | |
3750 && ! CHAR_HEAD_P (*p) | |
3751 && ((c = *p++), len++)); | |
3733 } | 3752 } |
3734 else | 3753 else |
3735 { | 3754 { |
3736 /* C is a multibyte character. */ | 3755 /* C is a multibyte character. */ |
3737 int charset = CHAR_CHARSET (c); | 3756 int charset = CHAR_CHARSET (c); |
3743 while (columns--) | 3762 while (columns--) |
3744 { | 3763 { |
3745 if (p1 >= leftmargin && p1 < endp) | 3764 if (p1 >= leftmargin && p1 < endp) |
3746 *p1 = g, g |= GLYPH_MASK_PADDING; | 3765 *p1 = g, g |= GLYPH_MASK_PADDING; |
3747 p1++; | 3766 p1++; |
3767 } | |
3768 | |
3769 p1_wide_column_end = p1; | |
3770 /* Check if binary data follows it. */ | |
3771 if (pos_byte + len < limit_byte | |
3772 && ! CHAR_HEAD_P (*p)) | |
3773 { | |
3774 eat_following_binary_data = 1; | |
3775 c = *p++; | |
3776 len++; | |
3777 goto label_display_binary_data; | |
3748 } | 3778 } |
3749 } | 3779 } |
3750 | 3780 |
3751 prevpos = pos; | 3781 prevpos = pos; |
3752 prevpos_byte = pos_byte; | 3782 prevpos_byte = pos_byte; |
3809 character code is C and the length of multi-byte form is | 3839 character code is C and the length of multi-byte form is |
3810 LEN. */ | 3840 LEN. */ |
3811 pos = prevpos; | 3841 pos = prevpos; |
3812 pos_byte = prevpos_byte; | 3842 pos_byte = prevpos_byte; |
3813 | 3843 |
3814 if (len == 1) | 3844 if (p1_wide_column_end < endp) |
3815 /* C is not a multi-byte character. We can break it and | 3845 /* As ENDP is not in the middle of wide-column character, |
3816 start from the middle column in the next line. So, | 3846 we can break the line at ENDP and start from the middle |
3817 adjust VAL.HPOS to skip the columns output on this | 3847 column in the next line. So, adjust VAL.HPOS to skip |
3818 line. */ | 3848 the columns output on this line. */ |
3819 val.hpos += p1prev - endp; | 3849 val.hpos += p1prev - endp; |
3820 else | 3850 else |
3821 { | 3851 { |
3822 /* C is a multibyte character. Since we can't broke it | 3852 /* We displayed a wide-column character at around ENDP. |
3823 in the middle, the whole character should be driven | 3853 Since we can't broke it in the middle, the whole |
3824 into the next line. */ | 3854 character should be driven into the next line. */ |
3825 /* As the result, the actual columns occupied by the | 3855 /* As the result, the actual columns occupied by the |
3826 text on this line is less than WIDTH. VAL.TAB_OFFSET | 3856 text on this line is less than WIDTH. VAL.TAB_OFFSET |
3827 must be adjusted. */ | 3857 must be adjusted. */ |
3828 taboffset = taboffset + (p1prev - endp); | 3858 taboffset = taboffset + (p1prev - endp); |
3829 /* Let's fill unused columns with TRUNCATOR or CONTINUER. */ | 3859 /* Let's fill unused columns with TRUNCATOR or CONTINUER. */ |
3895 else | 3925 else |
3896 { | 3926 { |
3897 *p1++ = fix_glyph (f, continuer, 0); | 3927 *p1++ = fix_glyph (f, continuer, 0); |
3898 val.vpos = 0; | 3928 val.vpos = 0; |
3899 lastpos--; | 3929 lastpos--; |
3900 DEC_POS (lastpos_byte); | 3930 if (multibyte) |
3931 DEC_POS (lastpos_byte); | |
3932 else | |
3933 lastpos_byte--; | |
3901 val.tab_offset = taboffset + width; | 3934 val.tab_offset = taboffset + width; |
3902 } | 3935 } |
3903 } | 3936 } |
3904 } | 3937 } |
3905 else | 3938 else |