diff options
| author | Eli Zaretskii | 2010-10-16 18:14:16 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2010-10-16 18:14:16 +0200 |
| commit | d0010be502380e58590d6e771f7b1853b99897aa (patch) | |
| tree | e6c2207007f06a2406ad35cc1ed8ad8359eba1d8 | |
| parent | d2038a612693faa218797ba5a8b39ce86ecbd675 (diff) | |
| download | emacs-d0010be502380e58590d6e771f7b1853b99897aa.tar.gz emacs-d0010be502380e58590d6e771f7b1853b99897aa.zip | |
Finished work on mouse highlight that comes from display strings.
Not tested yet.
xdisp.c (fast_find_string_pos): #ifdef away, not used anymore.
(mouse_face_from_string_pos): New function, replaces fast_find_string_pos.
(note_mouse_highlight): Call it instead of fast_find_string_pos.
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/xdisp.c | 107 |
2 files changed, 103 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5f6fed12620..04861f77082 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2010-10-16 Eli Zaretskii <eliz@gnu.org> | 1 | 2010-10-16 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | * xdisp.c (fast_find_string_pos): #ifdef away, not used anymore. | ||
| 4 | (mouse_face_from_string_pos): New function, replaces | ||
| 5 | fast_find_string_pos. | ||
| 6 | (note_mouse_highlight): Call it instead of fast_find_string_pos. | ||
| 7 | |||
| 8 | 2010-10-16 Eli Zaretskii <eliz@gnu.org> | ||
| 9 | |||
| 3 | * xdisp.c (note_mode_line_or_margin_highlight): Support | 10 | * xdisp.c (note_mode_line_or_margin_highlight): Support |
| 4 | bidi-reordered strings and R2L glyph rows. Fix more comments. | 11 | bidi-reordered strings and R2L glyph rows. Fix more comments. |
| 5 | 12 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index 41be01c407f..9b58e70176d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -24324,6 +24324,11 @@ mouse_face_from_buffer_pos (Lisp_Object window, | |||
| 24324 | show_mouse_face (dpyinfo, DRAW_MOUSE_FACE); | 24324 | show_mouse_face (dpyinfo, DRAW_MOUSE_FACE); |
| 24325 | } | 24325 | } |
| 24326 | 24326 | ||
| 24327 | /* The following function is not used anymore (replaced with | ||
| 24328 | mouse_face_from_string_pos), but I leave it here for the time | ||
| 24329 | being, in case someone would. */ | ||
| 24330 | |||
| 24331 | #if 0 /* not used */ | ||
| 24327 | 24332 | ||
| 24328 | /* Find the position of the glyph for position POS in OBJECT in | 24333 | /* Find the position of the glyph for position POS in OBJECT in |
| 24329 | window W's current matrix, and return in *X, *Y the pixel | 24334 | window W's current matrix, and return in *X, *Y the pixel |
| @@ -24401,7 +24406,96 @@ fast_find_string_pos (struct window *w, EMACS_INT pos, Lisp_Object object, | |||
| 24401 | 24406 | ||
| 24402 | return best_glyph != NULL; | 24407 | return best_glyph != NULL; |
| 24403 | } | 24408 | } |
| 24409 | #endif /* not used */ | ||
| 24410 | |||
| 24411 | /* Find the positions of the first and the last glyphs in window W's | ||
| 24412 | current matrix that occlude positions [STARTPOS..ENDPOS) in OBJECT | ||
| 24413 | (assumed to be a string), and return in DPYINFO's mouse_face | ||
| 24414 | members the pixel and column/row coordinates of those glyphs. */ | ||
| 24404 | 24415 | ||
| 24416 | static void | ||
| 24417 | mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo, | ||
| 24418 | Lisp_Object object, | ||
| 24419 | EMACS_INT startpos, EMACS_INT endpos) | ||
| 24420 | { | ||
| 24421 | int yb = window_text_bottom_y (w); | ||
| 24422 | struct glyph_row *r; | ||
| 24423 | struct glyph *g, *e; | ||
| 24424 | int gx; | ||
| 24425 | int found; | ||
| 24426 | |||
| 24427 | /* Find the glyph row with at least one position in the range | ||
| 24428 | [STARTPOS..ENDPOS), and the leftmost glyph in that row whose | ||
| 24429 | position belongs to that range. */ | ||
| 24430 | for (r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); | ||
| 24431 | r->enabled_p && r->y < yb; | ||
| 24432 | ++r) | ||
| 24433 | { | ||
| 24434 | g = r->glyphs[TEXT_AREA]; | ||
| 24435 | e = g + r->used[TEXT_AREA]; | ||
| 24436 | for (gx = r->x; g < e; gx += g->pixel_width, ++g) | ||
| 24437 | if (EQ (g->object, object) | ||
| 24438 | && startpos <= g->charpos && g->charpos < endpos) | ||
| 24439 | { | ||
| 24440 | dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows; | ||
| 24441 | dpyinfo->mouse_face_beg_y = r->y; | ||
| 24442 | if (!r->reversed_p) | ||
| 24443 | { | ||
| 24444 | dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA]; | ||
| 24445 | dpyinfo->mouse_face_beg_x = gx; | ||
| 24446 | } | ||
| 24447 | else | ||
| 24448 | { | ||
| 24449 | /* R2L rows want BEG and END swapped, see | ||
| 24450 | show_mouse_face. */ | ||
| 24451 | dpyinfo->mouse_face_end_col = g - r->glyphs[TEXT_AREA]; | ||
| 24452 | dpyinfo->mouse_face_end_x = gx; | ||
| 24453 | } | ||
| 24454 | break; | ||
| 24455 | } | ||
| 24456 | } | ||
| 24457 | |||
| 24458 | /* Starting with the next row, look for the first row which does NOT | ||
| 24459 | include any glyphs whose positions are in the range. */ | ||
| 24460 | for (++r; r->enabled_p && r->y < yb; ++r) | ||
| 24461 | { | ||
| 24462 | g = r->glyphs[TEXT_AREA]; | ||
| 24463 | e = g + r->used[TEXT_AREA]; | ||
| 24464 | found = 0; | ||
| 24465 | for ( ; g < e; ++g) | ||
| 24466 | if (EQ (g->object, object) | ||
| 24467 | && startpos <= g->charpos && g->charpos < endpos) | ||
| 24468 | { | ||
| 24469 | found = 1; | ||
| 24470 | break; | ||
| 24471 | } | ||
| 24472 | if (!found) | ||
| 24473 | break; | ||
| 24474 | } | ||
| 24475 | |||
| 24476 | if (!found) | ||
| 24477 | r--; | ||
| 24478 | dpyinfo->mouse_face_end_row = r - w->current_matrix->rows; | ||
| 24479 | dpyinfo->mouse_face_end_y = r->y; | ||
| 24480 | |||
| 24481 | g = r->glyphs[TEXT_AREA]; | ||
| 24482 | e = g + r->used[TEXT_AREA]; | ||
| 24483 | for ( ; e > g; --e) | ||
| 24484 | if (EQ ((e-1)->object, object) | ||
| 24485 | && startpos <= (e-1)->charpos && (e-1)->charpos < endpos) | ||
| 24486 | break; | ||
| 24487 | if (!r->reversed_p) | ||
| 24488 | dpyinfo->mouse_face_end_col = e - g; | ||
| 24489 | else | ||
| 24490 | dpyinfo->mouse_face_beg_col = e - g; | ||
| 24491 | |||
| 24492 | for (gx = r->x; g < e; ++g) | ||
| 24493 | gx += g->pixel_width; | ||
| 24494 | if (!r->reversed_p) | ||
| 24495 | dpyinfo->mouse_face_end_x = gx; | ||
| 24496 | else | ||
| 24497 | dpyinfo->mouse_face_beg_x = gx; | ||
| 24498 | } | ||
| 24405 | 24499 | ||
| 24406 | /* See if position X, Y is within a hot-spot of an image. */ | 24500 | /* See if position X, Y is within a hot-spot of an image. */ |
| 24407 | 24501 | ||
| @@ -25103,17 +25197,8 @@ note_mouse_highlight (struct frame *f, int x, int y) | |||
| 25103 | b = make_number (0); | 25197 | b = make_number (0); |
| 25104 | if (NILP (e)) | 25198 | if (NILP (e)) |
| 25105 | e = make_number (SCHARS (object) - 1); | 25199 | e = make_number (SCHARS (object) - 1); |
| 25106 | 25200 | mouse_face_from_string_pos (w, dpyinfo, object, | |
| 25107 | fast_find_string_pos (w, XINT (b), object, | 25201 | XINT (b), XINT (e)); |
| 25108 | &dpyinfo->mouse_face_beg_col, | ||
| 25109 | &dpyinfo->mouse_face_beg_row, | ||
| 25110 | &dpyinfo->mouse_face_beg_x, | ||
| 25111 | &dpyinfo->mouse_face_beg_y, 0); | ||
| 25112 | fast_find_string_pos (w, XINT (e), object, | ||
| 25113 | &dpyinfo->mouse_face_end_col, | ||
| 25114 | &dpyinfo->mouse_face_end_row, | ||
| 25115 | &dpyinfo->mouse_face_end_x, | ||
| 25116 | &dpyinfo->mouse_face_end_y, 1); | ||
| 25117 | dpyinfo->mouse_face_past_end = 0; | 25202 | dpyinfo->mouse_face_past_end = 0; |
| 25118 | dpyinfo->mouse_face_window = window; | 25203 | dpyinfo->mouse_face_window = window; |
| 25119 | dpyinfo->mouse_face_face_id | 25204 | dpyinfo->mouse_face_face_id |