diff options
| author | Eli Zaretskii | 2010-11-06 15:45:37 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2010-11-06 15:45:37 +0200 |
| commit | a971c0a724a6bcdb958143b747f94c151d40359d (patch) | |
| tree | 3aa53ccad9419b212f2fbcf9bdef7eb3005022d4 /src | |
| parent | f8aefe82d2bbca46b162c75b1217d8b4bd9ebb09 (diff) | |
| download | emacs-a971c0a724a6bcdb958143b747f94c151d40359d.tar.gz emacs-a971c0a724a6bcdb958143b747f94c151d40359d.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/w32fns.c | 81 | ||||
| -rw-r--r-- | src/xfns.c | 69 |
3 files changed, 140 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 142cfeb57d7..81e9eb8215e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2010-11-06 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * xfns.c (Fx_show_tip): If any of the tool-tip text lines is R2L, | ||
| 4 | adjust width of tool-tip frame to the width of text, excluding the | ||
| 5 | stretch glyph at the beginning of R2L glyph rows. | ||
| 6 | |||
| 7 | * w32fns.c (Fx_show_tip): Likewise. | ||
| 8 | |||
| 1 | 2010-11-06 Jan Djärv <jan.h.d@swipnet.se> | 9 | 2010-11-06 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 10 | ||
| 3 | * nsfont.m: Include termchar for new mouse-highlight. | 11 | * nsfont.m: Include termchar for new mouse-highlight. |
diff --git a/src/w32fns.c b/src/w32fns.c index 15dbb404737..5a4f1354993 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -5657,7 +5657,7 @@ Text larger than the specified size is clipped. */) | |||
| 5657 | int root_x, root_y; | 5657 | int root_x, root_y; |
| 5658 | struct buffer *old_buffer; | 5658 | struct buffer *old_buffer; |
| 5659 | struct text_pos pos; | 5659 | struct text_pos pos; |
| 5660 | int i, width, height; | 5660 | int i, width, height, seen_reversed_p; |
| 5661 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 5661 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 5662 | int old_windows_or_buffers_changed = windows_or_buffers_changed; | 5662 | int old_windows_or_buffers_changed = windows_or_buffers_changed; |
| 5663 | int count = SPECPDL_INDEX (); | 5663 | int count = SPECPDL_INDEX (); |
| @@ -5787,7 +5787,7 @@ Text larger than the specified size is clipped. */) | |||
| 5787 | try_window (FRAME_ROOT_WINDOW (f), pos, 0); | 5787 | try_window (FRAME_ROOT_WINDOW (f), pos, 0); |
| 5788 | 5788 | ||
| 5789 | /* Compute width and height of the tooltip. */ | 5789 | /* Compute width and height of the tooltip. */ |
| 5790 | width = height = 0; | 5790 | width = height = seen_reversed_p = 0; |
| 5791 | for (i = 0; i < w->desired_matrix->nrows; ++i) | 5791 | for (i = 0; i < w->desired_matrix->nrows; ++i) |
| 5792 | { | 5792 | { |
| 5793 | struct glyph_row *row = &w->desired_matrix->rows[i]; | 5793 | struct glyph_row *row = &w->desired_matrix->rows[i]; |
| @@ -5801,24 +5801,83 @@ Text larger than the specified size is clipped. */) | |||
| 5801 | /* Let the row go over the full width of the frame. */ | 5801 | /* Let the row go over the full width of the frame. */ |
| 5802 | row->full_width_p = 1; | 5802 | row->full_width_p = 1; |
| 5803 | 5803 | ||
| 5804 | #ifdef TODO /* Investigate why some fonts need more width than is | 5804 | row_width = row->pixel_width; |
| 5805 | calculated for some tooltips. */ | ||
| 5806 | /* There's a glyph at the end of rows that is use to place | ||
| 5807 | the cursor there. Don't include the width of this glyph. */ | ||
| 5808 | if (row->used[TEXT_AREA]) | 5805 | if (row->used[TEXT_AREA]) |
| 5809 | { | 5806 | { |
| 5810 | last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | 5807 | if (!row->reversed_p) |
| 5811 | row_width = row->pixel_width - last->pixel_width; | 5808 | { |
| 5812 | } | 5809 | #ifdef TODO /* Investigate why some fonts need more width than is |
| 5813 | else | 5810 | calculated for some tooltips. */ |
| 5811 | |||
| 5812 | /* There's a glyph at the end of rows that is used to | ||
| 5813 | place the cursor there. Don't include the width of | ||
| 5814 | this glyph. */ | ||
| 5815 | last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | ||
| 5816 | if (INTEGERP (last->object)) | ||
| 5817 | row_width -= last->pixel_width; | ||
| 5814 | #endif | 5818 | #endif |
| 5815 | row_width = row->pixel_width; | 5819 | } |
| 5820 | else | ||
| 5821 | { | ||
| 5822 | /* There could be a stretch glyph at the beginning of R2L | ||
| 5823 | rows that is produced by extend_face_to_end_of_line. | ||
| 5824 | Don't count that glyph. */ | ||
| 5825 | struct glyph *g = row->glyphs[TEXT_AREA]; | ||
| 5826 | |||
| 5827 | if (g->type == STRETCH_GLYPH && INTEGERP (g->object)) | ||
| 5828 | { | ||
| 5829 | row_width -= g->pixel_width; | ||
| 5830 | seen_reversed_p = 1; | ||
| 5831 | } | ||
| 5832 | } | ||
| 5833 | } | ||
| 5816 | 5834 | ||
| 5817 | /* TODO: find why tips do not draw along baseline as instructed. */ | 5835 | /* TODO: find why tips do not draw along baseline as instructed. */ |
| 5818 | height += row->height; | 5836 | height += row->height; |
| 5819 | width = max (width, row_width); | 5837 | width = max (width, row_width); |
| 5820 | } | 5838 | } |
| 5821 | 5839 | ||
| 5840 | /* If we've seen partial-length R2L rows, we need to re-adjust the | ||
| 5841 | tool-tip frame width and redisplay it again, to avoid over-wide | ||
| 5842 | tips due to the stretch glyph that extends R2L lines to full | ||
| 5843 | width of the frame. */ | ||
| 5844 | if (seen_reversed_p) | ||
| 5845 | { | ||
| 5846 | /* w->total_cols and FRAME_TOTAL_COLS want the width in columns, | ||
| 5847 | not in pixels. */ | ||
| 5848 | width /= WINDOW_FRAME_COLUMN_WIDTH (w); | ||
| 5849 | w->total_cols = make_number (width); | ||
| 5850 | FRAME_TOTAL_COLS (f) = width; | ||
| 5851 | adjust_glyphs (f); | ||
| 5852 | clear_glyph_matrix (w->desired_matrix); | ||
| 5853 | clear_glyph_matrix (w->current_matrix); | ||
| 5854 | try_window (FRAME_ROOT_WINDOW (f), pos, 0); | ||
| 5855 | width = height = 0; | ||
| 5856 | /* Recompute width and height of the tooltip. */ | ||
| 5857 | for (i = 0; i < w->desired_matrix->nrows; ++i) | ||
| 5858 | { | ||
| 5859 | struct glyph_row *row = &w->desired_matrix->rows[i]; | ||
| 5860 | struct glyph *last; | ||
| 5861 | int row_width; | ||
| 5862 | |||
| 5863 | if (!row->enabled_p || !row->displays_text_p) | ||
| 5864 | break; | ||
| 5865 | row->full_width_p = 1; | ||
| 5866 | row_width = row->pixel_width; | ||
| 5867 | #ifdef TODO /* See above. */ | ||
| 5868 | if (row->used[TEXT_AREA] && !row->reversed_p) | ||
| 5869 | { | ||
| 5870 | last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | ||
| 5871 | if (INTEGERP (last->object)) | ||
| 5872 | row_width -= last->pixel_width; | ||
| 5873 | } | ||
| 5874 | #endif | ||
| 5875 | |||
| 5876 | height += row->height; | ||
| 5877 | width = max (width, row_width); | ||
| 5878 | } | ||
| 5879 | } | ||
| 5880 | |||
| 5822 | /* Add the frame's internal border to the width and height the X | 5881 | /* Add the frame's internal border to the width and height the X |
| 5823 | window should have. */ | 5882 | window should have. */ |
| 5824 | height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f); | 5883 | height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f); |
diff --git a/src/xfns.c b/src/xfns.c index 6492bbd8a23..8ef9c92523e 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5017,7 +5017,7 @@ Text larger than the specified size is clipped. */) | |||
| 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 (); |
| @@ -5158,7 +5158,7 @@ Text larger than the specified size is clipped. */) | |||
| 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]; |
| @@ -5173,19 +5173,74 @@ Text larger than the specified size is clipped. */) | |||
| 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); |
| 5187 | } | 5203 | } |
| 5188 | 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 | } | ||
| 5242 | } | ||
| 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); |