diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 16 | ||||
| -rw-r--r-- | src/bidi.c | 6 | ||||
| -rw-r--r-- | src/dispextern.h | 3 | ||||
| -rw-r--r-- | src/xdisp.c | 103 |
4 files changed, 95 insertions, 33 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 96b8d7ae7be..51e4561f8db 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,21 @@ | |||
| 1 | 2011-06-09 Eli Zaretskii <eliz@gnu.org> | 1 | 2011-06-09 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * bidi.c (bidi_level_of_next_char): Allow the sentinel "position" | ||
| 4 | to pass the test for valid cached positions. | ||
| 5 | |||
| 6 | * xdisp.c (init_iterator): Call bidi_init_it only of a valid | ||
| 7 | buffer position was specified. Initialize paragraph_embedding to | ||
| 8 | L2R. | ||
| 9 | (reseat_to_string): Initialize the bidi iterator (for now ifdef'ed | ||
| 10 | out). | ||
| 11 | (display_string): If we need to ignore text properties of | ||
| 12 | LISP_STRING, set IT->stop_charpos to IT->end_charpos. (The | ||
| 13 | original value of -1 will not work with bidi.) | ||
| 14 | |||
| 15 | * dispextern.h (struct bidi_string_data): New member lstring. | ||
| 16 | |||
| 17 | 2011-06-09 Eli Zaretskii <eliz@gnu.org> | ||
| 18 | |||
| 3 | * xdisp.c (Fcurrent_bidi_paragraph_direction): Initialize | 19 | * xdisp.c (Fcurrent_bidi_paragraph_direction): Initialize |
| 4 | itb.string.s to NULL (avoids a crash in bidi_paragraph_init). | 20 | itb.string.s to NULL (avoids a crash in bidi_paragraph_init). |
| 5 | 21 | ||
diff --git a/src/bidi.c b/src/bidi.c index ac950a9000a..a0a57b4c681 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -1679,7 +1679,11 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) | |||
| 1679 | abort (); | 1679 | abort (); |
| 1680 | next_char_pos = bidi_it->charpos + bidi_it->nchars; | 1680 | next_char_pos = bidi_it->charpos + bidi_it->nchars; |
| 1681 | } | 1681 | } |
| 1682 | else if (bidi_it->charpos > (bidi_it->string.s ? 0 : 1)) | 1682 | else if (bidi_it->charpos >= (bidi_it->string.s ? 0 : 1)) |
| 1683 | /* Implementation note: we allow next_char_pos to be as low as | ||
| 1684 | 0 for buffers or -1 for strings, and that is okay because | ||
| 1685 | that's the "position" of the sentinel iterator state we | ||
| 1686 | cached at the beginning of the iteration. */ | ||
| 1683 | next_char_pos = bidi_it->charpos - 1; | 1687 | next_char_pos = bidi_it->charpos - 1; |
| 1684 | if (next_char_pos >= 0) | 1688 | if (next_char_pos >= 0) |
| 1685 | type = bidi_cache_find (next_char_pos, -1, bidi_it); | 1689 | type = bidi_cache_find (next_char_pos, -1, bidi_it); |
diff --git a/src/dispextern.h b/src/dispextern.h index 0f7089d7916..979cb43e98f 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -1814,7 +1814,8 @@ struct bidi_stack { | |||
| 1814 | 1814 | ||
| 1815 | /* Data type for storing information about a string being iterated on. */ | 1815 | /* Data type for storing information about a string being iterated on. */ |
| 1816 | struct bidi_string_data { | 1816 | struct bidi_string_data { |
| 1817 | const unsigned char *s; /* the string, or NULL if reordering buffer */ | 1817 | Lisp_Object lstring; /* Lisp string to reorder, or nil */ |
| 1818 | const unsigned char *s; /* string data, or NULL if reordering buffer */ | ||
| 1818 | EMACS_INT schars; /* the number of characters in the string, | 1819 | EMACS_INT schars; /* the number of characters in the string, |
| 1819 | excluding the terminating null */ | 1820 | excluding the terminating null */ |
| 1820 | unsigned from_disp_str : 1; /* 1 means the string comes from a | 1821 | unsigned from_disp_str : 1; /* 1 means the string comes from a |
diff --git a/src/xdisp.c b/src/xdisp.c index 72aea8d224f..712088db324 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -129,9 +129,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 129 | argument. | 129 | argument. |
| 130 | 130 | ||
| 131 | Iteration over things to be displayed is then simple. It is | 131 | Iteration over things to be displayed is then simple. It is |
| 132 | started by initializing an iterator with a call to init_iterator. | 132 | started by initializing an iterator with a call to init_iterator, |
| 133 | Calls to get_next_display_element fill the iterator structure with | 133 | passing it the buffer position where to start iteration. For |
| 134 | relevant information about the next thing to display. Calls to | 134 | iteration over strings, pass -1 as the position to init_iterator, |
| 135 | and call reseat_to_string when the string is ready, to initialize | ||
| 136 | the iterator for that string. Thereafter, calls to | ||
| 137 | get_next_display_element fill the iterator structure with relevant | ||
| 138 | information about the next thing to display. Calls to | ||
| 135 | set_iterator_to_next move the iterator to the next thing. | 139 | set_iterator_to_next move the iterator to the next thing. |
| 136 | 140 | ||
| 137 | Besides this, an iterator also contains information about the | 141 | Besides this, an iterator also contains information about the |
| @@ -2342,6 +2346,8 @@ init_iterator (struct it *it, struct window *w, | |||
| 2342 | it->base_face_id = remapped_base_face_id; | 2346 | it->base_face_id = remapped_base_face_id; |
| 2343 | it->string = Qnil; | 2347 | it->string = Qnil; |
| 2344 | IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = -1; | 2348 | IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = -1; |
| 2349 | it->paragraph_embedding = L2R; | ||
| 2350 | it->bidi_it.string.lstring = Qnil; | ||
| 2345 | it->bidi_it.string.s = NULL; | 2351 | it->bidi_it.string.s = NULL; |
| 2346 | 2352 | ||
| 2347 | /* The window in which we iterate over current_buffer: */ | 2353 | /* The window in which we iterate over current_buffer: */ |
| @@ -2555,21 +2561,6 @@ init_iterator (struct it *it, struct window *w, | |||
| 2555 | it->start_of_box_run_p = 1; | 2561 | it->start_of_box_run_p = 1; |
| 2556 | } | 2562 | } |
| 2557 | 2563 | ||
| 2558 | /* If we are to reorder bidirectional text, init the bidi | ||
| 2559 | iterator. */ | ||
| 2560 | if (it->bidi_p) | ||
| 2561 | { | ||
| 2562 | /* Note the paragraph direction that this buffer wants to | ||
| 2563 | use. */ | ||
| 2564 | if (EQ (BVAR (current_buffer, bidi_paragraph_direction), Qleft_to_right)) | ||
| 2565 | it->paragraph_embedding = L2R; | ||
| 2566 | else if (EQ (BVAR (current_buffer, bidi_paragraph_direction), Qright_to_left)) | ||
| 2567 | it->paragraph_embedding = R2L; | ||
| 2568 | else | ||
| 2569 | it->paragraph_embedding = NEUTRAL_DIR; | ||
| 2570 | bidi_init_it (charpos, bytepos, FRAME_WINDOW_P (it->f), &it->bidi_it); | ||
| 2571 | } | ||
| 2572 | |||
| 2573 | /* If a buffer position was specified, set the iterator there, | 2564 | /* If a buffer position was specified, set the iterator there, |
| 2574 | getting overlays and face properties from that position. */ | 2565 | getting overlays and face properties from that position. */ |
| 2575 | if (charpos >= BUF_BEG (current_buffer)) | 2566 | if (charpos >= BUF_BEG (current_buffer)) |
| @@ -2586,6 +2577,24 @@ init_iterator (struct it *it, struct window *w, | |||
| 2586 | 2577 | ||
| 2587 | it->start = it->current; | 2578 | it->start = it->current; |
| 2588 | 2579 | ||
| 2580 | /* If we are to reorder bidirectional text, init the bidi | ||
| 2581 | iterator. */ | ||
| 2582 | if (it->bidi_p) | ||
| 2583 | { | ||
| 2584 | /* Note the paragraph direction that this buffer wants to | ||
| 2585 | use. */ | ||
| 2586 | if (EQ (BVAR (current_buffer, bidi_paragraph_direction), | ||
| 2587 | Qleft_to_right)) | ||
| 2588 | it->paragraph_embedding = L2R; | ||
| 2589 | else if (EQ (BVAR (current_buffer, bidi_paragraph_direction), | ||
| 2590 | Qright_to_left)) | ||
| 2591 | it->paragraph_embedding = R2L; | ||
| 2592 | else | ||
| 2593 | it->paragraph_embedding = NEUTRAL_DIR; | ||
| 2594 | bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), | ||
| 2595 | &it->bidi_it); | ||
| 2596 | } | ||
| 2597 | |||
| 2589 | /* Compute faces etc. */ | 2598 | /* Compute faces etc. */ |
| 2590 | reseat (it, it->current.pos, 1); | 2599 | reseat (it, it->current.pos, 1); |
| 2591 | } | 2600 | } |
| @@ -5486,6 +5495,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p) | |||
| 5486 | it->bidi_it.paragraph_dir = NEUTRAL_DIR; | 5495 | it->bidi_it.paragraph_dir = NEUTRAL_DIR; |
| 5487 | it->bidi_it.disp_pos = -1; | 5496 | it->bidi_it.disp_pos = -1; |
| 5488 | it->bidi_it.string.s = NULL; | 5497 | it->bidi_it.string.s = NULL; |
| 5498 | it->bidi_it.string.lstring = Qnil; | ||
| 5489 | } | 5499 | } |
| 5490 | 5500 | ||
| 5491 | if (set_stop_p) | 5501 | if (set_stop_p) |
| @@ -5536,6 +5546,8 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string, | |||
| 5536 | if (multibyte >= 0) | 5546 | if (multibyte >= 0) |
| 5537 | it->multibyte_p = multibyte > 0; | 5547 | it->multibyte_p = multibyte > 0; |
| 5538 | #if 0 | 5548 | #if 0 |
| 5549 | /* String reordering is controlled by the default value of | ||
| 5550 | bidi-display-reordering. */ | ||
| 5539 | it->bidi_p = | 5551 | it->bidi_p = |
| 5540 | it->multibyte_p && BVAR (&buffer_defaults, bidi_display_reordering); | 5552 | it->multibyte_p && BVAR (&buffer_defaults, bidi_display_reordering); |
| 5541 | #endif | 5553 | #endif |
| @@ -5550,9 +5562,15 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string, | |||
| 5550 | it->current.string_pos = string_pos (charpos, string); | 5562 | it->current.string_pos = string_pos (charpos, string); |
| 5551 | #if 0 | 5563 | #if 0 |
| 5552 | if (it->bidi_p) | 5564 | if (it->bidi_p) |
| 5553 | bidi_init_it (); | 5565 | { |
| 5554 | it->bidi_it.string.s = SDATA (string); | 5566 | it->paragraph_embedding = NEUTRAL_DIR; |
| 5555 | it->bidi_it.string.schars = it->end_charpos; | 5567 | it->bidi_it.string.lstring = string; |
| 5568 | it->bidi_it.string.s = SDATA (string); | ||
| 5569 | it->bidi_it.string.schars = it->end_charpos; | ||
| 5570 | it->bidi_it.string.from_disp_str = 0; | ||
| 5571 | bidi_init_it (charpos, IT_STRING_BYTEPOS (*it), | ||
| 5572 | FRAME_WINDOW_P (it->f), &it->bidi_it); | ||
| 5573 | } | ||
| 5556 | #endif | 5574 | #endif |
| 5557 | } | 5575 | } |
| 5558 | else | 5576 | else |
| @@ -5569,18 +5587,22 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string, | |||
| 5569 | it->end_charpos = it->string_nchars = number_of_chars (s, 1); | 5587 | it->end_charpos = it->string_nchars = number_of_chars (s, 1); |
| 5570 | #if 0 | 5588 | #if 0 |
| 5571 | if (it->bidi_p) | 5589 | if (it->bidi_p) |
| 5572 | bidi_init_it (); | 5590 | { |
| 5573 | it->bidi_it.string.s = s; | 5591 | it->paragraph_embedding = NEUTRAL_DIR; |
| 5574 | it->bidi_it.string.schars = it->end_charpos; | 5592 | it->bidi_it.string.lstring = Qnil; |
| 5593 | it->bidi_it.string.s = s; | ||
| 5594 | it->bidi_it.string.schars = it->end_charpos; | ||
| 5595 | it->bidi_it.string.from_disp_str = 0; | ||
| 5596 | bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), | ||
| 5597 | &it->bidi_it); | ||
| 5598 | } | ||
| 5575 | #endif | 5599 | #endif |
| 5576 | } | 5600 | } |
| 5577 | else | 5601 | else |
| 5578 | { | 5602 | { |
| 5603 | /* Unibyte (a.k.a. ASCII) C strings are never bidi-reordered. */ | ||
| 5579 | IT_CHARPOS (*it) = IT_BYTEPOS (*it) = charpos; | 5604 | IT_CHARPOS (*it) = IT_BYTEPOS (*it) = charpos; |
| 5580 | it->end_charpos = it->string_nchars = strlen (s); | 5605 | it->end_charpos = it->string_nchars = strlen (s); |
| 5581 | #if 0 | ||
| 5582 | it->bidi_p = 0; | ||
| 5583 | #endif | ||
| 5584 | } | 5606 | } |
| 5585 | 5607 | ||
| 5586 | it->method = GET_FROM_C_STRING; | 5608 | it->method = GET_FROM_C_STRING; |
| @@ -5589,7 +5611,13 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string, | |||
| 5589 | /* PRECISION > 0 means don't return more than PRECISION characters | 5611 | /* PRECISION > 0 means don't return more than PRECISION characters |
| 5590 | from the string. */ | 5612 | from the string. */ |
| 5591 | if (precision > 0 && it->end_charpos - charpos > precision) | 5613 | if (precision > 0 && it->end_charpos - charpos > precision) |
| 5592 | it->end_charpos = it->string_nchars = charpos + precision; | 5614 | { |
| 5615 | it->end_charpos = it->string_nchars = charpos + precision; | ||
| 5616 | #if 0 | ||
| 5617 | if (it->bidi_p) | ||
| 5618 | it->bidi_it.string.schars = it->end_charpos; | ||
| 5619 | #endif | ||
| 5620 | } | ||
| 5593 | 5621 | ||
| 5594 | /* FIELD_WIDTH > 0 means pad with spaces until FIELD_WIDTH | 5622 | /* FIELD_WIDTH > 0 means pad with spaces until FIELD_WIDTH |
| 5595 | characters have been returned. FIELD_WIDTH == 0 means don't pad, | 5623 | characters have been returned. FIELD_WIDTH == 0 means don't pad, |
| @@ -5597,6 +5625,9 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string, | |||
| 5597 | padding with `-' at the end of a mode line. */ | 5625 | padding with `-' at the end of a mode line. */ |
| 5598 | if (field_width < 0) | 5626 | if (field_width < 0) |
| 5599 | field_width = INFINITY; | 5627 | field_width = INFINITY; |
| 5628 | /* Implementation note: We deliberately don't enlarge | ||
| 5629 | it->bidi_it.string.schars here to fit it->end_charpos, because | ||
| 5630 | the bidi iterator cannot produce characters out of thin air. */ | ||
| 5600 | if (field_width > it->end_charpos - charpos) | 5631 | if (field_width > it->end_charpos - charpos) |
| 5601 | it->end_charpos = charpos + field_width; | 5632 | it->end_charpos = charpos + field_width; |
| 5602 | 5633 | ||
| @@ -5605,6 +5636,16 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string, | |||
| 5605 | it->dp = XCHAR_TABLE (Vstandard_display_table); | 5636 | it->dp = XCHAR_TABLE (Vstandard_display_table); |
| 5606 | 5637 | ||
| 5607 | it->stop_charpos = charpos; | 5638 | it->stop_charpos = charpos; |
| 5639 | #if 0 | ||
| 5640 | it->prev_stop = charpos; | ||
| 5641 | it->base_level_stop = 0; | ||
| 5642 | if (it->bidi_p) | ||
| 5643 | { | ||
| 5644 | it->bidi_it.first_elt = 1; | ||
| 5645 | it->bidi_it.paragraph_dir = NEUTRAL_DIR; | ||
| 5646 | it->bidi_it.disp_pos = -1; | ||
| 5647 | } | ||
| 5648 | #endif | ||
| 5608 | if (s == NULL && it->multibyte_p) | 5649 | if (s == NULL && it->multibyte_p) |
| 5609 | { | 5650 | { |
| 5610 | EMACS_INT endpos = SCHARS (it->string); | 5651 | EMACS_INT endpos = SCHARS (it->string); |
| @@ -19989,10 +20030,10 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st | |||
| 19989 | if (string && STRINGP (lisp_string)) | 20030 | if (string && STRINGP (lisp_string)) |
| 19990 | /* LISP_STRING is the one returned by decode_mode_spec. We should | 20031 | /* LISP_STRING is the one returned by decode_mode_spec. We should |
| 19991 | ignore its text properties. */ | 20032 | ignore its text properties. */ |
| 19992 | it->stop_charpos = -1; | 20033 | it->stop_charpos = it->end_charpos; |
| 19993 | 20034 | ||
| 19994 | /* If displaying STRING, set up the face of the iterator | 20035 | /* If displaying STRING, set up the face of the iterator from |
| 19995 | from LISP_STRING, if that's given. */ | 20036 | FACE_STRING, if that's given. */ |
| 19996 | if (STRINGP (face_string)) | 20037 | if (STRINGP (face_string)) |
| 19997 | { | 20038 | { |
| 19998 | EMACS_INT endptr; | 20039 | EMACS_INT endptr; |