diff options
| author | Eli Zaretskii | 2010-01-01 10:04:53 -0500 |
|---|---|---|
| committer | Eli Zaretskii | 2010-01-01 10:04:53 -0500 |
| commit | 9443b3c70494e010991a11b3be68e4777559df04 (patch) | |
| tree | 02a709c69bae6fe9de690b3a8c8402237fbc401c /src | |
| parent | bc5a45f315808b1d7335bdc9ea0168b89782c101 (diff) | |
| download | emacs-9443b3c70494e010991a11b3be68e4777559df04.tar.gz emacs-9443b3c70494e010991a11b3be68e4777559df04.zip | |
Retrospective commit from 2009-12-26.
Redesign handle_stop_backwards.
Fix character mirroring for non-ASCII characters.
xdisp.c (handle_stop_backwards): Call compute_stop_pos in the
loop, instead of calling handle_stop. Call handle_stop only once,
after the loop.
(next_element_from_buffer): Don't call handle_stop_backwards if at
stop position. If base_level_stop is zero, set it to 1.
term.c (append_glyph): Fill resolved_level and bidi_type slots
of struct glyph for unidirectional display.
xdisp.c (set_cursor_from_row): Handle zero-width characters.
bidi.c (bidi_mirror_char): More efficient code (suggested by
Ehud Karni <ehud@unix.mvs.co.il>). Don't even try to mirror
non-ASCII characters.
Diffstat (limited to 'src')
| -rw-r--r-- | src/.gdbinit | 5 | ||||
| -rw-r--r-- | src/ChangeLog.bidi | 17 | ||||
| -rw-r--r-- | src/bidi.c | 7 | ||||
| -rw-r--r-- | src/term.c | 7 | ||||
| -rw-r--r-- | src/xdisp.c | 48 |
5 files changed, 61 insertions, 23 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index 61e3da6c68c..a500f2532f5 100644 --- a/src/.gdbinit +++ b/src/.gdbinit | |||
| @@ -448,6 +448,9 @@ Pretty print window structure w. | |||
| 448 | end | 448 | end |
| 449 | 449 | ||
| 450 | define pbiditype | 450 | define pbiditype |
| 451 | if ($arg0 == 0) | ||
| 452 | printf "UNDEF" | ||
| 453 | end | ||
| 451 | if ($arg0 == 1) | 454 | if ($arg0 == 1) |
| 452 | printf "L" | 455 | printf "L" |
| 453 | end | 456 | end |
| @@ -466,7 +469,7 @@ define pbiditype | |||
| 466 | if ($arg0 == 6) | 469 | if ($arg0 == 6) |
| 467 | printf "B" | 470 | printf "B" |
| 468 | end | 471 | end |
| 469 | if ($arg0 < 1 || $arg0 > 6) | 472 | if ($arg0 < 0 || $arg0 > 6) |
| 470 | printf "%d??", $arg0 | 473 | printf "%d??", $arg0 |
| 471 | end | 474 | end |
| 472 | end | 475 | end |
diff --git a/src/ChangeLog.bidi b/src/ChangeLog.bidi index b9fb7457cfd..7e11c6ec024 100644 --- a/src/ChangeLog.bidi +++ b/src/ChangeLog.bidi | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2009-12-26 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * xdisp.c (handle_stop_backwards): Call compute_stop_pos in the | ||
| 4 | loop, instead of calling handle_stop. Call handle_stop only once, | ||
| 5 | after the loop. | ||
| 6 | (next_element_from_buffer): Don't call handle_stop_backwards if at | ||
| 7 | stop position. If base_level_stop is zero, set it to 1. | ||
| 8 | |||
| 9 | * term.c (append_glyph): Fill resolved_level and bidi_type slots | ||
| 10 | of struct glyph for unidirectional display. | ||
| 11 | |||
| 12 | * xdisp.c (set_cursor_from_row): Handle zero-width characters. | ||
| 13 | |||
| 14 | * bidi.c (bidi_mirror_char): More efficient code (suggested by | ||
| 15 | Ehud Karni <ehud@unix.mvs.co.il>). Don't even try to mirror | ||
| 16 | non-ASCII characters. | ||
| 17 | |||
| 1 | 2009-12-19 Eli Zaretskii <eliz@gnu.org> | 18 | 2009-12-19 Eli Zaretskii <eliz@gnu.org> |
| 2 | 19 | ||
| 3 | * buffer.c (Fbuffer_swap_text): Swap the values of | 20 | * buffer.c (Fbuffer_swap_text): Swap the values of |
diff --git a/src/bidi.c b/src/bidi.c index d18629279d6..5abb4ca9f43 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -509,16 +509,13 @@ int | |||
| 509 | bidi_mirror_char (int c) | 509 | bidi_mirror_char (int c) |
| 510 | { | 510 | { |
| 511 | static const char mirrored_pairs[] = "()<>[]{}"; | 511 | static const char mirrored_pairs[] = "()<>[]{}"; |
| 512 | const char *p = strchr (mirrored_pairs, c); | 512 | const char *p = c > 0 && c < 128 ? strchr (mirrored_pairs, c) : NULL; |
| 513 | 513 | ||
| 514 | if (p) | 514 | if (p) |
| 515 | { | 515 | { |
| 516 | size_t i = p - mirrored_pairs; | 516 | size_t i = p - mirrored_pairs; |
| 517 | 517 | ||
| 518 | if ((i & 1) == 0) | 518 | return mirrored_pairs [(i ^ 1)]; |
| 519 | return mirrored_pairs[i + 1]; | ||
| 520 | else | ||
| 521 | return mirrored_pairs[i - 1]; | ||
| 522 | } | 519 | } |
| 523 | return c; | 520 | return c; |
| 524 | } | 521 | } |
diff --git a/src/term.c b/src/term.c index 7c9e05f36b2..51bf7a4aeb7 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -1579,8 +1579,15 @@ append_glyph (it) | |||
| 1579 | if (it->bidi_p) | 1579 | if (it->bidi_p) |
| 1580 | { | 1580 | { |
| 1581 | glyph->resolved_level = it->bidi_it.resolved_level; | 1581 | glyph->resolved_level = it->bidi_it.resolved_level; |
| 1582 | if ((it->bidi_it.type & 7) != it->bidi_it.type) | ||
| 1583 | abort (); | ||
| 1582 | glyph->bidi_type = it->bidi_it.type; | 1584 | glyph->bidi_type = it->bidi_it.type; |
| 1583 | } | 1585 | } |
| 1586 | else | ||
| 1587 | { | ||
| 1588 | glyph->resolved_level = 0; | ||
| 1589 | glyph->bidi_type = UNKNOWN_BT; | ||
| 1590 | } | ||
| 1584 | 1591 | ||
| 1585 | ++it->glyph_row->used[it->area]; | 1592 | ++it->glyph_row->used[it->area]; |
| 1586 | ++glyph; | 1593 | ++glyph; |
diff --git a/src/xdisp.c b/src/xdisp.c index ddd18d502a0..b18b0e04be2 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -6549,8 +6549,8 @@ next_element_from_stretch (it) | |||
| 6549 | } | 6549 | } |
| 6550 | 6550 | ||
| 6551 | /* Scan forward from CHARPOS in the current buffer, until we find a | 6551 | /* Scan forward from CHARPOS in the current buffer, until we find a |
| 6552 | stop position > current IT's position, handling all the stop | 6552 | stop position > current IT's position. Then handle the stop |
| 6553 | positions in between. | 6553 | position before that. |
| 6554 | 6554 | ||
| 6555 | This is called when we are reordering bidirectional text. The | 6555 | This is called when we are reordering bidirectional text. The |
| 6556 | caller should save and restore IT and in particular the bidi_p | 6556 | caller should save and restore IT and in particular the bidi_p |
| @@ -6563,6 +6563,7 @@ handle_stop_backwards (it, charpos) | |||
| 6563 | { | 6563 | { |
| 6564 | struct text_pos pos1; | 6564 | struct text_pos pos1; |
| 6565 | EMACS_INT where_we_are = IT_CHARPOS (*it); | 6565 | EMACS_INT where_we_are = IT_CHARPOS (*it); |
| 6566 | EMACS_INT next_stop; | ||
| 6566 | 6567 | ||
| 6567 | /* Scan in strict logical order. */ | 6568 | /* Scan in strict logical order. */ |
| 6568 | it->bidi_p = 0; | 6569 | it->bidi_p = 0; |
| @@ -6571,12 +6572,18 @@ handle_stop_backwards (it, charpos) | |||
| 6571 | it->prev_stop = charpos; | 6572 | it->prev_stop = charpos; |
| 6572 | SET_TEXT_POS (pos1, charpos, CHAR_TO_BYTE (charpos)); | 6573 | SET_TEXT_POS (pos1, charpos, CHAR_TO_BYTE (charpos)); |
| 6573 | reseat_1 (it, pos1, 0); | 6574 | reseat_1 (it, pos1, 0); |
| 6574 | handle_stop (it); | 6575 | compute_stop_pos (it); |
| 6575 | /* We must advance forward, right? */ | 6576 | /* We must advance forward, right? */ |
| 6576 | if (it->stop_charpos <= it->prev_stop) | 6577 | if (it->stop_charpos <= it->prev_stop) |
| 6577 | abort (); | 6578 | abort (); |
| 6579 | charpos = it->stop_charpos; | ||
| 6578 | } | 6580 | } |
| 6579 | while (it->stop_charpos <= where_we_are); | 6581 | while (charpos <= where_we_are); |
| 6582 | |||
| 6583 | next_stop = it->stop_charpos; | ||
| 6584 | it->stop_charpos = it->prev_stop; | ||
| 6585 | handle_stop (it); | ||
| 6586 | it->stop_charpos = next_stop; | ||
| 6580 | } | 6587 | } |
| 6581 | 6588 | ||
| 6582 | /* Load IT with the next display element from current_buffer. Value | 6589 | /* Load IT with the next display element from current_buffer. Value |
| @@ -6668,26 +6675,31 @@ next_element_from_buffer (it) | |||
| 6668 | success_p = 0; | 6675 | success_p = 0; |
| 6669 | } | 6676 | } |
| 6670 | } | 6677 | } |
| 6671 | else if (it->bidi_p && !BIDI_AT_BASE_LEVEL (it->bidi_it)) | 6678 | else if (!(!it->bidi_p |
| 6679 | || BIDI_AT_BASE_LEVEL (it->bidi_it) | ||
| 6680 | || IT_CHARPOS (*it) == it->stop_charpos)) | ||
| 6672 | { | 6681 | { |
| 6673 | /* With bidi non-linear iteration, we could find ourselves | 6682 | /* With bidi non-linear iteration, we could find ourselves |
| 6674 | far beyond the last computed stop_charpos, with several | 6683 | far beyond the last computed stop_charpos, with several |
| 6675 | other stop positions in between that we missed. Scan | 6684 | other stop positions in between that we missed. Scan |
| 6676 | them all now, in buffer's logical order. */ | 6685 | them all now, in buffer's logical order, until we find |
| 6686 | and handle the last stop_charpos that precedes our | ||
| 6687 | current position. */ | ||
| 6677 | struct it save_it = *it; | 6688 | struct it save_it = *it; |
| 6678 | 6689 | ||
| 6679 | handle_stop_backwards (it, it->stop_charpos); | 6690 | handle_stop_backwards (it, it->stop_charpos); |
| 6680 | save_it.stop_charpos = it->stop_charpos; | 6691 | it->bidi_p = 1; |
| 6681 | save_it.prev_stop = it->prev_stop; | 6692 | it->current = save_it.current; |
| 6682 | *it = save_it; | 6693 | it->position = save_it.position; |
| 6683 | return GET_NEXT_DISPLAY_ELEMENT (it); | 6694 | return GET_NEXT_DISPLAY_ELEMENT (it); |
| 6684 | } | 6695 | } |
| 6685 | else | 6696 | else |
| 6686 | { | 6697 | { |
| 6698 | /* If we are at base paragraph embedding level, take note of | ||
| 6699 | the last stop position seen at this level. */ | ||
| 6700 | if (BIDI_AT_BASE_LEVEL (it->bidi_it)) | ||
| 6701 | it->base_level_stop = it->stop_charpos; | ||
| 6687 | handle_stop (it); | 6702 | handle_stop (it); |
| 6688 | /* We are at base paragraph embedding level, so take note of | ||
| 6689 | the last stop_pos seen at this level. */ | ||
| 6690 | it->base_level_stop = it->stop_charpos; | ||
| 6691 | return GET_NEXT_DISPLAY_ELEMENT (it); | 6703 | return GET_NEXT_DISPLAY_ELEMENT (it); |
| 6692 | } | 6704 | } |
| 6693 | } | 6705 | } |
| @@ -6696,15 +6708,15 @@ next_element_from_buffer (it) | |||
| 6696 | struct it save_it = *it; | 6708 | struct it save_it = *it; |
| 6697 | 6709 | ||
| 6698 | if (it->base_level_stop <= 0) | 6710 | if (it->base_level_stop <= 0) |
| 6699 | abort (); | 6711 | it->base_level_stop = 1; |
| 6700 | if (IT_CHARPOS (*it) < it->base_level_stop) | 6712 | if (IT_CHARPOS (*it) < it->base_level_stop) |
| 6701 | abort (); | 6713 | abort (); |
| 6702 | if (BIDI_AT_BASE_LEVEL (it->bidi_it)) | 6714 | if (BIDI_AT_BASE_LEVEL (it->bidi_it)) |
| 6703 | abort (); | 6715 | abort (); |
| 6704 | handle_stop_backwards (it, it->base_level_stop); | 6716 | handle_stop_backwards (it, it->base_level_stop); |
| 6705 | save_it.stop_charpos = it->stop_charpos; | 6717 | it->bidi_p = 1; |
| 6706 | save_it.prev_stop = it->prev_stop; | 6718 | it->current = save_it.current; |
| 6707 | *it = save_it; | 6719 | it->position = save_it.position; |
| 6708 | return GET_NEXT_DISPLAY_ELEMENT (it); | 6720 | return GET_NEXT_DISPLAY_ELEMENT (it); |
| 6709 | } | 6721 | } |
| 6710 | else | 6722 | else |
| @@ -12771,7 +12783,9 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) | |||
| 12771 | glyph--; | 12783 | glyph--; |
| 12772 | } | 12784 | } |
| 12773 | } | 12785 | } |
| 12774 | else if (match_with_avoid_cursor) | 12786 | else if (match_with_avoid_cursor |
| 12787 | /* zero-width characters produce no glyphs */ | ||
| 12788 | || eabs (glyph_after - glyph_before) == 1) | ||
| 12775 | { | 12789 | { |
| 12776 | cursor = glyph_after; | 12790 | cursor = glyph_after; |
| 12777 | x = -1; | 12791 | x = -1; |