diff options
| author | Eli Zaretskii | 2010-04-10 15:40:35 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2010-04-10 15:40:35 +0300 |
| commit | 2204f4de61e2b10832e13748f36d705854f7bd56 (patch) | |
| tree | dc1519ab81e43f911977470b9f12ca9e5dbb0357 /src | |
| parent | 9cbb0335ff22a0b3f427626340e5028cc44bd698 (diff) | |
| download | emacs-2204f4de61e2b10832e13748f36d705854f7bd56.tar.gz emacs-2204f4de61e2b10832e13748f36d705854f7bd56.zip | |
Initial implementation of display of R2L paragraphs in GUI sessions.
xdisp.c [HAVE_WINDOW_SYSTEM]: Add prototype for
append_stretch_glyph.
(set_cursor_from_row) <cursor_x>: Remove unused variable. Fix
off-by-one error in computing x at end of text in the row.
(extend_face_to_end_of_line): If the row is reversed, prepend a
stretch glyph whose width is such that the rightmost glyph will be
drawn at the right margin of the window.
(append_stretch_glyph): In reversed row, prepend the glyph rather
than append it. Set resolved_level and bidi_type of the glyph.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/xdisp.c | 75 |
2 files changed, 80 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0f61c91c790..268a245caf3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2010-04-10 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | Implement display of R2L paragraphs in GUI sessions. | ||
| 4 | |||
| 5 | * xdisp.c [HAVE_WINDOW_SYSTEM]: Add prototype for | ||
| 6 | append_stretch_glyph. | ||
| 7 | (set_cursor_from_row) <cursor_x>: Remove unused variable. Fix | ||
| 8 | off-by-one error in computing x at end of text in the row. | ||
| 9 | (extend_face_to_end_of_line): If the row is reversed, prepend a | ||
| 10 | stretch glyph whose width is such that the rightmost glyph will be | ||
| 11 | drawn at the right margin of the window. | ||
| 12 | (append_stretch_glyph): In reversed row, prepend the glyph rather | ||
| 13 | than append it. Set resolved_level and bidi_type of the glyph. | ||
| 14 | |||
| 1 | 2010-04-08 Eli Zaretskii <eliz@gnu.org> | 15 | 2010-04-08 Eli Zaretskii <eliz@gnu.org> |
| 2 | 16 | ||
| 3 | * xdisp.c (set_cursor_from_row): Don't dereference glyphs beyond | 17 | * xdisp.c (set_cursor_from_row): Don't dereference glyphs beyond |
diff --git a/src/xdisp.c b/src/xdisp.c index baede013485..f93ed533c28 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -999,6 +999,8 @@ static void display_tool_bar_line P_ ((struct it *, int)); | |||
| 999 | static void notice_overwritten_cursor P_ ((struct window *, | 999 | static void notice_overwritten_cursor P_ ((struct window *, |
| 1000 | enum glyph_row_area, | 1000 | enum glyph_row_area, |
| 1001 | int, int, int, int)); | 1001 | int, int, int, int)); |
| 1002 | static void append_stretch_glyph P_ ((struct it *, Lisp_Object, | ||
| 1003 | int, int, int)); | ||
| 1002 | 1004 | ||
| 1003 | 1005 | ||
| 1004 | 1006 | ||
| @@ -12548,7 +12550,6 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) | |||
| 12548 | /* The last known character position in row. */ | 12550 | /* The last known character position in row. */ |
| 12549 | int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta; | 12551 | int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta; |
| 12550 | int x = row->x; | 12552 | int x = row->x; |
| 12551 | int cursor_x = x; | ||
| 12552 | EMACS_INT pt_old = PT - delta; | 12553 | EMACS_INT pt_old = PT - delta; |
| 12553 | EMACS_INT pos_before = MATRIX_ROW_START_CHARPOS (row) + delta; | 12554 | EMACS_INT pos_before = MATRIX_ROW_START_CHARPOS (row) + delta; |
| 12554 | EMACS_INT pos_after = MATRIX_ROW_END_CHARPOS (row) + delta; | 12555 | EMACS_INT pos_after = MATRIX_ROW_END_CHARPOS (row) + delta; |
| @@ -12616,7 +12617,6 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) | |||
| 12616 | rightmost (first in the reading order) glyph. */ | 12617 | rightmost (first in the reading order) glyph. */ |
| 12617 | for (g = end + 1; g < glyph; g++) | 12618 | for (g = end + 1; g < glyph; g++) |
| 12618 | x += g->pixel_width; | 12619 | x += g->pixel_width; |
| 12619 | cursor_x = x; | ||
| 12620 | while (end < glyph | 12620 | while (end < glyph |
| 12621 | && INTEGERP ((end + 1)->object) | 12621 | && INTEGERP ((end + 1)->object) |
| 12622 | && (end + 1)->charpos <= 0) | 12622 | && (end + 1)->charpos <= 0) |
| @@ -12631,7 +12631,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) | |||
| 12631 | rightmost glyph. Case in point: an empty last line that is | 12631 | rightmost glyph. Case in point: an empty last line that is |
| 12632 | part of an R2L paragraph. */ | 12632 | part of an R2L paragraph. */ |
| 12633 | cursor = end - 1; | 12633 | cursor = end - 1; |
| 12634 | x = -1; /* will be computed below, at lable compute_x */ | 12634 | x = -1; /* will be computed below, at label compute_x */ |
| 12635 | } | 12635 | } |
| 12636 | 12636 | ||
| 12637 | /* Step 1: Try to find the glyph whose character position | 12637 | /* Step 1: Try to find the glyph whose character position |
| @@ -12767,7 +12767,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) | |||
| 12767 | string_seen = 1; | 12767 | string_seen = 1; |
| 12768 | } | 12768 | } |
| 12769 | --glyph; | 12769 | --glyph; |
| 12770 | if (glyph == end) | 12770 | if (glyph == glyphs_end) /* don't dereference outside TEXT_AREA */ |
| 12771 | break; | 12771 | break; |
| 12772 | x -= glyph->pixel_width; | 12772 | x -= glyph->pixel_width; |
| 12773 | } | 12773 | } |
| @@ -16772,9 +16772,11 @@ append_space_for_newline (it, default_face_p) | |||
| 16772 | 16772 | ||
| 16773 | 16773 | ||
| 16774 | /* Extend the face of the last glyph in the text area of IT->glyph_row | 16774 | /* Extend the face of the last glyph in the text area of IT->glyph_row |
| 16775 | to the end of the display line. Called from display_line. | 16775 | to the end of the display line. Called from display_line. If the |
| 16776 | If the glyph row is empty, add a space glyph to it so that we | 16776 | glyph row is empty, add a space glyph to it so that we know the |
| 16777 | know the face to draw. Set the glyph row flag fill_line_p. */ | 16777 | face to draw. Set the glyph row flag fill_line_p. If the glyph |
| 16778 | row is R2L, prepend a stretch glyph to cover the empty space to the | ||
| 16779 | left of the leftmost glyph. */ | ||
| 16778 | 16780 | ||
| 16779 | static void | 16781 | static void |
| 16780 | extend_face_to_end_of_line (it) | 16782 | extend_face_to_end_of_line (it) |
| @@ -16791,7 +16793,7 @@ extend_face_to_end_of_line (it) | |||
| 16791 | to the end of the line. If the background equals the background | 16793 | to the end of the line. If the background equals the background |
| 16792 | of the frame, we don't have to do anything. */ | 16794 | of the frame, we don't have to do anything. */ |
| 16793 | if (it->face_before_selective_p) | 16795 | if (it->face_before_selective_p) |
| 16794 | face = FACE_FROM_ID (it->f, it->saved_face_id); | 16796 | face = FACE_FROM_ID (f, it->saved_face_id); |
| 16795 | else | 16797 | else |
| 16796 | face = FACE_FROM_ID (f, it->face_id); | 16798 | face = FACE_FROM_ID (f, it->face_id); |
| 16797 | 16799 | ||
| @@ -16799,7 +16801,8 @@ extend_face_to_end_of_line (it) | |||
| 16799 | && it->glyph_row->displays_text_p | 16801 | && it->glyph_row->displays_text_p |
| 16800 | && face->box == FACE_NO_BOX | 16802 | && face->box == FACE_NO_BOX |
| 16801 | && face->background == FRAME_BACKGROUND_PIXEL (f) | 16803 | && face->background == FRAME_BACKGROUND_PIXEL (f) |
| 16802 | && !face->stipple) | 16804 | && !face->stipple |
| 16805 | && !it->glyph_row->reversed_p) | ||
| 16803 | return; | 16806 | return; |
| 16804 | 16807 | ||
| 16805 | /* Set the glyph row flag indicating that the face of the last glyph | 16808 | /* Set the glyph row flag indicating that the face of the last glyph |
| @@ -16826,6 +16829,44 @@ extend_face_to_end_of_line (it) | |||
| 16826 | it->glyph_row->glyphs[TEXT_AREA][0].face_id = it->face_id; | 16829 | it->glyph_row->glyphs[TEXT_AREA][0].face_id = it->face_id; |
| 16827 | it->glyph_row->used[TEXT_AREA] = 1; | 16830 | it->glyph_row->used[TEXT_AREA] = 1; |
| 16828 | } | 16831 | } |
| 16832 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 16833 | if (it->glyph_row->reversed_p) | ||
| 16834 | { | ||
| 16835 | /* Prepend a stretch glyph to the row, such that the | ||
| 16836 | rightmost glyph will be drawn flushed all the way to the | ||
| 16837 | right margin of the window. The stretch glyph that will | ||
| 16838 | occupy the empty space, if any, to the left of the | ||
| 16839 | glyphs. */ | ||
| 16840 | struct font *font = face->font ? face->font : FRAME_FONT (f); | ||
| 16841 | struct glyph *row_start = it->glyph_row->glyphs[TEXT_AREA]; | ||
| 16842 | struct glyph *row_end = row_start + it->glyph_row->used[TEXT_AREA]; | ||
| 16843 | struct glyph *g; | ||
| 16844 | int row_width, stretch_ascent, stretch_width; | ||
| 16845 | struct text_pos saved_pos; | ||
| 16846 | int saved_face_id, saved_avoid_cursor; | ||
| 16847 | |||
| 16848 | for (row_width = 0, g = row_start; g < row_end; g++) | ||
| 16849 | row_width += g->pixel_width; | ||
| 16850 | stretch_width = WINDOW_BOX_RIGHT_EDGE_X(it->w) | ||
| 16851 | - WINDOW_BOX_LEFT_EDGE_X(it->w) | ||
| 16852 | - WINDOW_TOTAL_FRINGE_WIDTH(it->w) | ||
| 16853 | - row_width; | ||
| 16854 | stretch_ascent = | ||
| 16855 | (((it->ascent + it->descent) | ||
| 16856 | * FONT_BASE (font)) / FONT_HEIGHT (font)); | ||
| 16857 | saved_pos = it->position; | ||
| 16858 | saved_avoid_cursor = it->avoid_cursor_p; | ||
| 16859 | saved_face_id = it->face_id; | ||
| 16860 | bzero (&it->position, sizeof it->position); | ||
| 16861 | it->avoid_cursor_p = 1; | ||
| 16862 | it->face_id = face->id; | ||
| 16863 | append_stretch_glyph (it, make_number (0), stretch_width, | ||
| 16864 | it->ascent + it->descent, stretch_ascent); | ||
| 16865 | it->position = saved_pos; | ||
| 16866 | it->avoid_cursor_p = saved_avoid_cursor; | ||
| 16867 | it->face_id = saved_face_id; | ||
| 16868 | } | ||
| 16869 | #endif /* HAVE_WINDOW_SYSTEM */ | ||
| 16829 | } | 16870 | } |
| 16830 | else | 16871 | else |
| 16831 | { | 16872 | { |
| @@ -21658,6 +21699,17 @@ append_stretch_glyph (it, object, width, height, ascent) | |||
| 21658 | glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area]; | 21699 | glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area]; |
| 21659 | if (glyph < it->glyph_row->glyphs[area + 1]) | 21700 | if (glyph < it->glyph_row->glyphs[area + 1]) |
| 21660 | { | 21701 | { |
| 21702 | /* If the glyph row is reversed, we need to prepend the glyph | ||
| 21703 | rather than append it. */ | ||
| 21704 | if (it->glyph_row->reversed_p && area == TEXT_AREA) | ||
| 21705 | { | ||
| 21706 | struct glyph *g; | ||
| 21707 | |||
| 21708 | /* Make room for the additional glyph. */ | ||
| 21709 | for (g = glyph - 1; g >= it->glyph_row->glyphs[area]; g--) | ||
| 21710 | g[1] = *g; | ||
| 21711 | glyph = it->glyph_row->glyphs[area]; | ||
| 21712 | } | ||
| 21661 | glyph->charpos = CHARPOS (it->position); | 21713 | glyph->charpos = CHARPOS (it->position); |
| 21662 | glyph->object = object; | 21714 | glyph->object = object; |
| 21663 | glyph->pixel_width = width; | 21715 | glyph->pixel_width = width; |
| @@ -21684,6 +21736,11 @@ append_stretch_glyph (it, object, width, height, ascent) | |||
| 21684 | abort (); | 21736 | abort (); |
| 21685 | glyph->bidi_type = it->bidi_it.type; | 21737 | glyph->bidi_type = it->bidi_it.type; |
| 21686 | } | 21738 | } |
| 21739 | else | ||
| 21740 | { | ||
| 21741 | glyph->resolved_level = 0; | ||
| 21742 | glyph->bidi_type = UNKNOWN_BT; | ||
| 21743 | } | ||
| 21687 | ++it->glyph_row->used[area]; | 21744 | ++it->glyph_row->used[area]; |
| 21688 | } | 21745 | } |
| 21689 | else | 21746 | else |