aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMasatake YAMATO <[email protected]>2005-05-23 11:19:17 +0000
committerMasatake YAMATO <[email protected]>2005-05-23 11:19:17 +0000
commit359e4563cad1b8add855a43ef77b7bb5cb3f9f1d (patch)
tree2267264238ad326625994c395e647b70328d8a8b /src
parenta4632380faae651c8cbf322dc90d81aab1e01688 (diff)
Supprot mouse-face on mode-line.
2005-05-23 Masatake YAMATO <[email protected]> * 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 <[email protected]> * 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 0e4e571e85..2b8bf5bdb9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2005-05-23 Masatake YAMATO <[email protected]>
+
+ * 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-22 Andreas Schwab <[email protected]>
* process.c (send_process): Move misplaced volatile.
diff --git a/src/xdisp.c b/src/xdisp.c
index 5297b1235e..8a9c1d267a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -21236,11 +21236,12 @@ define_frame_cursor1 (f, cursor, pointer)
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;
@@ -21249,9 +21250,38 @@ note_mode_line_or_margin_highlight (w, x, y, area)
Lisp_Object string, object = Qnil;
Lisp_Object pos, help;
+ Lisp_Object mouse_face;
+ int original_x_pixel = x;
+ struct glyph * glyph = NULL;
+ struct glyph_row *row;
+
if (area == ON_MODE_LINE || area == ON_HEADER_LINE)
- string = mode_line_string (w, area, &x, &y, &charpos,
- &object, &dx, &dy, &width, &height);
+ {
+ int x0;
+ struct glyph *end;
+
+ string = mode_line_string (w, area, &x, &y, &charpos,
+ &object, &dx, &dy, &width, &height);
+
+ row = (area == ON_MODE_LINE)?
+ MATRIX_MODE_LINE_ROW (w->current_matrix):
+ MATRIX_HEADER_LINE_ROW(w->current_matrix);
+
+ /* Find glyph */
+ if (row->mode_line_p && row->enabled_p)
+ {
+ glyph = row->glyphs[TEXT_AREA];
+ end = glyph + row->used[TEXT_AREA];
+
+ for (x0 = original_x_pixel;
+ glyph < end && x0 >= glyph->pixel_width;
+ ++glyph)
+ x0 -= glyph->pixel_width;
+
+ if (glyph >= end)
+ glyph = NULL;
+ }
+ }
else
{
x -= WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w);
@@ -21329,6 +21359,91 @@ note_mode_line_or_margin_highlight (w, x, y, area)
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))
+ && glyph)
+ {
+ Lisp_Object b, e;
+
+ struct glyph * tmp_glyph;
+
+ int gpos;
+ int gseq_length;
+ int total_pixel_width;
+ int ignore;
+
+ if (clear_mouse_face (dpyinfo))
+ cursor = No_Cursor;
+
+ /* Calculate the position(glyph position: GPOS) of GLYPH in
+ displayed string. GPOS is different from CHARPOS.
+
+ CHARPOS is the position of glyph in internal string
+ object. A mode line string format has structures which
+ is converted to a flatten by emacs lisp interpreter.
+ The internal string is an element of the structures.
+ The displayed string is the flatten string. */
+ for (tmp_glyph = glyph - 1, gpos = 0;
+ tmp_glyph >= row->glyphs[TEXT_AREA];
+ tmp_glyph--, gpos++)
+ {
+ if (tmp_glyph->object != glyph->object)
+ break;
+ }
+
+ /* Calculate the lenght(glyph sequence length: GSEQ_LENGTH) of
+ displayed string holding GLYPH.
+
+ GSEQ_LENGTH is different from SCHARS (STRING).
+ SCHARS (STRING) returns the length of the internal string. */
+ for (tmp_glyph = glyph, gseq_length = gpos;
+ tmp_glyph < glyph + row->used[TEXT_AREA];
+ tmp_glyph++, gseq_length++)
+ {
+ if (tmp_glyph->object != glyph->object)
+ break;
+ }
+
+ 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(gseq_length);
+
+ total_pixel_width = 0;
+ for (tmp_glyph = glyph - (gpos - XINT(b)); tmp_glyph != glyph; tmp_glyph++)
+ total_pixel_width += tmp_glyph->pixel_width;
+
+ dpyinfo->mouse_face_beg_col = (x - gpos) + 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 - (total_pixel_width + dx);
+ dpyinfo->mouse_face_beg_y = 0;
+
+ dpyinfo->mouse_face_end_col = (x - gpos) + XINT(e);
+ 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;
+
+ 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);
@@ -21409,7 +21524,7 @@ note_mouse_highlight (f, x, y)
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;
}