comparison src/xfns.c @ 111417:6316c70b291e

Support R2L lines in tool-tip text. xfns.c (Fx_show_tip): If any of the tool-tip text lines is R2L, adjust width of tool-tip frame to the width of text, excluding the stretch glyph at the beginning of R2L glyph rows. w32fns.c (Fx_show_tip): Likewise.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 06 Nov 2010 15:45:37 +0200
parents b9e560ce3ab6
children 8426207480fa
comparison
equal deleted inserted replaced
111416:7a88e72dff57 111417:6316c70b291e
5015 struct frame *f; 5015 struct frame *f;
5016 struct window *w; 5016 struct window *w;
5017 int root_x, root_y; 5017 int root_x, root_y;
5018 struct buffer *old_buffer; 5018 struct buffer *old_buffer;
5019 struct text_pos pos; 5019 struct text_pos pos;
5020 int i, width, height; 5020 int i, width, height, seen_reversed_p;
5021 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 5021 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
5022 int old_windows_or_buffers_changed = windows_or_buffers_changed; 5022 int old_windows_or_buffers_changed = windows_or_buffers_changed;
5023 int count = SPECPDL_INDEX (); 5023 int count = SPECPDL_INDEX ();
5024 5024
5025 specbind (Qinhibit_redisplay, Qt); 5025 specbind (Qinhibit_redisplay, Qt);
5156 clear_glyph_matrix (w->current_matrix); 5156 clear_glyph_matrix (w->current_matrix);
5157 SET_TEXT_POS (pos, BEGV, BEGV_BYTE); 5157 SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
5158 try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE); 5158 try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
5159 5159
5160 /* Compute width and height of the tooltip. */ 5160 /* Compute width and height of the tooltip. */
5161 width = height = 0; 5161 width = height = seen_reversed_p = 0;
5162 for (i = 0; i < w->desired_matrix->nrows; ++i) 5162 for (i = 0; i < w->desired_matrix->nrows; ++i)
5163 { 5163 {
5164 struct glyph_row *row = &w->desired_matrix->rows[i]; 5164 struct glyph_row *row = &w->desired_matrix->rows[i];
5165 struct glyph *last; 5165 struct glyph *last;
5166 int row_width; 5166 int row_width;
5171 5171
5172 /* Let the row go over the full width of the frame. */ 5172 /* Let the row go over the full width of the frame. */
5173 row->full_width_p = 1; 5173 row->full_width_p = 1;
5174 5174
5175 row_width = row->pixel_width; 5175 row_width = row->pixel_width;
5176 /* There's a glyph at the end of rows that is used to place
5177 the cursor there. Don't include the width of this glyph. */
5178 if (row->used[TEXT_AREA]) 5176 if (row->used[TEXT_AREA])
5179 { 5177 {
5180 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; 5178 /* There's a glyph at the end of rows that is used to place
5181 if (INTEGERP (last->object)) 5179 the cursor there. Don't include the width of this glyph. */
5182 row_width -= last->pixel_width; 5180 if (!row->reversed_p)
5181 {
5182 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
5183 if (INTEGERP (last->object))
5184 row_width -= last->pixel_width;
5185 }
5186 else
5187 {
5188 /* There could be a stretch glyph at the beginning of R2L
5189 rows that is produced by extend_face_to_end_of_line.
5190 Don't count that glyph. */
5191 struct glyph *g = row->glyphs[TEXT_AREA];
5192
5193 if (g->type == STRETCH_GLYPH && INTEGERP (g->object))
5194 {
5195 row_width -= g->pixel_width;
5196 seen_reversed_p = 1;
5197 }
5198 }
5183 } 5199 }
5184 5200
5185 height += row->height; 5201 height += row->height;
5186 width = max (width, row_width); 5202 width = max (width, row_width);
5203 }
5204
5205 /* If we've seen partial-length R2L rows, we need to re-adjust the
5206 tool-tip frame width and redisplay it again, to avoid over-wide
5207 tips due to the stretch glyph that extends R2L lines to full
5208 width of the frame. */
5209 if (seen_reversed_p)
5210 {
5211 /* w->total_cols and FRAME_TOTAL_COLS want the width in columns,
5212 not in pixels. */
5213 width /= WINDOW_FRAME_COLUMN_WIDTH (w);
5214 w->total_cols = make_number (width);
5215 FRAME_TOTAL_COLS (f) = width;
5216 adjust_glyphs (f);
5217 clear_glyph_matrix (w->desired_matrix);
5218 clear_glyph_matrix (w->current_matrix);
5219 try_window (FRAME_ROOT_WINDOW (f), pos, 0);
5220 width = height = 0;
5221 /* Recompute width and height of the tooltip. */
5222 for (i = 0; i < w->desired_matrix->nrows; ++i)
5223 {
5224 struct glyph_row *row = &w->desired_matrix->rows[i];
5225 struct glyph *last;
5226 int row_width;
5227
5228 if (!row->enabled_p || !row->displays_text_p)
5229 break;
5230 row->full_width_p = 1;
5231 row_width = row->pixel_width;
5232 if (row->used[TEXT_AREA] && !row->reversed_p)
5233 {
5234 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
5235 if (INTEGERP (last->object))
5236 row_width -= last->pixel_width;
5237 }
5238
5239 height += row->height;
5240 width = max (width, row_width);
5241 }
5187 } 5242 }
5188 5243
5189 /* Add the frame's internal border to the width and height the X 5244 /* Add the frame's internal border to the width and height the X
5190 window should have. */ 5245 window should have. */
5191 height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f); 5246 height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);