annotate lisp/utils/live-icon.el @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +0200
parents 0293115a14e9
children 9b50b4588a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; live-icon.el --- make frame icons represent the current frame contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995 Rich Williams <rdw@hplb.hpl.hp.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Jamie Zawinski <jwz@netscape.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Authors: Rich Williams <rdw@hplb.hpl.hp.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Jamie Zawinski <jwz@netscape.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Version 1.2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
26 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; Generates little pixmaps representing the contents of your frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; #### This thing is somewhat of a mess and could stand some clean-up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (defun live-icon-colour-name-from-face (face &optional bg-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 "Do backward compatible things to faces and colours"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (if (and (boundp 'emacs-major-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (or (> emacs-major-version 19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (and (= emacs-major-version 19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (>= emacs-minor-version 12))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (let ((colour (if bg-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (face-background face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (face-foreground face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (if (consp colour)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (setq colour (cdr (car colour))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (if (color-instance-p colour)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (setq colour (color-instance-name colour)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (if (specifierp colour)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (setq colour (color-name colour)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (if colour
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (let ((hack (format "%s" colour)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (if (string-match "(?\\([^)]*\\))?" hack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (substring hack (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 hack))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (let ((p (if bg-p (face-background face) (face-foreground face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (and (pixelp p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (pixel-name p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defun live-icon-alloc-colour (cmv colour)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "Allocate a colour and a char from the magic vector"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (let ((bob (assoc colour (aref cmv 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (jim (aref cmv 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (if bob
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (cdr bob)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (aset cmv 0 (cons (cons colour jim) (aref cmv 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (aset cmv 1 (1+ (aref cmv 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (aset cmv 2 (1+ jim))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 jim)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defun live-icon-from-frame (&optional frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "Calculates the live-icon XPM of FRAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (if (not frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (setq frame (selected-screen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (select-screen frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (let* ((w (screen-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (h (screen-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (pix (make-vector h nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (ny 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (cmv (vector nil 0 ?A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (d (live-icon-alloc-colour
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 cmv (pixel-name (face-background 'default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (m (live-icon-alloc-colour
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 cmv (pixel-name (face-background 'modeline))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (x (live-icon-alloc-colour
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 cmv (pixel-name (face-foreground 'default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (let ((loop 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (while (< loop h)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (aset pix loop (make-string w d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (setq loop (1+ loop))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (mapcar #'(lambda (win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (select-window win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (setq y ny
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ny (+ ny (1- (window-height))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (aset pix (- ny 2) (make-string w m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (if (> (window-end) (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (narrow-to-region (window-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (1- (window-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (while (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (< y (1- ny)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (while (and (not (eolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (< (current-column) w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if (> (char-after (point)) 32)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (let* ((ex (extent-at (point) (current-buffer) 'face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (f (if ex (extent-face ex)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (z (if f (live-icon-colour-name-from-face f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (c (if z (live-icon-alloc-colour cmv z) x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (aset (aref pix y) (current-column) c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (setq y (1+ y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (forward-line 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (sort (if (fboundp 'window-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (window-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (let* ((w (screen-root-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (ws nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (while (not (memq (setq w (next-window w)) ws))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (setq ws (cons w ws)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ws))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (if (fboundp 'window-pixel-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 #'(lambda (won woo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (< (nth 1 (window-pixel-edges won))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (nth 1 (window-pixel-edges woo))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 #'(lambda (won woo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (< (nth 1 (window-edges won))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (nth 1 (window-edges woo)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (concat "/* XPM */\nstatic char icon[] = {\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (format "\"%d %d %d 1\",\n" w (* h 2) (aref cmv 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (mapconcat #'(lambda (colour-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (format "\"%c c %s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (cdr colour-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (car colour-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (aref cmv 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ",\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ",\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (mapconcat #'(lambda (scan-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (concat "\"" scan-line "\"," "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; "\"" scan-line "\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 "\"" (make-string w d) "\","
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 pix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ",\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "};\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defun live-icon-start-ppm-stuff (&optional frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 "Start a live icon conversion going"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (if (not frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (setq frame (selected-screen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (let ((buf (get-buffer-create " *live-icon*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (message "live-icon...(backgrounding)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (set-process-sentinel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (start-process-shell-command "live-icon"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "xwd"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "-id" (format "%s" (x-window-id frame)) "|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "xwdtopnm" "|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 "pnmscale" "-xysize" "64" "64" "|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 "ppmquant" "256" "|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 "ppmtoxpm")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 #'(lambda (p s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (message "live-icon...(munching)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (set-buffer " *live-icon*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (search-forward "/* XPM */")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (x-set-screen-icon-pixmap frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (make-pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (match-beginning 0) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (message "live-icon...... done"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (defun live-icon-one-frame (&optional frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 "Gives FRAME (defaulting to (selected-frame)) a live icon."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ; (message "Updating live icon...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (if (not frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (setq frame (selected-screen)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (x-set-screen-icon-pixmap frame (make-pixmap (live-icon-from-frame frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ; (message "Updating live icon... done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defun live-icon-all-frames ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 "Gives all your frames live-icons."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (message "Updating live icons...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (mapcar #'(lambda (fr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (x-set-screen-icon-pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 fr (make-pixmap (live-icon-from-frame fr))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (screen-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (message "Updating live icons... done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (add-hook 'unmap-screen-hook 'live-icon-one-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;(start-itimer "live-icon" 'live-icon-all-frames 120 120)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (defun live-icon-goto-position (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (let (window edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (walk-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 #'(lambda (w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (setq edges (window-edges w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (if (and (>= x (nth 0 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (<= x (nth 2 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (>= y (nth 1 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (<= y (nth 3 edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (throw 'done (setq window w))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (if (not window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (move-to-window-line (- y (nth 1 edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (move-to-column (- x (nth 0 edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (defun live-icon-make-image (width height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (let* ((text-aspect 1.5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (xscale (/ (/ (* (screen-width) 1.0) width) text-aspect))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (yscale (/ (* (screen-height) 1.0) height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (x 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (y 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (cmv (vector nil 0 ?A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (default-fg (live-icon-alloc-colour
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 cmv (pixel-name (face-foreground 'default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (default-bg (live-icon-alloc-colour
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 cmv (pixel-name (face-background 'default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (modeline-bg (live-icon-alloc-colour
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 cmv (pixel-name (face-background 'modeline))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (lines (make-vector height nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;; Put in the text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (while (< y height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (aset lines y (make-string width default-bg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (setq x 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (while (< x width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (let ((sx (floor (* x xscale)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (sy (floor (* y yscale))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (live-icon-goto-position sx sy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (let* ((extent (extent-at (point) (current-buffer) 'face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (face (if extent (extent-face extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (name (if face (live-icon-colour-name-from-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 face (<= (char-after (point)) 32))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (color (if name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (live-icon-alloc-colour cmv name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (if (<= (or (char-after (point)) 0) 32)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 default-bg default-fg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (aset (aref lines y) x color)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (setq x (1+ x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setq y (1+ y)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; Now put in the modelines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (let (sx sy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (walk-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 #'(lambda (w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (let ((edges (window-edges w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (setq x (nth 0 edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 y (nth 3 edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 sx (floor (/ x xscale))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 sy (floor (/ y yscale)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (while (and (< x (1- (nth 2 edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (< sx (length (aref lines 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (aset (aref lines sy) sx modeline-bg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (if (> sy 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (aset (aref lines (1- sy)) sx modeline-bg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (setq x (1+ x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 sx (floor (/ x xscale))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (if (>= sx (length (aref lines 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (setq sx (1- sx)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (while (>= y (nth 1 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (aset (aref lines sy) sx modeline-bg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (setq y (1- y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 sy (floor (/ y yscale))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;; Now put in the top and left edges
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (setq x 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (while (< x width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (aset (aref lines 0) x modeline-bg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq x (1+ x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (setq y 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (while (< y height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (aset (aref lines y) 0 modeline-bg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (setq y (1+ y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; Now make the XPM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (concat "/* XPM */\nstatic char icon[] = {\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (format "\"%d %d %d 1\",\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; (* height 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (aref cmv 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (mapconcat #'(lambda (colour-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (format "\"%c c %s\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (cdr colour-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (car colour-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (aref cmv 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ",\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ",\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (mapconcat #'(lambda (scan-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (concat "\"" scan-line "\"," "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ;; "\"" scan-line "\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;; "\"" (make-string width default-bg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;; "\","
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ",\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 "};\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (provide 'live-icon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;;; live-icon.el ends here