From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Re: Mode-line customization. Date: Thu, 06 May 2004 09:17:15 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040506.091715.126780933.jet@gyve.org> References: <1z3c6f738s.fsf@tcdec3.bham.ac.uk> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1083806471 15100 80.91.224.253 (6 May 2004 01:21:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 6 May 2004 01:21:11 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu May 06 03:21:02 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BLXZO-0007tG-00 for ; Thu, 06 May 2004 03:21:02 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BLXZN-0000rK-00 for ; Thu, 06 May 2004 03:21:01 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BLXYL-0002jh-DA for emacs-devel@quimby.gnus.org; Wed, 05 May 2004 21:19:57 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BLXXi-0002hD-GW for emacs-devel@gnu.org; Wed, 05 May 2004 21:19:18 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BLXX9-0002Ic-VK for emacs-devel@gnu.org; Wed, 05 May 2004 21:19:15 -0400 Original-Received: from [210.130.136.40] (helo=r-maa.spacetown.ne.jp) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BLWaE-0006pg-9I for emacs-devel@gnu.org; Wed, 05 May 2004 20:17:50 -0400 Original-Received: from localhost (h220-215-186-170.catv01.itscom.jp [220.215.186.170]) by r-maa.spacetown.ne.jp (8.11.6) with ESMTP id i460Hk127262 for ; Thu, 6 May 2004 09:17:46 +0900 (JST) Original-To: emacs-devel@gnu.org In-Reply-To: <1z3c6f738s.fsf@tcdec3.bham.ac.uk> X-Mailer: Mew version 4.0.62 on Emacs 21.3.50 / Mule 5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:22829 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22829 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)