21236 |
position relative to the start of the mode line. */ |
position relative to the start of the mode line. */ |
21237 |
|
|
21238 |
static void |
static void |
21239 |
note_mode_line_or_margin_highlight (w, x, y, area) |
note_mode_line_or_margin_highlight (window, x, y, area) |
21240 |
struct window *w; |
Lisp_Object window; |
21241 |
int x, y; |
int x, y; |
21242 |
enum window_part area; |
enum window_part area; |
21243 |
{ |
{ |
21244 |
|
struct window *w = XWINDOW (window); |
21245 |
struct frame *f = XFRAME (w->frame); |
struct frame *f = XFRAME (w->frame); |
21246 |
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
21247 |
Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor; |
Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor; |
21250 |
Lisp_Object string, object = Qnil; |
Lisp_Object string, object = Qnil; |
21251 |
Lisp_Object pos, help; |
Lisp_Object pos, help; |
21252 |
|
|
21253 |
|
Lisp_Object mouse_face; |
21254 |
|
int original_x_pixel = x; |
21255 |
|
struct glyph * glyph = NULL; |
21256 |
|
struct glyph_row *row; |
21257 |
|
|
21258 |
if (area == ON_MODE_LINE || area == ON_HEADER_LINE) |
if (area == ON_MODE_LINE || area == ON_HEADER_LINE) |
21259 |
string = mode_line_string (w, area, &x, &y, &charpos, |
{ |
21260 |
&object, &dx, &dy, &width, &height); |
int x0; |
21261 |
|
struct glyph *end; |
21262 |
|
|
21263 |
|
string = mode_line_string (w, area, &x, &y, &charpos, |
21264 |
|
&object, &dx, &dy, &width, &height); |
21265 |
|
|
21266 |
|
row = (area == ON_MODE_LINE)? |
21267 |
|
MATRIX_MODE_LINE_ROW (w->current_matrix): |
21268 |
|
MATRIX_HEADER_LINE_ROW(w->current_matrix); |
21269 |
|
|
21270 |
|
/* Find glyph */ |
21271 |
|
if (row->mode_line_p && row->enabled_p) |
21272 |
|
{ |
21273 |
|
glyph = row->glyphs[TEXT_AREA]; |
21274 |
|
end = glyph + row->used[TEXT_AREA]; |
21275 |
|
|
21276 |
|
for (x0 = original_x_pixel; |
21277 |
|
glyph < end && x0 >= glyph->pixel_width; |
21278 |
|
++glyph) |
21279 |
|
x0 -= glyph->pixel_width; |
21280 |
|
|
21281 |
|
if (glyph >= end) |
21282 |
|
glyph = NULL; |
21283 |
|
} |
21284 |
|
} |
21285 |
else |
else |
21286 |
{ |
{ |
21287 |
x -= WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w); |
x -= WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w); |
21359 |
if (!KEYMAPP (map)) |
if (!KEYMAPP (map)) |
21360 |
cursor = dpyinfo->vertical_scroll_bar_cursor; |
cursor = dpyinfo->vertical_scroll_bar_cursor; |
21361 |
} |
} |
21362 |
|
|
21363 |
|
/* Change the mouse face according to what is under X/Y. */ |
21364 |
|
mouse_face = Fget_text_property (pos, Qmouse_face, string); |
21365 |
|
if (!NILP (mouse_face) |
21366 |
|
&& ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)) |
21367 |
|
&& glyph) |
21368 |
|
{ |
21369 |
|
Lisp_Object b, e; |
21370 |
|
|
21371 |
|
struct glyph * tmp_glyph; |
21372 |
|
|
21373 |
|
int gpos; |
21374 |
|
int gseq_length; |
21375 |
|
int total_pixel_width; |
21376 |
|
int ignore; |
21377 |
|
|
21378 |
|
if (clear_mouse_face (dpyinfo)) |
21379 |
|
cursor = No_Cursor; |
21380 |
|
|
21381 |
|
/* Calculate the position(glyph position: GPOS) of GLYPH in |
21382 |
|
displayed string. GPOS is different from CHARPOS. |
21383 |
|
|
21384 |
|
CHARPOS is the position of glyph in internal string |
21385 |
|
object. A mode line string format has structures which |
21386 |
|
is converted to a flatten by emacs lisp interpreter. |
21387 |
|
The internal string is an element of the structures. |
21388 |
|
The displayed string is the flatten string. */ |
21389 |
|
for (tmp_glyph = glyph - 1, gpos = 0; |
21390 |
|
tmp_glyph >= row->glyphs[TEXT_AREA]; |
21391 |
|
tmp_glyph--, gpos++) |
21392 |
|
{ |
21393 |
|
if (tmp_glyph->object != glyph->object) |
21394 |
|
break; |
21395 |
|
} |
21396 |
|
|
21397 |
|
/* Calculate the lenght(glyph sequence length: GSEQ_LENGTH) of |
21398 |
|
displayed string holding GLYPH. |
21399 |
|
|
21400 |
|
GSEQ_LENGTH is different from SCHARS (STRING). |
21401 |
|
SCHARS (STRING) returns the length of the internal string. */ |
21402 |
|
for (tmp_glyph = glyph, gseq_length = gpos; |
21403 |
|
tmp_glyph < glyph + row->used[TEXT_AREA]; |
21404 |
|
tmp_glyph++, gseq_length++) |
21405 |
|
{ |
21406 |
|
if (tmp_glyph->object != glyph->object) |
21407 |
|
break; |
21408 |
|
} |
21409 |
|
|
21410 |
|
b = Fprevious_single_property_change(make_number (charpos + 1), |
21411 |
|
Qmouse_face, string, Qnil); |
21412 |
|
e = Fnext_single_property_change (pos, Qmouse_face, string, Qnil); |
21413 |
|
|
21414 |
|
if (NILP (b)) |
21415 |
|
b = make_number (0); |
21416 |
|
|
21417 |
|
if (NILP (e)) |
21418 |
|
e = make_number(gseq_length); |
21419 |
|
|
21420 |
|
total_pixel_width = 0; |
21421 |
|
for (tmp_glyph = glyph - (gpos - XINT(b)); tmp_glyph != glyph; tmp_glyph++) |
21422 |
|
total_pixel_width += tmp_glyph->pixel_width; |
21423 |
|
|
21424 |
|
dpyinfo->mouse_face_beg_col = (x - gpos) + XINT(b); |
21425 |
|
dpyinfo->mouse_face_beg_row = (area == ON_MODE_LINE)? |
21426 |
|
(w->current_matrix)->nrows - 1: |
21427 |
|
0; |
21428 |
|
|
21429 |
|
dpyinfo->mouse_face_beg_x = original_x_pixel - (total_pixel_width + dx); |
21430 |
|
dpyinfo->mouse_face_beg_y = 0; |
21431 |
|
|
21432 |
|
dpyinfo->mouse_face_end_col = (x - gpos) + XINT(e); |
21433 |
|
dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row; |
21434 |
|
|
21435 |
|
dpyinfo->mouse_face_end_x = 0; |
21436 |
|
dpyinfo->mouse_face_end_y = 0; |
21437 |
|
|
21438 |
|
dpyinfo->mouse_face_past_end = 0; |
21439 |
|
dpyinfo->mouse_face_window = window; |
21440 |
|
|
21441 |
|
dpyinfo->mouse_face_face_id = face_at_string_position(w, string, |
21442 |
|
charpos, |
21443 |
|
0, 0, 0, &ignore, |
21444 |
|
glyph->face_id, 1); |
21445 |
|
show_mouse_face (dpyinfo, DRAW_MOUSE_FACE); |
21446 |
|
} |
21447 |
} |
} |
21448 |
|
|
21449 |
define_frame_cursor1 (f, cursor, pointer); |
define_frame_cursor1 (f, cursor, pointer); |
21524 |
if (part == ON_MODE_LINE || part == ON_HEADER_LINE |
if (part == ON_MODE_LINE || part == ON_HEADER_LINE |
21525 |
|| part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) |
|| part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) |
21526 |
{ |
{ |
21527 |
note_mode_line_or_margin_highlight (w, x, y, part); |
note_mode_line_or_margin_highlight (window, x, y, part); |
21528 |
return; |
return; |
21529 |
} |
} |
21530 |
|
|