diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/xdisp.c | 51 |
2 files changed, 46 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 772ebd4d273..315ac040d41 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | 2011-06-18 Eli Zaretskii <eliz@gnu.org> | 1 | 2011-06-18 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * xdisp.c (face_before_or_after_it_pos): Support bidi iteration | 3 | * xdisp.c (face_before_or_after_it_pos): Support bidi iteration. |
| 4 | when BEFORE_P is zero. | ||
| 5 | (next_element_from_c_string): Handle the case of the first string | 4 | (next_element_from_c_string): Handle the case of the first string |
| 6 | character that is not the first one in the visual order. | 5 | character that is not the first one in the visual order. |
| 7 | 6 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index 6a289bb51c0..998076b30bb 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -3480,6 +3480,7 @@ face_before_or_after_it_pos (struct it *it, int before_p) | |||
| 3480 | { | 3480 | { |
| 3481 | int face_id, limit; | 3481 | int face_id, limit; |
| 3482 | EMACS_INT next_check_charpos; | 3482 | EMACS_INT next_check_charpos; |
| 3483 | struct it it_copy; | ||
| 3483 | 3484 | ||
| 3484 | xassert (it->s == NULL); | 3485 | xassert (it->s == NULL); |
| 3485 | 3486 | ||
| @@ -3512,15 +3513,34 @@ face_before_or_after_it_pos (struct it *it, int before_p) | |||
| 3512 | else | 3513 | else |
| 3513 | { | 3514 | { |
| 3514 | if (before_p) | 3515 | if (before_p) |
| 3515 | charpos = IT_STRING_CHARPOS (*it) - 1; /* FIXME! */ | 3516 | { |
| 3517 | /* With bidi iteration, the character before the current | ||
| 3518 | in the visual order cannot be found by simple | ||
| 3519 | iteration, because "reverse" reordering is not | ||
| 3520 | supported. Instead, we need to use the move_it_* | ||
| 3521 | family of functions. */ | ||
| 3522 | /* Ignore face changes before the first visible | ||
| 3523 | character on this display line. */ | ||
| 3524 | if (it->current_x <= it->first_visible_x) | ||
| 3525 | return it->face_id; | ||
| 3526 | it_copy = *it; | ||
| 3527 | /* Implementation note: Since move_it_in_display_line | ||
| 3528 | works in the iterator geometry, and thinks the first | ||
| 3529 | character is always the leftmost, even in R2L lines, | ||
| 3530 | we don't need to distinguish between the R2L and L2R | ||
| 3531 | cases here. */ | ||
| 3532 | move_it_in_display_line (&it_copy, SCHARS (it_copy.string), | ||
| 3533 | it_copy.current_x - 1, MOVE_TO_X); | ||
| 3534 | charpos = IT_STRING_CHARPOS (it_copy); | ||
| 3535 | } | ||
| 3516 | else | 3536 | else |
| 3517 | { | 3537 | { |
| 3518 | /* Set charpos to the string position of the character | 3538 | /* Set charpos to the string position of the character |
| 3519 | that comes after IT's current position in the visual | 3539 | that comes after IT's current position in the visual |
| 3520 | order. */ | 3540 | order. */ |
| 3521 | int n = (it->what == IT_COMPOSITION ? it->cmp_it.nchars : 1); | 3541 | int n = (it->what == IT_COMPOSITION ? it->cmp_it.nchars : 1); |
| 3522 | struct it it_copy = *it; | ||
| 3523 | 3542 | ||
| 3543 | it_copy = *it; | ||
| 3524 | while (n--) | 3544 | while (n--) |
| 3525 | bidi_move_to_visually_next (&it_copy.bidi_it); | 3545 | bidi_move_to_visually_next (&it_copy.bidi_it); |
| 3526 | 3546 | ||
| @@ -3551,8 +3571,8 @@ face_before_or_after_it_pos (struct it *it, int before_p) | |||
| 3551 | suitable for unibyte text if IT->string is unibyte. */ | 3571 | suitable for unibyte text if IT->string is unibyte. */ |
| 3552 | if (STRING_MULTIBYTE (it->string)) | 3572 | if (STRING_MULTIBYTE (it->string)) |
| 3553 | { | 3573 | { |
| 3554 | struct text_pos pos = string_pos (charpos, it->string); | 3574 | struct text_pos pos1 = string_pos (charpos, it->string); |
| 3555 | const unsigned char *p = SDATA (it->string) + BYTEPOS (pos); | 3575 | const unsigned char *p = SDATA (it->string) + BYTEPOS (pos1); |
| 3556 | int c, len; | 3576 | int c, len; |
| 3557 | struct face *face = FACE_FROM_ID (it->f, face_id); | 3577 | struct face *face = FACE_FROM_ID (it->f, face_id); |
| 3558 | 3578 | ||
| @@ -3591,15 +3611,34 @@ face_before_or_after_it_pos (struct it *it, int before_p) | |||
| 3591 | else | 3611 | else |
| 3592 | { | 3612 | { |
| 3593 | if (before_p) | 3613 | if (before_p) |
| 3594 | DEC_TEXT_POS (pos, it->multibyte_p); /* FIXME! */ | 3614 | { |
| 3615 | /* With bidi iteration, the character before the current | ||
| 3616 | in the visual order cannot be found by simple | ||
| 3617 | iteration, because "reverse" reordering is not | ||
| 3618 | supported. Instead, we need to use the move_it_* | ||
| 3619 | family of functions. */ | ||
| 3620 | /* Ignore face changes before the first visible | ||
| 3621 | character on this display line. */ | ||
| 3622 | if (it->current_x <= it->first_visible_x) | ||
| 3623 | return it->face_id; | ||
| 3624 | it_copy = *it; | ||
| 3625 | /* Implementation note: Since move_it_in_display_line | ||
| 3626 | works in the iterator geometry, and thinks the first | ||
| 3627 | character is always the leftmost, even in R2L lines, | ||
| 3628 | we don't need to distinguish between the R2L and L2R | ||
| 3629 | cases here. */ | ||
| 3630 | move_it_in_display_line (&it_copy, ZV, | ||
| 3631 | it_copy.current_x - 1, MOVE_TO_X); | ||
| 3632 | pos = it_copy.current.pos; | ||
| 3633 | } | ||
| 3595 | else | 3634 | else |
| 3596 | { | 3635 | { |
| 3597 | /* Set charpos to the buffer position of the character | 3636 | /* Set charpos to the buffer position of the character |
| 3598 | that comes after IT's current position in the visual | 3637 | that comes after IT's current position in the visual |
| 3599 | order. */ | 3638 | order. */ |
| 3600 | int n = (it->what == IT_COMPOSITION ? it->cmp_it.nchars : 1); | 3639 | int n = (it->what == IT_COMPOSITION ? it->cmp_it.nchars : 1); |
| 3601 | struct it it_copy = *it; | ||
| 3602 | 3640 | ||
| 3641 | it_copy = *it; | ||
| 3603 | while (n--) | 3642 | while (n--) |
| 3604 | bidi_move_to_visually_next (&it_copy.bidi_it); | 3643 | bidi_move_to_visually_next (&it_copy.bidi_it); |
| 3605 | 3644 | ||