[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mode-line customization.
From: |
Masatake YAMATO |
Subject: |
Re: Mode-line customization. |
Date: |
Thu, 06 May 2004 09:17:15 +0900 (JST) |
About Mode-line customization, it may be nice to support mouse-face on
mode-line (and header-line).
I've tried to implement mouse-face on mode-line, but it doesn't work perfectly.
I need advices from the display engine experts.
- success:
With the patch, the major mode indicator on mode-line is highlighted
when the mouse cursor is moved on it.
- problem:
However, in ruler-mode, current column indicator on header-line is not
highlighted but the character at 0 column on header-line is highlighted
when the mouse cursor is moved on the current column indicator.
Masatake YAMATO
Index: src/xdisp.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xdisp.c,v
retrieving revision 1.887
diff -u -r1.887 xdisp.c
--- src/xdisp.c 4 May 2004 12:51:45 -0000 1.887
+++ src/xdisp.c 6 May 2004 00:06:20 -0000
@@ -20640,11 +20640,12 @@
position relative to the start of the mode line. */
static void
-note_mode_line_or_margin_highlight (w, x, y, area)
- struct window *w;
+note_mode_line_or_margin_highlight (window, x, y, area)
+ Lisp_Object window;
int x, y;
enum window_part area;
{
+ struct window *w = XWINDOW (window);
struct frame *f = XFRAME (w->frame);
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
@@ -20653,6 +20654,9 @@
Lisp_Object string, object = Qnil;
Lisp_Object pos, help;
+ Lisp_Object mouse_face;
+ int original_x_pixel = x;
+
if (area == ON_MODE_LINE || area == ON_HEADER_LINE)
string = mode_line_string (w, area, &x, &y, &charpos,
&object, &dx, &dy, &width, &height);
@@ -20728,6 +20732,53 @@
if (!KEYMAPP (map))
cursor = dpyinfo->vertical_scroll_bar_cursor;
}
+
+ /* Change the mouse face according to what is under X/Y. */
+ mouse_face = Fget_text_property (pos, Qmouse_face, string);
+ if (!NILP (mouse_face) && ((area == ON_MODE_LINE) || (area ==
ON_HEADER_LINE)))
+ {
+ Lisp_Object b, e;
+ struct glyph * glyph;
+ struct glyph_row *row;
+ int ignore;
+
+ if (clear_mouse_face (dpyinfo))
+ cursor = No_Cursor;
+
+ b = Fprevious_single_property_change(make_number (charpos + 1),
+ Qmouse_face, string, Qnil);
+ e = Fnext_single_property_change (pos, Qmouse_face, string, Qnil);
+ if (NILP (b))
+ b = make_number (0);
+ if (NILP (e))
+ e = make_number (SCHARS (string) - 1);
+
+ dpyinfo->mouse_face_beg_col = (x - charpos) + XINT(b);
+ dpyinfo->mouse_face_beg_row = (area == ON_MODE_LINE)?
+ (w->current_matrix)->nrows - 1:
+ 0;
+ dpyinfo->mouse_face_beg_x = original_x_pixel - ((charpos * width)
+ dx);
+ dpyinfo->mouse_face_beg_y = 0;
+
+ dpyinfo->mouse_face_end_col = (x - charpos) + XINT(e) + 1;
+ dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row;
+ dpyinfo->mouse_face_end_x = 0;
+ dpyinfo->mouse_face_end_y = 0;
+
+ dpyinfo->mouse_face_past_end = 0;
+ dpyinfo->mouse_face_window = window;
+
+ row = (area == ON_MODE_LINE)?
+ MATRIX_MODE_LINE_ROW (w->current_matrix):
+ MATRIX_HEADER_LINE_ROW(w->current_matrix);
+ glyph = row->glyphs[TEXT_AREA] + dpyinfo->mouse_face_beg_col;
+ dpyinfo->mouse_face_face_id = face_at_string_position(w, string,
+ charpos,
+ 0, 0, 0,
&ignore,
+ glyph->face_id,
1);
+
+ show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
+ }
}
define_frame_cursor1 (f, cursor, pointer);
@@ -20806,7 +20857,7 @@
if (part == ON_MODE_LINE || part == ON_HEADER_LINE
|| part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN)
{
- note_mode_line_or_margin_highlight (w, x, y, part);
+ note_mode_line_or_margin_highlight (window, x, y, part);
return;
}
Index: lisp/ruler-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ruler-mode.el,v
retrieving revision 1.20
diff -u -r1.20 ruler-mode.el
--- lisp/ruler-mode.el 19 Mar 2004 13:15:57 -0000 1.20
+++ lisp/ruler-mode.el 6 May 2004 00:06:20 -0000
@@ -690,6 +690,9 @@
(aset ruler i ruler-mode-current-column-char)
(put-text-property
i (1+ i) 'face 'ruler-mode-current-column-face
+ ruler)
+ (put-text-property
+ i (1+ i) 'mouse-face 'highlight
ruler))
;; Show the `goal-column' marker.
((and goal-column (= j goal-column))
Index: lisp/bindings.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.130
diff -u -r1.130 bindings.el
--- lisp/bindings.el 1 May 2004 03:50:24 -0000 1.130
+++ lisp/bindings.el 6 May 2004 00:06:20 -0000
@@ -285,7 +285,7 @@
(dashes (propertize "--" 'help-echo help-echo)))
(setq-default mode-line-format
(list
- (propertize "-" 'help-echo help-echo)
+ (propertize "-" 'help-echo help-echo 'mouse-face 'highlight)
'mode-line-mule-info
'mode-line-modified
'mode-line-frame-identification
@@ -303,6 +303,7 @@
(list
(propertize "%[(" 'help-echo help-echo)
`(:propertize ("" mode-name)
+ mouse-face highlight
help-echo "mouse-2: help for current major mode"
local-map ,mode-line-major-mode-keymap)
'("" mode-line-process)
- Re: Mode-line customization., (continued)
- Re: Mode-line customization., Richard Stallman, 2004/05/08
- Re: Mode-line customization., David Kastrup, 2004/05/06
- Re: Mode-line customization., Richard Stallman, 2004/05/07
- Re: Mode-line customization., Stefan Monnier, 2004/05/06
- Re: Mode-line customization., Peter Whaite, 2004/05/08
- Re: Mode-line customization., Chris Green, 2004/05/11
Re: Mode-line customization.,
Masatake YAMATO <=