annotate lisp/cedet/pulse.el @ 108881:5582106cddf0

Remove obsolete pre-unicode2 macros. * character.h (MULTIBYTE_FORM_LENGTH, PARSE_MULTIBYTE_SEQ): Remove. * composite.c (composition_reseat_it): * data.c (Faset): * fns.c (Ffillarray): * regex.c (re_search_2): Use BYTES_BY_CHAR_HEAD. [!emacs] (BYTES_BY_CHAR_HEAD): Define instead of MULTIBYTE_FORM_LENGTH.
author Juanma Barranquero <lekktu@gmail.com>
date Thu, 03 Jun 2010 21:02:32 +0200
parents 1d1d5d9bd884
children 67ff8ad45bd5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
105241
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; pulse.el --- Pulsing Overlays
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105500
diff changeset
3 ;;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
105241
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; (at your option) any later version.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU General Public License for more details.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;;; Commentary:
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; Manage temporary pulsing of faces and overlays.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; This is a temporal decoration technique where something is to be
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; highlighted briefly. This adds a gentle pulsing style to the text
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;; decorated this way.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; The following are useful entry points:
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; `pulse' - Cause `pulse-highlight-face' to shift toward background color.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;; Assumes you are using a version of Emacs that supports pulsing.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;; `pulse-momentary-highlight-one-line' - Pulse a single line at POINT.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;; `pulse-momentary-highlight-region' - Pulse a region.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;; `pulse-momentary-highlight-overlay' - Pulse an overlay
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;; These three functions will just blink the specified area if
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ;; the version of Emacs you are using doesn't support pulsing.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 ;; `pulse-line-hook-function' - A simple function that can be used in a
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;; hook that will pulse whatever line the cursor is on.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ;;; History:
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ;; The original pulse code was written for semantic tag highlighting.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 ;; It has been extracted, and adapted for general purpose pulsing.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ;; Pulse is a part of CEDET. http://cedet.sf.net
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (defun pulse-available-p ()
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 "Return non-nil if pulsing is available on the current frame."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 (condition-case nil
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (let ((v (color-values (face-background 'default))))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 (numberp (car-safe v)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 (error nil)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 (defcustom pulse-flag (pulse-available-p)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 "*Non-nil means to pulse the overlay face for momentary highlighting.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 Pulsing involves a bright highlight that slowly shifts to the background
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 color. Non-nil just means to highlight with an unchanging color for a short
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 time.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 If `pulse-flag' is non-nil, but `pulse-available-p' is nil, then
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 this flag is ignored."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 :group 'pulse
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 :type 'boolean)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 (defface pulse-highlight-start-face
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 '((((class color) (background dark))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 (:background "#AAAA33"))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 (((class color) (background light))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 (:background "#FFFFAA")))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 "*Face used at beginning of a highight."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 :group 'pulse)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 (defface pulse-highlight-face
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 '((((class color) (background dark))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 (:background "#AAAA33"))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 (((class color) (background light))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (:background "#FFFFAA")))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 "*Face used during a pulse for display. *DO NOT CUSTOMIZE*
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 Face used for temporary highlighting of tags for effect."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 :group 'pulse)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 ;;; Code:
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 (defun pulse-int-to-hex (int &optional nb-digits)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 "Convert integer argument INT to a #XXXXXXXXXXXX format hex string.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 Each X in the output string is a hexadecimal digit.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 NB-DIGITS is the number of hex digits. If INT is too large to be
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 represented with NB-DIGITS, then the result is truncated from the
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 left. So, for example, INT=256 and NB-DIGITS=2 returns \"00\", since
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 the hex equivalent of 256 decimal is 100, which is more than 2 digits.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 This function was blindly copied from hexrgb.el by Drew Adams.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 http://www.emacswiki.org/cgi-bin/wiki/hexrgb.el"
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 (setq nb-digits (or nb-digits 4))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (substring (format (concat "%0" (int-to-string nb-digits) "X") int) (- nb-digits)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 (defun pulse-color-values-to-hex (values)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 "Convert list of rgb color VALUES to a hex string, #XXXXXXXXXXXX.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 Each X in the string is a hexadecimal digit.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 Input VALUES is as for the output of `x-color-values'.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 This function was blindly copied from hexrgb.el by Drew Adams.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 http://www.emacswiki.org/cgi-bin/wiki/hexrgb.el"
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (concat "#"
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (pulse-int-to-hex (nth 0 values) 4) ; red
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (pulse-int-to-hex (nth 1 values) 4) ; green
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (pulse-int-to-hex (nth 2 values) 4))) ; blue
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 (defcustom pulse-iterations 10
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 "Number of iterations in a pulse operation."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 :group 'pulse
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 :type 'number)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 (defcustom pulse-delay .03
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 "Delay between face lightening iterations, as used by `sit-for'."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 :group 'pulse
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 :type 'number)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 (defun pulse-lighten-highlight ()
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 "Lighten the face by 1/`pulse-iterations' toward the background color.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 Return t if there is more drift to do, nil if completed."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 (if (>= (get 'pulse-highlight-face :iteration) pulse-iterations)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 nil
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 (let* ((frame (color-values (face-background 'default)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 (start (color-values (face-background
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (get 'pulse-highlight-face
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 :startface))))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (frac (list (/ (- (nth 0 frame) (nth 0 start)) pulse-iterations)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 (/ (- (nth 1 frame) (nth 1 start)) pulse-iterations)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (/ (- (nth 2 frame) (nth 2 start)) pulse-iterations)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 (it (get 'pulse-highlight-face :iteration))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 )
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (set-face-background 'pulse-highlight-face
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 (pulse-color-values-to-hex
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (list
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (+ (nth 0 start) (* (nth 0 frac) it))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (+ (nth 1 start) (* (nth 1 frac) it))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 (+ (nth 2 start) (* (nth 2 frac) it)))))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (put 'pulse-highlight-face :iteration (1+ it))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (if (>= (1+ it) pulse-iterations)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 nil
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 t))))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (defun pulse-reset-face (&optional face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 "Reset the pulse highlighting FACE."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 (set-face-background 'pulse-highlight-face
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 (if face
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 (face-background face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (face-background 'pulse-highlight-start-face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 ))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 (put 'pulse-highlight-face :startface (or face
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 'pulse-highlight-start-face))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 (put 'pulse-highlight-face :iteration 0))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 (defun pulse (&optional face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 "Pulse the colors on our highlight face.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 If optional FACE is provide, reset the face to FACE color,
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 instead of `pulse-highlight-start-face'.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 Be sure to call `pulse-reset-face' after calling pulse."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (unwind-protect
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 (progn
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (pulse-reset-face face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 (while (and (pulse-lighten-highlight)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 (sit-for pulse-delay))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 nil))))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 ;;; Convenience Functions
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 ;;
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 (defvar pulse-momentary-overlay nil
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 "The current pulsing overlay.")
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (defun pulse-momentary-highlight-overlay (o &optional face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 "Pulse the overlay O, unhighlighting before next command.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 Optional argument FACE specifies the fact to do the highlighting."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (overlay-put o 'original-face (overlay-get o 'face))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 (add-to-list 'pulse-momentary-overlay o)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (if (or (not pulse-flag) (not (pulse-available-p)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 ;; Provide a face... clear on next command
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (progn
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (overlay-put o 'face (or face 'pulse-highlight-start-face))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 (add-hook 'pre-command-hook
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 'pulse-momentary-unhighlight)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 )
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 ;; pulse it.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (unwind-protect
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (progn
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (overlay-put o 'face 'pulse-highlight-face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 ;; The pulse function puts FACE onto 'pulse-highlight-face.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 ;; Thus above we put our face on the overlay, but pulse
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 ;; with a reference face needed for the color.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 (pulse face))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 (pulse-momentary-unhighlight))))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 (defun pulse-momentary-unhighlight ()
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 "Unhighlight a line recently highlighted."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 ;; If someone passes in an overlay, then pulse-momentary-overlay
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 ;; will still be nil, and won't need modifying.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (when pulse-momentary-overlay
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 ;; clear the starting face
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (mapc
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (lambda (ol)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 (overlay-put ol 'face (overlay-get ol 'original-face))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (overlay-put ol 'original-face nil)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 ;; Clear the overlay if it needs deleting.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (when (overlay-get ol 'pulse-delete) (delete-overlay ol)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 pulse-momentary-overlay)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 ;; Clear the variable.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (setq pulse-momentary-overlay nil))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 ;; Reset the pulsing face.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (pulse-reset-face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 ;; Remove this hook.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 (remove-hook 'pre-command-hook 'pulse-momentary-unhighlight))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (defun pulse-momentary-highlight-one-line (point &optional face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 "Highlight the line around POINT, unhighlighting before next command.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 Optional argument FACE specifies the face to do the highlighting."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (let ((start (point-at-bol))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 (end (save-excursion
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (end-of-line)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 (when (not (eobp))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 (forward-char 1))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 (point))))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 (pulse-momentary-highlight-region start end face)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 (defun pulse-momentary-highlight-region (start end &optional face)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 "Highlight between START and END, unhighlighting before next command.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 Optional argument FACE specifies the fact to do the highlighting."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 (let ((o (make-overlay start end)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 ;; Mark it for deletion
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 (overlay-put o 'pulse-delete t)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 (pulse-momentary-highlight-overlay o face)))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 ;;; Random integration with other tools
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (defvar pulse-command-advice-flag nil)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (defun pulse-line-hook-function ()
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 "Function used in hooks to pulse the current line.
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 Only pulses the line if `pulse-command-advice-flag' is non-nil."
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (when pulse-command-advice-flag
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (pulse-momentary-highlight-one-line (point))))
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 (provide 'pulse)
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105241
diff changeset
252 ;; arch-tag: 6e2f78c1-65b3-4164-a141-872cb1552959
105241
130db1220dfd * cedet/cedet-cscope.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 ;;; pulse.el ends here