diff options
| author | Masatake YAMATO | 2005-05-23 11:19:17 +0000 |
|---|---|---|
| committer | Masatake YAMATO | 2005-05-23 11:19:17 +0000 |
| commit | 359e4563cad1b8add855a43ef77b7bb5cb3f9f1d (patch) | |
| tree | 2267264238ad326625994c395e647b70328d8a8b | |
| parent | a4632380faae651c8cbf322dc90d81aab1e01688 (diff) | |
| download | emacs-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.
| -rw-r--r-- | lisp/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/bindings.el | 20 | ||||
| -rw-r--r-- | lisp/ruler-mode.el | 9 | ||||
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/xdisp.c | 125 |
5 files changed, 166 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9eefd8afc2e..da684c69ede 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2005-05-23 Masatake YAMATO <jet@gyve.org> | ||
| 2 | |||
| 3 | * bindings.el (mode-line-major-mode-keymap): Bind | ||
| 4 | [mode-line down-mouse-1] to `mouse-major-mode-menu'. | ||
| 5 | |||
| 6 | * faces.el (mode-line-highlight): New face. | ||
| 7 | |||
| 8 | * ruler-mode.el (ruler-mode-ruler): Use mode-line-highlight | ||
| 9 | as mouse-face. | ||
| 10 | |||
| 11 | * bindings.el (top-level, help-echo, mode-line-modified) | ||
| 12 | (mode-line-mule-info, mode-line-eol-desc): Use mode-line-highlight | ||
| 13 | as mouse-face. | ||
| 14 | |||
| 1 | 2005-05-23 Juanma Barranquero <lekktu@gmail.com> | 15 | 2005-05-23 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 16 | ||
| 3 | * progmodes/cc-engine.el (c-guess-basic-syntax): | 17 | * progmodes/cc-engine.el (c-guess-basic-syntax): |
diff --git a/lisp/bindings.el b/lisp/bindings.el index 396e1e49216..4781f8dfa59 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el | |||
| @@ -165,7 +165,8 @@ corresponding to the mode line clicked." | |||
| 165 | (eval-when-compile | 165 | (eval-when-compile |
| 166 | (let ((map (make-sparse-keymap))) | 166 | (let ((map (make-sparse-keymap))) |
| 167 | (define-key map [mode-line mouse-3] 'mode-line-change-eol) | 167 | (define-key map [mode-line mouse-3] 'mode-line-change-eol) |
| 168 | map)))) | 168 | map)) |
| 169 | 'mouse-face 'mode-line-highlight)) | ||
| 169 | (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache) | 170 | (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache) |
| 170 | desc))) | 171 | desc))) |
| 171 | 172 | ||
| @@ -177,7 +178,8 @@ corresponding to the mode line clicked." | |||
| 177 | "Input method: " | 178 | "Input method: " |
| 178 | current-input-method | 179 | current-input-method |
| 179 | ". mouse-2: disable, mouse-3: describe") | 180 | ". mouse-2: disable, mouse-3: describe") |
| 180 | local-map ,mode-line-input-method-map)) | 181 | local-map ,mode-line-input-method-map |
| 182 | mouse-face mode-line-highlight)) | ||
| 181 | ,(propertize | 183 | ,(propertize |
| 182 | "%z" | 184 | "%z" |
| 183 | 'help-echo | 185 | 'help-echo |
| @@ -191,6 +193,7 @@ corresponding to the mode line clicked." | |||
| 191 | " buffer; mouse-3: describe coding system") | 193 | " buffer; mouse-3: describe coding system") |
| 192 | (concat "Unibyte " (symbol-name buffer-file-coding-system) | 194 | (concat "Unibyte " (symbol-name buffer-file-coding-system) |
| 193 | " buffer"))))) | 195 | " buffer"))))) |
| 196 | 'mouse-face 'mode-line-highlight | ||
| 194 | 'local-map mode-line-coding-system-map) | 197 | 'local-map mode-line-coding-system-map) |
| 195 | (:eval (mode-line-eol-desc))) | 198 | (:eval (mode-line-eol-desc))) |
| 196 | "Mode-line control for displaying information of multilingual environment. | 199 | "Mode-line control for displaying information of multilingual environment. |
| @@ -235,7 +238,8 @@ Normally nil in most modes, since there is no process to display.") | |||
| 235 | "Not r"))))) | 238 | "Not r"))))) |
| 236 | 'local-map (purecopy (make-mode-line-mouse-map | 239 | 'local-map (purecopy (make-mode-line-mouse-map |
| 237 | 'mouse-3 | 240 | 'mouse-3 |
| 238 | #'mode-line-toggle-read-only))) | 241 | #'mode-line-toggle-read-only)) |
| 242 | 'mouse-face 'mode-line-highlight) | ||
| 239 | (propertize | 243 | (propertize |
| 240 | "%1+" | 244 | "%1+" |
| 241 | 'help-echo (purecopy (lambda (window object point) | 245 | 'help-echo (purecopy (lambda (window object point) |
| @@ -246,7 +250,8 @@ Normally nil in most modes, since there is no process to display.") | |||
| 246 | "M" | 250 | "M" |
| 247 | "Not m"))))) | 251 | "Not m"))))) |
| 248 | 'local-map (purecopy (make-mode-line-mouse-map | 252 | 'local-map (purecopy (make-mode-line-mouse-map |
| 249 | 'mouse-3 #'mode-line-toggle-modified)))) | 253 | 'mouse-3 #'mode-line-toggle-modified)) |
| 254 | 'mouse-face 'mode-line-highlight)) | ||
| 250 | "Mode-line control for displaying whether current buffer is modified.") | 255 | "Mode-line control for displaying whether current buffer is modified.") |
| 251 | 256 | ||
| 252 | (make-variable-buffer-local 'mode-line-modified) | 257 | (make-variable-buffer-local 'mode-line-modified) |
| @@ -262,6 +267,7 @@ buffer size, the line number and the column number.") | |||
| 262 | 267 | ||
| 263 | (defvar mode-line-major-mode-keymap | 268 | (defvar mode-line-major-mode-keymap |
| 264 | (let ((map (make-sparse-keymap))) | 269 | (let ((map (make-sparse-keymap))) |
| 270 | (define-key map [mode-line down-mouse-1] 'mouse-major-mode-menu) | ||
| 265 | (define-key map [mode-line mouse-2] 'describe-mode) | 271 | (define-key map [mode-line mouse-2] 'describe-mode) |
| 266 | (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1) | 272 | (define-key map [mode-line down-mouse-3] 'mode-line-mode-menu-1) |
| 267 | map) "\ | 273 | map) "\ |
| @@ -303,13 +309,16 @@ Keymap to display on minor modes.") | |||
| 303 | (list | 309 | (list |
| 304 | (propertize "%[(" 'help-echo help-echo) | 310 | (propertize "%[(" 'help-echo help-echo) |
| 305 | `(:propertize ("" mode-name) | 311 | `(:propertize ("" mode-name) |
| 306 | help-echo "mouse-2: help for current major mode" | 312 | help-echo "mouse-1: major-mode-menu mouse-2: help for current major mode" |
| 313 | mouse-face mode-line-highlight | ||
| 307 | local-map ,mode-line-major-mode-keymap) | 314 | local-map ,mode-line-major-mode-keymap) |
| 308 | '("" mode-line-process) | 315 | '("" mode-line-process) |
| 309 | `(:propertize ("" minor-mode-alist) | 316 | `(:propertize ("" minor-mode-alist) |
| 317 | mouse-face mode-line-highlight | ||
| 310 | help-echo "mouse-2: help for minor modes, mouse-3: minor mode menu" | 318 | help-echo "mouse-2: help for minor modes, mouse-3: minor mode menu" |
| 311 | local-map ,mode-line-minor-mode-keymap) | 319 | local-map ,mode-line-minor-mode-keymap) |
| 312 | (propertize "%n" 'help-echo "mouse-2: widen" | 320 | (propertize "%n" 'help-echo "mouse-2: widen" |
| 321 | 'mouse-face 'mode-line-highlight | ||
| 313 | 'local-map (make-mode-line-mouse-map | 322 | 'local-map (make-mode-line-mouse-map |
| 314 | 'mouse-2 #'mode-line-widen)) | 323 | 'mouse-2 #'mode-line-widen)) |
| 315 | (propertize ")%]--" 'help-echo help-echo))) | 324 | (propertize ")%]--" 'help-echo help-echo))) |
| @@ -465,6 +474,7 @@ text properties for face, help-echo, and local-map to it." | |||
| 465 | 'face 'Buffer-menu-buffer-face | 474 | 'face 'Buffer-menu-buffer-face |
| 466 | 'help-echo | 475 | 'help-echo |
| 467 | (purecopy "mouse-1: previous buffer, mouse-3: next buffer") | 476 | (purecopy "mouse-1: previous buffer, mouse-3: next buffer") |
| 477 | 'mouse-face 'mode-line-highlight | ||
| 468 | 'local-map mode-line-buffer-identification-keymap))) | 478 | 'local-map mode-line-buffer-identification-keymap))) |
| 469 | 479 | ||
| 470 | (setq-default mode-line-buffer-identification | 480 | (setq-default mode-line-buffer-identification |
diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el index 928b5baabec..46a28ce5069 100644 --- a/lisp/ruler-mode.el +++ b/lisp/ruler-mode.el | |||
| @@ -697,6 +697,9 @@ Optional argument PROPS specifies other text properties to apply." | |||
| 697 | (put-text-property | 697 | (put-text-property |
| 698 | i (1+ i) 'face 'ruler-mode-goal-column-face | 698 | i (1+ i) 'face 'ruler-mode-goal-column-face |
| 699 | ruler) | 699 | ruler) |
| 700 | (put-text-property | ||
| 701 | i (1+ i) 'mouse-face 'mode-line-highlight | ||
| 702 | ruler) | ||
| 700 | (put-text-property | 703 | (put-text-property |
| 701 | i (1+ i) 'help-echo ruler-mode-goal-column-help-echo | 704 | i (1+ i) 'help-echo ruler-mode-goal-column-help-echo |
| 702 | ruler)) | 705 | ruler)) |
| @@ -706,6 +709,9 @@ Optional argument PROPS specifies other text properties to apply." | |||
| 706 | (put-text-property | 709 | (put-text-property |
| 707 | i (1+ i) 'face 'ruler-mode-comment-column-face | 710 | i (1+ i) 'face 'ruler-mode-comment-column-face |
| 708 | ruler) | 711 | ruler) |
| 712 | (put-text-property | ||
| 713 | i (1+ i) 'mouse-face 'mode-line-highlight | ||
| 714 | ruler) | ||
| 709 | (put-text-property | 715 | (put-text-property |
| 710 | i (1+ i) 'help-echo ruler-mode-comment-column-help-echo | 716 | i (1+ i) 'help-echo ruler-mode-comment-column-help-echo |
| 711 | ruler)) | 717 | ruler)) |
| @@ -715,6 +721,9 @@ Optional argument PROPS specifies other text properties to apply." | |||
| 715 | (put-text-property | 721 | (put-text-property |
| 716 | i (1+ i) 'face 'ruler-mode-fill-column-face | 722 | i (1+ i) 'face 'ruler-mode-fill-column-face |
| 717 | ruler) | 723 | ruler) |
| 724 | (put-text-property | ||
| 725 | i (1+ i) 'mouse-face 'mode-line-highlight | ||
| 726 | ruler) | ||
| 718 | (put-text-property | 727 | (put-text-property |
| 719 | i (1+ i) 'help-echo ruler-mode-fill-column-help-echo | 728 | i (1+ i) 'help-echo ruler-mode-fill-column-help-echo |
| 720 | ruler)) | 729 | ruler)) |
diff --git a/src/ChangeLog b/src/ChangeLog index 0e4e571e852..2b8bf5bdb92 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2005-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 | |||
| 1 | 2005-05-22 Andreas Schwab <schwab@suse.de> | 9 | 2005-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 | ||
| 21238 | static void | 21238 | static void |
| 21239 | note_mode_line_or_margin_highlight (w, x, y, area) | 21239 | note_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 | ||