aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMasatake YAMATO2005-05-23 11:19:17 +0000
committerMasatake YAMATO2005-05-23 11:19:17 +0000
commit359e4563cad1b8add855a43ef77b7bb5cb3f9f1d (patch)
tree2267264238ad326625994c395e647b70328d8a8b /src
parenta4632380faae651c8cbf322dc90d81aab1e01688 (diff)
downloademacs-359e4563cad1b8add855a43ef77b7bb5cb3f9f1d.tar.gz
emacs-359e4563cad1b8add855a43ef77b7bb5cb3f9f1d.zip
Supprot mouse-face on mode-line.
2005-05-23 Masatake YAMATO <jet@gyve.org> * xdisp.c (note_mode_line_or_margin_highlight): Added code for mouse-face. Change the type of the first argument from `window' to `List_Object'. (note_mouse_highlight): Call note_mode_line_or_margin_highlight with window instead of w. 2005-05-23 Masatake YAMATO <jet@gyve.org> * bindings.el (mode-line-major-mode-keymap): Bind [mode-line down-mouse-1] to `mouse-major-mode-menu'. * faces.el (mode-line-highlight): New face. * ruler-mode.el (ruler-mode-ruler): Use mode-line-highlight as mouse-face. * bindings.el (top-level, help-echo, mode-line-modified) (mode-line-mule-info, mode-line-eol-desc): Use mode-line-highlight as mouse-face.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/xdisp.c125
2 files changed, 128 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0e4e571e852..2b8bf5bdb92 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12005-05-23 Masatake YAMATO <jet@gyve.org>
2
3 * xdisp.c (note_mode_line_or_margin_highlight): Added code
4 for mouse-face. Change the type of the first argument from `window'
5 to `List_Object'.
6 (note_mouse_highlight): Call note_mode_line_or_margin_highlight with
7 window instead of w.
8
12005-05-22 Andreas Schwab <schwab@suse.de> 92005-05-22 Andreas Schwab <schwab@suse.de>
2 10
3 * process.c (send_process): Move misplaced volatile. 11 * process.c (send_process): Move misplaced volatile.
diff --git a/src/xdisp.c b/src/xdisp.c
index 5297b1235e9..8a9c1d267af 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -21236,11 +21236,12 @@ define_frame_cursor1 (f, cursor, pointer)
21236 position relative to the start of the mode line. */ 21236 position relative to the start of the mode line. */
21237 21237
21238static void 21238static void
21239note_mode_line_or_margin_highlight (w, x, y, area) 21239note_mode_line_or_margin_highlight (window, x, y, area)
21240 struct window *w; 21240 Lisp_Object window;
21241 int x, y; 21241 int x, y;
21242 enum window_part area; 21242 enum window_part area;
21243{ 21243{
21244 struct window *w = XWINDOW (window);
21244 struct frame *f = XFRAME (w->frame); 21245 struct frame *f = XFRAME (w->frame);
21245 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 21246 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
21246 Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 21247 Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
@@ -21249,9 +21250,38 @@ note_mode_line_or_margin_highlight (w, x, y, area)
21249 Lisp_Object string, object = Qnil; 21250 Lisp_Object string, object = Qnil;
21250 Lisp_Object pos, help; 21251 Lisp_Object pos, help;
21251 21252
21253 Lisp_Object mouse_face;
21254 int original_x_pixel = x;
21255 struct glyph * glyph = NULL;
21256 struct glyph_row *row;
21257
21252 if (area == ON_MODE_LINE || area == ON_HEADER_LINE) 21258 if (area == ON_MODE_LINE || area == ON_HEADER_LINE)
21253 string = mode_line_string (w, area, &x, &y, &charpos, 21259 {
21254 &object, &dx, &dy, &width, &height); 21260 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 }
21255 else 21285 else
21256 { 21286 {
21257 x -= WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w); 21287 x -= WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w);
@@ -21329,6 +21359,91 @@ note_mode_line_or_margin_highlight (w, x, y, area)
21329 if (!KEYMAPP (map)) 21359 if (!KEYMAPP (map))
21330 cursor = dpyinfo->vertical_scroll_bar_cursor; 21360 cursor = dpyinfo->vertical_scroll_bar_cursor;
21331 } 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 }
21332 } 21447 }
21333 21448
21334 define_frame_cursor1 (f, cursor, pointer); 21449 define_frame_cursor1 (f, cursor, pointer);
@@ -21409,7 +21524,7 @@ note_mouse_highlight (f, x, y)
21409 if (part == ON_MODE_LINE || part == ON_HEADER_LINE 21524 if (part == ON_MODE_LINE || part == ON_HEADER_LINE
21410 || part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) 21525 || part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN)
21411 { 21526 {
21412 note_mode_line_or_margin_highlight (w, x, y, part); 21527 note_mode_line_or_margin_highlight (window, x, y, part);
21413 return; 21528 return;
21414 } 21529 }
21415 21530