comparison src/xdisp.c @ 62682:01fdbc2b3226

2005-05-24 Masatake YAMATO <jet@gyve.org> * xdisp.c (note_mode_line_or_margin_highlight): Use b and e as loop sentinels.
author Masatake YAMATO <jet@gyve.org>
date Tue, 24 May 2005 16:56:41 +0000
parents 8d965863dd8c
children 6da36651c817
comparison
equal deleted inserted replaced
62681:d140f1408030 62682:01fdbc2b3226
21251 Lisp_Object pos, help; 21251 Lisp_Object pos, help;
21252 21252
21253 Lisp_Object mouse_face; 21253 Lisp_Object mouse_face;
21254 int original_x_pixel = x; 21254 int original_x_pixel = x;
21255 struct glyph * glyph = NULL; 21255 struct glyph * glyph = NULL;
21256 struct glyph_row *row; 21256 struct glyph_row *row;
21257 21257
21258 if (area == ON_MODE_LINE || area == ON_HEADER_LINE) 21258 if (area == ON_MODE_LINE || area == ON_HEADER_LINE)
21259 { 21259 {
21260 int x0; 21260 int x0;
21261 struct glyph *end; 21261 struct glyph *end;
21262 21262
21263 string = mode_line_string (w, area, &x, &y, &charpos, 21263 string = mode_line_string (w, area, &x, &y, &charpos,
21264 &object, &dx, &dy, &width, &height); 21264 &object, &dx, &dy, &width, &height);
21265 21265
21266 row = (area == ON_MODE_LINE)? 21266 row = (area == ON_MODE_LINE)?
21267 MATRIX_MODE_LINE_ROW (w->current_matrix): 21267 MATRIX_MODE_LINE_ROW (w->current_matrix):
21268 MATRIX_HEADER_LINE_ROW(w->current_matrix); 21268 MATRIX_HEADER_LINE_ROW(w->current_matrix);
21269 21269
21270 /* Find glyph */ 21270 /* Find glyph */
21271 if (row->mode_line_p && row->enabled_p) 21271 if (row->mode_line_p && row->enabled_p)
21272 { 21272 {
21273 glyph = row->glyphs[TEXT_AREA]; 21273 glyph = row->glyphs[TEXT_AREA];
21274 end = glyph + row->used[TEXT_AREA]; 21274 end = glyph + row->used[TEXT_AREA];
21275 21275
21276 for (x0 = original_x_pixel; 21276 for (x0 = original_x_pixel;
21277 glyph < end && x0 >= glyph->pixel_width; 21277 glyph < end && x0 >= glyph->pixel_width;
21278 ++glyph) 21278 ++glyph)
21279 x0 -= glyph->pixel_width; 21279 x0 -= glyph->pixel_width;
21280 21280
21281 if (glyph >= end) 21281 if (glyph >= end)
21282 glyph = NULL; 21282 glyph = NULL;
21283 } 21283 }
21284 } 21284 }
21285 else 21285 else
21357 if (!KEYMAPP (map)) 21357 if (!KEYMAPP (map))
21358 map = Fget_text_property (pos, Qkeymap, string); 21358 map = Fget_text_property (pos, Qkeymap, string);
21359 if (!KEYMAPP (map)) 21359 if (!KEYMAPP (map))
21360 cursor = dpyinfo->vertical_scroll_bar_cursor; 21360 cursor = dpyinfo->vertical_scroll_bar_cursor;
21361 } 21361 }
21362 21362
21363 /* Change the mouse face according to what is under X/Y. */ 21363 /* Change the mouse face according to what is under X/Y. */
21364 mouse_face = Fget_text_property (pos, Qmouse_face, string); 21364 mouse_face = Fget_text_property (pos, Qmouse_face, string);
21365 if (!NILP (mouse_face) 21365 if (!NILP (mouse_face)
21366 && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)) 21366 && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE))
21367 && glyph) 21367 && glyph)
21373 int gpos; 21373 int gpos;
21374 int gseq_length; 21374 int gseq_length;
21375 int total_pixel_width; 21375 int total_pixel_width;
21376 int ignore; 21376 int ignore;
21377 21377
21378
21378 if (clear_mouse_face (dpyinfo)) 21379 if (clear_mouse_face (dpyinfo))
21379 cursor = No_Cursor; 21380 cursor = No_Cursor;
21380 21381
21381 /* Calculate the position(glyph position: GPOS) of GLYPH in 21382 b = Fprevious_single_property_change(make_number (charpos + 1),
21382 displayed string. GPOS is different from CHARPOS. 21383 Qmouse_face, string, Qnil);
21383 21384 if (NILP (b))
21385 b = make_number (0);
21386
21387 e = Fnext_single_property_change (pos, Qmouse_face, string, Qnil);
21388 if (NILP (e))
21389 e = make_number (SCHARS (string));
21390
21391 /* Calculate the position(glyph position: GPOS) of GLYPH in
21392 displayed string. GPOS is different from CHARPOS.
21393
21384 CHARPOS is the position of glyph in internal string 21394 CHARPOS is the position of glyph in internal string
21385 object. A mode line string format has structures which 21395 object. A mode line string format has structures which
21386 is converted to a flatten by emacs lisp interpreter. 21396 is converted to a flatten by emacs lisp interpreter.
21387 The internal string is an element of the structures. 21397 The internal string is an element of the structures.
21388 The displayed string is the flatten string. */ 21398 The displayed string is the flatten string. */
21389 for (tmp_glyph = glyph - 1, gpos = 0; 21399 for (tmp_glyph = glyph - 1, gpos = 0;
21390 tmp_glyph >= row->glyphs[TEXT_AREA]; 21400 tmp_glyph->charpos >= XINT(b);
21391 tmp_glyph--, gpos++) 21401 tmp_glyph--, gpos++)
21392 { 21402 {
21393 if (tmp_glyph->object != glyph->object) 21403 if (tmp_glyph->object != glyph->object)
21394 break; 21404 break;
21395 } 21405 }
21396 21406
21397 /* Calculate the lenght(glyph sequence length: GSEQ_LENGTH) of 21407 /* Calculate the lenght(glyph sequence length: GSEQ_LENGTH) of
21398 displayed string holding GLYPH. 21408 displayed string holding GLYPH.
21399 21409
21400 GSEQ_LENGTH is different from SCHARS (STRING). 21410 GSEQ_LENGTH is different from SCHARS (STRING).
21401 SCHARS (STRING) returns the length of the internal string. */ 21411 SCHARS (STRING) returns the length of the internal string. */
21402 for (tmp_glyph = glyph, gseq_length = gpos; 21412 for (tmp_glyph = glyph, gseq_length = gpos;
21403 tmp_glyph < glyph + row->used[TEXT_AREA]; 21413 tmp_glyph->charpos < XINT(e);
21404 tmp_glyph++, gseq_length++) 21414 tmp_glyph++, gseq_length++)
21405 { 21415 {
21406 if (tmp_glyph->object != glyph->object) 21416 if (tmp_glyph->object != glyph->object)
21407 break; 21417 break;
21408 } 21418 }
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 21419
21420 total_pixel_width = 0; 21420 total_pixel_width = 0;
21421 for (tmp_glyph = glyph - (gpos - XINT(b)); tmp_glyph != glyph; tmp_glyph++) 21421 for (tmp_glyph = glyph - gpos; tmp_glyph != glyph; tmp_glyph++)
21422 total_pixel_width += tmp_glyph->pixel_width; 21422 total_pixel_width += tmp_glyph->pixel_width;
21423 21423
21424 dpyinfo->mouse_face_beg_col = (x - gpos) + XINT(b); 21424 dpyinfo->mouse_face_beg_col = (x - gpos);
21425 dpyinfo->mouse_face_beg_row = (area == ON_MODE_LINE)? 21425 dpyinfo->mouse_face_beg_row = (area == ON_MODE_LINE)?
21426 (w->current_matrix)->nrows - 1: 21426 (w->current_matrix)->nrows - 1:
21427 0; 21427 0;
21428 21428
21429 dpyinfo->mouse_face_beg_x = original_x_pixel - (total_pixel_width + dx); 21429 dpyinfo->mouse_face_beg_x = original_x_pixel - (total_pixel_width + dx);
21430 dpyinfo->mouse_face_beg_y = 0; 21430 dpyinfo->mouse_face_beg_y = 0;
21431 21431
21432 dpyinfo->mouse_face_end_col = (x - gpos) + XINT(e); 21432 dpyinfo->mouse_face_end_col = (x - gpos) + gseq_length;
21433 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row; 21433 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row;
21434 21434
21435 dpyinfo->mouse_face_end_x = 0; 21435 dpyinfo->mouse_face_end_x = 0;
21436 dpyinfo->mouse_face_end_y = 0; 21436 dpyinfo->mouse_face_end_y = 0;
21437 21437
21438 dpyinfo->mouse_face_past_end = 0; 21438 dpyinfo->mouse_face_past_end = 0;
21439 dpyinfo->mouse_face_window = window; 21439 dpyinfo->mouse_face_window = window;
21440 21440
21441 dpyinfo->mouse_face_face_id = face_at_string_position(w, string, 21441 dpyinfo->mouse_face_face_id = face_at_string_position(w, string,
21442 charpos, 21442 charpos,
21443 0, 0, 0, &ignore, 21443 0, 0, 0, &ignore,
21444 glyph->face_id, 1); 21444 glyph->face_id, 1);
21445 show_mouse_face (dpyinfo, DRAW_MOUSE_FACE); 21445 show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
21446 } 21446 }
21782 object, Qnil); 21782 object, Qnil);
21783 if (NILP (b)) 21783 if (NILP (b))
21784 b = make_number (0); 21784 b = make_number (0);
21785 if (NILP (e)) 21785 if (NILP (e))
21786 e = make_number (SCHARS (object) - 1); 21786 e = make_number (SCHARS (object) - 1);
21787
21787 fast_find_string_pos (w, XINT (b), object, 21788 fast_find_string_pos (w, XINT (b), object,
21788 &dpyinfo->mouse_face_beg_col, 21789 &dpyinfo->mouse_face_beg_col,
21789 &dpyinfo->mouse_face_beg_row, 21790 &dpyinfo->mouse_face_beg_row,
21790 &dpyinfo->mouse_face_beg_x, 21791 &dpyinfo->mouse_face_beg_x,
21791 &dpyinfo->mouse_face_beg_y, 0); 21792 &dpyinfo->mouse_face_beg_y, 0);