comparison src/xdisp.c @ 111103:6af5749f5c94

Support L2R continued lines. xdisp.c (mouse_face_from_buffer_pos): Fix the case of continued L2R lines.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 28 Aug 2010 15:36:19 +0300
parents 9fbc584102c2
children 42b3175dc16e
comparison
equal deleted inserted replaced
111102:9fbc584102c2 111103:6af5749f5c94
23835 Lisp_Object after_string, 23835 Lisp_Object after_string,
23836 Lisp_Object display_string) 23836 Lisp_Object display_string)
23837 { 23837 {
23838 struct window *w = XWINDOW (window); 23838 struct window *w = XWINDOW (window);
23839 struct glyph_row *first = MATRIX_FIRST_TEXT_ROW (w->current_matrix); 23839 struct glyph_row *first = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
23840 struct glyph_row *row; 23840 struct glyph_row *row, *r;
23841 struct glyph *glyph, *end; 23841 struct glyph *glyph, *end;
23842 EMACS_INT ignore, pos; 23842 EMACS_INT ignore, pos;
23843 int x; 23843 int x;
23844 23844
23845 xassert (NILP (display_string) || STRINGP (display_string)); 23845 xassert (NILP (display_string) || STRINGP (display_string));
24014 dpyinfo->mouse_face_end_col = glyph - row->glyphs[TEXT_AREA]; 24014 dpyinfo->mouse_face_end_col = glyph - row->glyphs[TEXT_AREA];
24015 } 24015 }
24016 } 24016 }
24017 24017
24018 /* Find the last highlighted glyph. */ 24018 /* Find the last highlighted glyph. */
24019 row = row_containing_pos (w, end_charpos, first, NULL, 0); 24019 r = row_containing_pos (w, end_charpos, first, NULL, 0);
24020 if (row == NULL) 24020 if (r == NULL)
24021 { 24021 {
24022 row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); 24022 r = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
24023 dpyinfo->mouse_face_past_end = 1; 24023 dpyinfo->mouse_face_past_end = 1;
24024 } 24024 }
24025 else if (!NILP (after_string)) 24025 else if (!NILP (after_string))
24026 { 24026 {
24027 /* If the after-string has newlines, advance to its last row. */ 24027 /* If the after-string has newlines, advance to its last row. */
24028 struct glyph_row *next; 24028 struct glyph_row *next;
24029 struct glyph_row *last 24029 struct glyph_row *last
24030 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); 24030 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
24031 24031
24032 for (next = row + 1; 24032 for (next = r + 1;
24033 next <= last 24033 next <= last
24034 && next->used[TEXT_AREA] > 0 24034 && next->used[TEXT_AREA] > 0
24035 && EQ (next->glyphs[TEXT_AREA]->object, after_string); 24035 && EQ (next->glyphs[TEXT_AREA]->object, after_string);
24036 ++next) 24036 ++next)
24037 row = next; 24037 r = next;
24038 }
24039
24040 /* If the highlight ends in a different row, compute GLYPH and END
24041 for the end row. */
24042 if (r != row)
24043 {
24044 /* If the beginning row was an R2L row, we actually computed
24045 above the beginning of the highlighted area, not its end. */
24046 if (row->reversed_p)
24047 {
24048 dpyinfo->mouse_face_beg_x = dpyinfo->mouse_face_end_x;
24049 dpyinfo->mouse_face_beg_col = dpyinfo->mouse_face_end_col;
24050 }
24051 if (!r->reversed_p)
24052 {
24053 glyph = r->glyphs[TEXT_AREA];
24054 end = glyph + r->used[TEXT_AREA];
24055 x = r->x;
24056 }
24057 else
24058 {
24059 end = r->glyphs[TEXT_AREA] - 1;
24060 glyph = end + r->used[TEXT_AREA];
24061 }
24062 row = r;
24038 } 24063 }
24039 24064
24040 dpyinfo->mouse_face_end_y = row->y; 24065 dpyinfo->mouse_face_end_y = row->y;
24041 dpyinfo->mouse_face_end_row = MATRIX_ROW_VPOS (row, w->current_matrix); 24066 dpyinfo->mouse_face_end_row = MATRIX_ROW_VPOS (row, w->current_matrix);
24042 24067
24128 break; 24153 break;
24129 } 24154 }
24130 x += end->pixel_width; 24155 x += end->pixel_width;
24131 } 24156 }
24132 /* In the left-to-right screen geometry, END is actually the 24157 /* In the left-to-right screen geometry, END is actually the
24133 _beginning_ of the highlighted area for R2L paragraphs. */ 24158 _beginning_ of the highlighted area for R2L paragraphs, if
24134 dpyinfo->mouse_face_beg_x = x; 24159 the highlight begins and ends in the same row. */
24135 dpyinfo->mouse_face_beg_col = end - row->glyphs[TEXT_AREA]; 24160 if (dpyinfo->mouse_face_end_row == dpyinfo->mouse_face_beg_row)
24161 {
24162 dpyinfo->mouse_face_beg_x = x;
24163 dpyinfo->mouse_face_beg_col = end - row->glyphs[TEXT_AREA];
24164 }
24165 else
24166 {
24167 dpyinfo->mouse_face_end_x = x;
24168 dpyinfo->mouse_face_end_col = end - row->glyphs[TEXT_AREA];
24169 }
24136 } 24170 }
24137 24171
24138 dpyinfo->mouse_face_window = window; 24172 dpyinfo->mouse_face_window = window;
24139 dpyinfo->mouse_face_face_id 24173 dpyinfo->mouse_face_face_id
24140 = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore, 24174 = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore,