diff options
| author | Eli Zaretskii | 2010-08-28 14:09:02 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2010-08-28 14:09:02 +0300 |
| commit | 3e61caebcf490a3d99f50221aed1f11c6bcfdcd7 (patch) | |
| tree | e9232291b1d88ab5e49279a8fcd4f2712be723db | |
| parent | 544bbc31d93719ca7419f6da97809ad5eef1c378 (diff) | |
| download | emacs-3e61caebcf490a3d99f50221aed1f11c6bcfdcd7.tar.gz emacs-3e61caebcf490a3d99f50221aed1f11c6bcfdcd7.zip | |
Support R2L rows. Continued lines still don't work correctly.
xdisp.c (mouse_face_from_buffer_pos): Fix code using bug#1220 as
test case. Implement highlight for R2L rows.
| -rw-r--r-- | src/ChangeLog | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 118 |
2 files changed, 112 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9b7c11d3bde..01dc3dfb305 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | 2010-08-28 Eli Zaretskii <eliz@gnu.org> | 1 | 2010-08-28 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * xdisp.c (mouse_face_from_buffer_pos): Fix code using bug#1220 as | 3 | * xdisp.c (mouse_face_from_buffer_pos): Fix code using bug#1220 as |
| 4 | test case. | 4 | test case. Implement highlight for R2L rows. |
| 5 | 5 | ||
| 6 | 2010-08-21 Eli Zaretskii <eliz@gnu.org> | 6 | 2010-08-21 Eli Zaretskii <eliz@gnu.org> |
| 7 | 7 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index c6d441fa6c1..296fe5d2c59 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -23916,9 +23916,10 @@ mouse_face_from_buffer_pos (Lisp_Object window, | |||
| 23916 | ++glyph) | 23916 | ++glyph) |
| 23917 | x += glyph->pixel_width; | 23917 | x += glyph->pixel_width; |
| 23918 | 23918 | ||
| 23919 | /* Scan the glyph row, looking for BEFORE_STRING, AFTER_STRING, | 23919 | /* Scan the glyph row, looking for BEFORE_STRING, |
| 23920 | or DISPLAY_STRING, and the first glyph whose position is | 23920 | AFTER_STRING, or DISPLAY_STRING, and the first glyph from |
| 23921 | between START_CHARPOS and END_CHARPOS. */ | 23921 | buffer whose position is between START_CHARPOS and |
| 23922 | END_CHARPOS. */ | ||
| 23922 | for (; glyph < end | 23923 | for (; glyph < end |
| 23923 | && !INTEGERP (glyph->object) | 23924 | && !INTEGERP (glyph->object) |
| 23924 | && !EQ (glyph->object, display_string) | 23925 | && !EQ (glyph->object, display_string) |
| @@ -23953,7 +23954,64 @@ mouse_face_from_buffer_pos (Lisp_Object window, | |||
| 23953 | } | 23954 | } |
| 23954 | else | 23955 | else |
| 23955 | { | 23956 | { |
| 23956 | /* FIXME! */ | 23957 | /* This row is in a right to left paragraph. Scan it right |
| 23958 | to left. */ | ||
| 23959 | struct glyph *g; | ||
| 23960 | |||
| 23961 | end = row->glyphs[TEXT_AREA] - 1; | ||
| 23962 | glyph = end + row->used[TEXT_AREA]; | ||
| 23963 | |||
| 23964 | /* Skip truncation glyphs at the start of the glyph row. */ | ||
| 23965 | if (row->displays_text_p) | ||
| 23966 | for (; glyph > end | ||
| 23967 | && INTEGERP (glyph->object) | ||
| 23968 | && glyph->charpos < 0; | ||
| 23969 | --glyph) | ||
| 23970 | ; | ||
| 23971 | |||
| 23972 | /* Scan the glyph row, looking for BEFORE_STRING, | ||
| 23973 | AFTER_STRING, or DISPLAY_STRING, and the first glyph from | ||
| 23974 | buffer whose position is between START_CHARPOS and | ||
| 23975 | END_CHARPOS. */ | ||
| 23976 | for (; glyph > end | ||
| 23977 | && !INTEGERP (glyph->object) | ||
| 23978 | && !EQ (glyph->object, display_string) | ||
| 23979 | && !(BUFFERP (glyph->object) | ||
| 23980 | && (glyph->charpos >= start_charpos | ||
| 23981 | && glyph->charpos < end_charpos)); | ||
| 23982 | --glyph) | ||
| 23983 | { | ||
| 23984 | /* BEFORE_STRING or AFTER_STRING are only relevant if | ||
| 23985 | they are present at buffer positions between | ||
| 23986 | START_CHARPOS and END_CHARPOS, or if they come from | ||
| 23987 | an overlay. */ | ||
| 23988 | if (EQ (glyph->object, before_string)) | ||
| 23989 | { | ||
| 23990 | pos = string_buffer_position (w, before_string, | ||
| 23991 | start_charpos); | ||
| 23992 | /* If pos == 0, it means before_string came from an | ||
| 23993 | overlay, not from a buffer position. */ | ||
| 23994 | if (!pos || pos >= start_charpos && pos < end_charpos) | ||
| 23995 | break; | ||
| 23996 | } | ||
| 23997 | else if (EQ (glyph->object, after_string)) | ||
| 23998 | { | ||
| 23999 | pos = string_buffer_position (w, after_string, end_charpos); | ||
| 24000 | if (!pos || pos >= start_charpos && pos < end_charpos) | ||
| 24001 | break; | ||
| 24002 | } | ||
| 24003 | } | ||
| 24004 | |||
| 24005 | /* Mouse highlight uses the screen geometry, which is left | ||
| 24006 | to right even in R2L paragraphs. Therefore, for R2L | ||
| 24007 | paragraphs, the "first" highlighted glyph actually | ||
| 24008 | determines the _end_ column and x of the highlighted | ||
| 24009 | area. */ | ||
| 24010 | glyph++; /* first glyph beyond the highlighted area */ | ||
| 24011 | for (g = row->glyphs[TEXT_AREA], x = row->x; g < glyph; g++) | ||
| 24012 | x += g->pixel_width; | ||
| 24013 | dpyinfo->mouse_face_end_x = x; | ||
| 24014 | dpyinfo->mouse_face_end_col = glyph - row->glyphs[TEXT_AREA]; | ||
| 23957 | } | 24015 | } |
| 23958 | } | 24016 | } |
| 23959 | 24017 | ||
| @@ -24023,14 +24081,60 @@ mouse_face_from_buffer_pos (Lisp_Object window, | |||
| 24023 | /* Find the X coordinate of the last glyph to be highlighted. */ | 24081 | /* Find the X coordinate of the last glyph to be highlighted. */ |
| 24024 | for (; glyph <= end; ++glyph) | 24082 | for (; glyph <= end; ++glyph) |
| 24025 | x += glyph->pixel_width; | 24083 | x += glyph->pixel_width; |
| 24084 | |||
| 24085 | dpyinfo->mouse_face_end_x = x; | ||
| 24086 | dpyinfo->mouse_face_end_col = glyph - row->glyphs[TEXT_AREA]; | ||
| 24026 | } | 24087 | } |
| 24027 | else | 24088 | else |
| 24028 | { | 24089 | { |
| 24029 | /* FIXME! */ | 24090 | /* Skip truncation and continuation glyphs near the end of the |
| 24091 | row, and also blanks and stretch glyphs inserted by | ||
| 24092 | extend_face_to_end_of_line. */ | ||
| 24093 | x = row->x; | ||
| 24094 | end++; | ||
| 24095 | while (end < glyph | ||
| 24096 | && INTEGERP (end->object) | ||
| 24097 | && end->charpos <= 0) | ||
| 24098 | { | ||
| 24099 | x += end->pixel_width; | ||
| 24100 | ++end; | ||
| 24101 | } | ||
| 24102 | /* Scan the rest of the glyph row from the end, looking for the | ||
| 24103 | first glyph that comes from BEFORE_STRING, AFTER_STRING, or | ||
| 24104 | DISPLAY_STRING, or whose position is between START_CHARPOS | ||
| 24105 | and END_CHARPOS */ | ||
| 24106 | for ( ; | ||
| 24107 | end < glyph | ||
| 24108 | && !INTEGERP (end->object) | ||
| 24109 | && !EQ (end->object, display_string) | ||
| 24110 | && !(BUFFERP (end->object) | ||
| 24111 | && (end->charpos >= start_charpos | ||
| 24112 | && end->charpos < end_charpos)); | ||
| 24113 | ++end) | ||
| 24114 | { | ||
| 24115 | /* BEFORE_STRING or AFTER_STRING are only relevant if they | ||
| 24116 | are present at buffer positions between START_CHARPOS and | ||
| 24117 | END_CHARPOS, or if they come from an overlay. */ | ||
| 24118 | if (EQ (end->object, before_string)) | ||
| 24119 | { | ||
| 24120 | pos = string_buffer_position (w, before_string, start_charpos); | ||
| 24121 | if (!pos || pos >= start_charpos && pos < end_charpos) | ||
| 24122 | break; | ||
| 24123 | } | ||
| 24124 | else if (EQ (end->object, after_string)) | ||
| 24125 | { | ||
| 24126 | pos = string_buffer_position (w, after_string, end_charpos); | ||
| 24127 | if (!pos || pos >= start_charpos && pos < end_charpos) | ||
| 24128 | break; | ||
| 24129 | } | ||
| 24130 | x += end->pixel_width; | ||
| 24131 | } | ||
| 24132 | /* In the left-to-right screen geometry, END is actually the | ||
| 24133 | _beginning_ of the highlighted area for R2L paragraphs. */ | ||
| 24134 | dpyinfo->mouse_face_beg_x = x; | ||
| 24135 | dpyinfo->mouse_face_beg_col = end - row->glyphs[TEXT_AREA]; | ||
| 24030 | } | 24136 | } |
| 24031 | 24137 | ||
| 24032 | dpyinfo->mouse_face_end_x = x; | ||
| 24033 | dpyinfo->mouse_face_end_col = glyph - row->glyphs[TEXT_AREA]; | ||
| 24034 | dpyinfo->mouse_face_window = window; | 24138 | dpyinfo->mouse_face_window = window; |
| 24035 | dpyinfo->mouse_face_face_id | 24139 | dpyinfo->mouse_face_face_id |
| 24036 | = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore, | 24140 | = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore, |